From 4a0f7e4294d2ccc2d2bf460bea87b342fe934d03 Mon Sep 17 00:00:00 2001 From: Wang Haomin Date: Wed, 24 Dec 2025 09:06:39 +0000 Subject: [PATCH 001/712] 8374321: Fix undefined reference to 'png_init_filter_functions_lsx' after 8371914 Reviewed-by: jiefu, jdv --- make/modules/java.desktop/lib/ClientLibraries.gmk | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/make/modules/java.desktop/lib/ClientLibraries.gmk b/make/modules/java.desktop/lib/ClientLibraries.gmk index f273065a6df..b76cb8dc4e3 100644 --- a/make/modules/java.desktop/lib/ClientLibraries.gmk +++ b/make/modules/java.desktop/lib/ClientLibraries.gmk @@ -164,7 +164,7 @@ ifeq ($(ENABLE_HEADLESS_ONLY), false) ifeq ($(USE_EXTERNAL_LIBPNG), false) LIBSPLASHSCREEN_HEADER_DIRS += libsplashscreen/libpng - LIBSPLASHSCREEN_CFLAGS += -DPNG_NO_MMX_CODE -DPNG_ARM_NEON_OPT=0 + LIBSPLASHSCREEN_CFLAGS += -DPNG_NO_MMX_CODE -DPNG_ARM_NEON_OPT=0 \ -DPNG_ARM_NEON_IMPLEMENTATION=0 -DPNG_LOONGARCH_LSX_OPT=0 ifeq ($(call isTargetOs, linux)+$(call isTargetCpuArch, ppc), true+true) From f23b958eca5c1b9f4e22b897ede6a07ed9224c5f Mon Sep 17 00:00:00 2001 From: Nizar Benalla Date: Wed, 24 Dec 2025 14:31:54 +0000 Subject: [PATCH 002/712] 8373446: Update --release 26 symbol information for JDK 26 build 29 Reviewed-by: iris, liach --- .../data/symbols/jdk.management-Q.sym.txt | 32 +++++++++++++++++++ src/jdk.compiler/share/data/symbols/symbols | 2 +- 2 files changed, 33 insertions(+), 1 deletion(-) create mode 100644 src/jdk.compiler/share/data/symbols/jdk.management-Q.sym.txt diff --git a/src/jdk.compiler/share/data/symbols/jdk.management-Q.sym.txt b/src/jdk.compiler/share/data/symbols/jdk.management-Q.sym.txt new file mode 100644 index 00000000000..6d553af80d5 --- /dev/null +++ b/src/jdk.compiler/share/data/symbols/jdk.management-Q.sym.txt @@ -0,0 +1,32 @@ +# +# Copyright (c) 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. 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. +# +# ########################################################## +# ### THIS FILE IS AUTOMATICALLY GENERATED. DO NOT EDIT. ### +# ########################################################## +# +class name jdk/management/HotSpotAOTCacheMXBean +header extends java/lang/Object implements java/lang/management/PlatformManagedObject flags 601 +method name endRecording descriptor ()Z flags 401 + diff --git a/src/jdk.compiler/share/data/symbols/symbols b/src/jdk.compiler/share/data/symbols/symbols index 8fdcac5c652..f31e521513c 100644 --- a/src/jdk.compiler/share/data/symbols/symbols +++ b/src/jdk.compiler/share/data/symbols/symbols @@ -48,4 +48,4 @@ platform version M base L files java.base-M.sym.txt:java.compiler-M.sym.txt:java platform version N base M files java.base-N.sym.txt:java.compiler-N.sym.txt:java.desktop-N.sym.txt:java.management-N.sym.txt:java.management.rmi-N.sym.txt:jdk.compiler-N.sym.txt:jdk.httpserver-N.sym.txt:jdk.incubator.foreign-N.sym.txt:jdk.javadoc-N.sym.txt:jdk.jshell-N.sym.txt:jdk.localedata-N.sym.txt:jdk.unsupported-N.sym.txt platform version O base N files java.base-O.sym.txt:java.compiler-O.sym.txt:java.datatransfer-O.sym.txt:java.desktop-O.sym.txt:java.instrument-O.sym.txt:java.logging-O.sym.txt:java.management-O.sym.txt:java.management.rmi-O.sym.txt:java.naming-O.sym.txt:java.net.http-O.sym.txt:java.prefs-O.sym.txt:java.rmi-O.sym.txt:java.scripting-O.sym.txt:java.se-O.sym.txt:java.security.jgss-O.sym.txt:java.security.sasl-O.sym.txt:java.smartcardio-O.sym.txt:java.sql-O.sym.txt:java.sql.rowset-O.sym.txt:java.transaction.xa-O.sym.txt:java.xml-O.sym.txt:java.xml.crypto-O.sym.txt:jdk.accessibility-O.sym.txt:jdk.attach-O.sym.txt:jdk.charsets-O.sym.txt:jdk.compiler-O.sym.txt:jdk.crypto.cryptoki-O.sym.txt:jdk.dynalink-O.sym.txt:jdk.editpad-O.sym.txt:jdk.hotspot.agent-O.sym.txt:jdk.httpserver-O.sym.txt:jdk.incubator.foreign-O.sym.txt:jdk.incubator.vector-O.sym.txt:jdk.jartool-O.sym.txt:jdk.javadoc-O.sym.txt:jdk.jcmd-O.sym.txt:jdk.jconsole-O.sym.txt:jdk.jdeps-O.sym.txt:jdk.jdi-O.sym.txt:jdk.jdwp.agent-O.sym.txt:jdk.jfr-O.sym.txt:jdk.jlink-O.sym.txt:jdk.jpackage-O.sym.txt:jdk.jshell-O.sym.txt:jdk.jsobject-O.sym.txt:jdk.jstatd-O.sym.txt:jdk.localedata-O.sym.txt:jdk.management-O.sym.txt:jdk.management.agent-O.sym.txt:jdk.management.jfr-O.sym.txt:jdk.naming.dns-O.sym.txt:jdk.naming.rmi-O.sym.txt:jdk.net-O.sym.txt:jdk.nio.mapmode-O.sym.txt:jdk.sctp-O.sym.txt:jdk.security.auth-O.sym.txt:jdk.security.jgss-O.sym.txt:jdk.unsupported-O.sym.txt:jdk.xml.dom-O.sym.txt:jdk.zipfs-O.sym.txt platform version P base O files java.base-P.sym.txt:java.compiler-P.sym.txt:java.desktop-P.sym.txt:java.logging-P.sym.txt:java.management-P.sym.txt:java.net.http-P.sym.txt:java.security.jgss-P.sym.txt:java.xml.crypto-P.sym.txt:jdk.attach-P.sym.txt:jdk.compiler-P.sym.txt:jdk.incubator.foreign-P.sym.txt:jdk.incubator.vector-P.sym.txt:jdk.jdi-P.sym.txt:jdk.jfr-P.sym.txt:jdk.jpackage-P.sym.txt:jdk.jshell-P.sym.txt:jdk.net-P.sym.txt:jdk.security.jgss-P.sym.txt -platform version Q base P files java.base-Q.sym.txt:java.compiler-Q.sym.txt:java.desktop-Q.sym.txt:java.management-Q.sym.txt:java.net.http-Q.sym.txt:java.sql-Q.sym.txt:jdk.httpserver-Q.sym.txt:jdk.incubator.foreign-Q.sym.txt:jdk.incubator.vector-Q.sym.txt:jdk.jartool-Q.sym.txt:jdk.jdeps-Q.sym.txt:jdk.jfr-Q.sym.txt:jdk.jlink-Q.sym.txt:jdk.jpackage-Q.sym.txt:jdk.jshell-Q.sym.txt:jdk.jsobject-Q.sym.txt:jdk.localedata-Q.sym.txt +platform version Q base P files java.base-Q.sym.txt:java.compiler-Q.sym.txt:java.desktop-Q.sym.txt:java.management-Q.sym.txt:java.net.http-Q.sym.txt:java.sql-Q.sym.txt:jdk.httpserver-Q.sym.txt:jdk.incubator.foreign-Q.sym.txt:jdk.incubator.vector-Q.sym.txt:jdk.jartool-Q.sym.txt:jdk.jdeps-Q.sym.txt:jdk.jfr-Q.sym.txt:jdk.jlink-Q.sym.txt:jdk.jpackage-Q.sym.txt:jdk.jshell-Q.sym.txt:jdk.jsobject-Q.sym.txt:jdk.localedata-Q.sym.txt:jdk.management-Q.sym.txt From 6ade34804f175b5dd1bf78515b78e5444d8be7f5 Mon Sep 17 00:00:00 2001 From: Nizar Benalla Date: Wed, 24 Dec 2025 14:38:08 +0000 Subject: [PATCH 003/712] 8374177: Update @since of HotSpotAOTCacheMXBean after JDK-8373607 Reviewed-by: alanb, iklam --- .../share/classes/jdk/management/HotSpotAOTCacheMXBean.java | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/jdk.management/share/classes/jdk/management/HotSpotAOTCacheMXBean.java b/src/jdk.management/share/classes/jdk/management/HotSpotAOTCacheMXBean.java index 4a921c348d0..f8e1e5a7f05 100644 --- a/src/jdk.management/share/classes/jdk/management/HotSpotAOTCacheMXBean.java +++ b/src/jdk.management/share/classes/jdk/management/HotSpotAOTCacheMXBean.java @@ -39,7 +39,7 @@ import javax.management.ObjectName; *

Direct access to the MXBean interface can be obtained with * {@link ManagementFactory#getPlatformMXBean(Class)}. * - * @since 27 + * @since 26 */ public interface HotSpotAOTCacheMXBean extends PlatformManagedObject { /** From 98b7792a072380978b09fda4ec194f333d2ce7e3 Mon Sep 17 00:00:00 2001 From: Nizar Benalla Date: Wed, 24 Dec 2025 14:47:04 +0000 Subject: [PATCH 004/712] 8372801: tools/sincechecker/modules/java.base/JavaBaseCheckSince.java fails with JDK 27 Reviewed-by: liach --- test/jdk/ProblemList.txt | 1 - 1 file changed, 1 deletion(-) diff --git a/test/jdk/ProblemList.txt b/test/jdk/ProblemList.txt index a81e48f3883..addcc8830af 100644 --- a/test/jdk/ProblemList.txt +++ b/test/jdk/ProblemList.txt @@ -780,4 +780,3 @@ java/awt/Cursor/CursorDragTest/ListDragCursor.java 7177297 macosx-all # jdk_since_checks tools/sincechecker/modules/jdk.management.jfr/JdkManagementJfrCheckSince.java 8354921 generic-all -tools/sincechecker/modules/java.base/JavaBaseCheckSince.java 8372801 generic-all From 73a8629c5b52b678febcc9d339e01ebcc5277909 Mon Sep 17 00:00:00 2001 From: Sergey Bylokhov Date: Thu, 25 Dec 2025 01:25:29 +0000 Subject: [PATCH 005/712] 8374310: Update copyright year to 2025 for client-libs in files where it was missed Reviewed-by: jdv, aivanov --- src/java.desktop/aix/classes/sun/awt/X11InputMethod.java | 2 +- src/java.desktop/macosx/classes/apple/laf/JRSUIControl.java | 2 +- src/java.desktop/macosx/classes/apple/laf/JRSUIFocus.java | 2 +- src/java.desktop/macosx/classes/apple/laf/JRSUIState.java | 2 +- .../macosx/classes/apple/laf/JRSUIStateFactory.java | 2 +- src/java.desktop/macosx/classes/apple/laf/JRSUIUtils.java | 2 +- .../macosx/classes/com/apple/eawt/ApplicationBeanInfo.java | 2 +- .../macosx/classes/com/apple/eawt/FullScreenAdapter.java | 2 +- .../macosx/classes/com/apple/eawt/MacQuitResponse.java | 2 +- .../macosx/classes/com/apple/eawt/_AppDockIconHandler.java | 2 +- .../macosx/classes/com/apple/eawt/_AppEventHandler.java | 2 +- .../macosx/classes/com/apple/eawt/_AppMenuBarHandler.java | 2 +- .../macosx/classes/com/apple/eawt/_AppMiscHandlers.java | 2 +- .../macosx/classes/com/apple/eawt/event/FullScreenEvent.java | 2 +- .../macosx/classes/com/apple/eawt/event/GestureAdapter.java | 2 +- .../macosx/classes/com/apple/eawt/event/GestureHandler.java | 2 +- .../macosx/classes/com/apple/eawt/event/GesturePhaseEvent.java | 2 +- .../macosx/classes/com/apple/eawt/event/MagnificationEvent.java | 2 +- .../macosx/classes/com/apple/eawt/event/RotationEvent.java | 2 +- .../macosx/classes/com/apple/eawt/event/SwipeEvent.java | 2 +- src/java.desktop/macosx/classes/com/apple/eio/FileManager.java | 2 +- .../macosx/classes/com/apple/laf/AquaButtonCheckBoxUI.java | 2 +- .../macosx/classes/com/apple/laf/AquaButtonExtendedTypes.java | 2 +- .../macosx/classes/com/apple/laf/AquaButtonLabeledUI.java | 2 +- .../macosx/classes/com/apple/laf/AquaButtonRadioUI.java | 2 +- .../macosx/classes/com/apple/laf/AquaButtonToggleUI.java | 2 +- src/java.desktop/macosx/classes/com/apple/laf/AquaCaret.java | 2 +- .../macosx/classes/com/apple/laf/AquaComboBoxButton.java | 2 +- .../macosx/classes/com/apple/laf/AquaComboBoxRenderer.java | 2 +- .../classes/com/apple/laf/AquaComboBoxRendererInternal.java | 2 +- .../macosx/classes/com/apple/laf/AquaComboBoxUI.java | 2 +- .../macosx/classes/com/apple/laf/AquaEditorPaneUI.java | 2 +- .../macosx/classes/com/apple/laf/AquaFileChooserUI.java | 2 +- .../macosx/classes/com/apple/laf/AquaFileSystemModel.java | 2 +- src/java.desktop/macosx/classes/com/apple/laf/AquaFileView.java | 2 +- src/java.desktop/macosx/classes/com/apple/laf/AquaFocus.java | 2 +- .../macosx/classes/com/apple/laf/AquaFocusHandler.java | 2 +- src/java.desktop/macosx/classes/com/apple/laf/AquaFonts.java | 2 +- .../macosx/classes/com/apple/laf/AquaGroupBorder.java | 2 +- .../macosx/classes/com/apple/laf/AquaHighlighter.java | 2 +- src/java.desktop/macosx/classes/com/apple/laf/AquaIcon.java | 2 +- .../macosx/classes/com/apple/laf/AquaImageFactory.java | 2 +- .../macosx/classes/com/apple/laf/AquaInternalFrameBorder.java | 2 +- .../macosx/classes/com/apple/laf/AquaInternalFrameManager.java | 2 +- .../macosx/classes/com/apple/laf/AquaInternalFramePaneUI.java | 2 +- .../macosx/classes/com/apple/laf/AquaInternalFrameUI.java | 2 +- src/java.desktop/macosx/classes/com/apple/laf/AquaLabelUI.java | 2 +- src/java.desktop/macosx/classes/com/apple/laf/AquaListUI.java | 2 +- .../macosx/classes/com/apple/laf/AquaLookAndFeel.java | 2 +- .../macosx/classes/com/apple/laf/AquaMenuBarBorder.java | 2 +- .../macosx/classes/com/apple/laf/AquaMenuBarUI.java | 2 +- .../macosx/classes/com/apple/laf/AquaMenuBorder.java | 2 +- .../macosx/classes/com/apple/laf/AquaMenuItemUI.java | 2 +- .../macosx/classes/com/apple/laf/AquaMenuPainter.java | 2 +- src/java.desktop/macosx/classes/com/apple/laf/AquaMenuUI.java | 2 +- .../macosx/classes/com/apple/laf/AquaNativeResources.java | 2 +- .../macosx/classes/com/apple/laf/AquaOptionPaneUI.java | 2 +- src/java.desktop/macosx/classes/com/apple/laf/AquaPainter.java | 2 +- src/java.desktop/macosx/classes/com/apple/laf/AquaPanelUI.java | 2 +- .../macosx/classes/com/apple/laf/AquaPopupMenuSeparatorUI.java | 2 +- .../macosx/classes/com/apple/laf/AquaPopupMenuUI.java | 2 +- .../macosx/classes/com/apple/laf/AquaProgressBarUI.java | 2 +- .../macosx/classes/com/apple/laf/AquaScrollBarUI.java | 2 +- .../macosx/classes/com/apple/laf/AquaScrollPaneUI.java | 2 +- .../macosx/classes/com/apple/laf/AquaScrollRegionBorder.java | 2 +- src/java.desktop/macosx/classes/com/apple/laf/AquaSliderUI.java | 2 +- .../macosx/classes/com/apple/laf/AquaSpinnerUI.java | 2 +- .../macosx/classes/com/apple/laf/AquaSplitPaneDividerUI.java | 2 +- .../macosx/classes/com/apple/laf/AquaSplitPaneUI.java | 2 +- .../macosx/classes/com/apple/laf/AquaTabbedPaneContrastUI.java | 2 +- .../macosx/classes/com/apple/laf/AquaTabbedPaneTabState.java | 2 +- .../macosx/classes/com/apple/laf/AquaTabbedPaneUI.java | 2 +- .../macosx/classes/com/apple/laf/AquaTableHeaderBorder.java | 2 +- .../macosx/classes/com/apple/laf/AquaTableHeaderUI.java | 2 +- src/java.desktop/macosx/classes/com/apple/laf/AquaTableUI.java | 2 +- .../macosx/classes/com/apple/laf/AquaTextAreaUI.java | 2 +- .../macosx/classes/com/apple/laf/AquaTextFieldBorder.java | 2 +- .../macosx/classes/com/apple/laf/AquaTextFieldFormattedUI.java | 2 +- .../macosx/classes/com/apple/laf/AquaTextFieldSearch.java | 2 +- .../macosx/classes/com/apple/laf/AquaTextPaneUI.java | 2 +- .../macosx/classes/com/apple/laf/AquaTextPasswordFieldUI.java | 2 +- .../macosx/classes/com/apple/laf/AquaToolBarSeparatorUI.java | 2 +- .../macosx/classes/com/apple/laf/AquaToolBarUI.java | 2 +- .../macosx/classes/com/apple/laf/AquaToolTipUI.java | 2 +- src/java.desktop/macosx/classes/com/apple/laf/AquaTreeUI.java | 2 +- .../macosx/classes/com/apple/laf/AquaUtilControlSize.java | 2 +- src/java.desktop/macosx/classes/com/apple/laf/AquaUtils.java | 2 +- .../macosx/classes/com/apple/laf/ScreenMenuBar.java | 2 +- .../macosx/classes/com/apple/laf/ScreenMenuItem.java | 2 +- .../macosx/classes/com/apple/laf/ScreenMenuItemCheckbox.java | 2 +- .../classes/com/apple/laf/ScreenMenuPropertyListener.java | 2 +- .../macosx/classes/com/apple/laf/ScreenPopupFactory.java | 2 +- src/java.desktop/macosx/classes/sun/awt/CGraphicsConfig.java | 2 +- .../macosx/classes/sun/awt/CGraphicsEnvironment.java | 2 +- .../macosx/classes/sun/awt/PlatformGraphicsInfo.java | 2 +- .../macosx/classes/sun/font/CCompositeGlyphMapper.java | 2 +- src/java.desktop/macosx/classes/sun/font/CFont.java | 2 +- .../macosx/classes/sun/font/CFontConfiguration.java | 2 +- src/java.desktop/macosx/classes/sun/font/CFontManager.java | 2 +- src/java.desktop/macosx/classes/sun/font/CStrikeDisposer.java | 2 +- src/java.desktop/macosx/classes/sun/font/NativeFont.java | 2 +- src/java.desktop/macosx/classes/sun/font/NativeStrike.java | 2 +- src/java.desktop/macosx/classes/sun/java2d/CRenderer.java | 2 +- .../macosx/classes/sun/java2d/CompositeCRenderer.java | 2 +- .../macosx/classes/sun/java2d/DataBufferNIOInt.java | 2 +- .../macosx/classes/sun/java2d/IntegerNIORaster.java | 2 +- src/java.desktop/macosx/classes/sun/java2d/MacOSFlags.java | 2 +- .../macosx/classes/sun/java2d/OSXOffScreenSurfaceData.java | 2 +- src/java.desktop/macosx/classes/sun/java2d/OSXSurfaceData.java | 2 +- .../macosx/classes/sun/java2d/metal/MTLBlitLoops.java | 2 +- .../macosx/classes/sun/java2d/metal/MTLBufImgOps.java | 2 +- .../macosx/classes/sun/java2d/metal/MTLContext.java | 2 +- .../macosx/classes/sun/java2d/metal/MTLDrawImage.java | 2 +- .../macosx/classes/sun/java2d/metal/MTLGraphicsConfig.java | 2 +- src/java.desktop/macosx/classes/sun/java2d/metal/MTLLayer.java | 2 +- .../macosx/classes/sun/java2d/metal/MTLMaskBlit.java | 2 +- .../macosx/classes/sun/java2d/metal/MTLMaskFill.java | 2 +- src/java.desktop/macosx/classes/sun/java2d/metal/MTLPaints.java | 2 +- .../macosx/classes/sun/java2d/metal/MTLRenderQueue.java | 2 +- .../macosx/classes/sun/java2d/metal/MTLRenderer.java | 2 +- .../macosx/classes/sun/java2d/metal/MTLSurfaceData.java | 2 +- .../macosx/classes/sun/java2d/metal/MTLSurfaceDataProxy.java | 2 +- .../macosx/classes/sun/java2d/metal/MTLTextRenderer.java | 2 +- .../classes/sun/java2d/metal/MTLVolatileSurfaceManager.java | 2 +- .../macosx/classes/sun/java2d/opengl/CGLGraphicsConfig.java | 2 +- src/java.desktop/macosx/classes/sun/java2d/opengl/CGLLayer.java | 2 +- .../macosx/classes/sun/java2d/opengl/CGLSurfaceData.java | 2 +- .../classes/sun/java2d/opengl/CGLVolatileSurfaceManager.java | 2 +- .../macosx/classes/sun/lwawt/LWKeyboardFocusManagerPeer.java | 2 +- .../macosx/classes/sun/lwawt/LWLightweightFramePeer.java | 2 +- src/java.desktop/macosx/classes/sun/lwawt/LWMouseInfoPeer.java | 2 +- src/java.desktop/macosx/classes/sun/lwawt/LWWindowPeer.java | 2 +- .../macosx/classes/sun/lwawt/macosx/CAccessibleText.java | 2 +- .../macosx/classes/sun/lwawt/macosx/CCheckboxMenuItem.java | 2 +- .../macosx/classes/sun/lwawt/macosx/CCustomCursor.java | 2 +- .../macosx/classes/sun/lwawt/macosx/CDataTransferer.java | 2 +- .../macosx/classes/sun/lwawt/macosx/CDragSourceContextPeer.java | 2 +- .../macosx/classes/sun/lwawt/macosx/CDropTargetContextPeer.java | 2 +- .../macosx/classes/sun/lwawt/macosx/CEmbeddedFrame.java | 2 +- .../macosx/classes/sun/lwawt/macosx/CFileDialog.java | 2 +- src/java.desktop/macosx/classes/sun/lwawt/macosx/CImage.java | 2 +- .../macosx/classes/sun/lwawt/macosx/CInputMethod.java | 2 +- .../macosx/classes/sun/lwawt/macosx/CInputMethodDescriptor.java | 2 +- .../classes/sun/lwawt/macosx/CMouseDragGestureRecognizer.java | 2 +- .../macosx/classes/sun/lwawt/macosx/CPlatformEmbeddedFrame.java | 2 +- .../macosx/classes/sun/lwawt/macosx/CPlatformLWComponent.java | 2 +- .../macosx/classes/sun/lwawt/macosx/CPlatformLWView.java | 2 +- .../macosx/classes/sun/lwawt/macosx/CPlatformLWWindow.java | 2 +- .../macosx/classes/sun/lwawt/macosx/CPlatformResponder.java | 2 +- .../macosx/classes/sun/lwawt/macosx/CPlatformWindow.java | 2 +- .../macosx/classes/sun/lwawt/macosx/CPrinterDialogPeer.java | 2 +- .../macosx/classes/sun/lwawt/macosx/CSystemTray.java | 2 +- .../classes/sun/lwawt/macosx/CToolkitThreadBlockedHandler.java | 2 +- src/java.desktop/macosx/classes/sun/lwawt/macosx/CTrayIcon.java | 2 +- .../macosx/classes/sun/lwawt/macosx/CViewEmbeddedFrame.java | 2 +- .../classes/sun/lwawt/macosx/CViewPlatformEmbeddedFrame.java | 2 +- .../macosx/classes/sun/lwawt/macosx/LWCToolkit.java | 2 +- .../macosx/classes/sun/print/PlatformPrinterJobProxy.java | 2 +- src/java.desktop/macosx/native/libawt_lwawt/awt/AWTEvent.m | 2 +- .../macosx/native/libawt_lwawt/awt/CGraphicsDevice.m | 2 +- src/java.desktop/macosx/native/libawt_lwawt/awt/CGraphicsEnv.m | 2 +- src/java.desktop/macosx/native/libawt_lwawt/awt/CPrinterJob.m | 2 +- src/java.desktop/macosx/native/libawt_lwawt/awt/DnDUtilities.m | 2 +- .../native/libawt_lwawt/awt/a11y/TabButtonAccessibility.m | 2 +- .../macosx/native/libawt_lwawt/font/CGGlyphImages.m | 2 +- .../classes/com/sun/imageio/plugins/gif/GIFImageWriter.java | 2 +- .../classes/com/sun/imageio/plugins/png/PNGImageWriter.java | 2 +- .../classes/com/sun/imageio/plugins/tiff/TIFFImageWriter.java | 2 +- .../share/classes/com/sun/java/swing/plaf/gtk/GTKEngine.java | 2 +- .../com/sun/java/swing/plaf/motif/MotifFileChooserUI.java | 2 +- src/java.desktop/share/classes/java/awt/Dialog.java | 2 +- src/java.desktop/share/classes/java/awt/EventQueue.java | 2 +- src/java.desktop/share/classes/java/awt/Font.java | 2 +- .../share/classes/java/awt/GraphicsEnvironment.java | 2 +- src/java.desktop/share/classes/java/awt/HeadlessException.java | 2 +- .../share/classes/java/awt/KeyboardFocusManager.java | 2 +- src/java.desktop/share/classes/java/awt/Polygon.java | 2 +- src/java.desktop/share/classes/java/awt/PrintJob.java | 2 +- src/java.desktop/share/classes/java/awt/SystemTray.java | 2 +- .../share/classes/java/awt/doc-files/FocusSpec.html | 2 +- src/java.desktop/share/classes/java/awt/doc-files/Modality.html | 2 +- .../share/classes/java/awt/image/BandedSampleModel.java | 2 +- .../share/classes/java/awt/image/ComponentSampleModel.java | 2 +- src/java.desktop/share/classes/java/awt/image/LookupOp.java | 2 +- .../classes/java/awt/image/MultiPixelPackedSampleModel.java | 2 +- src/java.desktop/share/classes/java/awt/image/SampleModel.java | 2 +- .../classes/java/awt/image/SinglePixelPackedSampleModel.java | 2 +- src/java.desktop/share/classes/java/beans/Beans.java | 2 +- src/java.desktop/share/classes/java/beans/DesignMode.java | 2 +- src/java.desktop/share/classes/javax/imageio/ImageReader.java | 2 +- src/java.desktop/share/classes/javax/imageio/ImageWriter.java | 2 +- .../classes/javax/imageio/metadata/IIOMetadataFormatImpl.java | 2 +- .../share/classes/javax/imageio/spi/IIORegistry.java | 2 +- .../share/classes/javax/imageio/spi/ServiceRegistry.java | 2 +- .../classes/javax/imageio/stream/FileCacheImageInputStream.java | 2 +- .../javax/imageio/stream/FileCacheImageOutputStream.java | 2 +- .../classes/javax/imageio/stream/ImageInputStreamImpl.java | 2 +- .../javax/imageio/stream/MemoryCacheImageInputStream.java | 2 +- .../share/classes/javax/imageio/stream/package-info.java | 2 +- src/java.desktop/share/classes/javax/swing/Action.java | 2 +- .../share/classes/javax/swing/BufferStrategyPaintManager.java | 2 +- src/java.desktop/share/classes/javax/swing/JComponent.java | 2 +- src/java.desktop/share/classes/javax/swing/JEditorPane.java | 2 +- src/java.desktop/share/classes/javax/swing/JFileChooser.java | 2 +- src/java.desktop/share/classes/javax/swing/JOptionPane.java | 2 +- src/java.desktop/share/classes/javax/swing/JRootPane.java | 2 +- src/java.desktop/share/classes/javax/swing/JViewport.java | 2 +- .../share/classes/javax/swing/RootPaneContainer.java | 2 +- .../share/classes/javax/swing/SwingPaintEventDispatcher.java | 2 +- src/java.desktop/share/classes/javax/swing/SwingUtilities.java | 2 +- src/java.desktop/share/classes/javax/swing/Timer.java | 2 +- src/java.desktop/share/classes/javax/swing/ToolTipManager.java | 2 +- src/java.desktop/share/classes/javax/swing/UIManager.java | 2 +- src/java.desktop/share/classes/javax/swing/package-info.java | 2 +- .../classes/javax/swing/plaf/metal/MetalFileChooserUI.java | 2 +- .../classes/javax/swing/plaf/synth/SynthDefaultLookup.java | 2 +- .../share/classes/javax/swing/plaf/synth/SynthParser.java | 2 +- .../share/classes/javax/swing/plaf/synth/doc-files/synth.dtd | 2 +- .../javax/swing/plaf/synth/doc-files/synthFileFormat.html | 2 +- .../share/classes/javax/swing/text/StringContent.java | 2 +- .../share/classes/javax/swing/text/html/parser/Entity.java | 2 +- src/java.desktop/share/classes/sun/awt/AppContext.java | 2 +- src/java.desktop/share/classes/sun/awt/EmbeddedFrame.java | 2 +- src/java.desktop/share/classes/sun/awt/SunToolkit.java | 2 +- .../share/classes/sun/awt/image/ByteInterleavedRaster.java | 2 +- .../share/classes/sun/awt/image/SunVolatileImage.java | 2 +- .../share/classes/sun/awt/image/SurfaceManager.java | 2 +- .../share/classes/sun/awt/util/PerformanceLogger.java | 2 +- src/java.desktop/share/classes/sun/font/FileFont.java | 2 +- src/java.desktop/share/classes/sun/font/FontManager.java | 2 +- src/java.desktop/share/classes/sun/font/SunFontManager.java | 2 +- .../share/classes/sun/java2d/marlin/DMarlinRenderingEngine.java | 2 +- .../share/classes/sun/java2d/opengl/OGLGraphicsConfig.java | 2 +- .../share/classes/sun/java2d/pipe/BufferedContext.java | 2 +- src/java.desktop/share/classes/sun/print/PathGraphics.java | 2 +- src/java.desktop/share/classes/sun/swing/FilePane.java | 2 +- .../classes/sun/swing/plaf/synth/SynthFileChooserUIImpl.java | 2 +- src/java.desktop/share/conf/psfontj2d.properties | 2 +- src/java.desktop/share/native/libawt/awt/image/imageInitIDs.c | 2 +- src/java.desktop/share/native/libawt/awt/image/imageInitIDs.h | 2 +- src/java.desktop/share/native/libawt/java2d/SurfaceData.h | 2 +- src/java.desktop/share/native/libawt/java2d/loops/Blit.c | 2 +- src/java.desktop/share/native/libfontmanager/freetypeScaler.c | 2 +- src/java.desktop/unix/classes/sun/awt/FcFontManager.java | 2 +- .../unix/classes/sun/awt/X11/GtkFileDialogPeer.java | 2 +- src/java.desktop/unix/classes/sun/awt/X11/InfoWindow.java | 2 +- .../unix/classes/sun/awt/X11/MotifColorUtilities.java | 2 +- .../unix/classes/sun/awt/X11/MotifDnDConstants.java | 2 +- .../unix/classes/sun/awt/X11/MotifDnDDragSourceProtocol.java | 2 +- .../unix/classes/sun/awt/X11/MotifDnDDropTargetProtocol.java | 2 +- src/java.desktop/unix/classes/sun/awt/X11/Native.java | 2 +- .../unix/classes/sun/awt/X11/UnsafeXDisposerRecord.java | 2 +- src/java.desktop/unix/classes/sun/awt/X11/WindowDimensions.java | 2 +- .../unix/classes/sun/awt/X11/WindowPropertyGetter.java | 2 +- src/java.desktop/unix/classes/sun/awt/X11/XAWTLookAndFeel.java | 2 +- src/java.desktop/unix/classes/sun/awt/X11/XAWTXSettings.java | 2 +- src/java.desktop/unix/classes/sun/awt/X11/XAtom.java | 2 +- src/java.desktop/unix/classes/sun/awt/X11/XAtomList.java | 2 +- src/java.desktop/unix/classes/sun/awt/X11/XAwtState.java | 2 +- src/java.desktop/unix/classes/sun/awt/X11/XBaseMenuWindow.java | 2 +- src/java.desktop/unix/classes/sun/awt/X11/XBaseWindow.java | 2 +- src/java.desktop/unix/classes/sun/awt/X11/XButtonPeer.java | 2 +- src/java.desktop/unix/classes/sun/awt/X11/XCanvasPeer.java | 2 +- src/java.desktop/unix/classes/sun/awt/X11/XCheckboxPeer.java | 2 +- src/java.desktop/unix/classes/sun/awt/X11/XChoicePeer.java | 2 +- src/java.desktop/unix/classes/sun/awt/X11/XClipboard.java | 2 +- src/java.desktop/unix/classes/sun/awt/X11/XContentWindow.java | 2 +- .../unix/classes/sun/awt/X11/XCreateWindowParams.java | 2 +- src/java.desktop/unix/classes/sun/awt/X11/XCustomCursor.java | 2 +- src/java.desktop/unix/classes/sun/awt/X11/XDataTransferer.java | 2 +- src/java.desktop/unix/classes/sun/awt/X11/XDecoratedPeer.java | 2 +- src/java.desktop/unix/classes/sun/awt/X11/XDesktopPeer.java | 2 +- src/java.desktop/unix/classes/sun/awt/X11/XDialogPeer.java | 2 +- src/java.desktop/unix/classes/sun/awt/X11/XDnDConstants.java | 2 +- .../unix/classes/sun/awt/X11/XDnDDragSourceProtocol.java | 2 +- .../unix/classes/sun/awt/X11/XDnDDropTargetProtocol.java | 2 +- .../unix/classes/sun/awt/X11/XDragSourceContextPeer.java | 2 +- .../unix/classes/sun/awt/X11/XDragSourceProtocol.java | 2 +- .../unix/classes/sun/awt/X11/XDropTargetContextPeer.java | 2 +- src/java.desktop/unix/classes/sun/awt/X11/XEmbedCanvasPeer.java | 2 +- src/java.desktop/unix/classes/sun/awt/X11/XEmbedChildProxy.java | 2 +- .../unix/classes/sun/awt/X11/XEmbedChildProxyPeer.java | 2 +- .../unix/classes/sun/awt/X11/XEmbedClientHelper.java | 2 +- .../unix/classes/sun/awt/X11/XEmbedServerTester.java | 2 +- src/java.desktop/unix/classes/sun/awt/X11/XEmbeddedFrame.java | 2 +- .../unix/classes/sun/awt/X11/XEmbeddedFramePeer.java | 2 +- .../unix/classes/sun/awt/X11/XEmbeddingContainer.java | 2 +- src/java.desktop/unix/classes/sun/awt/X11/XErrorHandler.java | 2 +- src/java.desktop/unix/classes/sun/awt/X11/XException.java | 2 +- .../unix/classes/sun/awt/X11/XFocusProxyWindow.java | 2 +- src/java.desktop/unix/classes/sun/awt/X11/XFontPeer.java | 2 +- .../unix/classes/sun/awt/X11/XGlobalCursorManager.java | 2 +- .../unix/classes/sun/awt/X11/XHorizontalScrollbar.java | 2 +- src/java.desktop/unix/classes/sun/awt/X11/XIconWindow.java | 2 +- src/java.desktop/unix/classes/sun/awt/X11/XInputMethod.java | 2 +- .../unix/classes/sun/awt/X11/XInputMethodDescriptor.java | 2 +- .../unix/classes/sun/awt/X11/XKeyboardFocusManagerPeer.java | 2 +- src/java.desktop/unix/classes/sun/awt/X11/XLabelPeer.java | 2 +- .../unix/classes/sun/awt/X11/XLightweightFramePeer.java | 2 +- src/java.desktop/unix/classes/sun/awt/X11/XListPeer.java | 2 +- src/java.desktop/unix/classes/sun/awt/X11/XMSelection.java | 2 +- src/java.desktop/unix/classes/sun/awt/X11/XMenuBarPeer.java | 2 +- src/java.desktop/unix/classes/sun/awt/X11/XMenuItemPeer.java | 2 +- src/java.desktop/unix/classes/sun/awt/X11/XMenuPeer.java | 2 +- src/java.desktop/unix/classes/sun/awt/X11/XMenuWindow.java | 2 +- .../unix/classes/sun/awt/X11/XMouseDragGestureRecognizer.java | 2 +- src/java.desktop/unix/classes/sun/awt/X11/XNETProtocol.java | 2 +- src/java.desktop/unix/classes/sun/awt/X11/XPanelPeer.java | 2 +- src/java.desktop/unix/classes/sun/awt/X11/XPopupMenuPeer.java | 2 +- src/java.desktop/unix/classes/sun/awt/X11/XPropertyCache.java | 2 +- src/java.desktop/unix/classes/sun/awt/X11/XQueryTree.java | 2 +- src/java.desktop/unix/classes/sun/awt/X11/XRepaintArea.java | 2 +- src/java.desktop/unix/classes/sun/awt/X11/XRootWindow.java | 2 +- src/java.desktop/unix/classes/sun/awt/X11/XScrollPanePeer.java | 2 +- src/java.desktop/unix/classes/sun/awt/X11/XScrollbar.java | 2 +- src/java.desktop/unix/classes/sun/awt/X11/XScrollbarPeer.java | 2 +- src/java.desktop/unix/classes/sun/awt/X11/XSelection.java | 2 +- src/java.desktop/unix/classes/sun/awt/X11/XSystemTrayPeer.java | 2 +- src/java.desktop/unix/classes/sun/awt/X11/XTextAreaPeer.java | 2 +- .../unix/classes/sun/awt/X11/XToolkitThreadBlockedHandler.java | 2 +- .../unix/classes/sun/awt/X11/XTranslateCoordinates.java | 2 +- src/java.desktop/unix/classes/sun/awt/X11/XTrayIconPeer.java | 2 +- .../unix/classes/sun/awt/X11/XVerticalScrollbar.java | 2 +- src/java.desktop/unix/classes/sun/awt/X11/XWINProtocol.java | 2 +- src/java.desktop/unix/classes/sun/awt/X11/XWindow.java | 2 +- .../unix/classes/sun/awt/X11/XWindowAttributesData.java | 2 +- src/java.desktop/unix/classes/sun/awt/X11/XWrapperBase.java | 2 +- src/java.desktop/unix/classes/sun/awt/X11/XlibUtil.java | 2 +- src/java.desktop/unix/classes/sun/awt/X11CustomCursor.java | 2 +- src/java.desktop/unix/classes/sun/awt/X11FontManager.java | 2 +- src/java.desktop/unix/classes/sun/awt/X11GraphicsConfig.java | 2 +- .../unix/classes/sun/awt/X11GraphicsEnvironment.java | 2 +- src/java.desktop/unix/classes/sun/awt/X11InputMethod.java | 2 +- src/java.desktop/unix/classes/sun/awt/X11InputMethodBase.java | 2 +- .../unix/classes/sun/awt/X11InputMethodDescriptor.java | 2 +- src/java.desktop/unix/classes/sun/awt/XSettings.java | 2 +- src/java.desktop/unix/classes/sun/font/DelegateStrike.java | 2 +- src/java.desktop/unix/classes/sun/font/DoubleByteEncoder.java | 2 +- src/java.desktop/unix/classes/sun/font/FcFontConfiguration.java | 2 +- src/java.desktop/unix/classes/sun/font/FontConfigManager.java | 2 +- src/java.desktop/unix/classes/sun/font/MFontConfiguration.java | 2 +- src/java.desktop/unix/classes/sun/font/NativeFont.java | 2 +- src/java.desktop/unix/classes/sun/font/NativeStrike.java | 2 +- .../unix/classes/sun/font/NativeStrikeDisposer.java | 2 +- src/java.desktop/unix/classes/sun/font/X11Dingbats.java | 2 +- src/java.desktop/unix/classes/sun/font/X11GB18030_0.java | 2 +- src/java.desktop/unix/classes/sun/font/X11GB18030_1.java | 2 +- src/java.desktop/unix/classes/sun/font/X11GB2312.java | 2 +- src/java.desktop/unix/classes/sun/font/X11GBK.java | 2 +- src/java.desktop/unix/classes/sun/font/X11Johab.java | 2 +- src/java.desktop/unix/classes/sun/font/X11KSC5601.java | 2 +- src/java.desktop/unix/classes/sun/font/X11SunUnicode_0.java | 2 +- src/java.desktop/unix/classes/sun/font/X11TextRenderer.java | 2 +- src/java.desktop/unix/classes/sun/font/XMap.java | 2 +- src/java.desktop/unix/classes/sun/font/XRGlyphCache.java | 2 +- src/java.desktop/unix/classes/sun/font/XRGlyphCacheEntry.java | 2 +- src/java.desktop/unix/classes/sun/font/XRTextRenderer.java | 2 +- .../unix/classes/sun/java2d/opengl/GLXGraphicsConfig.java | 2 +- .../unix/classes/sun/java2d/opengl/GLXSurfaceData.java | 2 +- .../classes/sun/java2d/opengl/GLXVolatileSurfaceManager.java | 2 +- .../unix/classes/sun/java2d/x11/X11PMBlitBgLoops.java | 2 +- .../unix/classes/sun/java2d/x11/X11PMBlitLoops.java | 2 +- src/java.desktop/unix/classes/sun/java2d/x11/X11Renderer.java | 2 +- .../unix/classes/sun/java2d/x11/X11SurfaceData.java | 2 +- .../unix/classes/sun/java2d/x11/X11SurfaceDataProxy.java | 2 +- .../unix/classes/sun/java2d/x11/X11VolatileSurfaceManager.java | 2 +- src/java.desktop/unix/classes/sun/java2d/xr/DirtyRegion.java | 2 +- .../unix/classes/sun/java2d/xr/GrowableByteArray.java | 2 +- .../unix/classes/sun/java2d/xr/GrowableEltArray.java | 2 +- .../unix/classes/sun/java2d/xr/GrowablePointArray.java | 2 +- .../unix/classes/sun/java2d/xr/GrowableRectArray.java | 2 +- src/java.desktop/unix/classes/sun/java2d/xr/MaskTile.java | 2 +- .../unix/classes/sun/java2d/xr/MaskTileManager.java | 2 +- src/java.desktop/unix/classes/sun/java2d/xr/MutableInteger.java | 2 +- src/java.desktop/unix/classes/sun/java2d/xr/XIDGenerator.java | 2 +- .../unix/classes/sun/java2d/xr/XRBackendNative.java | 2 +- src/java.desktop/unix/classes/sun/java2d/xr/XRColor.java | 2 +- .../unix/classes/sun/java2d/xr/XRCompositeManager.java | 2 +- src/java.desktop/unix/classes/sun/java2d/xr/XRDrawImage.java | 2 +- src/java.desktop/unix/classes/sun/java2d/xr/XRDrawLine.java | 2 +- .../unix/classes/sun/java2d/xr/XRGraphicsConfig.java | 2 +- src/java.desktop/unix/classes/sun/java2d/xr/XRMaskBlit.java | 2 +- src/java.desktop/unix/classes/sun/java2d/xr/XRMaskFill.java | 2 +- src/java.desktop/unix/classes/sun/java2d/xr/XRMaskImage.java | 2 +- src/java.desktop/unix/classes/sun/java2d/xr/XRPMBlitLoops.java | 2 +- src/java.desktop/unix/classes/sun/java2d/xr/XRPaints.java | 2 +- src/java.desktop/unix/classes/sun/java2d/xr/XRRenderer.java | 2 +- src/java.desktop/unix/classes/sun/java2d/xr/XRSolidSrcPict.java | 2 +- src/java.desktop/unix/classes/sun/java2d/xr/XRSurfaceData.java | 2 +- .../unix/classes/sun/java2d/xr/XRSurfaceDataProxy.java | 2 +- src/java.desktop/unix/classes/sun/java2d/xr/XRUtils.java | 2 +- .../unix/classes/sun/java2d/xr/XRVolatileSurfaceManager.java | 2 +- .../unix/classes/sun/java2d/xr/XcbRequestCounter.java | 2 +- src/java.desktop/unix/classes/sun/print/AttributeClass.java | 2 +- src/java.desktop/unix/classes/sun/print/CUPSPrinter.java | 2 +- src/java.desktop/unix/classes/sun/print/IPPPrintService.java | 2 +- .../unix/classes/sun/print/PrintServiceLookupProvider.java | 2 +- src/java.desktop/unix/classes/sun/print/UnixPrintService.java | 2 +- src/java.desktop/unix/native/common/awt/awt_GraphicsEnv.h | 2 +- src/java.desktop/unix/native/common/awt/fontpath.c | 2 +- src/java.desktop/unix/native/libawt/awt/awt_LoadLibrary.c | 2 +- src/java.desktop/unix/native/libawt_xawt/awt/awt_InputMethod.c | 2 +- .../com/sun/java/swing/plaf/windows/AnimationController.java | 2 +- .../classes/com/sun/java/swing/plaf/windows/TMSchema.java | 2 +- .../classes/com/sun/java/swing/plaf/windows/WindowsBorders.java | 2 +- .../com/sun/java/swing/plaf/windows/WindowsButtonUI.java | 2 +- .../com/sun/java/swing/plaf/windows/WindowsCheckBoxUI.java | 2 +- .../sun/java/swing/plaf/windows/WindowsClassicLookAndFeel.java | 2 +- .../com/sun/java/swing/plaf/windows/WindowsComboBoxUI.java | 2 +- .../com/sun/java/swing/plaf/windows/WindowsDesktopIconUI.java | 2 +- .../com/sun/java/swing/plaf/windows/WindowsDesktopPaneUI.java | 2 +- .../com/sun/java/swing/plaf/windows/WindowsEditorPaneUI.java | 2 +- .../com/sun/java/swing/plaf/windows/WindowsGraphicsUtils.java | 2 +- .../com/sun/java/swing/plaf/windows/WindowsInternalFrameUI.java | 2 +- .../classes/com/sun/java/swing/plaf/windows/WindowsLabelUI.java | 2 +- .../com/sun/java/swing/plaf/windows/WindowsLookAndFeel.java | 2 +- .../com/sun/java/swing/plaf/windows/WindowsMenuBarUI.java | 2 +- .../com/sun/java/swing/plaf/windows/WindowsOptionPaneUI.java | 2 +- .../com/sun/java/swing/plaf/windows/WindowsPasswordFieldUI.java | 2 +- .../java/swing/plaf/windows/WindowsPopupMenuSeparatorUI.java | 2 +- .../com/sun/java/swing/plaf/windows/WindowsPopupMenuUI.java | 2 +- .../com/sun/java/swing/plaf/windows/WindowsPopupWindow.java | 2 +- .../com/sun/java/swing/plaf/windows/WindowsRadioButtonUI.java | 2 +- .../com/sun/java/swing/plaf/windows/WindowsRootPaneUI.java | 2 +- .../com/sun/java/swing/plaf/windows/WindowsScrollBarUI.java | 2 +- .../com/sun/java/swing/plaf/windows/WindowsScrollPaneUI.java | 2 +- .../com/sun/java/swing/plaf/windows/WindowsSeparatorUI.java | 2 +- .../com/sun/java/swing/plaf/windows/WindowsSliderUI.java | 2 +- .../com/sun/java/swing/plaf/windows/WindowsSpinnerUI.java | 2 +- .../sun/java/swing/plaf/windows/WindowsSplitPaneDivider.java | 2 +- .../com/sun/java/swing/plaf/windows/WindowsSplitPaneUI.java | 2 +- .../com/sun/java/swing/plaf/windows/WindowsTabbedPaneUI.java | 2 +- .../com/sun/java/swing/plaf/windows/WindowsTableHeaderUI.java | 2 +- .../com/sun/java/swing/plaf/windows/WindowsTextAreaUI.java | 2 +- .../com/sun/java/swing/plaf/windows/WindowsTextFieldUI.java | 2 +- .../com/sun/java/swing/plaf/windows/WindowsTextPaneUI.java | 2 +- .../classes/com/sun/java/swing/plaf/windows/WindowsTextUI.java | 2 +- .../com/sun/java/swing/plaf/windows/WindowsToggleButtonUI.java | 2 +- .../sun/java/swing/plaf/windows/WindowsToolBarSeparatorUI.java | 2 +- .../com/sun/java/swing/plaf/windows/WindowsToolBarUI.java | 2 +- .../classes/com/sun/java/swing/plaf/windows/WindowsTreeUI.java | 2 +- .../classes/com/sun/java/swing/plaf/windows/XPStyle.java | 2 +- .../windows/classes/sun/awt/PlatformGraphicsInfo.java | 2 +- src/java.desktop/windows/classes/sun/awt/Win32ColorModel24.java | 2 +- src/java.desktop/windows/classes/sun/awt/Win32FontManager.java | 2 +- .../windows/classes/sun/awt/Win32GraphicsConfig.java | 2 +- .../windows/classes/sun/awt/Win32GraphicsDevice.java | 2 +- .../windows/classes/sun/awt/Win32GraphicsEnvironment.java | 2 +- .../classes/sun/awt/windows/TranslucentWindowPainter.java | 2 +- .../windows/classes/sun/awt/windows/WComponentPeer.java | 2 +- .../windows/classes/sun/awt/windows/WDataTransferer.java | 2 +- .../windows/classes/sun/awt/windows/WDefaultFontCharset.java | 2 +- .../windows/classes/sun/awt/windows/WDesktopProperties.java | 2 +- .../windows/classes/sun/awt/windows/WDragSourceContextPeer.java | 2 +- .../windows/classes/sun/awt/windows/WEmbeddedFrame.java | 2 +- .../windows/classes/sun/awt/windows/WEmbeddedFramePeer.java | 2 +- .../windows/classes/sun/awt/windows/WInputMethod.java | 2 +- .../windows/classes/sun/awt/windows/WLabelPeer.java | 2 +- .../windows/classes/sun/awt/windows/WLightweightFramePeer.java | 2 +- .../windows/classes/sun/awt/windows/WMenuItemPeer.java | 2 +- .../windows/classes/sun/awt/windows/WMouseInfoPeer.java | 2 +- .../windows/classes/sun/awt/windows/WPopupMenuPeer.java | 2 +- .../windows/classes/sun/awt/windows/WScrollPanePeer.java | 2 +- .../windows/classes/sun/awt/windows/WScrollbarPeer.java | 2 +- .../windows/classes/sun/awt/windows/WTrayIconPeer.java | 2 +- .../windows/classes/sun/awt/windows/WWindowPeer.java | 2 +- src/java.desktop/windows/classes/sun/awt/windows/WingDings.java | 2 +- src/java.desktop/windows/classes/sun/font/NativeFont.java | 2 +- src/java.desktop/windows/classes/sun/font/NativeStrike.java | 2 +- .../windows/classes/sun/java2d/d3d/D3DBlitLoops.java | 2 +- .../windows/classes/sun/java2d/d3d/D3DBufImgOps.java | 2 +- src/java.desktop/windows/classes/sun/java2d/d3d/D3DContext.java | 2 +- .../windows/classes/sun/java2d/d3d/D3DDrawImage.java | 2 +- .../windows/classes/sun/java2d/d3d/D3DGraphicsConfig.java | 2 +- .../windows/classes/sun/java2d/d3d/D3DGraphicsDevice.java | 2 +- .../windows/classes/sun/java2d/d3d/D3DMaskBlit.java | 2 +- .../windows/classes/sun/java2d/d3d/D3DMaskFill.java | 2 +- src/java.desktop/windows/classes/sun/java2d/d3d/D3DPaints.java | 2 +- .../windows/classes/sun/java2d/d3d/D3DRenderQueue.java | 2 +- .../windows/classes/sun/java2d/d3d/D3DRenderer.java | 2 +- .../windows/classes/sun/java2d/d3d/D3DScreenUpdateManager.java | 2 +- .../windows/classes/sun/java2d/d3d/D3DSurfaceData.java | 2 +- .../windows/classes/sun/java2d/d3d/D3DSurfaceDataProxy.java | 2 +- .../windows/classes/sun/java2d/d3d/D3DTextRenderer.java | 2 +- .../classes/sun/java2d/d3d/D3DVolatileSurfaceManager.java | 2 +- .../windows/classes/sun/java2d/opengl/WGLGraphicsConfig.java | 2 +- .../windows/classes/sun/java2d/opengl/WGLSurfaceData.java | 2 +- .../classes/sun/java2d/opengl/WGLVolatileSurfaceManager.java | 2 +- .../windows/classes/sun/java2d/windows/GDIBlitLoops.java | 2 +- .../windows/classes/sun/java2d/windows/GDIRenderer.java | 2 +- .../classes/sun/java2d/windows/GDIWindowSurfaceData.java | 2 +- .../windows/classes/sun/print/PlatformPrinterJobProxy.java | 2 +- .../windows/classes/sun/print/PrintServiceLookupProvider.java | 2 +- src/java.desktop/windows/classes/sun/print/Win32MediaTray.java | 2 +- src/java.desktop/windows/classes/sun/print/Win32PrintJob.java | 2 +- .../windows/classes/sun/print/Win32PrintService.java | 2 +- .../classes/sun/swing/plaf/windows/ClassicSortArrowIcon.java | 2 +- src/java.desktop/windows/native/libawt/windows/awt_Dialog.h | 2 +- .../windows/native/libawt/windows/awt_GDIObject.cpp | 2 +- .../windows/native/libawt/windows/awt_InputMethod.cpp | 2 +- src/java.desktop/windows/native/libawt/windows/awt_Mlib.cpp | 2 +- src/java.desktop/windows/native/libawt/windows/awt_PrintJob.cpp | 2 +- src/java.desktop/windows/native/libawt/windows/awt_new.cpp | 2 +- .../java/awt/Choice/ChoiceLocationTest/ChoiceLocationTest.java | 2 +- test/jdk/java/awt/Dialog/CloseDialog/CloseDialogTest.java | 2 +- test/jdk/java/awt/Focus/ChoiceFocus/ChoiceFocus.java | 2 +- .../awt/Frame/GetGraphicsStressTest/GetGraphicsStressTest.java | 2 +- .../awt/Frame/ShapeNotSetSometimes/ShapeNotSetSometimes.java | 2 +- .../java/awt/List/FirstItemRemoveTest/FirstItemRemoveTest.java | 2 +- .../java/awt/List/FocusEmptyListTest/FocusEmptyListTest.java | 2 +- test/jdk/java/awt/Modal/PrintDialogsTest/PrintDialogsTest.java | 2 +- test/jdk/java/awt/Modal/PrintDialogsTest/Test.java | 2 +- .../Mouse/GetMousePositionTest/GetMousePositionWithOverlay.java | 2 +- .../Mouse/GetMousePositionTest/GetMousePositionWithPopup.java | 2 +- .../PageSetupDlgBlockingTest/PageSetupDlgBlockingTest.java | 2 +- .../TextArea/TextAreaCursorTest/HoveringAndDraggingTest.java | 2 +- test/jdk/java/awt/TextArea/TextScrollTest.java | 2 +- .../DragUnicodeBetweenJVMTest/DragUnicodeBetweenJVMTest.java | 2 +- .../datatransfer/MissedHtmlAndRtfBug/MissedHtmlAndRtfBug.java | 2 +- .../awt/dnd/DnDFileGroupDescriptor/DnDFileGroupDescriptor.java | 2 +- .../dnd/FileListBetweenJVMsTest/FileListBetweenJVMsTest.java | 2 +- .../awt/dnd/URIListBetweenJVMsTest/URIListBetweenJVMsTest.java | 2 +- .../URIListToFileListBetweenJVMsTest.java | 2 +- test/jdk/java/awt/event/KeyEvent/KeyTyped/EscapeKeyTyped.java | 2 +- .../MenuDragMouseEventAbsoluteCoordsTest.java | 2 +- .../MouseWheelEvent/InfiniteRecursion/InfiniteRecursion_2.java | 2 +- .../MouseWheelEvent/InfiniteRecursion/InfiniteRecursion_3.java | 2 +- test/jdk/java/awt/event/helpers/lwcomponents/LWButton.java | 2 +- test/jdk/java/awt/font/GlyphVector/GetGlyphCharIndexTest.java | 2 +- .../java/awt/grab/EmbeddedFrameTest1/EmbeddedFrameTest1.java | 2 +- test/jdk/java/awt/im/8041990/bug8041990.java | 2 +- test/jdk/java/awt/im/PinyinIMCapsTest.java | 2 +- test/jdk/java/awt/im/PinyinIMCommaTest.java | 2 +- test/jdk/java/awt/im/PinyinIMFullstopTest.java | 2 +- .../java/awt/image/AffineTransformOp/AffineTxOpSizeTest.java | 2 +- test/jdk/java/awt/image/DrawImage/TiledImage.java | 2 +- test/jdk/java/awt/print/Dialog/DialogOrient.java | 2 +- test/jdk/java/awt/print/PrinterJob/PageDialogTest.java | 2 +- test/jdk/java/awt/print/PrinterJob/PrintDialog.java | 2 +- test/jdk/java/awt/print/PrinterJob/PrintDialogCancel.java | 2 +- test/jdk/java/awt/print/PrinterJob/ThinLines.java | 2 +- .../RemotePrinterStatusRefresh/RemotePrinterStatusRefresh.java | 2 +- test/jdk/java/awt/regtesthelpers/AbstractTest.java | 2 +- test/jdk/java/awt/regtesthelpers/Util.java | 2 +- .../java/awt/regtesthelpers/process/ProcessCommunicator.java | 2 +- .../javax/sound/midi/MidiDeviceConnectors/TestAllDevices.java | 2 +- test/jdk/javax/sound/midi/Sequencer/Looping.java | 2 +- test/jdk/javax/sound/midi/SysexMessage/SendRawSysexMessage.java | 2 +- .../sound/midi/spi/MidiDeviceProvider/ExpectedNPEOnNull.java | 2 +- test/jdk/javax/sound/midi/spi/MidiDeviceProvider/FakeInfo.java | 2 +- .../sound/midi/spi/MidiDeviceProvider/UnsupportedInfo.java | 2 +- test/jdk/javax/sound/sampled/Clip/ClipFlushCrash.java | 2 +- test/jdk/javax/sound/sampled/Clip/IsRunningHang.java | 2 +- .../sound/sampled/Clip/OpenNonIntegralNumberOfSampleframes.java | 2 +- test/jdk/javax/sound/sampled/DataLine/LongFramePosition.java | 2 +- test/jdk/javax/sound/sampled/DirectAudio/bug6372428.java | 2 +- test/jdk/javax/sound/sampled/LinuxBlock/PlaySine.java | 2 +- test/jdk/javax/swing/JOptionPane/bug4174551.java | 2 +- test/jdk/javax/swing/JTextArea/4697612/bug4697612.java | 2 +- .../javax/swing/text/html/parser/Parser/6990651/bug6990651.java | 2 +- .../javax/swing/text/html/parser/Parser/8078268/bug8078268.java | 2 +- test/jdk/sun/java2d/marlin/ClipShapeTest.java | 2 +- test/jdk/sun/java2d/marlin/CrashNaNTest.java | 2 +- test/jdk/sun/java2d/marlin/CrashPaintTest.java | 2 +- test/jdk/sun/java2d/marlin/TextClipErrorTest.java | 2 +- 565 files changed, 565 insertions(+), 565 deletions(-) diff --git a/src/java.desktop/aix/classes/sun/awt/X11InputMethod.java b/src/java.desktop/aix/classes/sun/awt/X11InputMethod.java index 93098a04842..5e52421700c 100644 --- a/src/java.desktop/aix/classes/sun/awt/X11InputMethod.java +++ b/src/java.desktop/aix/classes/sun/awt/X11InputMethod.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 1997, 2021, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 1997, 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 diff --git a/src/java.desktop/macosx/classes/apple/laf/JRSUIControl.java b/src/java.desktop/macosx/classes/apple/laf/JRSUIControl.java index f28e05d1877..5bcd729a804 100644 --- a/src/java.desktop/macosx/classes/apple/laf/JRSUIControl.java +++ b/src/java.desktop/macosx/classes/apple/laf/JRSUIControl.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2011, 2017, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2011, 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 diff --git a/src/java.desktop/macosx/classes/apple/laf/JRSUIFocus.java b/src/java.desktop/macosx/classes/apple/laf/JRSUIFocus.java index e990273b200..3c6704093e6 100644 --- a/src/java.desktop/macosx/classes/apple/laf/JRSUIFocus.java +++ b/src/java.desktop/macosx/classes/apple/laf/JRSUIFocus.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2011, 2012, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2011, 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 diff --git a/src/java.desktop/macosx/classes/apple/laf/JRSUIState.java b/src/java.desktop/macosx/classes/apple/laf/JRSUIState.java index 62176e40497..bc2446a5b62 100644 --- a/src/java.desktop/macosx/classes/apple/laf/JRSUIState.java +++ b/src/java.desktop/macosx/classes/apple/laf/JRSUIState.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2011, 2012, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2011, 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 diff --git a/src/java.desktop/macosx/classes/apple/laf/JRSUIStateFactory.java b/src/java.desktop/macosx/classes/apple/laf/JRSUIStateFactory.java index 52913b9ed23..fccc1669e26 100644 --- a/src/java.desktop/macosx/classes/apple/laf/JRSUIStateFactory.java +++ b/src/java.desktop/macosx/classes/apple/laf/JRSUIStateFactory.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2011, 2012, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2011, 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 diff --git a/src/java.desktop/macosx/classes/apple/laf/JRSUIUtils.java b/src/java.desktop/macosx/classes/apple/laf/JRSUIUtils.java index 217985eecfa..fbd993d3fd3 100644 --- a/src/java.desktop/macosx/classes/apple/laf/JRSUIUtils.java +++ b/src/java.desktop/macosx/classes/apple/laf/JRSUIUtils.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2011, 2024, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2011, 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 diff --git a/src/java.desktop/macosx/classes/com/apple/eawt/ApplicationBeanInfo.java b/src/java.desktop/macosx/classes/com/apple/eawt/ApplicationBeanInfo.java index 9fc34576857..e3f8a103d79 100644 --- a/src/java.desktop/macosx/classes/com/apple/eawt/ApplicationBeanInfo.java +++ b/src/java.desktop/macosx/classes/com/apple/eawt/ApplicationBeanInfo.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2011, 2012, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2011, 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 diff --git a/src/java.desktop/macosx/classes/com/apple/eawt/FullScreenAdapter.java b/src/java.desktop/macosx/classes/com/apple/eawt/FullScreenAdapter.java index c1fdb932c90..5b50b1961bb 100644 --- a/src/java.desktop/macosx/classes/com/apple/eawt/FullScreenAdapter.java +++ b/src/java.desktop/macosx/classes/com/apple/eawt/FullScreenAdapter.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2011, 2017, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2011, 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 diff --git a/src/java.desktop/macosx/classes/com/apple/eawt/MacQuitResponse.java b/src/java.desktop/macosx/classes/com/apple/eawt/MacQuitResponse.java index c207e8d58a8..1ad917083fd 100644 --- a/src/java.desktop/macosx/classes/com/apple/eawt/MacQuitResponse.java +++ b/src/java.desktop/macosx/classes/com/apple/eawt/MacQuitResponse.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2011, 2017, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2011, 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 diff --git a/src/java.desktop/macosx/classes/com/apple/eawt/_AppDockIconHandler.java b/src/java.desktop/macosx/classes/com/apple/eawt/_AppDockIconHandler.java index 0fcbdce4720..02abb13f357 100644 --- a/src/java.desktop/macosx/classes/com/apple/eawt/_AppDockIconHandler.java +++ b/src/java.desktop/macosx/classes/com/apple/eawt/_AppDockIconHandler.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2011, 2016, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2011, 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 diff --git a/src/java.desktop/macosx/classes/com/apple/eawt/_AppEventHandler.java b/src/java.desktop/macosx/classes/com/apple/eawt/_AppEventHandler.java index 3cf6a1ba1d6..d1b747a8f30 100644 --- a/src/java.desktop/macosx/classes/com/apple/eawt/_AppEventHandler.java +++ b/src/java.desktop/macosx/classes/com/apple/eawt/_AppEventHandler.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2011, 2021, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2011, 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 diff --git a/src/java.desktop/macosx/classes/com/apple/eawt/_AppMenuBarHandler.java b/src/java.desktop/macosx/classes/com/apple/eawt/_AppMenuBarHandler.java index d891c65acf5..e62c8c557da 100644 --- a/src/java.desktop/macosx/classes/com/apple/eawt/_AppMenuBarHandler.java +++ b/src/java.desktop/macosx/classes/com/apple/eawt/_AppMenuBarHandler.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2011, 2018, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2011, 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 diff --git a/src/java.desktop/macosx/classes/com/apple/eawt/_AppMiscHandlers.java b/src/java.desktop/macosx/classes/com/apple/eawt/_AppMiscHandlers.java index 5870b8d3586..73792c83499 100644 --- a/src/java.desktop/macosx/classes/com/apple/eawt/_AppMiscHandlers.java +++ b/src/java.desktop/macosx/classes/com/apple/eawt/_AppMiscHandlers.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2011, 2012, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2011, 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 diff --git a/src/java.desktop/macosx/classes/com/apple/eawt/event/FullScreenEvent.java b/src/java.desktop/macosx/classes/com/apple/eawt/event/FullScreenEvent.java index cf4ec3bea99..6ccc0043393 100644 --- a/src/java.desktop/macosx/classes/com/apple/eawt/event/FullScreenEvent.java +++ b/src/java.desktop/macosx/classes/com/apple/eawt/event/FullScreenEvent.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2016, Oracle and/or its affiliates. All rights reserved. + * 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 diff --git a/src/java.desktop/macosx/classes/com/apple/eawt/event/GestureAdapter.java b/src/java.desktop/macosx/classes/com/apple/eawt/event/GestureAdapter.java index 1b1da4fb095..77ea46851ca 100644 --- a/src/java.desktop/macosx/classes/com/apple/eawt/event/GestureAdapter.java +++ b/src/java.desktop/macosx/classes/com/apple/eawt/event/GestureAdapter.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2011, 2017, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2011, 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 diff --git a/src/java.desktop/macosx/classes/com/apple/eawt/event/GestureHandler.java b/src/java.desktop/macosx/classes/com/apple/eawt/event/GestureHandler.java index e3ff511f6f0..13bccecbbdc 100644 --- a/src/java.desktop/macosx/classes/com/apple/eawt/event/GestureHandler.java +++ b/src/java.desktop/macosx/classes/com/apple/eawt/event/GestureHandler.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2011, 2013, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2011, 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 diff --git a/src/java.desktop/macosx/classes/com/apple/eawt/event/GesturePhaseEvent.java b/src/java.desktop/macosx/classes/com/apple/eawt/event/GesturePhaseEvent.java index befad3d2633..7cce50518ca 100644 --- a/src/java.desktop/macosx/classes/com/apple/eawt/event/GesturePhaseEvent.java +++ b/src/java.desktop/macosx/classes/com/apple/eawt/event/GesturePhaseEvent.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2011, 2012, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2011, 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 diff --git a/src/java.desktop/macosx/classes/com/apple/eawt/event/MagnificationEvent.java b/src/java.desktop/macosx/classes/com/apple/eawt/event/MagnificationEvent.java index 3e771e21833..d6227829c76 100644 --- a/src/java.desktop/macosx/classes/com/apple/eawt/event/MagnificationEvent.java +++ b/src/java.desktop/macosx/classes/com/apple/eawt/event/MagnificationEvent.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2011, 2012, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2011, 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 diff --git a/src/java.desktop/macosx/classes/com/apple/eawt/event/RotationEvent.java b/src/java.desktop/macosx/classes/com/apple/eawt/event/RotationEvent.java index 3b8375f83c2..6e3b3fff264 100644 --- a/src/java.desktop/macosx/classes/com/apple/eawt/event/RotationEvent.java +++ b/src/java.desktop/macosx/classes/com/apple/eawt/event/RotationEvent.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2011, 2012, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2011, 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 diff --git a/src/java.desktop/macosx/classes/com/apple/eawt/event/SwipeEvent.java b/src/java.desktop/macosx/classes/com/apple/eawt/event/SwipeEvent.java index 07ea97fcb7c..660cc68718b 100644 --- a/src/java.desktop/macosx/classes/com/apple/eawt/event/SwipeEvent.java +++ b/src/java.desktop/macosx/classes/com/apple/eawt/event/SwipeEvent.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2011, 2012, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2011, 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 diff --git a/src/java.desktop/macosx/classes/com/apple/eio/FileManager.java b/src/java.desktop/macosx/classes/com/apple/eio/FileManager.java index ce206446ce5..375591bcdd8 100644 --- a/src/java.desktop/macosx/classes/com/apple/eio/FileManager.java +++ b/src/java.desktop/macosx/classes/com/apple/eio/FileManager.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2011, 2024, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2011, 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 diff --git a/src/java.desktop/macosx/classes/com/apple/laf/AquaButtonCheckBoxUI.java b/src/java.desktop/macosx/classes/com/apple/laf/AquaButtonCheckBoxUI.java index 0e92da43084..958d5103771 100644 --- a/src/java.desktop/macosx/classes/com/apple/laf/AquaButtonCheckBoxUI.java +++ b/src/java.desktop/macosx/classes/com/apple/laf/AquaButtonCheckBoxUI.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2011, 2012, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2011, 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 diff --git a/src/java.desktop/macosx/classes/com/apple/laf/AquaButtonExtendedTypes.java b/src/java.desktop/macosx/classes/com/apple/laf/AquaButtonExtendedTypes.java index 0927df6aa9e..129175eef7b 100644 --- a/src/java.desktop/macosx/classes/com/apple/laf/AquaButtonExtendedTypes.java +++ b/src/java.desktop/macosx/classes/com/apple/laf/AquaButtonExtendedTypes.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2011, 2014, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2011, 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 diff --git a/src/java.desktop/macosx/classes/com/apple/laf/AquaButtonLabeledUI.java b/src/java.desktop/macosx/classes/com/apple/laf/AquaButtonLabeledUI.java index c4e2e1b8a5e..4e49c791928 100644 --- a/src/java.desktop/macosx/classes/com/apple/laf/AquaButtonLabeledUI.java +++ b/src/java.desktop/macosx/classes/com/apple/laf/AquaButtonLabeledUI.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2011, 2022, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2011, 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 diff --git a/src/java.desktop/macosx/classes/com/apple/laf/AquaButtonRadioUI.java b/src/java.desktop/macosx/classes/com/apple/laf/AquaButtonRadioUI.java index 1fdb8a30f5d..0aa81c57958 100644 --- a/src/java.desktop/macosx/classes/com/apple/laf/AquaButtonRadioUI.java +++ b/src/java.desktop/macosx/classes/com/apple/laf/AquaButtonRadioUI.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2011, 2018, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2011, 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 diff --git a/src/java.desktop/macosx/classes/com/apple/laf/AquaButtonToggleUI.java b/src/java.desktop/macosx/classes/com/apple/laf/AquaButtonToggleUI.java index 5eb0fbbccb6..740c7715d3f 100644 --- a/src/java.desktop/macosx/classes/com/apple/laf/AquaButtonToggleUI.java +++ b/src/java.desktop/macosx/classes/com/apple/laf/AquaButtonToggleUI.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2011, 2012, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2011, 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 diff --git a/src/java.desktop/macosx/classes/com/apple/laf/AquaCaret.java b/src/java.desktop/macosx/classes/com/apple/laf/AquaCaret.java index eaf84295c11..4e032d6afba 100644 --- a/src/java.desktop/macosx/classes/com/apple/laf/AquaCaret.java +++ b/src/java.desktop/macosx/classes/com/apple/laf/AquaCaret.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2011, 2024, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2011, 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 diff --git a/src/java.desktop/macosx/classes/com/apple/laf/AquaComboBoxButton.java b/src/java.desktop/macosx/classes/com/apple/laf/AquaComboBoxButton.java index e691153df73..310166c6151 100644 --- a/src/java.desktop/macosx/classes/com/apple/laf/AquaComboBoxButton.java +++ b/src/java.desktop/macosx/classes/com/apple/laf/AquaComboBoxButton.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2011, 2024, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2011, 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 diff --git a/src/java.desktop/macosx/classes/com/apple/laf/AquaComboBoxRenderer.java b/src/java.desktop/macosx/classes/com/apple/laf/AquaComboBoxRenderer.java index 02e0cc7aaf6..fa57316a7c6 100644 --- a/src/java.desktop/macosx/classes/com/apple/laf/AquaComboBoxRenderer.java +++ b/src/java.desktop/macosx/classes/com/apple/laf/AquaComboBoxRenderer.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2011, 2014, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2011, 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 diff --git a/src/java.desktop/macosx/classes/com/apple/laf/AquaComboBoxRendererInternal.java b/src/java.desktop/macosx/classes/com/apple/laf/AquaComboBoxRendererInternal.java index ac76eb0f771..97edcdadffe 100644 --- a/src/java.desktop/macosx/classes/com/apple/laf/AquaComboBoxRendererInternal.java +++ b/src/java.desktop/macosx/classes/com/apple/laf/AquaComboBoxRendererInternal.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2013, 2019, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2013, 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 diff --git a/src/java.desktop/macosx/classes/com/apple/laf/AquaComboBoxUI.java b/src/java.desktop/macosx/classes/com/apple/laf/AquaComboBoxUI.java index a4c85a7676f..9e90ae3c397 100644 --- a/src/java.desktop/macosx/classes/com/apple/laf/AquaComboBoxUI.java +++ b/src/java.desktop/macosx/classes/com/apple/laf/AquaComboBoxUI.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2011, 2024, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2011, 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 diff --git a/src/java.desktop/macosx/classes/com/apple/laf/AquaEditorPaneUI.java b/src/java.desktop/macosx/classes/com/apple/laf/AquaEditorPaneUI.java index 2f2e8e6c107..ba58f505b31 100644 --- a/src/java.desktop/macosx/classes/com/apple/laf/AquaEditorPaneUI.java +++ b/src/java.desktop/macosx/classes/com/apple/laf/AquaEditorPaneUI.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2011, 2015, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2011, 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 diff --git a/src/java.desktop/macosx/classes/com/apple/laf/AquaFileChooserUI.java b/src/java.desktop/macosx/classes/com/apple/laf/AquaFileChooserUI.java index feeec997ea4..023551e8f58 100644 --- a/src/java.desktop/macosx/classes/com/apple/laf/AquaFileChooserUI.java +++ b/src/java.desktop/macosx/classes/com/apple/laf/AquaFileChooserUI.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2011, 2024, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2011, 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 diff --git a/src/java.desktop/macosx/classes/com/apple/laf/AquaFileSystemModel.java b/src/java.desktop/macosx/classes/com/apple/laf/AquaFileSystemModel.java index 1c0b01e0a36..af7c9c09021 100644 --- a/src/java.desktop/macosx/classes/com/apple/laf/AquaFileSystemModel.java +++ b/src/java.desktop/macosx/classes/com/apple/laf/AquaFileSystemModel.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2011, 2021, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2011, 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 diff --git a/src/java.desktop/macosx/classes/com/apple/laf/AquaFileView.java b/src/java.desktop/macosx/classes/com/apple/laf/AquaFileView.java index 6a2c9f9466b..e271fdb391e 100644 --- a/src/java.desktop/macosx/classes/com/apple/laf/AquaFileView.java +++ b/src/java.desktop/macosx/classes/com/apple/laf/AquaFileView.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2011, 2024, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2011, 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 diff --git a/src/java.desktop/macosx/classes/com/apple/laf/AquaFocus.java b/src/java.desktop/macosx/classes/com/apple/laf/AquaFocus.java index c8ce8dd058b..33176e0b5e1 100644 --- a/src/java.desktop/macosx/classes/com/apple/laf/AquaFocus.java +++ b/src/java.desktop/macosx/classes/com/apple/laf/AquaFocus.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2011, 2012, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2011, 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 diff --git a/src/java.desktop/macosx/classes/com/apple/laf/AquaFocusHandler.java b/src/java.desktop/macosx/classes/com/apple/laf/AquaFocusHandler.java index a245ae35d8c..351fa8ea9cc 100644 --- a/src/java.desktop/macosx/classes/com/apple/laf/AquaFocusHandler.java +++ b/src/java.desktop/macosx/classes/com/apple/laf/AquaFocusHandler.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2011, 2022, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2011, 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 diff --git a/src/java.desktop/macosx/classes/com/apple/laf/AquaFonts.java b/src/java.desktop/macosx/classes/com/apple/laf/AquaFonts.java index 21886f9709f..b8761beafb9 100644 --- a/src/java.desktop/macosx/classes/com/apple/laf/AquaFonts.java +++ b/src/java.desktop/macosx/classes/com/apple/laf/AquaFonts.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2011, 2014, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2011, 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 diff --git a/src/java.desktop/macosx/classes/com/apple/laf/AquaGroupBorder.java b/src/java.desktop/macosx/classes/com/apple/laf/AquaGroupBorder.java index d85025a3b77..dc0382350c8 100644 --- a/src/java.desktop/macosx/classes/com/apple/laf/AquaGroupBorder.java +++ b/src/java.desktop/macosx/classes/com/apple/laf/AquaGroupBorder.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2011, 2012, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2011, 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 diff --git a/src/java.desktop/macosx/classes/com/apple/laf/AquaHighlighter.java b/src/java.desktop/macosx/classes/com/apple/laf/AquaHighlighter.java index cdb36932893..1ba237afeff 100644 --- a/src/java.desktop/macosx/classes/com/apple/laf/AquaHighlighter.java +++ b/src/java.desktop/macosx/classes/com/apple/laf/AquaHighlighter.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2011, 2012, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2011, 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 diff --git a/src/java.desktop/macosx/classes/com/apple/laf/AquaIcon.java b/src/java.desktop/macosx/classes/com/apple/laf/AquaIcon.java index 07287402b97..4dd6c9a7bb9 100644 --- a/src/java.desktop/macosx/classes/com/apple/laf/AquaIcon.java +++ b/src/java.desktop/macosx/classes/com/apple/laf/AquaIcon.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2011, 2012, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2011, 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 diff --git a/src/java.desktop/macosx/classes/com/apple/laf/AquaImageFactory.java b/src/java.desktop/macosx/classes/com/apple/laf/AquaImageFactory.java index 679632db107..880235ee9b2 100644 --- a/src/java.desktop/macosx/classes/com/apple/laf/AquaImageFactory.java +++ b/src/java.desktop/macosx/classes/com/apple/laf/AquaImageFactory.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2011, 2024, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2011, 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 diff --git a/src/java.desktop/macosx/classes/com/apple/laf/AquaInternalFrameBorder.java b/src/java.desktop/macosx/classes/com/apple/laf/AquaInternalFrameBorder.java index 7d988912829..32fe22dafd2 100644 --- a/src/java.desktop/macosx/classes/com/apple/laf/AquaInternalFrameBorder.java +++ b/src/java.desktop/macosx/classes/com/apple/laf/AquaInternalFrameBorder.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2011, 2022, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2011, 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 diff --git a/src/java.desktop/macosx/classes/com/apple/laf/AquaInternalFrameManager.java b/src/java.desktop/macosx/classes/com/apple/laf/AquaInternalFrameManager.java index 388710e5416..4196f10c5b2 100644 --- a/src/java.desktop/macosx/classes/com/apple/laf/AquaInternalFrameManager.java +++ b/src/java.desktop/macosx/classes/com/apple/laf/AquaInternalFrameManager.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2011, 2014, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2011, 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 diff --git a/src/java.desktop/macosx/classes/com/apple/laf/AquaInternalFramePaneUI.java b/src/java.desktop/macosx/classes/com/apple/laf/AquaInternalFramePaneUI.java index a41cee6ca30..b1103d3571b 100644 --- a/src/java.desktop/macosx/classes/com/apple/laf/AquaInternalFramePaneUI.java +++ b/src/java.desktop/macosx/classes/com/apple/laf/AquaInternalFramePaneUI.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2011, 2021, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2011, 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 diff --git a/src/java.desktop/macosx/classes/com/apple/laf/AquaInternalFrameUI.java b/src/java.desktop/macosx/classes/com/apple/laf/AquaInternalFrameUI.java index 56829f8abf7..f82d14d0df0 100644 --- a/src/java.desktop/macosx/classes/com/apple/laf/AquaInternalFrameUI.java +++ b/src/java.desktop/macosx/classes/com/apple/laf/AquaInternalFrameUI.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2011, 2021, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2011, 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 diff --git a/src/java.desktop/macosx/classes/com/apple/laf/AquaLabelUI.java b/src/java.desktop/macosx/classes/com/apple/laf/AquaLabelUI.java index bff6d13106d..2109758ac1e 100644 --- a/src/java.desktop/macosx/classes/com/apple/laf/AquaLabelUI.java +++ b/src/java.desktop/macosx/classes/com/apple/laf/AquaLabelUI.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2011, 2024, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2011, 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 diff --git a/src/java.desktop/macosx/classes/com/apple/laf/AquaListUI.java b/src/java.desktop/macosx/classes/com/apple/laf/AquaListUI.java index f0760c1f551..a15678b9357 100644 --- a/src/java.desktop/macosx/classes/com/apple/laf/AquaListUI.java +++ b/src/java.desktop/macosx/classes/com/apple/laf/AquaListUI.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2011, 2014, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2011, 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 diff --git a/src/java.desktop/macosx/classes/com/apple/laf/AquaLookAndFeel.java b/src/java.desktop/macosx/classes/com/apple/laf/AquaLookAndFeel.java index 633b292dbc3..ccc52fd0105 100644 --- a/src/java.desktop/macosx/classes/com/apple/laf/AquaLookAndFeel.java +++ b/src/java.desktop/macosx/classes/com/apple/laf/AquaLookAndFeel.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2011, 2024, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2011, 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 diff --git a/src/java.desktop/macosx/classes/com/apple/laf/AquaMenuBarBorder.java b/src/java.desktop/macosx/classes/com/apple/laf/AquaMenuBarBorder.java index ed70450ce88..7b5562d9a4a 100644 --- a/src/java.desktop/macosx/classes/com/apple/laf/AquaMenuBarBorder.java +++ b/src/java.desktop/macosx/classes/com/apple/laf/AquaMenuBarBorder.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2011, 2015, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2011, 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 diff --git a/src/java.desktop/macosx/classes/com/apple/laf/AquaMenuBarUI.java b/src/java.desktop/macosx/classes/com/apple/laf/AquaMenuBarUI.java index d1804c8ae29..d499b40f238 100644 --- a/src/java.desktop/macosx/classes/com/apple/laf/AquaMenuBarUI.java +++ b/src/java.desktop/macosx/classes/com/apple/laf/AquaMenuBarUI.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2011, 2024, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2011, 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 diff --git a/src/java.desktop/macosx/classes/com/apple/laf/AquaMenuBorder.java b/src/java.desktop/macosx/classes/com/apple/laf/AquaMenuBorder.java index 1712b4c2448..187532e315b 100644 --- a/src/java.desktop/macosx/classes/com/apple/laf/AquaMenuBorder.java +++ b/src/java.desktop/macosx/classes/com/apple/laf/AquaMenuBorder.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2011, 2012, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2011, 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 diff --git a/src/java.desktop/macosx/classes/com/apple/laf/AquaMenuItemUI.java b/src/java.desktop/macosx/classes/com/apple/laf/AquaMenuItemUI.java index 901fbd7b2c6..340f48534a3 100644 --- a/src/java.desktop/macosx/classes/com/apple/laf/AquaMenuItemUI.java +++ b/src/java.desktop/macosx/classes/com/apple/laf/AquaMenuItemUI.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2011, 2018, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2011, 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 diff --git a/src/java.desktop/macosx/classes/com/apple/laf/AquaMenuPainter.java b/src/java.desktop/macosx/classes/com/apple/laf/AquaMenuPainter.java index b7878b67483..c2007ef2774 100644 --- a/src/java.desktop/macosx/classes/com/apple/laf/AquaMenuPainter.java +++ b/src/java.desktop/macosx/classes/com/apple/laf/AquaMenuPainter.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2011, 2024, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2011, 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 diff --git a/src/java.desktop/macosx/classes/com/apple/laf/AquaMenuUI.java b/src/java.desktop/macosx/classes/com/apple/laf/AquaMenuUI.java index 7057e583c58..75e4bd98954 100644 --- a/src/java.desktop/macosx/classes/com/apple/laf/AquaMenuUI.java +++ b/src/java.desktop/macosx/classes/com/apple/laf/AquaMenuUI.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2011, 2018, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2011, 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 diff --git a/src/java.desktop/macosx/classes/com/apple/laf/AquaNativeResources.java b/src/java.desktop/macosx/classes/com/apple/laf/AquaNativeResources.java index 22457379fa1..ed68924ff4f 100644 --- a/src/java.desktop/macosx/classes/com/apple/laf/AquaNativeResources.java +++ b/src/java.desktop/macosx/classes/com/apple/laf/AquaNativeResources.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2011, 2024, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2011, 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 diff --git a/src/java.desktop/macosx/classes/com/apple/laf/AquaOptionPaneUI.java b/src/java.desktop/macosx/classes/com/apple/laf/AquaOptionPaneUI.java index b3312d9fa7b..59b00b315e3 100644 --- a/src/java.desktop/macosx/classes/com/apple/laf/AquaOptionPaneUI.java +++ b/src/java.desktop/macosx/classes/com/apple/laf/AquaOptionPaneUI.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2011, 2012, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2011, 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 diff --git a/src/java.desktop/macosx/classes/com/apple/laf/AquaPainter.java b/src/java.desktop/macosx/classes/com/apple/laf/AquaPainter.java index 910907134ee..a5ebcbaef4c 100644 --- a/src/java.desktop/macosx/classes/com/apple/laf/AquaPainter.java +++ b/src/java.desktop/macosx/classes/com/apple/laf/AquaPainter.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2011, 2014, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2011, 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 diff --git a/src/java.desktop/macosx/classes/com/apple/laf/AquaPanelUI.java b/src/java.desktop/macosx/classes/com/apple/laf/AquaPanelUI.java index 3db2eca1754..bec82195ec5 100644 --- a/src/java.desktop/macosx/classes/com/apple/laf/AquaPanelUI.java +++ b/src/java.desktop/macosx/classes/com/apple/laf/AquaPanelUI.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2011, 2012, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2011, 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 diff --git a/src/java.desktop/macosx/classes/com/apple/laf/AquaPopupMenuSeparatorUI.java b/src/java.desktop/macosx/classes/com/apple/laf/AquaPopupMenuSeparatorUI.java index 3b7388062cc..7e2e7849f42 100644 --- a/src/java.desktop/macosx/classes/com/apple/laf/AquaPopupMenuSeparatorUI.java +++ b/src/java.desktop/macosx/classes/com/apple/laf/AquaPopupMenuSeparatorUI.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2011, 2012, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2011, 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 diff --git a/src/java.desktop/macosx/classes/com/apple/laf/AquaPopupMenuUI.java b/src/java.desktop/macosx/classes/com/apple/laf/AquaPopupMenuUI.java index 4b9d9a301ba..64b3f1e35b1 100644 --- a/src/java.desktop/macosx/classes/com/apple/laf/AquaPopupMenuUI.java +++ b/src/java.desktop/macosx/classes/com/apple/laf/AquaPopupMenuUI.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2011, 2012, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2011, 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 diff --git a/src/java.desktop/macosx/classes/com/apple/laf/AquaProgressBarUI.java b/src/java.desktop/macosx/classes/com/apple/laf/AquaProgressBarUI.java index b6e5fb5f170..58aee090712 100644 --- a/src/java.desktop/macosx/classes/com/apple/laf/AquaProgressBarUI.java +++ b/src/java.desktop/macosx/classes/com/apple/laf/AquaProgressBarUI.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2011, 2024, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2011, 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 diff --git a/src/java.desktop/macosx/classes/com/apple/laf/AquaScrollBarUI.java b/src/java.desktop/macosx/classes/com/apple/laf/AquaScrollBarUI.java index d8cc229eb55..6bbc31c3a35 100644 --- a/src/java.desktop/macosx/classes/com/apple/laf/AquaScrollBarUI.java +++ b/src/java.desktop/macosx/classes/com/apple/laf/AquaScrollBarUI.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2021, 2024, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2021, 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 diff --git a/src/java.desktop/macosx/classes/com/apple/laf/AquaScrollPaneUI.java b/src/java.desktop/macosx/classes/com/apple/laf/AquaScrollPaneUI.java index f1f30e39cc9..c8d2b73b2bb 100644 --- a/src/java.desktop/macosx/classes/com/apple/laf/AquaScrollPaneUI.java +++ b/src/java.desktop/macosx/classes/com/apple/laf/AquaScrollPaneUI.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2011, 2012, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2011, 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 diff --git a/src/java.desktop/macosx/classes/com/apple/laf/AquaScrollRegionBorder.java b/src/java.desktop/macosx/classes/com/apple/laf/AquaScrollRegionBorder.java index 4c03991e55d..8f5bbc7c087 100644 --- a/src/java.desktop/macosx/classes/com/apple/laf/AquaScrollRegionBorder.java +++ b/src/java.desktop/macosx/classes/com/apple/laf/AquaScrollRegionBorder.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2011, 2012, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2011, 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 diff --git a/src/java.desktop/macosx/classes/com/apple/laf/AquaSliderUI.java b/src/java.desktop/macosx/classes/com/apple/laf/AquaSliderUI.java index 9f8b4458f73..2486dbb6213 100644 --- a/src/java.desktop/macosx/classes/com/apple/laf/AquaSliderUI.java +++ b/src/java.desktop/macosx/classes/com/apple/laf/AquaSliderUI.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2011, 2021, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2011, 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 diff --git a/src/java.desktop/macosx/classes/com/apple/laf/AquaSpinnerUI.java b/src/java.desktop/macosx/classes/com/apple/laf/AquaSpinnerUI.java index 057e898519a..4e4f5a315e2 100644 --- a/src/java.desktop/macosx/classes/com/apple/laf/AquaSpinnerUI.java +++ b/src/java.desktop/macosx/classes/com/apple/laf/AquaSpinnerUI.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2011, 2022, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2011, 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 diff --git a/src/java.desktop/macosx/classes/com/apple/laf/AquaSplitPaneDividerUI.java b/src/java.desktop/macosx/classes/com/apple/laf/AquaSplitPaneDividerUI.java index 7a4bc27470b..339484347aa 100644 --- a/src/java.desktop/macosx/classes/com/apple/laf/AquaSplitPaneDividerUI.java +++ b/src/java.desktop/macosx/classes/com/apple/laf/AquaSplitPaneDividerUI.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2011, 2014, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2011, 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 diff --git a/src/java.desktop/macosx/classes/com/apple/laf/AquaSplitPaneUI.java b/src/java.desktop/macosx/classes/com/apple/laf/AquaSplitPaneUI.java index 62e77a378dc..1b0ffe6caab 100644 --- a/src/java.desktop/macosx/classes/com/apple/laf/AquaSplitPaneUI.java +++ b/src/java.desktop/macosx/classes/com/apple/laf/AquaSplitPaneUI.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2011, 2012, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2011, 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 diff --git a/src/java.desktop/macosx/classes/com/apple/laf/AquaTabbedPaneContrastUI.java b/src/java.desktop/macosx/classes/com/apple/laf/AquaTabbedPaneContrastUI.java index 121af1c8bdc..bcbbe14557b 100644 --- a/src/java.desktop/macosx/classes/com/apple/laf/AquaTabbedPaneContrastUI.java +++ b/src/java.desktop/macosx/classes/com/apple/laf/AquaTabbedPaneContrastUI.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2011, 2021, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2011, 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 diff --git a/src/java.desktop/macosx/classes/com/apple/laf/AquaTabbedPaneTabState.java b/src/java.desktop/macosx/classes/com/apple/laf/AquaTabbedPaneTabState.java index 649b9d0f345..205226991b3 100644 --- a/src/java.desktop/macosx/classes/com/apple/laf/AquaTabbedPaneTabState.java +++ b/src/java.desktop/macosx/classes/com/apple/laf/AquaTabbedPaneTabState.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2011, 2018, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2011, 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 diff --git a/src/java.desktop/macosx/classes/com/apple/laf/AquaTabbedPaneUI.java b/src/java.desktop/macosx/classes/com/apple/laf/AquaTabbedPaneUI.java index 3e9a98d220b..1c9b33e3b75 100644 --- a/src/java.desktop/macosx/classes/com/apple/laf/AquaTabbedPaneUI.java +++ b/src/java.desktop/macosx/classes/com/apple/laf/AquaTabbedPaneUI.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2011, 2024, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2011, 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 diff --git a/src/java.desktop/macosx/classes/com/apple/laf/AquaTableHeaderBorder.java b/src/java.desktop/macosx/classes/com/apple/laf/AquaTableHeaderBorder.java index 0fd3d30e8be..506a59a1a2a 100644 --- a/src/java.desktop/macosx/classes/com/apple/laf/AquaTableHeaderBorder.java +++ b/src/java.desktop/macosx/classes/com/apple/laf/AquaTableHeaderBorder.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2011, 2022, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2011, 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 diff --git a/src/java.desktop/macosx/classes/com/apple/laf/AquaTableHeaderUI.java b/src/java.desktop/macosx/classes/com/apple/laf/AquaTableHeaderUI.java index b614ff2a5ab..0ea0b5d2121 100644 --- a/src/java.desktop/macosx/classes/com/apple/laf/AquaTableHeaderUI.java +++ b/src/java.desktop/macosx/classes/com/apple/laf/AquaTableHeaderUI.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2011, 2021, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2011, 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 diff --git a/src/java.desktop/macosx/classes/com/apple/laf/AquaTableUI.java b/src/java.desktop/macosx/classes/com/apple/laf/AquaTableUI.java index 31702152c3c..95ba34eeb1f 100644 --- a/src/java.desktop/macosx/classes/com/apple/laf/AquaTableUI.java +++ b/src/java.desktop/macosx/classes/com/apple/laf/AquaTableUI.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2011, 2012, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2011, 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 diff --git a/src/java.desktop/macosx/classes/com/apple/laf/AquaTextAreaUI.java b/src/java.desktop/macosx/classes/com/apple/laf/AquaTextAreaUI.java index 6ce1372c8f5..d968412da76 100644 --- a/src/java.desktop/macosx/classes/com/apple/laf/AquaTextAreaUI.java +++ b/src/java.desktop/macosx/classes/com/apple/laf/AquaTextAreaUI.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2011, 2015, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2011, 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 diff --git a/src/java.desktop/macosx/classes/com/apple/laf/AquaTextFieldBorder.java b/src/java.desktop/macosx/classes/com/apple/laf/AquaTextFieldBorder.java index eb07bb25724..effb97293e8 100644 --- a/src/java.desktop/macosx/classes/com/apple/laf/AquaTextFieldBorder.java +++ b/src/java.desktop/macosx/classes/com/apple/laf/AquaTextFieldBorder.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2011, 2012, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2011, 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 diff --git a/src/java.desktop/macosx/classes/com/apple/laf/AquaTextFieldFormattedUI.java b/src/java.desktop/macosx/classes/com/apple/laf/AquaTextFieldFormattedUI.java index 0bfbc556920..50085a9db9b 100644 --- a/src/java.desktop/macosx/classes/com/apple/laf/AquaTextFieldFormattedUI.java +++ b/src/java.desktop/macosx/classes/com/apple/laf/AquaTextFieldFormattedUI.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2011, 2012, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2011, 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 diff --git a/src/java.desktop/macosx/classes/com/apple/laf/AquaTextFieldSearch.java b/src/java.desktop/macosx/classes/com/apple/laf/AquaTextFieldSearch.java index 20b179da7d1..a8ae7fa3809 100644 --- a/src/java.desktop/macosx/classes/com/apple/laf/AquaTextFieldSearch.java +++ b/src/java.desktop/macosx/classes/com/apple/laf/AquaTextFieldSearch.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2011, 2024, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2011, 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 diff --git a/src/java.desktop/macosx/classes/com/apple/laf/AquaTextPaneUI.java b/src/java.desktop/macosx/classes/com/apple/laf/AquaTextPaneUI.java index 6fc391c5fec..571cbf6369a 100644 --- a/src/java.desktop/macosx/classes/com/apple/laf/AquaTextPaneUI.java +++ b/src/java.desktop/macosx/classes/com/apple/laf/AquaTextPaneUI.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2011, 2015, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2011, 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 diff --git a/src/java.desktop/macosx/classes/com/apple/laf/AquaTextPasswordFieldUI.java b/src/java.desktop/macosx/classes/com/apple/laf/AquaTextPasswordFieldUI.java index da52600075a..12b94e60243 100644 --- a/src/java.desktop/macosx/classes/com/apple/laf/AquaTextPasswordFieldUI.java +++ b/src/java.desktop/macosx/classes/com/apple/laf/AquaTextPasswordFieldUI.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2011, 2012, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2011, 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 diff --git a/src/java.desktop/macosx/classes/com/apple/laf/AquaToolBarSeparatorUI.java b/src/java.desktop/macosx/classes/com/apple/laf/AquaToolBarSeparatorUI.java index 09bd21f8c72..fc17d498a31 100644 --- a/src/java.desktop/macosx/classes/com/apple/laf/AquaToolBarSeparatorUI.java +++ b/src/java.desktop/macosx/classes/com/apple/laf/AquaToolBarSeparatorUI.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2011, 2012, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2011, 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 diff --git a/src/java.desktop/macosx/classes/com/apple/laf/AquaToolBarUI.java b/src/java.desktop/macosx/classes/com/apple/laf/AquaToolBarUI.java index 7adea86121e..0d15dd81f30 100644 --- a/src/java.desktop/macosx/classes/com/apple/laf/AquaToolBarUI.java +++ b/src/java.desktop/macosx/classes/com/apple/laf/AquaToolBarUI.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2011, 2014, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2011, 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 diff --git a/src/java.desktop/macosx/classes/com/apple/laf/AquaToolTipUI.java b/src/java.desktop/macosx/classes/com/apple/laf/AquaToolTipUI.java index e872cad0b94..38057c03f17 100644 --- a/src/java.desktop/macosx/classes/com/apple/laf/AquaToolTipUI.java +++ b/src/java.desktop/macosx/classes/com/apple/laf/AquaToolTipUI.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2011, 2012, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2011, 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 diff --git a/src/java.desktop/macosx/classes/com/apple/laf/AquaTreeUI.java b/src/java.desktop/macosx/classes/com/apple/laf/AquaTreeUI.java index 4a7aaff738e..2efb2bab994 100644 --- a/src/java.desktop/macosx/classes/com/apple/laf/AquaTreeUI.java +++ b/src/java.desktop/macosx/classes/com/apple/laf/AquaTreeUI.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2011, 2014, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2011, 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 diff --git a/src/java.desktop/macosx/classes/com/apple/laf/AquaUtilControlSize.java b/src/java.desktop/macosx/classes/com/apple/laf/AquaUtilControlSize.java index d5974049f30..48ecce0ecf4 100644 --- a/src/java.desktop/macosx/classes/com/apple/laf/AquaUtilControlSize.java +++ b/src/java.desktop/macosx/classes/com/apple/laf/AquaUtilControlSize.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2011, 2024, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2011, 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 diff --git a/src/java.desktop/macosx/classes/com/apple/laf/AquaUtils.java b/src/java.desktop/macosx/classes/com/apple/laf/AquaUtils.java index 610407e6160..da1785a9a63 100644 --- a/src/java.desktop/macosx/classes/com/apple/laf/AquaUtils.java +++ b/src/java.desktop/macosx/classes/com/apple/laf/AquaUtils.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2011, 2024, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2011, 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 diff --git a/src/java.desktop/macosx/classes/com/apple/laf/ScreenMenuBar.java b/src/java.desktop/macosx/classes/com/apple/laf/ScreenMenuBar.java index 83e37170fae..0b19064b96f 100644 --- a/src/java.desktop/macosx/classes/com/apple/laf/ScreenMenuBar.java +++ b/src/java.desktop/macosx/classes/com/apple/laf/ScreenMenuBar.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2011, 2015, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2011, 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 diff --git a/src/java.desktop/macosx/classes/com/apple/laf/ScreenMenuItem.java b/src/java.desktop/macosx/classes/com/apple/laf/ScreenMenuItem.java index 0e827e9b990..11eab4e2b36 100644 --- a/src/java.desktop/macosx/classes/com/apple/laf/ScreenMenuItem.java +++ b/src/java.desktop/macosx/classes/com/apple/laf/ScreenMenuItem.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2011, 2015, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2011, 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 diff --git a/src/java.desktop/macosx/classes/com/apple/laf/ScreenMenuItemCheckbox.java b/src/java.desktop/macosx/classes/com/apple/laf/ScreenMenuItemCheckbox.java index 4528d94df38..b5746a0ab90 100644 --- a/src/java.desktop/macosx/classes/com/apple/laf/ScreenMenuItemCheckbox.java +++ b/src/java.desktop/macosx/classes/com/apple/laf/ScreenMenuItemCheckbox.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2011, 2015, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2011, 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 diff --git a/src/java.desktop/macosx/classes/com/apple/laf/ScreenMenuPropertyListener.java b/src/java.desktop/macosx/classes/com/apple/laf/ScreenMenuPropertyListener.java index 5d04929fad6..c90991db597 100644 --- a/src/java.desktop/macosx/classes/com/apple/laf/ScreenMenuPropertyListener.java +++ b/src/java.desktop/macosx/classes/com/apple/laf/ScreenMenuPropertyListener.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2011, 2017, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2011, 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 diff --git a/src/java.desktop/macosx/classes/com/apple/laf/ScreenPopupFactory.java b/src/java.desktop/macosx/classes/com/apple/laf/ScreenPopupFactory.java index 2eda60c4e30..ff9cadae1b8 100644 --- a/src/java.desktop/macosx/classes/com/apple/laf/ScreenPopupFactory.java +++ b/src/java.desktop/macosx/classes/com/apple/laf/ScreenPopupFactory.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2011, 2012, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2011, 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 diff --git a/src/java.desktop/macosx/classes/sun/awt/CGraphicsConfig.java b/src/java.desktop/macosx/classes/sun/awt/CGraphicsConfig.java index 0ca85104817..a73809f0a4d 100644 --- a/src/java.desktop/macosx/classes/sun/awt/CGraphicsConfig.java +++ b/src/java.desktop/macosx/classes/sun/awt/CGraphicsConfig.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2011, 2024, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2011, 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 diff --git a/src/java.desktop/macosx/classes/sun/awt/CGraphicsEnvironment.java b/src/java.desktop/macosx/classes/sun/awt/CGraphicsEnvironment.java index 99e078c3064..292355ac2cf 100644 --- a/src/java.desktop/macosx/classes/sun/awt/CGraphicsEnvironment.java +++ b/src/java.desktop/macosx/classes/sun/awt/CGraphicsEnvironment.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2011, 2020, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2011, 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 diff --git a/src/java.desktop/macosx/classes/sun/awt/PlatformGraphicsInfo.java b/src/java.desktop/macosx/classes/sun/awt/PlatformGraphicsInfo.java index 97d4e444454..55eeda9b3e8 100644 --- a/src/java.desktop/macosx/classes/sun/awt/PlatformGraphicsInfo.java +++ b/src/java.desktop/macosx/classes/sun/awt/PlatformGraphicsInfo.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2019, 2024, Oracle and/or its affiliates. All rights reserved. + * 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 diff --git a/src/java.desktop/macosx/classes/sun/font/CCompositeGlyphMapper.java b/src/java.desktop/macosx/classes/sun/font/CCompositeGlyphMapper.java index b290d9a06e1..d9c2dadc87e 100644 --- a/src/java.desktop/macosx/classes/sun/font/CCompositeGlyphMapper.java +++ b/src/java.desktop/macosx/classes/sun/font/CCompositeGlyphMapper.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2015, 2018, Oracle and/or its affiliates. All rights reserved. + * 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 diff --git a/src/java.desktop/macosx/classes/sun/font/CFont.java b/src/java.desktop/macosx/classes/sun/font/CFont.java index f187c5bb14c..76409fb0b6a 100644 --- a/src/java.desktop/macosx/classes/sun/font/CFont.java +++ b/src/java.desktop/macosx/classes/sun/font/CFont.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2011, 2017, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2011, 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 diff --git a/src/java.desktop/macosx/classes/sun/font/CFontConfiguration.java b/src/java.desktop/macosx/classes/sun/font/CFontConfiguration.java index 6a711537be8..ba05dd733e3 100644 --- a/src/java.desktop/macosx/classes/sun/font/CFontConfiguration.java +++ b/src/java.desktop/macosx/classes/sun/font/CFontConfiguration.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2011, 2021, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2011, 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 diff --git a/src/java.desktop/macosx/classes/sun/font/CFontManager.java b/src/java.desktop/macosx/classes/sun/font/CFontManager.java index 72a9db3a01d..6504b71a27f 100644 --- a/src/java.desktop/macosx/classes/sun/font/CFontManager.java +++ b/src/java.desktop/macosx/classes/sun/font/CFontManager.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2011, 2024, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2011, 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 diff --git a/src/java.desktop/macosx/classes/sun/font/CStrikeDisposer.java b/src/java.desktop/macosx/classes/sun/font/CStrikeDisposer.java index c37209c8396..665f6465261 100644 --- a/src/java.desktop/macosx/classes/sun/font/CStrikeDisposer.java +++ b/src/java.desktop/macosx/classes/sun/font/CStrikeDisposer.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2011, 2013, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2011, 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 diff --git a/src/java.desktop/macosx/classes/sun/font/NativeFont.java b/src/java.desktop/macosx/classes/sun/font/NativeFont.java index 6faf4adfb53..f81540f795c 100644 --- a/src/java.desktop/macosx/classes/sun/font/NativeFont.java +++ b/src/java.desktop/macosx/classes/sun/font/NativeFont.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2015, Oracle and/or its affiliates. All rights reserved. + * 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 diff --git a/src/java.desktop/macosx/classes/sun/font/NativeStrike.java b/src/java.desktop/macosx/classes/sun/font/NativeStrike.java index d7c16150328..9a1b1ecec3d 100644 --- a/src/java.desktop/macosx/classes/sun/font/NativeStrike.java +++ b/src/java.desktop/macosx/classes/sun/font/NativeStrike.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2015, Oracle and/or its affiliates. All rights reserved. + * 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 diff --git a/src/java.desktop/macosx/classes/sun/java2d/CRenderer.java b/src/java.desktop/macosx/classes/sun/java2d/CRenderer.java index 9dd2c3a0bc7..72cd4316b47 100644 --- a/src/java.desktop/macosx/classes/sun/java2d/CRenderer.java +++ b/src/java.desktop/macosx/classes/sun/java2d/CRenderer.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2011, 2018, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2011, 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 diff --git a/src/java.desktop/macosx/classes/sun/java2d/CompositeCRenderer.java b/src/java.desktop/macosx/classes/sun/java2d/CompositeCRenderer.java index e23bcbdbbee..fec991ae418 100644 --- a/src/java.desktop/macosx/classes/sun/java2d/CompositeCRenderer.java +++ b/src/java.desktop/macosx/classes/sun/java2d/CompositeCRenderer.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2011, 2018, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2011, 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 diff --git a/src/java.desktop/macosx/classes/sun/java2d/DataBufferNIOInt.java b/src/java.desktop/macosx/classes/sun/java2d/DataBufferNIOInt.java index 3627a8f47f3..b00d05cead2 100644 --- a/src/java.desktop/macosx/classes/sun/java2d/DataBufferNIOInt.java +++ b/src/java.desktop/macosx/classes/sun/java2d/DataBufferNIOInt.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2011, 2018, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2011, 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 diff --git a/src/java.desktop/macosx/classes/sun/java2d/IntegerNIORaster.java b/src/java.desktop/macosx/classes/sun/java2d/IntegerNIORaster.java index 65631c0de86..fdc0aa4e3b8 100644 --- a/src/java.desktop/macosx/classes/sun/java2d/IntegerNIORaster.java +++ b/src/java.desktop/macosx/classes/sun/java2d/IntegerNIORaster.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2011, 2021, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2011, 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 diff --git a/src/java.desktop/macosx/classes/sun/java2d/MacOSFlags.java b/src/java.desktop/macosx/classes/sun/java2d/MacOSFlags.java index 14a8231d890..c7a7791b405 100644 --- a/src/java.desktop/macosx/classes/sun/java2d/MacOSFlags.java +++ b/src/java.desktop/macosx/classes/sun/java2d/MacOSFlags.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2019, 2024, Oracle and/or its affiliates. All rights reserved. + * 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 diff --git a/src/java.desktop/macosx/classes/sun/java2d/OSXOffScreenSurfaceData.java b/src/java.desktop/macosx/classes/sun/java2d/OSXOffScreenSurfaceData.java index 9685ee859ad..fda9b3b1127 100644 --- a/src/java.desktop/macosx/classes/sun/java2d/OSXOffScreenSurfaceData.java +++ b/src/java.desktop/macosx/classes/sun/java2d/OSXOffScreenSurfaceData.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2011, 2018, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2011, 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 diff --git a/src/java.desktop/macosx/classes/sun/java2d/OSXSurfaceData.java b/src/java.desktop/macosx/classes/sun/java2d/OSXSurfaceData.java index 1051fbda4cb..84b58087def 100644 --- a/src/java.desktop/macosx/classes/sun/java2d/OSXSurfaceData.java +++ b/src/java.desktop/macosx/classes/sun/java2d/OSXSurfaceData.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2011, 2018, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2011, 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 diff --git a/src/java.desktop/macosx/classes/sun/java2d/metal/MTLBlitLoops.java b/src/java.desktop/macosx/classes/sun/java2d/metal/MTLBlitLoops.java index d807f954d71..89692fac220 100644 --- a/src/java.desktop/macosx/classes/sun/java2d/metal/MTLBlitLoops.java +++ b/src/java.desktop/macosx/classes/sun/java2d/metal/MTLBlitLoops.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2019, 2021, Oracle and/or its affiliates. All rights reserved. + * 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 diff --git a/src/java.desktop/macosx/classes/sun/java2d/metal/MTLBufImgOps.java b/src/java.desktop/macosx/classes/sun/java2d/metal/MTLBufImgOps.java index 534ab101075..06c9eb8e8e3 100644 --- a/src/java.desktop/macosx/classes/sun/java2d/metal/MTLBufImgOps.java +++ b/src/java.desktop/macosx/classes/sun/java2d/metal/MTLBufImgOps.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2019, 2021, Oracle and/or its affiliates. All rights reserved. + * 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 diff --git a/src/java.desktop/macosx/classes/sun/java2d/metal/MTLContext.java b/src/java.desktop/macosx/classes/sun/java2d/metal/MTLContext.java index b3bcf6633c6..b18e993ab56 100644 --- a/src/java.desktop/macosx/classes/sun/java2d/metal/MTLContext.java +++ b/src/java.desktop/macosx/classes/sun/java2d/metal/MTLContext.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2019, 2021, Oracle and/or its affiliates. All rights reserved. + * 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 diff --git a/src/java.desktop/macosx/classes/sun/java2d/metal/MTLDrawImage.java b/src/java.desktop/macosx/classes/sun/java2d/metal/MTLDrawImage.java index cb24cfdea2c..185154a1679 100644 --- a/src/java.desktop/macosx/classes/sun/java2d/metal/MTLDrawImage.java +++ b/src/java.desktop/macosx/classes/sun/java2d/metal/MTLDrawImage.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2019, 2021, Oracle and/or its affiliates. All rights reserved. + * 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 diff --git a/src/java.desktop/macosx/classes/sun/java2d/metal/MTLGraphicsConfig.java b/src/java.desktop/macosx/classes/sun/java2d/metal/MTLGraphicsConfig.java index 0278a6bce36..641cb93714c 100644 --- a/src/java.desktop/macosx/classes/sun/java2d/metal/MTLGraphicsConfig.java +++ b/src/java.desktop/macosx/classes/sun/java2d/metal/MTLGraphicsConfig.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2019, 2024, Oracle and/or its affiliates. All rights reserved. + * 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 diff --git a/src/java.desktop/macosx/classes/sun/java2d/metal/MTLLayer.java b/src/java.desktop/macosx/classes/sun/java2d/metal/MTLLayer.java index 645b2e8a2f5..aafd465bbd2 100644 --- a/src/java.desktop/macosx/classes/sun/java2d/metal/MTLLayer.java +++ b/src/java.desktop/macosx/classes/sun/java2d/metal/MTLLayer.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2019, 2021, Oracle and/or its affiliates. All rights reserved. + * 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 diff --git a/src/java.desktop/macosx/classes/sun/java2d/metal/MTLMaskBlit.java b/src/java.desktop/macosx/classes/sun/java2d/metal/MTLMaskBlit.java index 3cc61ead145..95a0827b28c 100644 --- a/src/java.desktop/macosx/classes/sun/java2d/metal/MTLMaskBlit.java +++ b/src/java.desktop/macosx/classes/sun/java2d/metal/MTLMaskBlit.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2019, 2021, Oracle and/or its affiliates. All rights reserved. + * 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 diff --git a/src/java.desktop/macosx/classes/sun/java2d/metal/MTLMaskFill.java b/src/java.desktop/macosx/classes/sun/java2d/metal/MTLMaskFill.java index a6876c919e5..9b208dd5e0a 100644 --- a/src/java.desktop/macosx/classes/sun/java2d/metal/MTLMaskFill.java +++ b/src/java.desktop/macosx/classes/sun/java2d/metal/MTLMaskFill.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2019, 2022, Oracle and/or its affiliates. All rights reserved. + * 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 diff --git a/src/java.desktop/macosx/classes/sun/java2d/metal/MTLPaints.java b/src/java.desktop/macosx/classes/sun/java2d/metal/MTLPaints.java index 79625b875ce..556d09e1430 100644 --- a/src/java.desktop/macosx/classes/sun/java2d/metal/MTLPaints.java +++ b/src/java.desktop/macosx/classes/sun/java2d/metal/MTLPaints.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2019, 2021, Oracle and/or its affiliates. All rights reserved. + * 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 diff --git a/src/java.desktop/macosx/classes/sun/java2d/metal/MTLRenderQueue.java b/src/java.desktop/macosx/classes/sun/java2d/metal/MTLRenderQueue.java index f63ed523454..2fb06f0aa5b 100644 --- a/src/java.desktop/macosx/classes/sun/java2d/metal/MTLRenderQueue.java +++ b/src/java.desktop/macosx/classes/sun/java2d/metal/MTLRenderQueue.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2007, 2024, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2007, 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 diff --git a/src/java.desktop/macosx/classes/sun/java2d/metal/MTLRenderer.java b/src/java.desktop/macosx/classes/sun/java2d/metal/MTLRenderer.java index 9ef4dc9c3ab..3f402914614 100644 --- a/src/java.desktop/macosx/classes/sun/java2d/metal/MTLRenderer.java +++ b/src/java.desktop/macosx/classes/sun/java2d/metal/MTLRenderer.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2019, 2022, Oracle and/or its affiliates. All rights reserved. + * 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 diff --git a/src/java.desktop/macosx/classes/sun/java2d/metal/MTLSurfaceData.java b/src/java.desktop/macosx/classes/sun/java2d/metal/MTLSurfaceData.java index c8259f9056b..929c7c4794d 100644 --- a/src/java.desktop/macosx/classes/sun/java2d/metal/MTLSurfaceData.java +++ b/src/java.desktop/macosx/classes/sun/java2d/metal/MTLSurfaceData.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2019, 2024, Oracle and/or its affiliates. All rights reserved. + * 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 diff --git a/src/java.desktop/macosx/classes/sun/java2d/metal/MTLSurfaceDataProxy.java b/src/java.desktop/macosx/classes/sun/java2d/metal/MTLSurfaceDataProxy.java index a73728c7b03..0c6edc90be9 100644 --- a/src/java.desktop/macosx/classes/sun/java2d/metal/MTLSurfaceDataProxy.java +++ b/src/java.desktop/macosx/classes/sun/java2d/metal/MTLSurfaceDataProxy.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2019, 2021, Oracle and/or its affiliates. All rights reserved. + * 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 diff --git a/src/java.desktop/macosx/classes/sun/java2d/metal/MTLTextRenderer.java b/src/java.desktop/macosx/classes/sun/java2d/metal/MTLTextRenderer.java index ad7bd95071e..05f45ba79e8 100644 --- a/src/java.desktop/macosx/classes/sun/java2d/metal/MTLTextRenderer.java +++ b/src/java.desktop/macosx/classes/sun/java2d/metal/MTLTextRenderer.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2011, 2021, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2011, 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 diff --git a/src/java.desktop/macosx/classes/sun/java2d/metal/MTLVolatileSurfaceManager.java b/src/java.desktop/macosx/classes/sun/java2d/metal/MTLVolatileSurfaceManager.java index e7d4b166eef..3ea03265e91 100644 --- a/src/java.desktop/macosx/classes/sun/java2d/metal/MTLVolatileSurfaceManager.java +++ b/src/java.desktop/macosx/classes/sun/java2d/metal/MTLVolatileSurfaceManager.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2021, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2021, 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 diff --git a/src/java.desktop/macosx/classes/sun/java2d/opengl/CGLGraphicsConfig.java b/src/java.desktop/macosx/classes/sun/java2d/opengl/CGLGraphicsConfig.java index fb058fb38bf..b3dfbc1ba3c 100644 --- a/src/java.desktop/macosx/classes/sun/java2d/opengl/CGLGraphicsConfig.java +++ b/src/java.desktop/macosx/classes/sun/java2d/opengl/CGLGraphicsConfig.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2011, 2024, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2011, 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 diff --git a/src/java.desktop/macosx/classes/sun/java2d/opengl/CGLLayer.java b/src/java.desktop/macosx/classes/sun/java2d/opengl/CGLLayer.java index aa75a142e57..01ce48d0cb4 100644 --- a/src/java.desktop/macosx/classes/sun/java2d/opengl/CGLLayer.java +++ b/src/java.desktop/macosx/classes/sun/java2d/opengl/CGLLayer.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2011, 2019, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2011, 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 diff --git a/src/java.desktop/macosx/classes/sun/java2d/opengl/CGLSurfaceData.java b/src/java.desktop/macosx/classes/sun/java2d/opengl/CGLSurfaceData.java index 592d3783aba..e93a25473e9 100644 --- a/src/java.desktop/macosx/classes/sun/java2d/opengl/CGLSurfaceData.java +++ b/src/java.desktop/macosx/classes/sun/java2d/opengl/CGLSurfaceData.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2011, 2019, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2011, 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 diff --git a/src/java.desktop/macosx/classes/sun/java2d/opengl/CGLVolatileSurfaceManager.java b/src/java.desktop/macosx/classes/sun/java2d/opengl/CGLVolatileSurfaceManager.java index 86fe9387554..bbf3bef7555 100644 --- a/src/java.desktop/macosx/classes/sun/java2d/opengl/CGLVolatileSurfaceManager.java +++ b/src/java.desktop/macosx/classes/sun/java2d/opengl/CGLVolatileSurfaceManager.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2011, 2019, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2011, 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 diff --git a/src/java.desktop/macosx/classes/sun/lwawt/LWKeyboardFocusManagerPeer.java b/src/java.desktop/macosx/classes/sun/lwawt/LWKeyboardFocusManagerPeer.java index 918bef702b1..0f3cc07c447 100644 --- a/src/java.desktop/macosx/classes/sun/lwawt/LWKeyboardFocusManagerPeer.java +++ b/src/java.desktop/macosx/classes/sun/lwawt/LWKeyboardFocusManagerPeer.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2011, 2024, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2011, 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 diff --git a/src/java.desktop/macosx/classes/sun/lwawt/LWLightweightFramePeer.java b/src/java.desktop/macosx/classes/sun/lwawt/LWLightweightFramePeer.java index 89b4a02c9d7..f1cc05fea27 100644 --- a/src/java.desktop/macosx/classes/sun/lwawt/LWLightweightFramePeer.java +++ b/src/java.desktop/macosx/classes/sun/lwawt/LWLightweightFramePeer.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2013, 2021, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2013, 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 diff --git a/src/java.desktop/macosx/classes/sun/lwawt/LWMouseInfoPeer.java b/src/java.desktop/macosx/classes/sun/lwawt/LWMouseInfoPeer.java index cd25f2328c2..95b5f475f07 100644 --- a/src/java.desktop/macosx/classes/sun/lwawt/LWMouseInfoPeer.java +++ b/src/java.desktop/macosx/classes/sun/lwawt/LWMouseInfoPeer.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2011, 2015, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2011, 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 diff --git a/src/java.desktop/macosx/classes/sun/lwawt/LWWindowPeer.java b/src/java.desktop/macosx/classes/sun/lwawt/LWWindowPeer.java index 73e13908fbf..11099f6a8e6 100644 --- a/src/java.desktop/macosx/classes/sun/lwawt/LWWindowPeer.java +++ b/src/java.desktop/macosx/classes/sun/lwawt/LWWindowPeer.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2011, 2024, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2011, 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 diff --git a/src/java.desktop/macosx/classes/sun/lwawt/macosx/CAccessibleText.java b/src/java.desktop/macosx/classes/sun/lwawt/macosx/CAccessibleText.java index 1ad04eab47b..b87be60180e 100644 --- a/src/java.desktop/macosx/classes/sun/lwawt/macosx/CAccessibleText.java +++ b/src/java.desktop/macosx/classes/sun/lwawt/macosx/CAccessibleText.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2011, 2021, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2011, 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 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 21021b2e9d0..30ed1d1bba0 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, 2021, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2011, 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 diff --git a/src/java.desktop/macosx/classes/sun/lwawt/macosx/CCustomCursor.java b/src/java.desktop/macosx/classes/sun/lwawt/macosx/CCustomCursor.java index a2c749fcc79..f24419cbc8c 100644 --- a/src/java.desktop/macosx/classes/sun/lwawt/macosx/CCustomCursor.java +++ b/src/java.desktop/macosx/classes/sun/lwawt/macosx/CCustomCursor.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2011, 2014, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2011, 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 diff --git a/src/java.desktop/macosx/classes/sun/lwawt/macosx/CDataTransferer.java b/src/java.desktop/macosx/classes/sun/lwawt/macosx/CDataTransferer.java index 065163adbb1..ed8ca73a613 100644 --- a/src/java.desktop/macosx/classes/sun/lwawt/macosx/CDataTransferer.java +++ b/src/java.desktop/macosx/classes/sun/lwawt/macosx/CDataTransferer.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2011, 2022, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2011, 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 diff --git a/src/java.desktop/macosx/classes/sun/lwawt/macosx/CDragSourceContextPeer.java b/src/java.desktop/macosx/classes/sun/lwawt/macosx/CDragSourceContextPeer.java index 35ef3c3897c..b5ac470d1f8 100644 --- a/src/java.desktop/macosx/classes/sun/lwawt/macosx/CDragSourceContextPeer.java +++ b/src/java.desktop/macosx/classes/sun/lwawt/macosx/CDragSourceContextPeer.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2011, 2024, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2011, 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 diff --git a/src/java.desktop/macosx/classes/sun/lwawt/macosx/CDropTargetContextPeer.java b/src/java.desktop/macosx/classes/sun/lwawt/macosx/CDropTargetContextPeer.java index b35eb9afd5d..a4e07d46aab 100644 --- a/src/java.desktop/macosx/classes/sun/lwawt/macosx/CDropTargetContextPeer.java +++ b/src/java.desktop/macosx/classes/sun/lwawt/macosx/CDropTargetContextPeer.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2011, 2013, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2011, 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 diff --git a/src/java.desktop/macosx/classes/sun/lwawt/macosx/CEmbeddedFrame.java b/src/java.desktop/macosx/classes/sun/lwawt/macosx/CEmbeddedFrame.java index fc9618ccf04..780437cd423 100644 --- a/src/java.desktop/macosx/classes/sun/lwawt/macosx/CEmbeddedFrame.java +++ b/src/java.desktop/macosx/classes/sun/lwawt/macosx/CEmbeddedFrame.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2011, 2015, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2011, 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 diff --git a/src/java.desktop/macosx/classes/sun/lwawt/macosx/CFileDialog.java b/src/java.desktop/macosx/classes/sun/lwawt/macosx/CFileDialog.java index 8becf91f114..3f33f748154 100644 --- a/src/java.desktop/macosx/classes/sun/lwawt/macosx/CFileDialog.java +++ b/src/java.desktop/macosx/classes/sun/lwawt/macosx/CFileDialog.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2011, 2024, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2011, 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 diff --git a/src/java.desktop/macosx/classes/sun/lwawt/macosx/CImage.java b/src/java.desktop/macosx/classes/sun/lwawt/macosx/CImage.java index 84cb12586e0..d3f26285255 100644 --- a/src/java.desktop/macosx/classes/sun/lwawt/macosx/CImage.java +++ b/src/java.desktop/macosx/classes/sun/lwawt/macosx/CImage.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2011, 2018, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2011, 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 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 fc504cc297d..1eb896bf291 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, 2018, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2011, 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 diff --git a/src/java.desktop/macosx/classes/sun/lwawt/macosx/CInputMethodDescriptor.java b/src/java.desktop/macosx/classes/sun/lwawt/macosx/CInputMethodDescriptor.java index b681efc198b..b11ddba10be 100644 --- a/src/java.desktop/macosx/classes/sun/lwawt/macosx/CInputMethodDescriptor.java +++ b/src/java.desktop/macosx/classes/sun/lwawt/macosx/CInputMethodDescriptor.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2011, 2018, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2011, 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 diff --git a/src/java.desktop/macosx/classes/sun/lwawt/macosx/CMouseDragGestureRecognizer.java b/src/java.desktop/macosx/classes/sun/lwawt/macosx/CMouseDragGestureRecognizer.java index e23dcf19f1c..60269921d69 100644 --- a/src/java.desktop/macosx/classes/sun/lwawt/macosx/CMouseDragGestureRecognizer.java +++ b/src/java.desktop/macosx/classes/sun/lwawt/macosx/CMouseDragGestureRecognizer.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2011, 2014, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2011, 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 diff --git a/src/java.desktop/macosx/classes/sun/lwawt/macosx/CPlatformEmbeddedFrame.java b/src/java.desktop/macosx/classes/sun/lwawt/macosx/CPlatformEmbeddedFrame.java index 5b447d857f3..3c17e8f89d8 100644 --- a/src/java.desktop/macosx/classes/sun/lwawt/macosx/CPlatformEmbeddedFrame.java +++ b/src/java.desktop/macosx/classes/sun/lwawt/macosx/CPlatformEmbeddedFrame.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2011, 2022, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2011, 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 diff --git a/src/java.desktop/macosx/classes/sun/lwawt/macosx/CPlatformLWComponent.java b/src/java.desktop/macosx/classes/sun/lwawt/macosx/CPlatformLWComponent.java index 43c40647e99..1c453b72881 100644 --- a/src/java.desktop/macosx/classes/sun/lwawt/macosx/CPlatformLWComponent.java +++ b/src/java.desktop/macosx/classes/sun/lwawt/macosx/CPlatformLWComponent.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2013, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2013, 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 diff --git a/src/java.desktop/macosx/classes/sun/lwawt/macosx/CPlatformLWView.java b/src/java.desktop/macosx/classes/sun/lwawt/macosx/CPlatformLWView.java index 460c4235075..9e11e19ba95 100644 --- a/src/java.desktop/macosx/classes/sun/lwawt/macosx/CPlatformLWView.java +++ b/src/java.desktop/macosx/classes/sun/lwawt/macosx/CPlatformLWView.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2013, 2019, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2013, 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 diff --git a/src/java.desktop/macosx/classes/sun/lwawt/macosx/CPlatformLWWindow.java b/src/java.desktop/macosx/classes/sun/lwawt/macosx/CPlatformLWWindow.java index 1b87b31740b..f6b2151486b 100644 --- a/src/java.desktop/macosx/classes/sun/lwawt/macosx/CPlatformLWWindow.java +++ b/src/java.desktop/macosx/classes/sun/lwawt/macosx/CPlatformLWWindow.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2013, 2019, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2013, 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 diff --git a/src/java.desktop/macosx/classes/sun/lwawt/macosx/CPlatformResponder.java b/src/java.desktop/macosx/classes/sun/lwawt/macosx/CPlatformResponder.java index 5cdbbded9ac..852b6380808 100644 --- a/src/java.desktop/macosx/classes/sun/lwawt/macosx/CPlatformResponder.java +++ b/src/java.desktop/macosx/classes/sun/lwawt/macosx/CPlatformResponder.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2011, 2024, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2011, 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 diff --git a/src/java.desktop/macosx/classes/sun/lwawt/macosx/CPlatformWindow.java b/src/java.desktop/macosx/classes/sun/lwawt/macosx/CPlatformWindow.java index baaad51d953..2f74a16ef0f 100644 --- a/src/java.desktop/macosx/classes/sun/lwawt/macosx/CPlatformWindow.java +++ b/src/java.desktop/macosx/classes/sun/lwawt/macosx/CPlatformWindow.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2011, 2024, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2011, 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 diff --git a/src/java.desktop/macosx/classes/sun/lwawt/macosx/CPrinterDialogPeer.java b/src/java.desktop/macosx/classes/sun/lwawt/macosx/CPrinterDialogPeer.java index 68bae1f112b..98888230d31 100644 --- a/src/java.desktop/macosx/classes/sun/lwawt/macosx/CPrinterDialogPeer.java +++ b/src/java.desktop/macosx/classes/sun/lwawt/macosx/CPrinterDialogPeer.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2011, 2013, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2011, 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 diff --git a/src/java.desktop/macosx/classes/sun/lwawt/macosx/CSystemTray.java b/src/java.desktop/macosx/classes/sun/lwawt/macosx/CSystemTray.java index adbd79de28d..2a63be1c5fd 100644 --- a/src/java.desktop/macosx/classes/sun/lwawt/macosx/CSystemTray.java +++ b/src/java.desktop/macosx/classes/sun/lwawt/macosx/CSystemTray.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2011, 2012, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2011, 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 diff --git a/src/java.desktop/macosx/classes/sun/lwawt/macosx/CToolkitThreadBlockedHandler.java b/src/java.desktop/macosx/classes/sun/lwawt/macosx/CToolkitThreadBlockedHandler.java index 27c4a3e5740..166b3ac0024 100644 --- a/src/java.desktop/macosx/classes/sun/lwawt/macosx/CToolkitThreadBlockedHandler.java +++ b/src/java.desktop/macosx/classes/sun/lwawt/macosx/CToolkitThreadBlockedHandler.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2011, 2013, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2011, 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 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 3851bd18339..77639a262d5 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, 2024, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2011, 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 diff --git a/src/java.desktop/macosx/classes/sun/lwawt/macosx/CViewEmbeddedFrame.java b/src/java.desktop/macosx/classes/sun/lwawt/macosx/CViewEmbeddedFrame.java index 177184282e0..fc4c38129a0 100644 --- a/src/java.desktop/macosx/classes/sun/lwawt/macosx/CViewEmbeddedFrame.java +++ b/src/java.desktop/macosx/classes/sun/lwawt/macosx/CViewEmbeddedFrame.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2012, 2015, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2012, 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 diff --git a/src/java.desktop/macosx/classes/sun/lwawt/macosx/CViewPlatformEmbeddedFrame.java b/src/java.desktop/macosx/classes/sun/lwawt/macosx/CViewPlatformEmbeddedFrame.java index 118e9258531..642f506f3d1 100644 --- a/src/java.desktop/macosx/classes/sun/lwawt/macosx/CViewPlatformEmbeddedFrame.java +++ b/src/java.desktop/macosx/classes/sun/lwawt/macosx/CViewPlatformEmbeddedFrame.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2012, 2016, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2012, 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 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 14ad9621bbd..0e5bfc44bc5 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, 2024, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2011, 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 diff --git a/src/java.desktop/macosx/classes/sun/print/PlatformPrinterJobProxy.java b/src/java.desktop/macosx/classes/sun/print/PlatformPrinterJobProxy.java index 92e821f2e42..76172fd6f1b 100644 --- a/src/java.desktop/macosx/classes/sun/print/PlatformPrinterJobProxy.java +++ b/src/java.desktop/macosx/classes/sun/print/PlatformPrinterJobProxy.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2018, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2018, 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 diff --git a/src/java.desktop/macosx/native/libawt_lwawt/awt/AWTEvent.m b/src/java.desktop/macosx/native/libawt_lwawt/awt/AWTEvent.m index e81335c0d9e..f5dab40f0aa 100644 --- a/src/java.desktop/macosx/native/libawt_lwawt/awt/AWTEvent.m +++ b/src/java.desktop/macosx/native/libawt_lwawt/awt/AWTEvent.m @@ -1,5 +1,5 @@ /* - * Copyright (c) 2011, 2019, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2011, 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 diff --git a/src/java.desktop/macosx/native/libawt_lwawt/awt/CGraphicsDevice.m b/src/java.desktop/macosx/native/libawt_lwawt/awt/CGraphicsDevice.m index 70f0741347a..2e1833430e4 100644 --- a/src/java.desktop/macosx/native/libawt_lwawt/awt/CGraphicsDevice.m +++ b/src/java.desktop/macosx/native/libawt_lwawt/awt/CGraphicsDevice.m @@ -1,5 +1,5 @@ /* - * Copyright (c) 2012, 2024, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2012, 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 diff --git a/src/java.desktop/macosx/native/libawt_lwawt/awt/CGraphicsEnv.m b/src/java.desktop/macosx/native/libawt_lwawt/awt/CGraphicsEnv.m index 2fea4a1a4f7..d9d432fb96c 100644 --- a/src/java.desktop/macosx/native/libawt_lwawt/awt/CGraphicsEnv.m +++ b/src/java.desktop/macosx/native/libawt_lwawt/awt/CGraphicsEnv.m @@ -1,5 +1,5 @@ /* - * Copyright (c) 2011, 2015, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2011, 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 diff --git a/src/java.desktop/macosx/native/libawt_lwawt/awt/CPrinterJob.m b/src/java.desktop/macosx/native/libawt_lwawt/awt/CPrinterJob.m index 9db38ee21ff..9cc0a18564f 100644 --- a/src/java.desktop/macosx/native/libawt_lwawt/awt/CPrinterJob.m +++ b/src/java.desktop/macosx/native/libawt_lwawt/awt/CPrinterJob.m @@ -1,5 +1,5 @@ /* - * Copyright (c) 2011, 2024, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2011, 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 diff --git a/src/java.desktop/macosx/native/libawt_lwawt/awt/DnDUtilities.m b/src/java.desktop/macosx/native/libawt_lwawt/awt/DnDUtilities.m index 7eb7b104bcd..4cf9c91fad3 100644 --- a/src/java.desktop/macosx/native/libawt_lwawt/awt/DnDUtilities.m +++ b/src/java.desktop/macosx/native/libawt_lwawt/awt/DnDUtilities.m @@ -1,5 +1,5 @@ /* - * Copyright (c) 2011, 2023, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2011, 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 diff --git a/src/java.desktop/macosx/native/libawt_lwawt/awt/a11y/TabButtonAccessibility.m b/src/java.desktop/macosx/native/libawt_lwawt/awt/a11y/TabButtonAccessibility.m index 26f381ad475..7a156ef6523 100644 --- a/src/java.desktop/macosx/native/libawt_lwawt/awt/a11y/TabButtonAccessibility.m +++ b/src/java.desktop/macosx/native/libawt_lwawt/awt/a11y/TabButtonAccessibility.m @@ -1,5 +1,5 @@ /* - * Copyright (c) 2021, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2021, 2025, Oracle and/or its affiliates. All rights reserved. * Copyright (c) 2021, JetBrains s.r.o.. All rights reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * diff --git a/src/java.desktop/macosx/native/libawt_lwawt/font/CGGlyphImages.m b/src/java.desktop/macosx/native/libawt_lwawt/font/CGGlyphImages.m index 614fd7ec535..558c7754950 100644 --- a/src/java.desktop/macosx/native/libawt_lwawt/font/CGGlyphImages.m +++ b/src/java.desktop/macosx/native/libawt_lwawt/font/CGGlyphImages.m @@ -1,5 +1,5 @@ /* - * Copyright (c) 2011, 2024, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2011, 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 diff --git a/src/java.desktop/share/classes/com/sun/imageio/plugins/gif/GIFImageWriter.java b/src/java.desktop/share/classes/com/sun/imageio/plugins/gif/GIFImageWriter.java index e009e33d8a0..31f47d606c9 100644 --- a/src/java.desktop/share/classes/com/sun/imageio/plugins/gif/GIFImageWriter.java +++ b/src/java.desktop/share/classes/com/sun/imageio/plugins/gif/GIFImageWriter.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2005, 2023, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2005, 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 diff --git a/src/java.desktop/share/classes/com/sun/imageio/plugins/png/PNGImageWriter.java b/src/java.desktop/share/classes/com/sun/imageio/plugins/png/PNGImageWriter.java index b88574edd6e..036fc9045ba 100644 --- a/src/java.desktop/share/classes/com/sun/imageio/plugins/png/PNGImageWriter.java +++ b/src/java.desktop/share/classes/com/sun/imageio/plugins/png/PNGImageWriter.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2000, 2024, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2000, 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 diff --git a/src/java.desktop/share/classes/com/sun/imageio/plugins/tiff/TIFFImageWriter.java b/src/java.desktop/share/classes/com/sun/imageio/plugins/tiff/TIFFImageWriter.java index d56bc89035b..447db2ef803 100644 --- a/src/java.desktop/share/classes/com/sun/imageio/plugins/tiff/TIFFImageWriter.java +++ b/src/java.desktop/share/classes/com/sun/imageio/plugins/tiff/TIFFImageWriter.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2005, 2023, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2005, 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 diff --git a/src/java.desktop/share/classes/com/sun/java/swing/plaf/gtk/GTKEngine.java b/src/java.desktop/share/classes/com/sun/java/swing/plaf/gtk/GTKEngine.java index 2540f6e7880..4aa8afd3e56 100644 --- a/src/java.desktop/share/classes/com/sun/java/swing/plaf/gtk/GTKEngine.java +++ b/src/java.desktop/share/classes/com/sun/java/swing/plaf/gtk/GTKEngine.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2005, 2024, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2005, 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 diff --git a/src/java.desktop/share/classes/com/sun/java/swing/plaf/motif/MotifFileChooserUI.java b/src/java.desktop/share/classes/com/sun/java/swing/plaf/motif/MotifFileChooserUI.java index 342583aaa46..7d820930415 100644 --- a/src/java.desktop/share/classes/com/sun/java/swing/plaf/motif/MotifFileChooserUI.java +++ b/src/java.desktop/share/classes/com/sun/java/swing/plaf/motif/MotifFileChooserUI.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 1997, 2024, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 1997, 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 diff --git a/src/java.desktop/share/classes/java/awt/Dialog.java b/src/java.desktop/share/classes/java/awt/Dialog.java index 0fa4a74b61a..83aa89b9bf7 100644 --- a/src/java.desktop/share/classes/java/awt/Dialog.java +++ b/src/java.desktop/share/classes/java/awt/Dialog.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 1995, 2024, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 1995, 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 diff --git a/src/java.desktop/share/classes/java/awt/EventQueue.java b/src/java.desktop/share/classes/java/awt/EventQueue.java index be13548e998..571ec9f7e88 100644 --- a/src/java.desktop/share/classes/java/awt/EventQueue.java +++ b/src/java.desktop/share/classes/java/awt/EventQueue.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 1996, 2024, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 1996, 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 diff --git a/src/java.desktop/share/classes/java/awt/Font.java b/src/java.desktop/share/classes/java/awt/Font.java index 2da68fd8618..0614163fb7f 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, 2024, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 1995, 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 diff --git a/src/java.desktop/share/classes/java/awt/GraphicsEnvironment.java b/src/java.desktop/share/classes/java/awt/GraphicsEnvironment.java index ecaf5ae4e27..92bf16ec466 100644 --- a/src/java.desktop/share/classes/java/awt/GraphicsEnvironment.java +++ b/src/java.desktop/share/classes/java/awt/GraphicsEnvironment.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 1997, 2024, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 1997, 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 diff --git a/src/java.desktop/share/classes/java/awt/HeadlessException.java b/src/java.desktop/share/classes/java/awt/HeadlessException.java index cff97ee8c3c..b8717be69eb 100644 --- a/src/java.desktop/share/classes/java/awt/HeadlessException.java +++ b/src/java.desktop/share/classes/java/awt/HeadlessException.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2000, 2021, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2000, 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 diff --git a/src/java.desktop/share/classes/java/awt/KeyboardFocusManager.java b/src/java.desktop/share/classes/java/awt/KeyboardFocusManager.java index 6c6e4044131..348d0772cf4 100644 --- a/src/java.desktop/share/classes/java/awt/KeyboardFocusManager.java +++ b/src/java.desktop/share/classes/java/awt/KeyboardFocusManager.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2000, 2024, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2000, 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 diff --git a/src/java.desktop/share/classes/java/awt/Polygon.java b/src/java.desktop/share/classes/java/awt/Polygon.java index 3c91aaba90f..bbe6ed77b8b 100644 --- a/src/java.desktop/share/classes/java/awt/Polygon.java +++ b/src/java.desktop/share/classes/java/awt/Polygon.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 1995, 2021, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 1995, 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 diff --git a/src/java.desktop/share/classes/java/awt/PrintJob.java b/src/java.desktop/share/classes/java/awt/PrintJob.java index 926de65608b..52216b9cf08 100644 --- a/src/java.desktop/share/classes/java/awt/PrintJob.java +++ b/src/java.desktop/share/classes/java/awt/PrintJob.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 1996, 2020, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 1996, 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 diff --git a/src/java.desktop/share/classes/java/awt/SystemTray.java b/src/java.desktop/share/classes/java/awt/SystemTray.java index b51702bd125..bf1871765eb 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, 2024, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2005, 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 diff --git a/src/java.desktop/share/classes/java/awt/doc-files/FocusSpec.html b/src/java.desktop/share/classes/java/awt/doc-files/FocusSpec.html index 22df108b91a..f4b0cf9d3d3 100644 --- a/src/java.desktop/share/classes/java/awt/doc-files/FocusSpec.html +++ b/src/java.desktop/share/classes/java/awt/doc-files/FocusSpec.html @@ -5,7 +5,7 @@ The AWT Focus Subsystem " + dowDate); + assertEquals(dowExpected, dowResult, "Localized DayOfWeek not correct; " + day + " -->" + dowDate); int weekExpected = day.get(wowbyField) + 1; ValueRange range = day.range(wowbyField); weekExpected = ((weekExpected - 1) % (int)range.getMaximum()) + 1; LocalDate weekDate = day.with(wowbyField, weekExpected); int weekResult = weekDate.get(wowbyField); - assertEquals(weekResult, weekExpected, "Localized WeekOfWeekBasedYear not correct; " + day + " -->" + weekDate); + assertEquals(weekExpected, weekResult, "Localized WeekOfWeekBasedYear not correct; " + day + " -->" + weekDate); int yearExpected = day.get(yowbyField) + 1; LocalDate yearDate = day.with(yowbyField, yearExpected); int yearResult = yearDate.get(yowbyField); - assertEquals(yearResult, yearExpected, "Localized WeekBasedYear not correct; " + day + " --> " + yearDate); + assertEquals(yearExpected, yearResult, "Localized WeekBasedYear not correct; " + day + " --> " + yearDate); range = yearDate.range(wowbyField); weekExpected = Math.min(day.get(wowbyField), (int)range.getMaximum()); int weekActual = yearDate.get(wowbyField); - assertEquals(weekActual, weekExpected, "Localized WeekOfWeekBasedYear week should not change; " + day + " --> " + yearDate + ", actual: " + weekActual + ", weekExpected: " + weekExpected); + assertEquals(weekExpected, weekActual, "Localized WeekOfWeekBasedYear week should not change; " + day + " --> " + yearDate + ", actual: " + weekActual + ", weekExpected: " + weekExpected); } //----------------------------------------------------------------------- - @Test(dataProvider="weekFields") + @ParameterizedTest + @MethodSource("data_weekFields") public void test_parse_resolve_localizedWom(DayOfWeek firstDayOfWeek, int minDays) { LocalDate date = LocalDate.of(2012, 12, 15); WeekFields week = WeekFields.of(firstDayOfWeek, minDays); @@ -388,13 +403,14 @@ public class TCKWeekFields extends AbstractTCKTest { String str = date.getYear() + ":" + date.getMonthValue() + ":" + date.get(womField) + ":" + date.get(DAY_OF_WEEK); LocalDate parsed = LocalDate.parse(str, f); - assertEquals(parsed, date, " ::" + str + "::" + i); + assertEquals(date, parsed, " ::" + str + "::" + i); date = date.plusDays(1); } } - @Test(dataProvider="weekFields") + @ParameterizedTest + @MethodSource("data_weekFields") public void test_parse_resolve_localizedWom_lenient(DayOfWeek firstDayOfWeek, int minDays) { LocalDate date = LocalDate.of(2012, 12, 15); WeekFields week = WeekFields.of(firstDayOfWeek, minDays); @@ -411,14 +427,15 @@ public class TCKWeekFields extends AbstractTCKTest { for (int j = wom - 10; j < wom + 10; j++) { String str = date.getYear() + ":" + date.getMonthValue() + ":" + j + ":" + dow; LocalDate parsed = LocalDate.parse(str, f); - assertEquals(parsed, date.plusWeeks(j - wom), " ::" + str + ": :" + i + "::" + j); + assertEquals(date.plusWeeks(j - wom), parsed, " ::" + str + ": :" + i + "::" + j); } date = date.plusDays(1); } } - @Test(dataProvider="weekFields") + @ParameterizedTest + @MethodSource("data_weekFields") public void test_parse_resolve_localizedWom_strict(DayOfWeek firstDayOfWeek, int minDays) { WeekFields week = WeekFields.of(firstDayOfWeek, minDays); TemporalField womField = week.weekOfMonth(); @@ -430,17 +447,18 @@ public class TCKWeekFields extends AbstractTCKTest { String str = "2012:1:0:1"; try { LocalDate date = LocalDate.parse(str, f); - assertEquals(date.getYear(), 2012); - assertEquals(date.getMonthValue(), 1); - assertEquals(date.get(womField), 0); - assertEquals(date.get(DAY_OF_WEEK), 1); + assertEquals(2012, date.getYear()); + assertEquals(1, date.getMonthValue()); + assertEquals(0, date.get(womField)); + assertEquals(1, date.get(DAY_OF_WEEK)); } catch (DateTimeException ex) { // expected } } //----------------------------------------------------------------------- - @Test(dataProvider="weekFields") + @ParameterizedTest + @MethodSource("data_weekFields") public void test_parse_resolve_localizedWomDow(DayOfWeek firstDayOfWeek, int minDays) { LocalDate date = LocalDate.of(2012, 12, 15); WeekFields week = WeekFields.of(firstDayOfWeek, minDays); @@ -456,13 +474,14 @@ public class TCKWeekFields extends AbstractTCKTest { String str = date.getYear() + ":" + date.getMonthValue() + ":" + date.get(womField) + ":" + date.get(dowField); LocalDate parsed = LocalDate.parse(str, f); - assertEquals(parsed, date, " :: " + str + " " + i); + assertEquals(date, parsed, " :: " + str + " " + i); date = date.plusDays(1); } } - @Test(dataProvider="weekFields") + @ParameterizedTest + @MethodSource("data_weekFields") public void test_parse_resolve_localizedWomDow_lenient(DayOfWeek firstDayOfWeek, int minDays) { LocalDate date = LocalDate.of(2012, 12, 15); WeekFields week = WeekFields.of(firstDayOfWeek, minDays); @@ -480,7 +499,7 @@ public class TCKWeekFields extends AbstractTCKTest { for (int j = wom - 10; j < wom + 10; j++) { String str = date.getYear() + ":" + date.getMonthValue() + ":" + j + ":" + dow; LocalDate parsed = LocalDate.parse(str, f); - assertEquals(parsed, date.plusWeeks(j - wom), " ::" + str + ": :" + i + "::" + j); + assertEquals(date.plusWeeks(j - wom), parsed, " ::" + str + ": :" + i + "::" + j); } date = date.plusDays(1); @@ -488,7 +507,8 @@ public class TCKWeekFields extends AbstractTCKTest { } //----------------------------------------------------------------------- - @Test(dataProvider="weekFields") + @ParameterizedTest + @MethodSource("data_weekFields") public void test_parse_resolve_localizedWoy(DayOfWeek firstDayOfWeek, int minDays) { LocalDate date = LocalDate.of(2012, 12, 15); WeekFields week = WeekFields.of(firstDayOfWeek, minDays); @@ -502,13 +522,14 @@ public class TCKWeekFields extends AbstractTCKTest { String str = date.getYear() + ":" + date.get(woyField) + ":" + date.get(DAY_OF_WEEK); LocalDate parsed = LocalDate.parse(str, f); - assertEquals(parsed, date, " :: " + str + " " + i); + assertEquals(date, parsed, " :: " + str + " " + i); date = date.plusDays(1); } } - @Test(dataProvider="weekFields") + @ParameterizedTest + @MethodSource("data_weekFields") public void test_parse_resolve_localizedWoy_lenient(DayOfWeek firstDayOfWeek, int minDays) { LocalDate date = LocalDate.of(2012, 12, 15); WeekFields week = WeekFields.of(firstDayOfWeek, minDays); @@ -524,14 +545,15 @@ public class TCKWeekFields extends AbstractTCKTest { for (int j = woy - 60; j < woy + 60; j++) { String str = date.getYear() + ":" + j + ":" + dow; LocalDate parsed = LocalDate.parse(str, f); - assertEquals(parsed, date.plusWeeks(j - woy), " ::" + str + ": :" + i + "::" + j); + assertEquals(date.plusWeeks(j - woy), parsed, " ::" + str + ": :" + i + "::" + j); } date = date.plusDays(1); } } - @Test(dataProvider="weekFields") + @ParameterizedTest + @MethodSource("data_weekFields") public void test_parse_resolve_localizedWoy_strict(DayOfWeek firstDayOfWeek, int minDays) { WeekFields week = WeekFields.of(firstDayOfWeek, minDays); TemporalField woyField = week.weekOfYear(); @@ -542,16 +564,17 @@ public class TCKWeekFields extends AbstractTCKTest { String str = "2012:0:1"; try { LocalDate date = LocalDate.parse(str, f); - assertEquals(date.getYear(), 2012); - assertEquals(date.get(woyField), 0); - assertEquals(date.get(DAY_OF_WEEK), 1); + assertEquals(2012, date.getYear()); + assertEquals(0, date.get(woyField)); + assertEquals(1, date.get(DAY_OF_WEEK)); } catch (DateTimeException ex) { // expected } } //----------------------------------------------------------------------- - @Test(dataProvider="weekFields") + @ParameterizedTest + @MethodSource("data_weekFields") public void test_parse_resolve_localizedWoyDow(DayOfWeek firstDayOfWeek, int minDays) { LocalDate date = LocalDate.of(2012, 12, 15); WeekFields week = WeekFields.of(firstDayOfWeek, minDays); @@ -567,13 +590,14 @@ public class TCKWeekFields extends AbstractTCKTest { String str = date.getYear() + ":" + date.getMonthValue() + ":" + date.get(woyField) + ":" + date.get(dowField); LocalDate parsed = LocalDate.parse(str, f); - assertEquals(parsed, date, " :: " + str + " " + i); + assertEquals(date, parsed, " :: " + str + " " + i); date = date.plusDays(1); } } - @Test(dataProvider="weekFields") + @ParameterizedTest + @MethodSource("data_weekFields") public void test_parse_resolve_localizedWoyDow_lenient(DayOfWeek firstDayOfWeek, int minDays) { LocalDate date = LocalDate.of(2012, 12, 15); WeekFields week = WeekFields.of(firstDayOfWeek, minDays); @@ -590,7 +614,7 @@ public class TCKWeekFields extends AbstractTCKTest { for (int j = woy - 60; j < woy + 60; j++) { String str = date.getYear() + ":" + j + ":" + dow; LocalDate parsed = LocalDate.parse(str, f); - assertEquals(parsed, date.plusWeeks(j - woy), " ::" + str + ": :" + i + "::" + j); + assertEquals(date.plusWeeks(j - woy), parsed, " ::" + str + ": :" + i + "::" + j); } date = date.plusDays(1); @@ -598,7 +622,8 @@ public class TCKWeekFields extends AbstractTCKTest { } //----------------------------------------------------------------------- - @Test(dataProvider="weekFields") + @ParameterizedTest + @MethodSource("data_weekFields") public void test_parse_resolve_localizedWoWBY(DayOfWeek firstDayOfWeek, int minDays) { LocalDate date = LocalDate.of(2012, 12, 31); WeekFields week = WeekFields.of(firstDayOfWeek, minDays); @@ -613,13 +638,14 @@ public class TCKWeekFields extends AbstractTCKTest { String str = date.get(yowbyField) + ":" + date.get(wowbyField) + ":" + date.get(DAY_OF_WEEK); LocalDate parsed = LocalDate.parse(str, f); - assertEquals(parsed, date, " :: " + str + " " + i); + assertEquals(date, parsed, " :: " + str + " " + i); date = date.plusDays(1); } } - @Test(dataProvider="weekFields") + @ParameterizedTest + @MethodSource("data_weekFields") public void test_parse_resolve_localizedWoWBY_lenient(DayOfWeek firstDayOfWeek, int minDays) { LocalDate date = LocalDate.of(2012, 12, 31); WeekFields week = WeekFields.of(firstDayOfWeek, minDays); @@ -636,14 +662,15 @@ public class TCKWeekFields extends AbstractTCKTest { for (int j = wowby - 60; j < wowby + 60; j++) { String str = date.get(yowbyField) + ":" + j + ":" + dow; LocalDate parsed = LocalDate.parse(str, f); - assertEquals(parsed, date.plusWeeks(j - wowby), " ::" + str + ": :" + i + "::" + j); + assertEquals(date.plusWeeks(j - wowby), parsed, " ::" + str + ": :" + i + "::" + j); } date = date.plusDays(1); } } - @Test(dataProvider="weekFields") + @ParameterizedTest + @MethodSource("data_weekFields") public void test_parse_resolve_localizedWoWBY_strict(DayOfWeek firstDayOfWeek, int minDays) { WeekFields week = WeekFields.of(firstDayOfWeek, minDays); TemporalField wowbyField = week.weekOfWeekBasedYear(); @@ -655,16 +682,17 @@ public class TCKWeekFields extends AbstractTCKTest { String str = "2012:0:1"; try { LocalDate date = LocalDate.parse(str, f); - assertEquals(date.get(yowbyField), 2012); - assertEquals(date.get(wowbyField), 0); - assertEquals(date.get(DAY_OF_WEEK), 1); + assertEquals(2012, date.get(yowbyField)); + assertEquals(0, date.get(wowbyField)); + assertEquals(1, date.get(DAY_OF_WEEK)); } catch (DateTimeException ex) { // expected } } //----------------------------------------------------------------------- - @Test(dataProvider="weekFields") + @ParameterizedTest + @MethodSource("data_weekFields") public void test_parse_resolve_localizedWoWBYDow(DayOfWeek firstDayOfWeek, int minDays) { LocalDate date = LocalDate.of(2012, 12, 31); WeekFields week = WeekFields.of(firstDayOfWeek, minDays); @@ -680,13 +708,14 @@ public class TCKWeekFields extends AbstractTCKTest { String str = date.get(yowbyField) + ":" + date.get(wowbyField) + ":" + date.get(dowField); LocalDate parsed = LocalDate.parse(str, f); - assertEquals(parsed, date, " :: " + str + " " + i); + assertEquals(date, parsed, " :: " + str + " " + i); date = date.plusDays(1); } } - @Test(dataProvider="weekFields") + @ParameterizedTest + @MethodSource("data_weekFields") public void test_parse_resolve_localizedWoWBYDow_lenient(DayOfWeek firstDayOfWeek, int minDays) { LocalDate date = LocalDate.of(2012, 12, 31); WeekFields week = WeekFields.of(firstDayOfWeek, minDays); @@ -704,7 +733,7 @@ public class TCKWeekFields extends AbstractTCKTest { for (int j = wowby - 60; j < wowby + 60; j++) { String str = date.get(yowbyField) + ":" + j + ":" + dow; LocalDate parsed = LocalDate.parse(str, f); - assertEquals(parsed, date.plusWeeks(j - wowby), " ::" + str + ": :" + i + "::" + j); + assertEquals(date.plusWeeks(j - wowby), parsed, " ::" + str + ": :" + i + "::" + j); } date = date.plusDays(1); @@ -713,7 +742,6 @@ public class TCKWeekFields extends AbstractTCKTest { //----------------------------------------------------------------------- - @DataProvider(name="weekFields") Object[][] data_weekFields() { Object[][] objects = new Object[49][]; int i = 0; @@ -726,7 +754,6 @@ public class TCKWeekFields extends AbstractTCKTest { } //----------------------------------------------------------------------- - @DataProvider(name="WeekBasedYearData") Object[][] provider_WeekBasedYearData() { return new Object[][] { {WeekFields.of(DayOfWeek.SUNDAY, 1), 2008, 52, 7, LocalDate.of(2008, 12, 27)}, @@ -741,20 +768,20 @@ public class TCKWeekFields extends AbstractTCKTest { }; } - @Test(dataProvider="WeekBasedYearData") + @ParameterizedTest + @MethodSource("provider_WeekBasedYearData") public void test_weekBasedYears(WeekFields weekDef, int weekBasedYear, int weekOfWeekBasedYear, int dayOfWeek, LocalDate date) { TemporalField dowField = weekDef.dayOfWeek(); TemporalField wowbyField = weekDef.weekOfWeekBasedYear(); TemporalField yowbyField = weekDef.weekBasedYear(); - assertEquals(date.get(dowField), dayOfWeek, "DayOfWeek mismatch"); - assertEquals(date.get(wowbyField), weekOfWeekBasedYear, "Week of WeekBasedYear mismatch"); - assertEquals(date.get(yowbyField), weekBasedYear, "Year of WeekBasedYear mismatch"); + assertEquals(dayOfWeek, date.get(dowField), "DayOfWeek mismatch"); + assertEquals(weekOfWeekBasedYear, date.get(wowbyField), "Week of WeekBasedYear mismatch"); + assertEquals(weekBasedYear, date.get(yowbyField), "Year of WeekBasedYear mismatch"); } //----------------------------------------------------------------------- - @DataProvider(name="IsoWeekData") Object[][] data_week() { return new Object[][] { {LocalDate.of(1969, 12, 29), DayOfWeek.MONDAY, 1, 1970}, @@ -776,16 +803,17 @@ public class TCKWeekFields extends AbstractTCKTest { // WEEK_OF_WEEK_BASED_YEAR // Validate with the same data used by IsoFields. //----------------------------------------------------------------------- - @Test(dataProvider="IsoWeekData") + @ParameterizedTest + @MethodSource("data_week") public void test_WOWBY(LocalDate date, DayOfWeek dow, int week, int wby) { WeekFields weekDef = WeekFields.ISO; TemporalField dowField = weekDef.dayOfWeek(); TemporalField wowbyField = weekDef.weekOfWeekBasedYear(); TemporalField yowbyField = weekDef.weekBasedYear(); - assertEquals(date.get(dowField), dow.getValue()); - assertEquals(date.get(wowbyField), week); - assertEquals(date.get(yowbyField), wby); + assertEquals(dow.getValue(), date.get(dowField)); + assertEquals(week, date.get(wowbyField)); + assertEquals(wby, date.get(yowbyField)); } //----------------------------------------------------------------------- @@ -798,11 +826,11 @@ public class TCKWeekFields extends AbstractTCKTest { assertTrue(weekDef_iso.equals(WeekFields.of(DayOfWeek.MONDAY, 4))); assertTrue(weekDef_sundayStart.equals(WeekFields.of(DayOfWeek.SUNDAY, 1))); - assertEquals(weekDef_iso.hashCode(), WeekFields.of(DayOfWeek.MONDAY, 4).hashCode()); - assertEquals(weekDef_sundayStart.hashCode(), WeekFields.of(DayOfWeek.SUNDAY, 1).hashCode()); + assertEquals(WeekFields.of(DayOfWeek.MONDAY, 4).hashCode(), weekDef_iso.hashCode()); + assertEquals(WeekFields.of(DayOfWeek.SUNDAY, 1).hashCode(), weekDef_sundayStart.hashCode()); assertFalse(weekDef_iso.equals(weekDef_sundayStart)); - assertNotEquals(weekDef_iso.hashCode(), weekDef_sundayStart.hashCode()); + assertNotEquals(weekDef_sundayStart.hashCode(), weekDef_iso.hashCode()); } } diff --git a/test/jdk/java/time/tck/java/time/temporal/serial/TCKChronoFieldSerialization.java b/test/jdk/java/time/tck/java/time/temporal/serial/TCKChronoFieldSerialization.java index bb8c5c566a5..b82a278cb34 100644 --- a/test/jdk/java/time/tck/java/time/temporal/serial/TCKChronoFieldSerialization.java +++ b/test/jdk/java/time/tck/java/time/temporal/serial/TCKChronoFieldSerialization.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2012, 2013, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2012, 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 @@ -86,21 +86,21 @@ import static java.time.temporal.ChronoField.ERA; import java.io.IOException; import java.time.temporal.ChronoField; -import org.testng.annotations.DataProvider; -import org.testng.annotations.Test; +import org.junit.jupiter.api.TestInstance; +import org.junit.jupiter.params.ParameterizedTest; +import org.junit.jupiter.params.provider.MethodSource; import tck.java.time.AbstractTCKTest; /** * Test serialization of ChronoField. */ -@Test +@TestInstance(TestInstance.Lifecycle.PER_CLASS) public class TCKChronoFieldSerialization extends AbstractTCKTest { //----------------------------------------------------------------------- // List of Fields //----------------------------------------------------------------------- - @DataProvider(name="fieldBased") Object[][] data_fieldBased() { return new Object[][] { {DAY_OF_WEEK}, @@ -135,7 +135,8 @@ public class TCKChronoFieldSerialization extends AbstractTCKTest { }; } - @Test(dataProvider = "fieldBased") + @ParameterizedTest + @MethodSource("data_fieldBased") public void test_fieldSerializable(ChronoField field) throws IOException, ClassNotFoundException { assertSerializableSame(field); } diff --git a/test/jdk/java/time/tck/java/time/temporal/serial/TCKChronoUnitSerialization.java b/test/jdk/java/time/tck/java/time/temporal/serial/TCKChronoUnitSerialization.java index e97e183d252..9714220b7be 100644 --- a/test/jdk/java/time/tck/java/time/temporal/serial/TCKChronoUnitSerialization.java +++ b/test/jdk/java/time/tck/java/time/temporal/serial/TCKChronoUnitSerialization.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2012, 2013, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2012, 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 @@ -74,21 +74,21 @@ import static java.time.temporal.ChronoUnit.YEARS; import java.io.IOException; import java.time.temporal.ChronoUnit; -import org.testng.annotations.DataProvider; -import org.testng.annotations.Test; +import org.junit.jupiter.api.TestInstance; +import org.junit.jupiter.params.ParameterizedTest; +import org.junit.jupiter.params.provider.MethodSource; import tck.java.time.AbstractTCKTest; /** * Test. */ -@Test +@TestInstance(TestInstance.Lifecycle.PER_CLASS) public class TCKChronoUnitSerialization extends AbstractTCKTest { //----------------------------------------------------------------------- // ChronoUnits //----------------------------------------------------------------------- - @DataProvider(name="chronoUnit") Object[][] data_chronoUnit() { return new Object[][] { {FOREVER}, @@ -112,7 +112,8 @@ public class TCKChronoUnitSerialization extends AbstractTCKTest { }; } - @Test(dataProvider = "chronoUnit") + @ParameterizedTest + @MethodSource("data_chronoUnit") public void test_unitType(ChronoUnit unit) throws IOException, ClassNotFoundException { assertSerializableSame(unit); } diff --git a/test/jdk/java/time/tck/java/time/temporal/serial/TCKJulianFieldsSerialization.java b/test/jdk/java/time/tck/java/time/temporal/serial/TCKJulianFieldsSerialization.java index 53047f8441a..a861290ac0e 100644 --- a/test/jdk/java/time/tck/java/time/temporal/serial/TCKJulianFieldsSerialization.java +++ b/test/jdk/java/time/tck/java/time/temporal/serial/TCKJulianFieldsSerialization.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2012, 2013, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2012, 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 @@ -63,19 +63,19 @@ import java.io.IOException; import java.time.temporal.JulianFields; import java.time.temporal.TemporalField; -import org.testng.annotations.DataProvider; -import org.testng.annotations.Test; +import org.junit.jupiter.api.TestInstance; +import org.junit.jupiter.params.ParameterizedTest; +import org.junit.jupiter.params.provider.MethodSource; import tck.java.time.AbstractTCKTest; /** * Test serialization of JulianFields */ -@Test +@TestInstance(TestInstance.Lifecycle.PER_CLASS) public class TCKJulianFieldsSerialization extends AbstractTCKTest { //----------------------------------------------------------------------- - @DataProvider(name="julian_fields") Object[][] julian_samples() { return new Object[][] { {JulianFields.JULIAN_DAY}, @@ -86,7 +86,8 @@ public class TCKJulianFieldsSerialization extends AbstractTCKTest { //----------------------------------------------------------------------- - @Test(dataProvider="julian_fields") + @ParameterizedTest + @MethodSource("julian_samples") public void test_serializable(TemporalField field) throws IOException, ClassNotFoundException { assertSerializable(field); } diff --git a/test/jdk/java/time/tck/java/time/temporal/serial/TCKValueRangeSerialization.java b/test/jdk/java/time/tck/java/time/temporal/serial/TCKValueRangeSerialization.java index d99efd03535..a3612e7f6a6 100644 --- a/test/jdk/java/time/tck/java/time/temporal/serial/TCKValueRangeSerialization.java +++ b/test/jdk/java/time/tck/java/time/temporal/serial/TCKValueRangeSerialization.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2012, 2013, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2012, 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 @@ -59,8 +59,7 @@ */ package tck.java.time.temporal.serial; -import static org.testng.Assert.assertEquals; -import static org.testng.Assert.fail; +import static org.junit.jupiter.api.Assertions.fail; import java.io.ByteArrayInputStream; import java.io.ByteArrayOutputStream; @@ -71,19 +70,20 @@ import java.io.ObjectOutputStream; import java.time.temporal.ValueRange; import java.util.Arrays; -import org.testng.annotations.Test; +import org.junit.jupiter.api.Assertions; +import org.junit.jupiter.api.Test; import tck.java.time.AbstractTCKTest; /** * Test serialization of ValueRange. */ -@Test public class TCKValueRangeSerialization extends AbstractTCKTest { //----------------------------------------------------------------------- // Serialization //----------------------------------------------------------------------- + @Test public void test_serialization() throws Exception { ValueRange range = ValueRange.of(1, 2, 3, 4); assertSerializable(range); @@ -94,6 +94,7 @@ public class TCKValueRangeSerialization extends AbstractTCKTest { * Verify Serialized bytes of a ValueRange. * @throws IOException if thrown during serialization is an unexpected test tailure */ + @Test public void test_valueRangeSerialized() throws IOException { byte[] expected = { (byte)172, (byte)237, 0, 5, 115, 114, 0, 29, 106, 97, /* \u00ac \u00ed \u0000 \u0005 s r \u0000 \u001d j a */ @@ -118,7 +119,7 @@ public class TCKValueRangeSerialization extends AbstractTCKTest { oos.writeObject(range); byte[] actual = baos.toByteArray(); - assertEquals(actual, expected, "Serialized bytes incorrect"); + Assertions.assertArrayEquals(expected, actual, "Serialized bytes incorrect"); } } diff --git a/test/jdk/java/time/tck/java/time/temporal/serial/TCKWeekFieldsSerialization.java b/test/jdk/java/time/tck/java/time/temporal/serial/TCKWeekFieldsSerialization.java index 3523f05c88c..34171276cd1 100644 --- a/test/jdk/java/time/tck/java/time/temporal/serial/TCKWeekFieldsSerialization.java +++ b/test/jdk/java/time/tck/java/time/temporal/serial/TCKWeekFieldsSerialization.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2012, 2013, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2012, 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 @@ -54,13 +54,11 @@ */ package tck.java.time.temporal.serial; -import static org.testng.Assert.assertEquals; -import static org.testng.Assert.fail; +import static org.junit.jupiter.api.Assertions.assertEquals; +import static org.junit.jupiter.api.Assertions.fail; import java.io.ByteArrayInputStream; import java.io.ByteArrayOutputStream; -import org.testng.annotations.DataProvider; -import org.testng.annotations.Test; import tck.java.time.AbstractTCKTest; import java.io.IOException; @@ -70,21 +68,26 @@ import java.time.DayOfWeek; import java.time.temporal.WeekFields; import java.util.Arrays; +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 serialization of WeekFields. */ -@Test +@TestInstance(TestInstance.Lifecycle.PER_CLASS) public class TCKWeekFieldsSerialization extends AbstractTCKTest { //----------------------------------------------------------------------- - @Test(dataProvider="weekFields") + @ParameterizedTest + @MethodSource("data_weekFields") public void test_serializable_singleton(DayOfWeek firstDayOfWeek, int minDays) throws IOException, ClassNotFoundException { WeekFields weekDef = WeekFields.of(firstDayOfWeek, minDays); assertSerializableSame(weekDef); // spec state singleton } //----------------------------------------------------------------------- - @DataProvider(name="weekFields") Object[][] data_weekFields() { Object[][] objects = new Object[49][]; int i = 0; @@ -110,7 +113,7 @@ public class TCKWeekFieldsSerialization extends AbstractTCKTest { System.arraycopy(good1, 0, val, 105, good1.length); try (ObjectInputStream in = new ObjectInputStream(new ByteArrayInputStream(val))) { Object o = in.readObject(); - assertEquals(o, WeekFields.of(DayOfWeek.MONDAY, 5), "Should be MONDAY, min = 5"); + assertEquals(WeekFields.of(DayOfWeek.MONDAY, 5), o, "Should be MONDAY, min = 5"); } catch (Exception ioe) { fail("Unexpected exception " + ioe); } diff --git a/test/jdk/java/time/tck/java/time/zone/TCKFixedZoneRules.java b/test/jdk/java/time/tck/java/time/zone/TCKFixedZoneRules.java index 08df5433349..83d8af37306 100644 --- a/test/jdk/java/time/tck/java/time/zone/TCKFixedZoneRules.java +++ b/test/jdk/java/time/tck/java/time/zone/TCKFixedZoneRules.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2012, 2013, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2012, 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 @@ -59,7 +59,7 @@ */ package tck.java.time.zone; -import static org.testng.Assert.assertEquals; +import static org.junit.jupiter.api.Assertions.assertEquals; import java.io.ByteArrayInputStream; import java.io.ByteArrayOutputStream; @@ -76,13 +76,16 @@ import java.time.zone.ZoneOffsetTransitionRule; import java.time.zone.ZoneOffsetTransitionRule.TimeDefinition; import java.time.zone.ZoneRules; -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.api.TestInstance; +import org.junit.jupiter.params.ParameterizedTest; +import org.junit.jupiter.params.provider.MethodSource; /** * Test ZoneRules for fixed offset time-zones. */ -@Test +@TestInstance(TestInstance.Lifecycle.PER_CLASS) public class TCKFixedZoneRules { private static final ZoneOffset OFFSET_PONE = ZoneOffset.ofHours(1); @@ -95,7 +98,6 @@ public class TCKFixedZoneRules { return offset.getRules(); } - @DataProvider(name="rules") Object[][] data_rules() { return new Object[][] { {make(OFFSET_PONE), OFFSET_PONE}, @@ -108,95 +110,111 @@ public class TCKFixedZoneRules { // Basics //----------------------------------------------------------------------- - @Test(dataProvider="rules") + @ParameterizedTest + @MethodSource("data_rules") public void test_getOffset_Instant(ZoneRules test, ZoneOffset expectedOffset) { - assertEquals(test.getOffset(INSTANT), expectedOffset); - assertEquals(test.getOffset((Instant) null), expectedOffset); + assertEquals(expectedOffset, test.getOffset(INSTANT)); + assertEquals(expectedOffset, test.getOffset((Instant) null)); } - @Test(dataProvider="rules") + @ParameterizedTest + @MethodSource("data_rules") public void test_getOffset_LocalDateTime(ZoneRules test, ZoneOffset expectedOffset) { - assertEquals(test.getOffset(LDT), expectedOffset); - assertEquals(test.getOffset((LocalDateTime) null), expectedOffset); + assertEquals(expectedOffset, test.getOffset(LDT)); + assertEquals(expectedOffset, test.getOffset((LocalDateTime) null)); } - @Test(dataProvider="rules") + @ParameterizedTest + @MethodSource("data_rules") public void test_getValidOffsets_LDT(ZoneRules test, ZoneOffset expectedOffset) { - assertEquals(test.getValidOffsets(LDT).size(), 1); - assertEquals(test.getValidOffsets(LDT).get(0), expectedOffset); - assertEquals(test.getValidOffsets(null).size(), 1); - assertEquals(test.getValidOffsets(null).get(0), expectedOffset); + assertEquals(1, test.getValidOffsets(LDT).size()); + assertEquals(expectedOffset, test.getValidOffsets(LDT).get(0)); + assertEquals(1, test.getValidOffsets(null).size()); + assertEquals(expectedOffset, test.getValidOffsets(null).get(0)); } - @Test(dataProvider="rules") + @ParameterizedTest + @MethodSource("data_rules") public void test_getTransition_LDT(ZoneRules test, ZoneOffset expectedOffset) { - assertEquals(test.getTransition(LDT), null); - assertEquals(test.getTransition(null), null); + assertEquals(null, test.getTransition(LDT)); + assertEquals(null, test.getTransition(null)); } - @Test(dataProvider="rules") + @ParameterizedTest + @MethodSource("data_rules") public void test_isValidOffset_LDT_ZO(ZoneRules test, ZoneOffset expectedOffset) { - assertEquals(test.isValidOffset(LDT, expectedOffset), true); - assertEquals(test.isValidOffset(LDT, ZoneOffset.UTC), false); - assertEquals(test.isValidOffset(LDT, null), false); + assertEquals(true, test.isValidOffset(LDT, expectedOffset)); + assertEquals(false, test.isValidOffset(LDT, ZoneOffset.UTC)); + assertEquals(false, test.isValidOffset(LDT, null)); - assertEquals(test.isValidOffset(null, expectedOffset), true); - assertEquals(test.isValidOffset(null, ZoneOffset.UTC), false); - assertEquals(test.isValidOffset(null, null), false); + assertEquals(true, test.isValidOffset(null, expectedOffset)); + assertEquals(false, test.isValidOffset(null, ZoneOffset.UTC)); + assertEquals(false, test.isValidOffset(null, null)); } - @Test(dataProvider="rules") + @ParameterizedTest + @MethodSource("data_rules") public void test_getStandardOffset_Instant(ZoneRules test, ZoneOffset expectedOffset) { - assertEquals(test.getStandardOffset(INSTANT), expectedOffset); - assertEquals(test.getStandardOffset(null), expectedOffset); + assertEquals(expectedOffset, test.getStandardOffset(INSTANT)); + assertEquals(expectedOffset, test.getStandardOffset(null)); } - @Test(dataProvider="rules") + @ParameterizedTest + @MethodSource("data_rules") public void test_getDaylightSavings_Instant(ZoneRules test, ZoneOffset expectedOffset) { - assertEquals(test.getDaylightSavings(INSTANT), Duration.ZERO); - assertEquals(test.getDaylightSavings(null), Duration.ZERO); + assertEquals(Duration.ZERO, test.getDaylightSavings(INSTANT)); + assertEquals(Duration.ZERO, test.getDaylightSavings(null)); } - @Test(dataProvider="rules") + @ParameterizedTest + @MethodSource("data_rules") public void test_isDaylightSavings_Instant(ZoneRules test, ZoneOffset expectedOffset) { - assertEquals(test.isDaylightSavings(INSTANT), false); - assertEquals(test.isDaylightSavings(null), false); + assertEquals(false, test.isDaylightSavings(INSTANT)); + assertEquals(false, test.isDaylightSavings(null)); } //------------------------------------------------------------------------- - @Test(dataProvider="rules") + @ParameterizedTest + @MethodSource("data_rules") public void test_nextTransition_Instant(ZoneRules test, ZoneOffset expectedOffset) { - assertEquals(test.nextTransition(INSTANT), null); - assertEquals(test.nextTransition(null), null); + assertEquals(null, test.nextTransition(INSTANT)); + assertEquals(null, test.nextTransition(null)); } - @Test(dataProvider="rules") + @ParameterizedTest + @MethodSource("data_rules") public void test_previousTransition_Instant(ZoneRules test, ZoneOffset expectedOffset) { - assertEquals(test.previousTransition(INSTANT), null); - assertEquals(test.previousTransition(null), null); + assertEquals(null, test.previousTransition(INSTANT)); + assertEquals(null, test.previousTransition(null)); } //------------------------------------------------------------------------- - @Test(dataProvider="rules") + @ParameterizedTest + @MethodSource("data_rules") public void test_getTransitions(ZoneRules test, ZoneOffset expectedOffset) { - assertEquals(test.getTransitions().size(), 0); + assertEquals(0, test.getTransitions().size()); } - @Test(expectedExceptions=UnsupportedOperationException.class) + @Test public void test_getTransitions_immutable() { - ZoneRules test = make(OFFSET_PTWO); - test.getTransitions().add(ZoneOffsetTransition.of(LDT, OFFSET_PONE, OFFSET_PTWO)); + Assertions.assertThrows(UnsupportedOperationException.class, () -> { + ZoneRules test = make(OFFSET_PTWO); + test.getTransitions().add(ZoneOffsetTransition.of(LDT, OFFSET_PONE, OFFSET_PTWO)); + }); } - @Test(dataProvider="rules") + @ParameterizedTest + @MethodSource("data_rules") public void test_getTransitionRules(ZoneRules test, ZoneOffset expectedOffset) { - assertEquals(test.getTransitionRules().size(), 0); + assertEquals(0, test.getTransitionRules().size()); } - @Test(expectedExceptions=UnsupportedOperationException.class) + @Test public void test_getTransitionRules_immutable() { - ZoneRules test = make(OFFSET_PTWO); - test.getTransitionRules().add(ZoneOffsetTransitionRule.of(Month.JULY, 2, null, LocalTime.of(12, 30), false, TimeDefinition.STANDARD, OFFSET_PONE, OFFSET_PTWO, OFFSET_PONE)); + Assertions.assertThrows(UnsupportedOperationException.class, () -> { + ZoneRules test = make(OFFSET_PTWO); + test.getTransitionRules().add(ZoneOffsetTransitionRule.of(Month.JULY, 2, null, LocalTime.of(12, 30), false, TimeDefinition.STANDARD, OFFSET_PONE, OFFSET_PTWO, OFFSET_PONE)); + }); } //----------------------------------------------------------------------- @@ -207,16 +225,16 @@ public class TCKFixedZoneRules { ZoneRules a = make(OFFSET_PONE); ZoneRules b = make(OFFSET_PTWO); - assertEquals(a.equals(a), true); - assertEquals(a.equals(b), false); - assertEquals(b.equals(a), false); - assertEquals(b.equals(b), true); + assertEquals(true, a.equals(a)); + assertEquals(false, a.equals(b)); + assertEquals(false, b.equals(a)); + assertEquals(true, b.equals(b)); - assertEquals(a.equals("Rubbish"), false); - assertEquals(a.equals(null), false); + assertEquals(false, a.equals("Rubbish")); + assertEquals(false, a.equals(null)); - assertEquals(a.hashCode() == a.hashCode(), true); - assertEquals(b.hashCode() == b.hashCode(), true); + assertEquals(true, a.hashCode() == a.hashCode()); + assertEquals(true, b.hashCode() == b.hashCode()); } } diff --git a/test/jdk/java/time/tck/java/time/zone/TCKZoneOffsetTransition.java b/test/jdk/java/time/tck/java/time/zone/TCKZoneOffsetTransition.java index 9cd42624bfa..241da3d0519 100644 --- a/test/jdk/java/time/tck/java/time/zone/TCKZoneOffsetTransition.java +++ b/test/jdk/java/time/tck/java/time/zone/TCKZoneOffsetTransition.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2012, 2013, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2012, 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 @@ -60,7 +60,8 @@ package tck.java.time.zone; import static java.time.temporal.ChronoUnit.HOURS; -import static org.testng.Assert.assertEquals; + +import static org.junit.jupiter.api.Assertions.assertEquals; import java.time.Duration; import java.time.LocalDateTime; @@ -68,13 +69,14 @@ import java.time.Year; import java.time.ZoneOffset; import java.time.zone.ZoneOffsetTransition; -import org.testng.annotations.Test; +import org.junit.jupiter.api.Assertions; +import org.junit.jupiter.api.Test; + import tck.java.time.AbstractTCKTest; /** * Test ZoneOffsetTransition. */ -@Test public class TCKZoneOffsetTransition extends AbstractTCKTest { private static final ZoneOffset OFFSET_0100 = ZoneOffset.ofHours(1); @@ -86,29 +88,29 @@ public class TCKZoneOffsetTransition extends AbstractTCKTest { //----------------------------------------------------------------------- // factory //----------------------------------------------------------------------- - @Test(expectedExceptions=NullPointerException.class) + @Test public void test_factory_nullTransition() { - ZoneOffsetTransition.of(null, OFFSET_0100, OFFSET_0200); + Assertions.assertThrows(NullPointerException.class, () -> ZoneOffsetTransition.of(null, OFFSET_0100, OFFSET_0200)); } - @Test(expectedExceptions=NullPointerException.class) + @Test public void test_factory_nullOffsetBefore() { - ZoneOffsetTransition.of(LocalDateTime.of(2010, 12, 3, 11, 30), null, OFFSET_0200); + Assertions.assertThrows(NullPointerException.class, () -> ZoneOffsetTransition.of(LocalDateTime.of(2010, 12, 3, 11, 30), null, OFFSET_0200)); } - @Test(expectedExceptions=NullPointerException.class) + @Test public void test_factory_nullOffsetAfter() { - ZoneOffsetTransition.of(LocalDateTime.of(2010, 12, 3, 11, 30), OFFSET_0200, null); + Assertions.assertThrows(NullPointerException.class, () -> ZoneOffsetTransition.of(LocalDateTime.of(2010, 12, 3, 11, 30), OFFSET_0200, null)); } - @Test(expectedExceptions=IllegalArgumentException.class) + @Test public void test_factory_sameOffset() { - ZoneOffsetTransition.of(LocalDateTime.of(2010, 12, 3, 11, 30), OFFSET_0200, OFFSET_0200); + Assertions.assertThrows(IllegalArgumentException.class, () -> ZoneOffsetTransition.of(LocalDateTime.of(2010, 12, 3, 11, 30), OFFSET_0200, OFFSET_0200)); } - @Test(expectedExceptions=IllegalArgumentException.class) + @Test public void test_factory_noNanos() { - ZoneOffsetTransition.of(LocalDateTime.of(2010, 12, 3, 11, 30, 0, 500), OFFSET_0200, OFFSET_0300); + Assertions.assertThrows(IllegalArgumentException.class, () -> ZoneOffsetTransition.of(LocalDateTime.of(2010, 12, 3, 11, 30, 0, 500), OFFSET_0200, OFFSET_0300)); } //----------------------------------------------------------------------- @@ -119,14 +121,14 @@ public class TCKZoneOffsetTransition extends AbstractTCKTest { LocalDateTime before = LocalDateTime.of(2010, 3, 31, 1, 0); LocalDateTime after = LocalDateTime.of(2010, 3, 31, 2, 0); ZoneOffsetTransition test = ZoneOffsetTransition.of(before, OFFSET_0200, OFFSET_0300); - assertEquals(test.isGap(), true); - assertEquals(test.isOverlap(), false); - assertEquals(test.getDateTimeBefore(), before); - assertEquals(test.getDateTimeAfter(), after); - assertEquals(test.getInstant(), before.toInstant(OFFSET_0200)); - assertEquals(test.getOffsetBefore(), OFFSET_0200); - assertEquals(test.getOffsetAfter(), OFFSET_0300); - assertEquals(test.getDuration(), Duration.of(1, HOURS)); + assertEquals(true, test.isGap()); + assertEquals(false, test.isOverlap()); + assertEquals(before, test.getDateTimeBefore()); + assertEquals(after, test.getDateTimeAfter()); + assertEquals(before.toInstant(OFFSET_0200), test.getInstant()); + assertEquals(OFFSET_0200, test.getOffsetBefore()); + assertEquals(OFFSET_0300, test.getOffsetAfter()); + assertEquals(Duration.of(1, HOURS), test.getDuration()); } @Test @@ -134,14 +136,14 @@ public class TCKZoneOffsetTransition extends AbstractTCKTest { LocalDateTime before = LocalDateTime.of(2010, 10, 31, 1, 0); LocalDateTime after = LocalDateTime.of(2010, 10, 31, 0, 0); ZoneOffsetTransition test = ZoneOffsetTransition.of(before, OFFSET_0300, OFFSET_0200); - assertEquals(test.isGap(), false); - assertEquals(test.isOverlap(), true); - assertEquals(test.getDateTimeBefore(), before); - assertEquals(test.getDateTimeAfter(), after); - assertEquals(test.getInstant(), before.toInstant(OFFSET_0300)); - assertEquals(test.getOffsetBefore(), OFFSET_0300); - assertEquals(test.getOffsetAfter(), OFFSET_0200); - assertEquals(test.getDuration(), Duration.of(-1, HOURS)); + assertEquals(false, test.isGap()); + assertEquals(true, test.isOverlap()); + assertEquals(before, test.getDateTimeBefore()); + assertEquals(after, test.getDateTimeAfter()); + assertEquals(before.toInstant(OFFSET_0300), test.getInstant()); + assertEquals(OFFSET_0300, test.getOffsetBefore()); + assertEquals(OFFSET_0200, test.getOffsetAfter()); + assertEquals(Duration.of(-1, HOURS), test.getDuration()); } @@ -152,22 +154,22 @@ public class TCKZoneOffsetTransition extends AbstractTCKTest { public void test_isValidOffset_gap() { LocalDateTime ldt = LocalDateTime.of(2010, 3, 31, 1, 0); ZoneOffsetTransition test = ZoneOffsetTransition.of(ldt, OFFSET_0200, OFFSET_0300); - assertEquals(test.isValidOffset(OFFSET_0100), false); - assertEquals(test.isValidOffset(OFFSET_0200), false); - assertEquals(test.isValidOffset(OFFSET_0230), false); - assertEquals(test.isValidOffset(OFFSET_0300), false); - assertEquals(test.isValidOffset(OFFSET_0400), false); + assertEquals(false, test.isValidOffset(OFFSET_0100)); + assertEquals(false, test.isValidOffset(OFFSET_0200)); + assertEquals(false, test.isValidOffset(OFFSET_0230)); + assertEquals(false, test.isValidOffset(OFFSET_0300)); + assertEquals(false, test.isValidOffset(OFFSET_0400)); } @Test public void test_isValidOffset_overlap() { LocalDateTime ldt = LocalDateTime.of(2010, 10, 31, 1, 0); ZoneOffsetTransition test = ZoneOffsetTransition.of(ldt, OFFSET_0300, OFFSET_0200); - assertEquals(test.isValidOffset(OFFSET_0100), false); - assertEquals(test.isValidOffset(OFFSET_0200), true); - assertEquals(test.isValidOffset(OFFSET_0230), false); - assertEquals(test.isValidOffset(OFFSET_0300), true); - assertEquals(test.isValidOffset(OFFSET_0400), false); + assertEquals(false, test.isValidOffset(OFFSET_0100)); + assertEquals(true, test.isValidOffset(OFFSET_0200)); + assertEquals(false, test.isValidOffset(OFFSET_0230)); + assertEquals(true, test.isValidOffset(OFFSET_0300)); + assertEquals(false, test.isValidOffset(OFFSET_0400)); } //----------------------------------------------------------------------- @@ -182,17 +184,17 @@ public class TCKZoneOffsetTransition extends AbstractTCKTest { ZoneOffsetTransition c = ZoneOffsetTransition.of( LocalDateTime.ofEpochSecond(23875287L + 1, 0, OFFSET_0100), OFFSET_0100,OFFSET_0400); - assertEquals(a.compareTo(a) == 0, true); - assertEquals(a.compareTo(b) < 0, true); - assertEquals(a.compareTo(c) < 0, true); + assertEquals(true, a.compareTo(a) == 0); + assertEquals(true, a.compareTo(b) < 0); + assertEquals(true, a.compareTo(c) < 0); - assertEquals(b.compareTo(a) > 0, true); - assertEquals(b.compareTo(b) == 0, true); - assertEquals(b.compareTo(c) < 0, true); + assertEquals(true, b.compareTo(a) > 0); + assertEquals(true, b.compareTo(b) == 0); + assertEquals(true, b.compareTo(c) < 0); - assertEquals(c.compareTo(a) > 0, true); - assertEquals(c.compareTo(b) > 0, true); - assertEquals(c.compareTo(c) == 0, true); + assertEquals(true, c.compareTo(a) > 0); + assertEquals(true, c.compareTo(b) > 0); + assertEquals(true, c.compareTo(c) == 0); } @Test @@ -204,17 +206,17 @@ public class TCKZoneOffsetTransition extends AbstractTCKTest { ZoneOffsetTransition c = ZoneOffsetTransition.of( LocalDateTime.ofEpochSecond(23875287L, 0, OFFSET_0100), OFFSET_0100, OFFSET_0400); - assertEquals(a.compareTo(a) == 0, true); - assertEquals(a.compareTo(b) == 0, true); - assertEquals(a.compareTo(c) == 0, true); + assertEquals(true, a.compareTo(a) == 0); + assertEquals(true, a.compareTo(b) == 0); + assertEquals(true, a.compareTo(c) == 0); - assertEquals(b.compareTo(a) == 0, true); - assertEquals(b.compareTo(b) == 0, true); - assertEquals(b.compareTo(c) == 0, true); + assertEquals(true, b.compareTo(a) == 0); + assertEquals(true, b.compareTo(b) == 0); + assertEquals(true, b.compareTo(c) == 0); - assertEquals(c.compareTo(a) == 0, true); - assertEquals(c.compareTo(b) == 0, true); - assertEquals(c.compareTo(c) == 0, true); + assertEquals(true, c.compareTo(a) == 0); + assertEquals(true, c.compareTo(b) == 0); + assertEquals(true, c.compareTo(c) == 0); } //----------------------------------------------------------------------- @@ -228,18 +230,18 @@ public class TCKZoneOffsetTransition extends AbstractTCKTest { LocalDateTime ldtB = LocalDateTime.of(2010, 10, 31, 1, 0); ZoneOffsetTransition b = ZoneOffsetTransition.of(ldtB, OFFSET_0300, OFFSET_0200); - assertEquals(a1.equals(a1), true); - assertEquals(a1.equals(a2), true); - assertEquals(a1.equals(b), false); - assertEquals(a2.equals(a1), true); - assertEquals(a2.equals(a2), true); - assertEquals(a2.equals(b), false); - assertEquals(b.equals(a1), false); - assertEquals(b.equals(a2), false); - assertEquals(b.equals(b), true); + assertEquals(true, a1.equals(a1)); + assertEquals(true, a1.equals(a2)); + assertEquals(false, a1.equals(b)); + assertEquals(true, a2.equals(a1)); + assertEquals(true, a2.equals(a2)); + assertEquals(false, a2.equals(b)); + assertEquals(false, b.equals(a1)); + assertEquals(false, b.equals(a2)); + assertEquals(true, b.equals(b)); - assertEquals(a1.equals(""), false); - assertEquals(a1.equals(null), false); + assertEquals(false, a1.equals("")); + assertEquals(false, a1.equals(null)); } //----------------------------------------------------------------------- @@ -254,7 +256,7 @@ public class TCKZoneOffsetTransition extends AbstractTCKTest { ZoneOffsetTransition b = ZoneOffsetTransition.of(ldtB, OFFSET_0300, OFFSET_0200); assertEquals(a1.hashCode(), a1.hashCode()); - assertEquals(a1.hashCode(), a2.hashCode()); + assertEquals(a2.hashCode(), a1.hashCode()); assertEquals(b.hashCode(), b.hashCode()); } @@ -265,14 +267,14 @@ public class TCKZoneOffsetTransition extends AbstractTCKTest { public void test_toString_gap() { LocalDateTime ldt = LocalDateTime.of(2010, 3, 31, 1, 0); ZoneOffsetTransition test = ZoneOffsetTransition.of(ldt, OFFSET_0200, OFFSET_0300); - assertEquals(test.toString(), "Transition[Gap at 2010-03-31T01:00+02:00 to +03:00]"); + assertEquals("Transition[Gap at 2010-03-31T01:00+02:00 to +03:00]", test.toString()); } @Test public void test_toString_overlap() { LocalDateTime ldt = LocalDateTime.of(2010, 10, 31, 1, 0); ZoneOffsetTransition test = ZoneOffsetTransition.of(ldt, OFFSET_0300, OFFSET_0200); - assertEquals(test.toString(), "Transition[Overlap at 2010-10-31T01:00+03:00 to +02:00]"); + assertEquals("Transition[Overlap at 2010-10-31T01:00+03:00 to +02:00]", test.toString()); } } diff --git a/test/jdk/java/time/tck/java/time/zone/TCKZoneOffsetTransitionRule.java b/test/jdk/java/time/tck/java/time/zone/TCKZoneOffsetTransitionRule.java index 3c0c14c1ca6..e12251c6874 100644 --- a/test/jdk/java/time/tck/java/time/zone/TCKZoneOffsetTransitionRule.java +++ b/test/jdk/java/time/tck/java/time/zone/TCKZoneOffsetTransitionRule.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2012, 2015, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2012, 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 @@ -59,7 +59,7 @@ */ package tck.java.time.zone; -import static org.testng.Assert.assertEquals; +import static org.junit.jupiter.api.Assertions.assertEquals; import java.time.DayOfWeek; import java.time.LocalDateTime; @@ -70,13 +70,14 @@ import java.time.zone.ZoneOffsetTransition; import java.time.zone.ZoneOffsetTransitionRule; import java.time.zone.ZoneOffsetTransitionRule.TimeDefinition; -import org.testng.annotations.Test; +import org.junit.jupiter.api.Assertions; +import org.junit.jupiter.api.Test; + import tck.java.time.AbstractTCKTest; /** * Test ZoneOffsetTransitionRule. */ -@Test public class TCKZoneOffsetTransitionRule extends AbstractTCKTest { private static final LocalTime TIME_0100 = LocalTime.of(1, 0); @@ -86,81 +87,81 @@ public class TCKZoneOffsetTransitionRule extends AbstractTCKTest { //----------------------------------------------------------------------- // factory //----------------------------------------------------------------------- - @Test(expectedExceptions=NullPointerException.class) + @Test public void test_factory_nullMonth() { - ZoneOffsetTransitionRule.of( + Assertions.assertThrows(NullPointerException.class, () -> ZoneOffsetTransitionRule.of( null, 20, DayOfWeek.SUNDAY, TIME_0100, false, TimeDefinition.WALL, - OFFSET_0200, OFFSET_0200, OFFSET_0300); + OFFSET_0200, OFFSET_0200, OFFSET_0300)); } - @Test(expectedExceptions=NullPointerException.class) + @Test public void test_factory_nullTime() { - ZoneOffsetTransitionRule.of( + Assertions.assertThrows(NullPointerException.class, () -> ZoneOffsetTransitionRule.of( Month.MARCH, 20, DayOfWeek.SUNDAY, null, false, TimeDefinition.WALL, - OFFSET_0200, OFFSET_0200, OFFSET_0300); + OFFSET_0200, OFFSET_0200, OFFSET_0300)); } - @Test(expectedExceptions=NullPointerException.class) + @Test public void test_factory_nullTimeDefinition() { - ZoneOffsetTransitionRule.of( + Assertions.assertThrows(NullPointerException.class, () -> ZoneOffsetTransitionRule.of( Month.MARCH, 20, DayOfWeek.SUNDAY, TIME_0100, false, null, - OFFSET_0200, OFFSET_0200, OFFSET_0300); + OFFSET_0200, OFFSET_0200, OFFSET_0300)); } - @Test(expectedExceptions=NullPointerException.class) + @Test public void test_factory_nullStandardOffset() { - ZoneOffsetTransitionRule.of( + Assertions.assertThrows(NullPointerException.class, () -> ZoneOffsetTransitionRule.of( Month.MARCH, 20, DayOfWeek.SUNDAY, TIME_0100, false, TimeDefinition.WALL, - null, OFFSET_0200, OFFSET_0300); + null, OFFSET_0200, OFFSET_0300)); } - @Test(expectedExceptions=NullPointerException.class) + @Test public void test_factory_nullOffsetBefore() { - ZoneOffsetTransitionRule.of( + Assertions.assertThrows(NullPointerException.class, () -> ZoneOffsetTransitionRule.of( Month.MARCH, 20, DayOfWeek.SUNDAY, TIME_0100, false, TimeDefinition.WALL, - OFFSET_0200, null, OFFSET_0300); + OFFSET_0200, null, OFFSET_0300)); } - @Test(expectedExceptions=NullPointerException.class) + @Test public void test_factory_nullOffsetAfter() { - ZoneOffsetTransitionRule.of( + Assertions.assertThrows(NullPointerException.class, () -> ZoneOffsetTransitionRule.of( Month.MARCH, 20, DayOfWeek.SUNDAY, TIME_0100, false, TimeDefinition.WALL, - OFFSET_0200, OFFSET_0200, null); + OFFSET_0200, OFFSET_0200, null)); } - @Test(expectedExceptions=IllegalArgumentException.class) + @Test public void test_factory_invalidDayOfMonthIndicator_tooSmall() { - ZoneOffsetTransitionRule.of( + Assertions.assertThrows(IllegalArgumentException.class, () -> ZoneOffsetTransitionRule.of( Month.MARCH, -29, DayOfWeek.SUNDAY, TIME_0100, false, TimeDefinition.WALL, - OFFSET_0200, OFFSET_0200, OFFSET_0300); + OFFSET_0200, OFFSET_0200, OFFSET_0300)); } - @Test(expectedExceptions=IllegalArgumentException.class) + @Test public void test_factory_invalidDayOfMonthIndicator_zero() { - ZoneOffsetTransitionRule.of( + Assertions.assertThrows(IllegalArgumentException.class, () -> ZoneOffsetTransitionRule.of( Month.MARCH, 0, DayOfWeek.SUNDAY, TIME_0100, false, TimeDefinition.WALL, - OFFSET_0200, OFFSET_0200, OFFSET_0300); + OFFSET_0200, OFFSET_0200, OFFSET_0300)); } - @Test(expectedExceptions=IllegalArgumentException.class) + @Test public void test_factory_invalidDayOfMonthIndicator_tooLarge() { - ZoneOffsetTransitionRule.of( + Assertions.assertThrows(IllegalArgumentException.class, () -> ZoneOffsetTransitionRule.of( Month.MARCH, 32, DayOfWeek.SUNDAY, TIME_0100, false, TimeDefinition.WALL, - OFFSET_0200, OFFSET_0200, OFFSET_0300); + OFFSET_0200, OFFSET_0200, OFFSET_0300)); } - @Test(expectedExceptions=IllegalArgumentException.class) + @Test public void test_factory_invalidMidnightFlag() { - ZoneOffsetTransitionRule.of( + Assertions.assertThrows(IllegalArgumentException.class, () -> ZoneOffsetTransitionRule.of( Month.MARCH, 20, DayOfWeek.SUNDAY, TIME_0100, true, TimeDefinition.WALL, - OFFSET_0200, OFFSET_0200, OFFSET_0300); + OFFSET_0200, OFFSET_0200, OFFSET_0300)); } - @Test(expectedExceptions=IllegalArgumentException.class) + @Test public void test_factory_nonZeroTimeNanos() { - ZoneOffsetTransitionRule.of( - Month.MARCH, 20, DayOfWeek.SUNDAY, LocalTime.of(1, 2, 3, 400_000_000), - false, TimeDefinition.WALL, OFFSET_0200, OFFSET_0200, OFFSET_0300); + Assertions.assertThrows(IllegalArgumentException.class, () -> ZoneOffsetTransitionRule.of( + Month.MARCH, 20, DayOfWeek.SUNDAY, LocalTime.of(1, 2, 3, 400_000_000), + false, TimeDefinition.WALL, OFFSET_0200, OFFSET_0200, OFFSET_0300)); } //----------------------------------------------------------------------- @@ -171,15 +172,15 @@ public class TCKZoneOffsetTransitionRule extends AbstractTCKTest { ZoneOffsetTransitionRule test = ZoneOffsetTransitionRule.of( Month.MARCH, 20, DayOfWeek.SUNDAY, TIME_0100, false, TimeDefinition.WALL, OFFSET_0200, OFFSET_0200, OFFSET_0300); - assertEquals(test.getMonth(), Month.MARCH); - assertEquals(test.getDayOfMonthIndicator(), 20); - assertEquals(test.getDayOfWeek(), DayOfWeek.SUNDAY); - assertEquals(test.getLocalTime(), TIME_0100); - assertEquals(test.isMidnightEndOfDay(), false); - assertEquals(test.getTimeDefinition(), TimeDefinition.WALL); - assertEquals(test.getStandardOffset(), OFFSET_0200); - assertEquals(test.getOffsetBefore(), OFFSET_0200); - assertEquals(test.getOffsetAfter(), OFFSET_0300); + assertEquals(Month.MARCH, test.getMonth()); + assertEquals(20, test.getDayOfMonthIndicator()); + assertEquals(DayOfWeek.SUNDAY, test.getDayOfWeek()); + assertEquals(TIME_0100, test.getLocalTime()); + assertEquals(false, test.isMidnightEndOfDay()); + assertEquals(TimeDefinition.WALL, test.getTimeDefinition()); + assertEquals(OFFSET_0200, test.getStandardOffset()); + assertEquals(OFFSET_0200, test.getOffsetBefore()); + assertEquals(OFFSET_0300, test.getOffsetAfter()); } @Test @@ -187,15 +188,15 @@ public class TCKZoneOffsetTransitionRule extends AbstractTCKTest { ZoneOffsetTransitionRule test = ZoneOffsetTransitionRule.of( Month.MARCH, -1, DayOfWeek.SUNDAY, TIME_0100, false, TimeDefinition.WALL, OFFSET_0200, OFFSET_0200, OFFSET_0300); - assertEquals(test.getMonth(), Month.MARCH); - assertEquals(test.getDayOfMonthIndicator(), -1); - assertEquals(test.getDayOfWeek(), DayOfWeek.SUNDAY); - assertEquals(test.getLocalTime(), TIME_0100); - assertEquals(test.isMidnightEndOfDay(), false); - assertEquals(test.getTimeDefinition(), TimeDefinition.WALL); - assertEquals(test.getStandardOffset(), OFFSET_0200); - assertEquals(test.getOffsetBefore(), OFFSET_0200); - assertEquals(test.getOffsetAfter(), OFFSET_0300); + assertEquals(Month.MARCH, test.getMonth()); + assertEquals(-1, test.getDayOfMonthIndicator()); + assertEquals(DayOfWeek.SUNDAY, test.getDayOfWeek()); + assertEquals(TIME_0100, test.getLocalTime()); + assertEquals(false, test.isMidnightEndOfDay()); + assertEquals(TimeDefinition.WALL, test.getTimeDefinition()); + assertEquals(OFFSET_0200, test.getStandardOffset()); + assertEquals(OFFSET_0200, test.getOffsetBefore()); + assertEquals(OFFSET_0300, test.getOffsetAfter()); } @Test @@ -203,15 +204,15 @@ public class TCKZoneOffsetTransitionRule extends AbstractTCKTest { ZoneOffsetTransitionRule test = ZoneOffsetTransitionRule.of( Month.MARCH, 20, null, TIME_0100, false, TimeDefinition.WALL, OFFSET_0200, OFFSET_0200, OFFSET_0300); - assertEquals(test.getMonth(), Month.MARCH); - assertEquals(test.getDayOfMonthIndicator(), 20); - assertEquals(test.getDayOfWeek(), null); - assertEquals(test.getLocalTime(), TIME_0100); - assertEquals(test.isMidnightEndOfDay(), false); - assertEquals(test.getTimeDefinition(), TimeDefinition.WALL); - assertEquals(test.getStandardOffset(), OFFSET_0200); - assertEquals(test.getOffsetBefore(), OFFSET_0200); - assertEquals(test.getOffsetAfter(), OFFSET_0300); + assertEquals(Month.MARCH, test.getMonth()); + assertEquals(20, test.getDayOfMonthIndicator()); + assertEquals(null, test.getDayOfWeek()); + assertEquals(TIME_0100, test.getLocalTime()); + assertEquals(false, test.isMidnightEndOfDay()); + assertEquals(TimeDefinition.WALL, test.getTimeDefinition()); + assertEquals(OFFSET_0200, test.getStandardOffset()); + assertEquals(OFFSET_0200, test.getOffsetBefore()); + assertEquals(OFFSET_0300, test.getOffsetAfter()); } @@ -225,7 +226,7 @@ public class TCKZoneOffsetTransitionRule extends AbstractTCKTest { OFFSET_0200, OFFSET_0200, OFFSET_0300); ZoneOffsetTransition trans = ZoneOffsetTransition.of( LocalDateTime.of(2000, Month.MARCH, 26, 1, 0), OFFSET_0200, OFFSET_0300); - assertEquals(test.createTransition(2000), trans); + assertEquals(trans, test.createTransition(2000)); } @Test @@ -235,7 +236,7 @@ public class TCKZoneOffsetTransitionRule extends AbstractTCKTest { OFFSET_0200, OFFSET_0300, OFFSET_0200); ZoneOffsetTransition trans = ZoneOffsetTransition.of( LocalDateTime.of(2000, Month.MARCH, 27, 0, 0), OFFSET_0300, OFFSET_0200); - assertEquals(test.createTransition(2000), trans); + assertEquals(trans, test.createTransition(2000)); } @Test @@ -245,7 +246,7 @@ public class TCKZoneOffsetTransitionRule extends AbstractTCKTest { OFFSET_0200, OFFSET_0200, OFFSET_0300); ZoneOffsetTransition trans = ZoneOffsetTransition.of( LocalDateTime.of(2000, Month.MARCH, 26, 1, 0), OFFSET_0200, OFFSET_0300); - assertEquals(test.createTransition(2000), trans); + assertEquals(trans, test.createTransition(2000)); } @Test @@ -255,7 +256,7 @@ public class TCKZoneOffsetTransitionRule extends AbstractTCKTest { OFFSET_0200, OFFSET_0200, OFFSET_0300); ZoneOffsetTransition trans = ZoneOffsetTransition.of( LocalDateTime.of(2000, Month.MARCH, 19, 1, 0), OFFSET_0200, OFFSET_0300); - assertEquals(test.createTransition(2000), trans); + assertEquals(trans, test.createTransition(2000)); } @Test @@ -265,7 +266,7 @@ public class TCKZoneOffsetTransitionRule extends AbstractTCKTest { OFFSET_0200, OFFSET_0200, OFFSET_0300); ZoneOffsetTransition trans = ZoneOffsetTransition.of( LocalDateTime.of(2000, Month.MARCH, 26, 1, 0), OFFSET_0200, OFFSET_0300); - assertEquals(test.createTransition(2000), trans); + assertEquals(trans, test.createTransition(2000)); } @Test @@ -275,7 +276,7 @@ public class TCKZoneOffsetTransitionRule extends AbstractTCKTest { OFFSET_0200, OFFSET_0200, OFFSET_0300); ZoneOffsetTransition trans = ZoneOffsetTransition.of( LocalDateTime.of(2000, Month.MARCH, 20, 1, 0), OFFSET_0200, OFFSET_0300); - assertEquals(test.createTransition(2000), trans); + assertEquals(trans, test.createTransition(2000)); } //----------------------------------------------------------------------- @@ -289,10 +290,10 @@ public class TCKZoneOffsetTransitionRule extends AbstractTCKTest { ZoneOffsetTransitionRule b = ZoneOffsetTransitionRule.of( Month.APRIL, 20, DayOfWeek.SUNDAY, TIME_0100, false, TimeDefinition.WALL, OFFSET_0200, OFFSET_0200, OFFSET_0300); - assertEquals(a.equals(a), true); - assertEquals(a.equals(b), false); - assertEquals(b.equals(a), false); - assertEquals(b.equals(b), true); + assertEquals(true, a.equals(a)); + assertEquals(false, a.equals(b)); + assertEquals(false, b.equals(a)); + assertEquals(true, b.equals(b)); } @Test @@ -303,10 +304,10 @@ public class TCKZoneOffsetTransitionRule extends AbstractTCKTest { ZoneOffsetTransitionRule b = ZoneOffsetTransitionRule.of( Month.MARCH, 21, DayOfWeek.SUNDAY, TIME_0100, false, TimeDefinition.WALL, OFFSET_0200, OFFSET_0200, OFFSET_0300); - assertEquals(a.equals(a), true); - assertEquals(a.equals(b), false); - assertEquals(b.equals(a), false); - assertEquals(b.equals(b), true); + assertEquals(true, a.equals(a)); + assertEquals(false, a.equals(b)); + assertEquals(false, b.equals(a)); + assertEquals(true, b.equals(b)); } @Test @@ -317,10 +318,10 @@ public class TCKZoneOffsetTransitionRule extends AbstractTCKTest { ZoneOffsetTransitionRule b = ZoneOffsetTransitionRule.of( Month.MARCH, 20, DayOfWeek.SATURDAY, TIME_0100, false, TimeDefinition.WALL, OFFSET_0200, OFFSET_0200, OFFSET_0300); - assertEquals(a.equals(a), true); - assertEquals(a.equals(b), false); - assertEquals(b.equals(a), false); - assertEquals(b.equals(b), true); + assertEquals(true, a.equals(a)); + assertEquals(false, a.equals(b)); + assertEquals(false, b.equals(a)); + assertEquals(true, b.equals(b)); } @Test @@ -331,10 +332,10 @@ public class TCKZoneOffsetTransitionRule extends AbstractTCKTest { ZoneOffsetTransitionRule b = ZoneOffsetTransitionRule.of( Month.MARCH, 20, null, TIME_0100, false, TimeDefinition.WALL, OFFSET_0200, OFFSET_0200, OFFSET_0300); - assertEquals(a.equals(a), true); - assertEquals(a.equals(b), false); - assertEquals(b.equals(a), false); - assertEquals(b.equals(b), true); + assertEquals(true, a.equals(a)); + assertEquals(false, a.equals(b)); + assertEquals(false, b.equals(a)); + assertEquals(true, b.equals(b)); } @Test @@ -345,10 +346,10 @@ public class TCKZoneOffsetTransitionRule extends AbstractTCKTest { ZoneOffsetTransitionRule b = ZoneOffsetTransitionRule.of( Month.MARCH, 20, DayOfWeek.SUNDAY, LocalTime.MIDNIGHT, false, TimeDefinition.WALL, OFFSET_0200, OFFSET_0200, OFFSET_0300); - assertEquals(a.equals(a), true); - assertEquals(a.equals(b), false); - assertEquals(b.equals(a), false); - assertEquals(b.equals(b), true); + assertEquals(true, a.equals(a)); + assertEquals(false, a.equals(b)); + assertEquals(false, b.equals(a)); + assertEquals(true, b.equals(b)); } @Test @@ -359,10 +360,10 @@ public class TCKZoneOffsetTransitionRule extends AbstractTCKTest { ZoneOffsetTransitionRule b = ZoneOffsetTransitionRule.of( Month.MARCH, 20, DayOfWeek.SUNDAY, LocalTime.MIDNIGHT, true, TimeDefinition.WALL, OFFSET_0200, OFFSET_0200, OFFSET_0300); - assertEquals(a.equals(a), true); - assertEquals(a.equals(b), false); - assertEquals(b.equals(a), false); - assertEquals(b.equals(b), true); + assertEquals(true, a.equals(a)); + assertEquals(false, a.equals(b)); + assertEquals(false, b.equals(a)); + assertEquals(true, b.equals(b)); } @Test @@ -373,10 +374,10 @@ public class TCKZoneOffsetTransitionRule extends AbstractTCKTest { ZoneOffsetTransitionRule b = ZoneOffsetTransitionRule.of( Month.MARCH, 20, DayOfWeek.SUNDAY, TIME_0100, false, TimeDefinition.STANDARD, OFFSET_0200, OFFSET_0200, OFFSET_0300); - assertEquals(a.equals(a), true); - assertEquals(a.equals(b), false); - assertEquals(b.equals(a), false); - assertEquals(b.equals(b), true); + assertEquals(true, a.equals(a)); + assertEquals(false, a.equals(b)); + assertEquals(false, b.equals(a)); + assertEquals(true, b.equals(b)); } @Test @@ -387,10 +388,10 @@ public class TCKZoneOffsetTransitionRule extends AbstractTCKTest { ZoneOffsetTransitionRule b = ZoneOffsetTransitionRule.of( Month.MARCH, 20, DayOfWeek.SUNDAY, TIME_0100, false, TimeDefinition.WALL, OFFSET_0300, OFFSET_0200, OFFSET_0300); - assertEquals(a.equals(a), true); - assertEquals(a.equals(b), false); - assertEquals(b.equals(a), false); - assertEquals(b.equals(b), true); + assertEquals(true, a.equals(a)); + assertEquals(false, a.equals(b)); + assertEquals(false, b.equals(a)); + assertEquals(true, b.equals(b)); } @Test @@ -401,10 +402,10 @@ public class TCKZoneOffsetTransitionRule extends AbstractTCKTest { ZoneOffsetTransitionRule b = ZoneOffsetTransitionRule.of( Month.MARCH, 20, DayOfWeek.SUNDAY, TIME_0100, false, TimeDefinition.WALL, OFFSET_0200, OFFSET_0300, OFFSET_0300); - assertEquals(a.equals(a), true); - assertEquals(a.equals(b), false); - assertEquals(b.equals(a), false); - assertEquals(b.equals(b), true); + assertEquals(true, a.equals(a)); + assertEquals(false, a.equals(b)); + assertEquals(false, b.equals(a)); + assertEquals(true, b.equals(b)); } @Test @@ -415,10 +416,10 @@ public class TCKZoneOffsetTransitionRule extends AbstractTCKTest { ZoneOffsetTransitionRule b = ZoneOffsetTransitionRule.of( Month.MARCH, 20, DayOfWeek.SUNDAY, TIME_0100, false, TimeDefinition.WALL, OFFSET_0200, OFFSET_0200, OFFSET_0200); - assertEquals(a.equals(a), true); - assertEquals(a.equals(b), false); - assertEquals(b.equals(a), false); - assertEquals(b.equals(b), true); + assertEquals(true, a.equals(a)); + assertEquals(false, a.equals(b)); + assertEquals(false, b.equals(a)); + assertEquals(true, b.equals(b)); } @Test @@ -426,7 +427,7 @@ public class TCKZoneOffsetTransitionRule extends AbstractTCKTest { ZoneOffsetTransitionRule a = ZoneOffsetTransitionRule.of( Month.MARCH, 20, DayOfWeek.SUNDAY, TIME_0100, false, TimeDefinition.WALL, OFFSET_0200, OFFSET_0200, OFFSET_0300); - assertEquals(a.equals("TZDB"), false); + assertEquals(false, a.equals("TZDB")); } @Test @@ -434,7 +435,7 @@ public class TCKZoneOffsetTransitionRule extends AbstractTCKTest { ZoneOffsetTransitionRule a = ZoneOffsetTransitionRule.of( Month.MARCH, 20, DayOfWeek.SUNDAY, TIME_0100, false, TimeDefinition.WALL, OFFSET_0200, OFFSET_0200, OFFSET_0300); - assertEquals(a.equals(null), false); + assertEquals(false, a.equals(null)); } //----------------------------------------------------------------------- @@ -448,7 +449,7 @@ public class TCKZoneOffsetTransitionRule extends AbstractTCKTest { ZoneOffsetTransitionRule b = ZoneOffsetTransitionRule.of( Month.MARCH, 20, DayOfWeek.SUNDAY, TIME_0100, false, TimeDefinition.WALL, OFFSET_0200, OFFSET_0200, OFFSET_0300); - assertEquals(a.hashCode(), b.hashCode()); + assertEquals(b.hashCode(), a.hashCode()); } @Test @@ -459,7 +460,7 @@ public class TCKZoneOffsetTransitionRule extends AbstractTCKTest { ZoneOffsetTransitionRule b = ZoneOffsetTransitionRule.of( Month.OCTOBER, 20, null, LocalTime.MIDNIGHT, true, TimeDefinition.WALL, OFFSET_0200, OFFSET_0300, OFFSET_0200); - assertEquals(a.hashCode(), b.hashCode()); + assertEquals(b.hashCode(), a.hashCode()); } @Test @@ -470,7 +471,7 @@ public class TCKZoneOffsetTransitionRule extends AbstractTCKTest { ZoneOffsetTransitionRule b = ZoneOffsetTransitionRule.of( Month.MARCH, -1, DayOfWeek.SUNDAY, TIME_0100, false, TimeDefinition.WALL, OFFSET_0200, OFFSET_0200, OFFSET_0300); - assertEquals(a.hashCode(), b.hashCode()); + assertEquals(b.hashCode(), a.hashCode()); } @Test @@ -481,7 +482,7 @@ public class TCKZoneOffsetTransitionRule extends AbstractTCKTest { ZoneOffsetTransitionRule b = ZoneOffsetTransitionRule.of( Month.MARCH, 20, null, TIME_0100, false, TimeDefinition.STANDARD, OFFSET_0200, OFFSET_0200, OFFSET_0300); - assertEquals(a.hashCode(), b.hashCode()); + assertEquals(b.hashCode(), a.hashCode()); } //----------------------------------------------------------------------- @@ -492,7 +493,7 @@ public class TCKZoneOffsetTransitionRule extends AbstractTCKTest { ZoneOffsetTransitionRule test = ZoneOffsetTransitionRule.of( Month.MARCH, 20, DayOfWeek.SUNDAY, TIME_0100, false, TimeDefinition.WALL, OFFSET_0200, OFFSET_0200, OFFSET_0300); - assertEquals(test.toString(), "TransitionRule[Gap +02:00 to +03:00, SUNDAY on or after MARCH 20 at 01:00 WALL, standard offset +02:00]"); + assertEquals("TransitionRule[Gap +02:00 to +03:00, SUNDAY on or after MARCH 20 at 01:00 WALL, standard offset +02:00]", test.toString()); } @Test @@ -500,7 +501,7 @@ public class TCKZoneOffsetTransitionRule extends AbstractTCKTest { ZoneOffsetTransitionRule test = ZoneOffsetTransitionRule.of( Month.OCTOBER, 20, DayOfWeek.SUNDAY, LocalTime.MIDNIGHT, true, TimeDefinition.WALL, OFFSET_0200, OFFSET_0300, OFFSET_0200); - assertEquals(test.toString(), "TransitionRule[Overlap +03:00 to +02:00, SUNDAY on or after OCTOBER 20 at 24:00 WALL, standard offset +02:00]"); + assertEquals("TransitionRule[Overlap +03:00 to +02:00, SUNDAY on or after OCTOBER 20 at 24:00 WALL, standard offset +02:00]", test.toString()); } @Test @@ -508,7 +509,7 @@ public class TCKZoneOffsetTransitionRule extends AbstractTCKTest { ZoneOffsetTransitionRule test = ZoneOffsetTransitionRule.of( Month.MARCH, -1, DayOfWeek.SUNDAY, TIME_0100, false, TimeDefinition.WALL, OFFSET_0200, OFFSET_0200, OFFSET_0300); - assertEquals(test.toString(), "TransitionRule[Gap +02:00 to +03:00, SUNDAY on or before last day of MARCH at 01:00 WALL, standard offset +02:00]"); + assertEquals("TransitionRule[Gap +02:00 to +03:00, SUNDAY on or before last day of MARCH at 01:00 WALL, standard offset +02:00]", test.toString()); } @Test @@ -516,7 +517,7 @@ public class TCKZoneOffsetTransitionRule extends AbstractTCKTest { ZoneOffsetTransitionRule test = ZoneOffsetTransitionRule.of( Month.MARCH, -2, DayOfWeek.SUNDAY, TIME_0100, false, TimeDefinition.WALL, OFFSET_0200, OFFSET_0200, OFFSET_0300); - assertEquals(test.toString(), "TransitionRule[Gap +02:00 to +03:00, SUNDAY on or before last day minus 1 of MARCH at 01:00 WALL, standard offset +02:00]"); + assertEquals("TransitionRule[Gap +02:00 to +03:00, SUNDAY on or before last day minus 1 of MARCH at 01:00 WALL, standard offset +02:00]", test.toString()); } @Test @@ -524,7 +525,7 @@ public class TCKZoneOffsetTransitionRule extends AbstractTCKTest { ZoneOffsetTransitionRule test = ZoneOffsetTransitionRule.of( Month.MARCH, 20, null, TIME_0100, false, TimeDefinition.STANDARD, OFFSET_0200, OFFSET_0200, OFFSET_0300); - assertEquals(test.toString(), "TransitionRule[Gap +02:00 to +03:00, MARCH 20 at 01:00 STANDARD, standard offset +02:00]"); + assertEquals("TransitionRule[Gap +02:00 to +03:00, MARCH 20 at 01:00 STANDARD, standard offset +02:00]", test.toString()); } } diff --git a/test/jdk/java/time/tck/java/time/zone/TCKZoneRules.java b/test/jdk/java/time/tck/java/time/zone/TCKZoneRules.java index d44216b69b5..265555a1792 100644 --- a/test/jdk/java/time/tck/java/time/zone/TCKZoneRules.java +++ b/test/jdk/java/time/tck/java/time/zone/TCKZoneRules.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2012, 2018, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2012, 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 @@ -59,10 +59,10 @@ */ package tck.java.time.zone; -import static org.testng.Assert.assertEquals; -import static org.testng.Assert.assertFalse; -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.assertFalse; +import static org.junit.jupiter.api.Assertions.assertNotNull; +import static org.junit.jupiter.api.Assertions.assertTrue; import java.io.ByteArrayInputStream; import java.io.ByteArrayOutputStream; @@ -88,12 +88,12 @@ import java.util.ArrayList; import java.util.Iterator; import java.util.List; -import org.testng.annotations.Test; +import org.junit.jupiter.api.Assertions; +import org.junit.jupiter.api.Test; /** * Test ZoneRules. */ -@Test public class TCKZoneRules { private static final ZoneOffset OFFSET_ZERO = ZoneOffset.ofHours(0); @@ -115,7 +115,7 @@ public class TCKZoneRules { @Test public void test_London() { ZoneRules test = europeLondon(); - assertEquals(test.isFixedOffset(), false); + assertEquals(false, test.isFixedOffset()); } @Test @@ -124,60 +124,60 @@ public class TCKZoneRules { ZonedDateTime old = createZDT(1800, 1, 1, ZoneOffset.UTC); Instant instant = old.toInstant(); ZoneOffset offset = ZoneOffset.ofHoursMinutesSeconds(0, -1, -15); - assertEquals(test.getOffset(instant), offset); + assertEquals(offset, test.getOffset(instant)); checkOffset(test, old.toLocalDateTime(), offset, 1); - assertEquals(test.getStandardOffset(instant), offset); - assertEquals(test.getDaylightSavings(instant), Duration.ZERO); - assertEquals(test.isDaylightSavings(instant), false); + assertEquals(offset, test.getStandardOffset(instant)); + assertEquals(Duration.ZERO, test.getDaylightSavings(instant)); + assertEquals(false, test.isDaylightSavings(instant)); } @Test public void test_London_getOffset() { ZoneRules test = europeLondon(); - assertEquals(test.getOffset(createInstant(2008, 1, 1, ZoneOffset.UTC)), OFFSET_ZERO); - assertEquals(test.getOffset(createInstant(2008, 2, 1, ZoneOffset.UTC)), OFFSET_ZERO); - assertEquals(test.getOffset(createInstant(2008, 3, 1, ZoneOffset.UTC)), OFFSET_ZERO); - assertEquals(test.getOffset(createInstant(2008, 4, 1, ZoneOffset.UTC)), OFFSET_PONE); - assertEquals(test.getOffset(createInstant(2008, 5, 1, ZoneOffset.UTC)), OFFSET_PONE); - assertEquals(test.getOffset(createInstant(2008, 6, 1, ZoneOffset.UTC)), OFFSET_PONE); - assertEquals(test.getOffset(createInstant(2008, 7, 1, ZoneOffset.UTC)), OFFSET_PONE); - assertEquals(test.getOffset(createInstant(2008, 8, 1, ZoneOffset.UTC)), OFFSET_PONE); - assertEquals(test.getOffset(createInstant(2008, 9, 1, ZoneOffset.UTC)), OFFSET_PONE); - assertEquals(test.getOffset(createInstant(2008, 10, 1, ZoneOffset.UTC)), OFFSET_PONE); - assertEquals(test.getOffset(createInstant(2008, 11, 1, ZoneOffset.UTC)), OFFSET_ZERO); - assertEquals(test.getOffset(createInstant(2008, 12, 1, ZoneOffset.UTC)), OFFSET_ZERO); + assertEquals(OFFSET_ZERO, test.getOffset(createInstant(2008, 1, 1, ZoneOffset.UTC))); + assertEquals(OFFSET_ZERO, test.getOffset(createInstant(2008, 2, 1, ZoneOffset.UTC))); + assertEquals(OFFSET_ZERO, test.getOffset(createInstant(2008, 3, 1, ZoneOffset.UTC))); + assertEquals(OFFSET_PONE, test.getOffset(createInstant(2008, 4, 1, ZoneOffset.UTC))); + assertEquals(OFFSET_PONE, test.getOffset(createInstant(2008, 5, 1, ZoneOffset.UTC))); + assertEquals(OFFSET_PONE, test.getOffset(createInstant(2008, 6, 1, ZoneOffset.UTC))); + assertEquals(OFFSET_PONE, test.getOffset(createInstant(2008, 7, 1, ZoneOffset.UTC))); + assertEquals(OFFSET_PONE, test.getOffset(createInstant(2008, 8, 1, ZoneOffset.UTC))); + assertEquals(OFFSET_PONE, test.getOffset(createInstant(2008, 9, 1, ZoneOffset.UTC))); + assertEquals(OFFSET_PONE, test.getOffset(createInstant(2008, 10, 1, ZoneOffset.UTC))); + assertEquals(OFFSET_ZERO, test.getOffset(createInstant(2008, 11, 1, ZoneOffset.UTC))); + assertEquals(OFFSET_ZERO, test.getOffset(createInstant(2008, 12, 1, ZoneOffset.UTC))); } @Test public void test_London_getOffset_toDST() { ZoneRules test = europeLondon(); - assertEquals(test.getOffset(createInstant(2008, 3, 24, ZoneOffset.UTC)), OFFSET_ZERO); - assertEquals(test.getOffset(createInstant(2008, 3, 25, ZoneOffset.UTC)), OFFSET_ZERO); - assertEquals(test.getOffset(createInstant(2008, 3, 26, ZoneOffset.UTC)), OFFSET_ZERO); - assertEquals(test.getOffset(createInstant(2008, 3, 27, ZoneOffset.UTC)), OFFSET_ZERO); - assertEquals(test.getOffset(createInstant(2008, 3, 28, ZoneOffset.UTC)), OFFSET_ZERO); - assertEquals(test.getOffset(createInstant(2008, 3, 29, ZoneOffset.UTC)), OFFSET_ZERO); - assertEquals(test.getOffset(createInstant(2008, 3, 30, ZoneOffset.UTC)), OFFSET_ZERO); - assertEquals(test.getOffset(createInstant(2008, 3, 31, ZoneOffset.UTC)), OFFSET_PONE); + assertEquals(OFFSET_ZERO, test.getOffset(createInstant(2008, 3, 24, ZoneOffset.UTC))); + assertEquals(OFFSET_ZERO, test.getOffset(createInstant(2008, 3, 25, ZoneOffset.UTC))); + assertEquals(OFFSET_ZERO, test.getOffset(createInstant(2008, 3, 26, ZoneOffset.UTC))); + assertEquals(OFFSET_ZERO, test.getOffset(createInstant(2008, 3, 27, ZoneOffset.UTC))); + assertEquals(OFFSET_ZERO, test.getOffset(createInstant(2008, 3, 28, ZoneOffset.UTC))); + assertEquals(OFFSET_ZERO, test.getOffset(createInstant(2008, 3, 29, ZoneOffset.UTC))); + assertEquals(OFFSET_ZERO, test.getOffset(createInstant(2008, 3, 30, ZoneOffset.UTC))); + assertEquals(OFFSET_PONE, test.getOffset(createInstant(2008, 3, 31, ZoneOffset.UTC))); // cutover at 01:00Z - assertEquals(test.getOffset(createInstant(2008, 3, 30, 0, 59, 59, 999999999, ZoneOffset.UTC)), OFFSET_ZERO); - assertEquals(test.getOffset(createInstant(2008, 3, 30, 1, 0, 0, 0, ZoneOffset.UTC)), OFFSET_PONE); + assertEquals(OFFSET_ZERO, test.getOffset(createInstant(2008, 3, 30, 0, 59, 59, 999999999, ZoneOffset.UTC))); + assertEquals(OFFSET_PONE, test.getOffset(createInstant(2008, 3, 30, 1, 0, 0, 0, ZoneOffset.UTC))); } @Test public void test_London_getOffset_fromDST() { ZoneRules test = europeLondon(); - assertEquals(test.getOffset(createInstant(2008, 10, 24, ZoneOffset.UTC)), OFFSET_PONE); - assertEquals(test.getOffset(createInstant(2008, 10, 25, ZoneOffset.UTC)), OFFSET_PONE); - assertEquals(test.getOffset(createInstant(2008, 10, 26, ZoneOffset.UTC)), OFFSET_PONE); - assertEquals(test.getOffset(createInstant(2008, 10, 27, ZoneOffset.UTC)), OFFSET_ZERO); - assertEquals(test.getOffset(createInstant(2008, 10, 28, ZoneOffset.UTC)), OFFSET_ZERO); - assertEquals(test.getOffset(createInstant(2008, 10, 29, ZoneOffset.UTC)), OFFSET_ZERO); - assertEquals(test.getOffset(createInstant(2008, 10, 30, ZoneOffset.UTC)), OFFSET_ZERO); - assertEquals(test.getOffset(createInstant(2008, 10, 31, ZoneOffset.UTC)), OFFSET_ZERO); + assertEquals(OFFSET_PONE, test.getOffset(createInstant(2008, 10, 24, ZoneOffset.UTC))); + assertEquals(OFFSET_PONE, test.getOffset(createInstant(2008, 10, 25, ZoneOffset.UTC))); + assertEquals(OFFSET_PONE, test.getOffset(createInstant(2008, 10, 26, ZoneOffset.UTC))); + assertEquals(OFFSET_ZERO, test.getOffset(createInstant(2008, 10, 27, ZoneOffset.UTC))); + assertEquals(OFFSET_ZERO, test.getOffset(createInstant(2008, 10, 28, ZoneOffset.UTC))); + assertEquals(OFFSET_ZERO, test.getOffset(createInstant(2008, 10, 29, ZoneOffset.UTC))); + assertEquals(OFFSET_ZERO, test.getOffset(createInstant(2008, 10, 30, ZoneOffset.UTC))); + assertEquals(OFFSET_ZERO, test.getOffset(createInstant(2008, 10, 31, ZoneOffset.UTC))); // cutover at 01:00Z - assertEquals(test.getOffset(createInstant(2008, 10, 26, 0, 59, 59, 999999999, ZoneOffset.UTC)), OFFSET_PONE); - assertEquals(test.getOffset(createInstant(2008, 10, 26, 1, 0, 0, 0, ZoneOffset.UTC)), OFFSET_ZERO); + assertEquals(OFFSET_PONE, test.getOffset(createInstant(2008, 10, 26, 0, 59, 59, 999999999, ZoneOffset.UTC))); + assertEquals(OFFSET_ZERO, test.getOffset(createInstant(2008, 10, 26, 1, 0, 0, 0, ZoneOffset.UTC))); } @Test @@ -234,17 +234,17 @@ public class TCKZoneRules { ZoneRules test = europeLondon(); final LocalDateTime dateTime = LocalDateTime.of(2008, 3, 30, 1, 0, 0, 0); ZoneOffsetTransition trans = checkOffset(test, dateTime, OFFSET_ZERO, GAP); - assertEquals(trans.isGap(), true); - assertEquals(trans.isOverlap(), false); - assertEquals(trans.getOffsetBefore(), OFFSET_ZERO); - assertEquals(trans.getOffsetAfter(), OFFSET_PONE); - assertEquals(trans.getInstant(), createInstant(2008, 3, 30, 1, 0, ZoneOffset.UTC)); - assertEquals(trans.getDateTimeBefore(), LocalDateTime.of(2008, 3, 30, 1, 0)); - assertEquals(trans.getDateTimeAfter(), LocalDateTime.of(2008, 3, 30, 2, 0)); - assertEquals(trans.isValidOffset(OFFSET_ZERO), false); - assertEquals(trans.isValidOffset(OFFSET_PONE), false); - assertEquals(trans.isValidOffset(OFFSET_PTWO), false); - assertEquals(trans.toString(), "Transition[Gap at 2008-03-30T01:00Z to +01:00]"); + assertEquals(true, trans.isGap()); + assertEquals(false, trans.isOverlap()); + assertEquals(OFFSET_ZERO, trans.getOffsetBefore()); + assertEquals(OFFSET_PONE, trans.getOffsetAfter()); + assertEquals(createInstant(2008, 3, 30, 1, 0, ZoneOffset.UTC), trans.getInstant()); + assertEquals(LocalDateTime.of(2008, 3, 30, 1, 0), trans.getDateTimeBefore()); + assertEquals(LocalDateTime.of(2008, 3, 30, 2, 0), trans.getDateTimeAfter()); + assertEquals(false, trans.isValidOffset(OFFSET_ZERO)); + assertEquals(false, trans.isValidOffset(OFFSET_PONE)); + assertEquals(false, trans.isValidOffset(OFFSET_PTWO)); + assertEquals("Transition[Gap at 2008-03-30T01:00Z to +01:00]", trans.toString()); assertFalse(trans.equals(null)); assertFalse(trans.equals(OFFSET_ZERO)); @@ -252,7 +252,7 @@ public class TCKZoneRules { final ZoneOffsetTransition otherTrans = test.getTransition(dateTime); assertTrue(trans.equals(otherTrans)); - assertEquals(trans.hashCode(), otherTrans.hashCode()); + assertEquals(otherTrans.hashCode(), trans.hashCode()); } @Test @@ -260,18 +260,18 @@ public class TCKZoneRules { ZoneRules test = europeLondon(); final LocalDateTime dateTime = LocalDateTime.of(2008, 10, 26, 1, 0, 0, 0); ZoneOffsetTransition trans = checkOffset(test, dateTime, OFFSET_PONE, OVERLAP); - assertEquals(trans.isGap(), false); - assertEquals(trans.isOverlap(), true); - assertEquals(trans.getOffsetBefore(), OFFSET_PONE); - assertEquals(trans.getOffsetAfter(), OFFSET_ZERO); - assertEquals(trans.getInstant(), createInstant(2008, 10, 26, 1, 0, ZoneOffset.UTC)); - assertEquals(trans.getDateTimeBefore(), LocalDateTime.of(2008, 10, 26, 2, 0)); - assertEquals(trans.getDateTimeAfter(), LocalDateTime.of(2008, 10, 26, 1, 0)); - assertEquals(trans.isValidOffset(ZoneOffset.ofHours(-1)), false); - assertEquals(trans.isValidOffset(OFFSET_ZERO), true); - assertEquals(trans.isValidOffset(OFFSET_PONE), true); - assertEquals(trans.isValidOffset(OFFSET_PTWO), false); - assertEquals(trans.toString(), "Transition[Overlap at 2008-10-26T02:00+01:00 to Z]"); + assertEquals(false, trans.isGap()); + assertEquals(true, trans.isOverlap()); + assertEquals(OFFSET_PONE, trans.getOffsetBefore()); + assertEquals(OFFSET_ZERO, trans.getOffsetAfter()); + assertEquals(createInstant(2008, 10, 26, 1, 0, ZoneOffset.UTC), trans.getInstant()); + assertEquals(LocalDateTime.of(2008, 10, 26, 2, 0), trans.getDateTimeBefore()); + assertEquals(LocalDateTime.of(2008, 10, 26, 1, 0), trans.getDateTimeAfter()); + assertEquals(false, trans.isValidOffset(ZoneOffset.ofHours(-1))); + assertEquals(true, trans.isValidOffset(OFFSET_ZERO)); + assertEquals(true, trans.isValidOffset(OFFSET_PONE)); + assertEquals(false, trans.isValidOffset(OFFSET_PTWO)); + assertEquals("Transition[Overlap at 2008-10-26T02:00+01:00 to Z]", trans.toString()); assertFalse(trans.equals(null)); assertFalse(trans.equals(OFFSET_PONE)); @@ -279,7 +279,7 @@ public class TCKZoneRules { final ZoneOffsetTransition otherTrans = test.getTransition(dateTime); assertTrue(trans.equals(otherTrans)); - assertEquals(trans.hashCode(), otherTrans.hashCode()); + assertEquals(otherTrans.hashCode(), trans.hashCode()); } @Test @@ -289,11 +289,11 @@ public class TCKZoneRules { while (zdt.getYear() < 2010) { Instant instant = zdt.toInstant(); if (zdt.getYear() < 1848) { - assertEquals(test.getStandardOffset(instant), ZoneOffset.ofHoursMinutesSeconds(0, -1, -15)); + assertEquals(ZoneOffset.ofHoursMinutesSeconds(0, -1, -15), test.getStandardOffset(instant)); } else if (zdt.getYear() >= 1969 && zdt.getYear() < 1972) { - assertEquals(test.getStandardOffset(instant), OFFSET_PONE); + assertEquals(OFFSET_PONE, test.getStandardOffset(instant)); } else { - assertEquals(test.getStandardOffset(instant), OFFSET_ZERO); + assertEquals(OFFSET_ZERO, test.getStandardOffset(instant)); } zdt = zdt.plusMonths(6); } @@ -305,19 +305,19 @@ public class TCKZoneRules { List trans = test.getTransitions(); ZoneOffsetTransition first = trans.get(0); - assertEquals(first.getDateTimeBefore(), LocalDateTime.of(1847, 12, 1, 0, 0)); - assertEquals(first.getOffsetBefore(), ZoneOffset.ofHoursMinutesSeconds(0, -1, -15)); - assertEquals(first.getOffsetAfter(), OFFSET_ZERO); + assertEquals(LocalDateTime.of(1847, 12, 1, 0, 0), first.getDateTimeBefore()); + assertEquals(ZoneOffset.ofHoursMinutesSeconds(0, -1, -15), first.getOffsetBefore()); + assertEquals(OFFSET_ZERO, first.getOffsetAfter()); ZoneOffsetTransition spring1916 = trans.get(1); - assertEquals(spring1916.getDateTimeBefore(), LocalDateTime.of(1916, 5, 21, 2, 0)); - assertEquals(spring1916.getOffsetBefore(), OFFSET_ZERO); - assertEquals(spring1916.getOffsetAfter(), OFFSET_PONE); + assertEquals(LocalDateTime.of(1916, 5, 21, 2, 0), spring1916.getDateTimeBefore()); + assertEquals(OFFSET_ZERO, spring1916.getOffsetBefore()); + assertEquals(OFFSET_PONE, spring1916.getOffsetAfter()); ZoneOffsetTransition autumn1916 = trans.get(2); - assertEquals(autumn1916.getDateTimeBefore(), LocalDateTime.of(1916, 10, 1, 3, 0)); - assertEquals(autumn1916.getOffsetBefore(), OFFSET_PONE); - assertEquals(autumn1916.getOffsetAfter(), OFFSET_ZERO); + assertEquals(LocalDateTime.of(1916, 10, 1, 3, 0), autumn1916.getDateTimeBefore()); + assertEquals(OFFSET_PONE, autumn1916.getOffsetBefore()); + assertEquals(OFFSET_ZERO, autumn1916.getOffsetAfter()); ZoneOffsetTransition zot = null; Iterator it = trans.iterator(); @@ -327,81 +327,81 @@ public class TCKZoneRules { break; } } - assertEquals(zot.getDateTimeBefore(), LocalDateTime.of(1990, 3, 25, 1, 0)); - assertEquals(zot.getOffsetBefore(), OFFSET_ZERO); + assertEquals(LocalDateTime.of(1990, 3, 25, 1, 0), zot.getDateTimeBefore()); + assertEquals(OFFSET_ZERO, zot.getOffsetBefore()); zot = it.next(); - assertEquals(zot.getDateTimeBefore(), LocalDateTime.of(1990, 10, 28, 2, 0)); - assertEquals(zot.getOffsetBefore(), OFFSET_PONE); + assertEquals(LocalDateTime.of(1990, 10, 28, 2, 0), zot.getDateTimeBefore()); + assertEquals(OFFSET_PONE, zot.getOffsetBefore()); zot = it.next(); - assertEquals(zot.getDateTimeBefore(), LocalDateTime.of(1991, 3, 31, 1, 0)); - assertEquals(zot.getOffsetBefore(), OFFSET_ZERO); + assertEquals(LocalDateTime.of(1991, 3, 31, 1, 0), zot.getDateTimeBefore()); + assertEquals(OFFSET_ZERO, zot.getOffsetBefore()); zot = it.next(); - assertEquals(zot.getDateTimeBefore(), LocalDateTime.of(1991, 10, 27, 2, 0)); - assertEquals(zot.getOffsetBefore(), OFFSET_PONE); + assertEquals(LocalDateTime.of(1991, 10, 27, 2, 0), zot.getDateTimeBefore()); + assertEquals(OFFSET_PONE, zot.getOffsetBefore()); zot = it.next(); - assertEquals(zot.getDateTimeBefore(), LocalDateTime.of(1992, 3, 29, 1, 0)); - assertEquals(zot.getOffsetBefore(), OFFSET_ZERO); + assertEquals(LocalDateTime.of(1992, 3, 29, 1, 0), zot.getDateTimeBefore()); + assertEquals(OFFSET_ZERO, zot.getOffsetBefore()); zot = it.next(); - assertEquals(zot.getDateTimeBefore(), LocalDateTime.of(1992, 10, 25, 2, 0)); - assertEquals(zot.getOffsetBefore(), OFFSET_PONE); + assertEquals(LocalDateTime.of(1992, 10, 25, 2, 0), zot.getDateTimeBefore()); + assertEquals(OFFSET_PONE, zot.getOffsetBefore()); zot = it.next(); - assertEquals(zot.getDateTimeBefore(), LocalDateTime.of(1993, 3, 28, 1, 0)); - assertEquals(zot.getOffsetBefore(), OFFSET_ZERO); + assertEquals(LocalDateTime.of(1993, 3, 28, 1, 0), zot.getDateTimeBefore()); + assertEquals(OFFSET_ZERO, zot.getOffsetBefore()); zot = it.next(); - assertEquals(zot.getDateTimeBefore(), LocalDateTime.of(1993, 10, 24, 2, 0)); - assertEquals(zot.getOffsetBefore(), OFFSET_PONE); + assertEquals(LocalDateTime.of(1993, 10, 24, 2, 0), zot.getDateTimeBefore()); + assertEquals(OFFSET_PONE, zot.getOffsetBefore()); zot = it.next(); - assertEquals(zot.getDateTimeBefore(), LocalDateTime.of(1994, 3, 27, 1, 0)); - assertEquals(zot.getOffsetBefore(), OFFSET_ZERO); + assertEquals(LocalDateTime.of(1994, 3, 27, 1, 0), zot.getDateTimeBefore()); + assertEquals(OFFSET_ZERO, zot.getOffsetBefore()); zot = it.next(); - assertEquals(zot.getDateTimeBefore(), LocalDateTime.of(1994, 10, 23, 2, 0)); - assertEquals(zot.getOffsetBefore(), OFFSET_PONE); + assertEquals(LocalDateTime.of(1994, 10, 23, 2, 0), zot.getDateTimeBefore()); + assertEquals(OFFSET_PONE, zot.getOffsetBefore()); zot = it.next(); - assertEquals(zot.getDateTimeBefore(), LocalDateTime.of(1995, 3, 26, 1, 0)); - assertEquals(zot.getOffsetBefore(), OFFSET_ZERO); + assertEquals(LocalDateTime.of(1995, 3, 26, 1, 0), zot.getDateTimeBefore()); + assertEquals(OFFSET_ZERO, zot.getOffsetBefore()); zot = it.next(); - assertEquals(zot.getDateTimeBefore(), LocalDateTime.of(1995, 10, 22, 2, 0)); - assertEquals(zot.getOffsetBefore(), OFFSET_PONE); + assertEquals(LocalDateTime.of(1995, 10, 22, 2, 0), zot.getDateTimeBefore()); + assertEquals(OFFSET_PONE, zot.getOffsetBefore()); zot = it.next(); - assertEquals(zot.getDateTimeBefore(), LocalDateTime.of(1996, 3, 31, 1, 0)); - assertEquals(zot.getOffsetBefore(), OFFSET_ZERO); + assertEquals(LocalDateTime.of(1996, 3, 31, 1, 0), zot.getDateTimeBefore()); + assertEquals(OFFSET_ZERO, zot.getOffsetBefore()); zot = it.next(); - assertEquals(zot.getDateTimeBefore(), LocalDateTime.of(1996, 10, 27, 2, 0)); - assertEquals(zot.getOffsetBefore(), OFFSET_PONE); + assertEquals(LocalDateTime.of(1996, 10, 27, 2, 0), zot.getDateTimeBefore()); + assertEquals(OFFSET_PONE, zot.getOffsetBefore()); zot = it.next(); - assertEquals(zot.getDateTimeBefore(), LocalDateTime.of(1997, 3, 30, 1, 0)); - assertEquals(zot.getOffsetBefore(), OFFSET_ZERO); + assertEquals(LocalDateTime.of(1997, 3, 30, 1, 0), zot.getDateTimeBefore()); + assertEquals(OFFSET_ZERO, zot.getOffsetBefore()); zot = it.next(); - assertEquals(zot.getDateTimeBefore(), LocalDateTime.of(1997, 10, 26, 2, 0)); - assertEquals(zot.getOffsetBefore(), OFFSET_PONE); - assertEquals(it.hasNext(), false); + assertEquals(LocalDateTime.of(1997, 10, 26, 2, 0), zot.getDateTimeBefore()); + assertEquals(OFFSET_PONE, zot.getOffsetBefore()); + assertEquals(false, it.hasNext()); } @Test public void test_London_getTransitionRules() { ZoneRules test = europeLondon(); List rules = test.getTransitionRules(); - assertEquals(rules.size(), 2); + assertEquals(2, rules.size()); ZoneOffsetTransitionRule in = rules.get(0); - assertEquals(in.getMonth(), Month.MARCH); - assertEquals(in.getDayOfMonthIndicator(), 25); // optimized from -1 - assertEquals(in.getDayOfWeek(), DayOfWeek.SUNDAY); - assertEquals(in.getLocalTime(), LocalTime.of(1, 0)); - assertEquals(in.getTimeDefinition(), TimeDefinition.UTC); - assertEquals(in.getStandardOffset(), OFFSET_ZERO); - assertEquals(in.getOffsetBefore(), OFFSET_ZERO); - assertEquals(in.getOffsetAfter(), OFFSET_PONE); + assertEquals(Month.MARCH, in.getMonth()); + assertEquals(25, in.getDayOfMonthIndicator()); // optimized from -1 + assertEquals(DayOfWeek.SUNDAY, in.getDayOfWeek()); + assertEquals(LocalTime.of(1, 0), in.getLocalTime()); + assertEquals(TimeDefinition.UTC, in.getTimeDefinition()); + assertEquals(OFFSET_ZERO, in.getStandardOffset()); + assertEquals(OFFSET_ZERO, in.getOffsetBefore()); + assertEquals(OFFSET_PONE, in.getOffsetAfter()); ZoneOffsetTransitionRule out = rules.get(1); - assertEquals(out.getMonth(), Month.OCTOBER); - assertEquals(out.getDayOfMonthIndicator(), 25); // optimized from -1 - assertEquals(out.getDayOfWeek(), DayOfWeek.SUNDAY); - assertEquals(out.getLocalTime(), LocalTime.of(1, 0)); - assertEquals(out.getTimeDefinition(), TimeDefinition.UTC); - assertEquals(out.getStandardOffset(), OFFSET_ZERO); - assertEquals(out.getOffsetBefore(), OFFSET_PONE); - assertEquals(out.getOffsetAfter(), OFFSET_ZERO); + assertEquals(Month.OCTOBER, out.getMonth()); + assertEquals(25, out.getDayOfMonthIndicator()); // optimized from -1 + assertEquals(DayOfWeek.SUNDAY, out.getDayOfWeek()); + assertEquals(LocalTime.of(1, 0), out.getLocalTime()); + assertEquals(TimeDefinition.UTC, out.getTimeDefinition()); + assertEquals(OFFSET_ZERO, out.getStandardOffset()); + assertEquals(OFFSET_PONE, out.getOffsetBefore()); + assertEquals(OFFSET_ZERO, out.getOffsetAfter()); } //----------------------------------------------------------------------- @@ -411,14 +411,14 @@ public class TCKZoneRules { List trans = test.getTransitions(); ZoneOffsetTransition first = trans.get(0); - assertEquals(test.nextTransition(first.getInstant().minusNanos(1)), first); + assertEquals(first, test.nextTransition(first.getInstant().minusNanos(1))); for (int i = 0; i < trans.size() - 1; i++) { ZoneOffsetTransition cur = trans.get(i); ZoneOffsetTransition next = trans.get(i + 1); - assertEquals(test.nextTransition(cur.getInstant()), next); - assertEquals(test.nextTransition(next.getInstant().minusNanos(1)), next); + assertEquals(next, test.nextTransition(cur.getInstant())); + assertEquals(next, test.nextTransition(next.getInstant().minusNanos(1))); } } @@ -429,18 +429,18 @@ public class TCKZoneRules { List trans = test.getTransitions(); ZoneOffsetTransition last = trans.get(trans.size() - 1); - assertEquals(test.nextTransition(last.getInstant()), rules.get(0).createTransition(1998)); + assertEquals(rules.get(0).createTransition(1998), test.nextTransition(last.getInstant())); for (int year = 1998; year < 2010; year++) { ZoneOffsetTransition a = rules.get(0).createTransition(year); ZoneOffsetTransition b = rules.get(1).createTransition(year); ZoneOffsetTransition c = rules.get(0).createTransition(year + 1); - assertEquals(test.nextTransition(a.getInstant()), b); - assertEquals(test.nextTransition(b.getInstant().minusNanos(1)), b); + assertEquals(b, test.nextTransition(a.getInstant())); + assertEquals(b, test.nextTransition(b.getInstant().minusNanos(1))); - assertEquals(test.nextTransition(b.getInstant()), c); - assertEquals(test.nextTransition(c.getInstant().minusNanos(1)), c); + assertEquals(c, test.nextTransition(b.getInstant())); + assertEquals(c, test.nextTransition(c.getInstant().minusNanos(1))); } } @@ -449,7 +449,7 @@ public class TCKZoneRules { ZoneRules test = europeLondon(); List rules = test.getTransitionRules(); ZoneOffsetTransition zot = rules.get(1).createTransition(Year.MAX_VALUE); - assertEquals(test.nextTransition(zot.getInstant()), null); + assertEquals(null, test.nextTransition(zot.getInstant())); } //----------------------------------------------------------------------- @@ -459,16 +459,16 @@ public class TCKZoneRules { List trans = test.getTransitions(); ZoneOffsetTransition first = trans.get(0); - assertEquals(test.previousTransition(first.getInstant()), null); - assertEquals(test.previousTransition(first.getInstant().minusNanos(1)), null); + assertEquals(null, test.previousTransition(first.getInstant())); + assertEquals(null, test.previousTransition(first.getInstant().minusNanos(1))); for (int i = 0; i < trans.size() - 1; i++) { ZoneOffsetTransition prev = trans.get(i); ZoneOffsetTransition cur = trans.get(i + 1); - assertEquals(test.previousTransition(cur.getInstant()), prev); - assertEquals(test.previousTransition(prev.getInstant().plusSeconds(1)), prev); - assertEquals(test.previousTransition(prev.getInstant().plusNanos(1)), prev); + assertEquals(prev, test.previousTransition(cur.getInstant())); + assertEquals(prev, test.previousTransition(prev.getInstant().plusSeconds(1))); + assertEquals(prev, test.previousTransition(prev.getInstant().plusNanos(1))); } } @@ -479,13 +479,13 @@ public class TCKZoneRules { List trans = test.getTransitions(); ZoneOffsetTransition last = trans.get(trans.size() - 1); - assertEquals(test.previousTransition(last.getInstant().plusSeconds(1)), last); - assertEquals(test.previousTransition(last.getInstant().plusNanos(1)), last); + assertEquals(last, test.previousTransition(last.getInstant().plusSeconds(1))); + assertEquals(last, test.previousTransition(last.getInstant().plusNanos(1))); // Jan 1st of year between transitions and rules ZonedDateTime odt = ZonedDateTime.ofInstant(last.getInstant(), last.getOffsetAfter()); odt = odt.withDayOfYear(1).plusYears(1).with(LocalTime.MIDNIGHT); - assertEquals(test.previousTransition(odt.toInstant()), last); + assertEquals(last, test.previousTransition(odt.toInstant())); // later years for (int year = 1998; year < 2010; year++) { @@ -493,13 +493,13 @@ public class TCKZoneRules { ZoneOffsetTransition b = rules.get(1).createTransition(year); ZoneOffsetTransition c = rules.get(0).createTransition(year + 1); - assertEquals(test.previousTransition(c.getInstant()), b); - assertEquals(test.previousTransition(b.getInstant().plusSeconds(1)), b); - assertEquals(test.previousTransition(b.getInstant().plusNanos(1)), b); + assertEquals(b, test.previousTransition(c.getInstant())); + assertEquals(b, test.previousTransition(b.getInstant().plusSeconds(1))); + assertEquals(b, test.previousTransition(b.getInstant().plusNanos(1))); - assertEquals(test.previousTransition(b.getInstant()), a); - assertEquals(test.previousTransition(a.getInstant().plusSeconds(1)), a); - assertEquals(test.previousTransition(a.getInstant().plusNanos(1)), a); + assertEquals(a, test.previousTransition(b.getInstant())); + assertEquals(a, test.previousTransition(a.getInstant().plusSeconds(1))); + assertEquals(a, test.previousTransition(a.getInstant().plusNanos(1))); } } @@ -513,7 +513,7 @@ public class TCKZoneRules { @Test public void test_Paris() { ZoneRules test = europeParis(); - assertEquals(test.isFixedOffset(), false); + assertEquals(false, test.isFixedOffset()); } @Test @@ -522,60 +522,60 @@ public class TCKZoneRules { ZonedDateTime old = createZDT(1800, 1, 1, ZoneOffset.UTC); Instant instant = old.toInstant(); ZoneOffset offset = ZoneOffset.ofHoursMinutesSeconds(0, 9, 21); - assertEquals(test.getOffset(instant), offset); + assertEquals(offset, test.getOffset(instant)); checkOffset(test, old.toLocalDateTime(), offset, 1); - assertEquals(test.getStandardOffset(instant), offset); - assertEquals(test.getDaylightSavings(instant), Duration.ZERO); - assertEquals(test.isDaylightSavings(instant), false); + assertEquals(offset, test.getStandardOffset(instant)); + assertEquals(Duration.ZERO, test.getDaylightSavings(instant)); + assertEquals(false, test.isDaylightSavings(instant)); } @Test public void test_Paris_getOffset() { ZoneRules test = europeParis(); - assertEquals(test.getOffset(createInstant(2008, 1, 1, ZoneOffset.UTC)), OFFSET_PONE); - assertEquals(test.getOffset(createInstant(2008, 2, 1, ZoneOffset.UTC)), OFFSET_PONE); - assertEquals(test.getOffset(createInstant(2008, 3, 1, ZoneOffset.UTC)), OFFSET_PONE); - assertEquals(test.getOffset(createInstant(2008, 4, 1, ZoneOffset.UTC)), OFFSET_PTWO); - assertEquals(test.getOffset(createInstant(2008, 5, 1, ZoneOffset.UTC)), OFFSET_PTWO); - assertEquals(test.getOffset(createInstant(2008, 6, 1, ZoneOffset.UTC)), OFFSET_PTWO); - assertEquals(test.getOffset(createInstant(2008, 7, 1, ZoneOffset.UTC)), OFFSET_PTWO); - assertEquals(test.getOffset(createInstant(2008, 8, 1, ZoneOffset.UTC)), OFFSET_PTWO); - assertEquals(test.getOffset(createInstant(2008, 9, 1, ZoneOffset.UTC)), OFFSET_PTWO); - assertEquals(test.getOffset(createInstant(2008, 10, 1, ZoneOffset.UTC)), OFFSET_PTWO); - assertEquals(test.getOffset(createInstant(2008, 11, 1, ZoneOffset.UTC)), OFFSET_PONE); - assertEquals(test.getOffset(createInstant(2008, 12, 1, ZoneOffset.UTC)), OFFSET_PONE); + assertEquals(OFFSET_PONE, test.getOffset(createInstant(2008, 1, 1, ZoneOffset.UTC))); + assertEquals(OFFSET_PONE, test.getOffset(createInstant(2008, 2, 1, ZoneOffset.UTC))); + assertEquals(OFFSET_PONE, test.getOffset(createInstant(2008, 3, 1, ZoneOffset.UTC))); + assertEquals(OFFSET_PTWO, test.getOffset(createInstant(2008, 4, 1, ZoneOffset.UTC))); + assertEquals(OFFSET_PTWO, test.getOffset(createInstant(2008, 5, 1, ZoneOffset.UTC))); + assertEquals(OFFSET_PTWO, test.getOffset(createInstant(2008, 6, 1, ZoneOffset.UTC))); + assertEquals(OFFSET_PTWO, test.getOffset(createInstant(2008, 7, 1, ZoneOffset.UTC))); + assertEquals(OFFSET_PTWO, test.getOffset(createInstant(2008, 8, 1, ZoneOffset.UTC))); + assertEquals(OFFSET_PTWO, test.getOffset(createInstant(2008, 9, 1, ZoneOffset.UTC))); + assertEquals(OFFSET_PTWO, test.getOffset(createInstant(2008, 10, 1, ZoneOffset.UTC))); + assertEquals(OFFSET_PONE, test.getOffset(createInstant(2008, 11, 1, ZoneOffset.UTC))); + assertEquals(OFFSET_PONE, test.getOffset(createInstant(2008, 12, 1, ZoneOffset.UTC))); } @Test public void test_Paris_getOffset_toDST() { ZoneRules test = europeParis(); - assertEquals(test.getOffset(createInstant(2008, 3, 24, ZoneOffset.UTC)), OFFSET_PONE); - assertEquals(test.getOffset(createInstant(2008, 3, 25, ZoneOffset.UTC)), OFFSET_PONE); - assertEquals(test.getOffset(createInstant(2008, 3, 26, ZoneOffset.UTC)), OFFSET_PONE); - assertEquals(test.getOffset(createInstant(2008, 3, 27, ZoneOffset.UTC)), OFFSET_PONE); - assertEquals(test.getOffset(createInstant(2008, 3, 28, ZoneOffset.UTC)), OFFSET_PONE); - assertEquals(test.getOffset(createInstant(2008, 3, 29, ZoneOffset.UTC)), OFFSET_PONE); - assertEquals(test.getOffset(createInstant(2008, 3, 30, ZoneOffset.UTC)), OFFSET_PONE); - assertEquals(test.getOffset(createInstant(2008, 3, 31, ZoneOffset.UTC)), OFFSET_PTWO); + assertEquals(OFFSET_PONE, test.getOffset(createInstant(2008, 3, 24, ZoneOffset.UTC))); + assertEquals(OFFSET_PONE, test.getOffset(createInstant(2008, 3, 25, ZoneOffset.UTC))); + assertEquals(OFFSET_PONE, test.getOffset(createInstant(2008, 3, 26, ZoneOffset.UTC))); + assertEquals(OFFSET_PONE, test.getOffset(createInstant(2008, 3, 27, ZoneOffset.UTC))); + assertEquals(OFFSET_PONE, test.getOffset(createInstant(2008, 3, 28, ZoneOffset.UTC))); + assertEquals(OFFSET_PONE, test.getOffset(createInstant(2008, 3, 29, ZoneOffset.UTC))); + assertEquals(OFFSET_PONE, test.getOffset(createInstant(2008, 3, 30, ZoneOffset.UTC))); + assertEquals(OFFSET_PTWO, test.getOffset(createInstant(2008, 3, 31, ZoneOffset.UTC))); // cutover at 01:00Z - assertEquals(test.getOffset(createInstant(2008, 3, 30, 0, 59, 59, 999999999, ZoneOffset.UTC)), OFFSET_PONE); - assertEquals(test.getOffset(createInstant(2008, 3, 30, 1, 0, 0, 0, ZoneOffset.UTC)), OFFSET_PTWO); + assertEquals(OFFSET_PONE, test.getOffset(createInstant(2008, 3, 30, 0, 59, 59, 999999999, ZoneOffset.UTC))); + assertEquals(OFFSET_PTWO, test.getOffset(createInstant(2008, 3, 30, 1, 0, 0, 0, ZoneOffset.UTC))); } @Test public void test_Paris_getOffset_fromDST() { ZoneRules test = europeParis(); - assertEquals(test.getOffset(createInstant(2008, 10, 24, ZoneOffset.UTC)), OFFSET_PTWO); - assertEquals(test.getOffset(createInstant(2008, 10, 25, ZoneOffset.UTC)), OFFSET_PTWO); - assertEquals(test.getOffset(createInstant(2008, 10, 26, ZoneOffset.UTC)), OFFSET_PTWO); - assertEquals(test.getOffset(createInstant(2008, 10, 27, ZoneOffset.UTC)), OFFSET_PONE); - assertEquals(test.getOffset(createInstant(2008, 10, 28, ZoneOffset.UTC)), OFFSET_PONE); - assertEquals(test.getOffset(createInstant(2008, 10, 29, ZoneOffset.UTC)), OFFSET_PONE); - assertEquals(test.getOffset(createInstant(2008, 10, 30, ZoneOffset.UTC)), OFFSET_PONE); - assertEquals(test.getOffset(createInstant(2008, 10, 31, ZoneOffset.UTC)), OFFSET_PONE); + assertEquals(OFFSET_PTWO, test.getOffset(createInstant(2008, 10, 24, ZoneOffset.UTC))); + assertEquals(OFFSET_PTWO, test.getOffset(createInstant(2008, 10, 25, ZoneOffset.UTC))); + assertEquals(OFFSET_PTWO, test.getOffset(createInstant(2008, 10, 26, ZoneOffset.UTC))); + assertEquals(OFFSET_PONE, test.getOffset(createInstant(2008, 10, 27, ZoneOffset.UTC))); + assertEquals(OFFSET_PONE, test.getOffset(createInstant(2008, 10, 28, ZoneOffset.UTC))); + assertEquals(OFFSET_PONE, test.getOffset(createInstant(2008, 10, 29, ZoneOffset.UTC))); + assertEquals(OFFSET_PONE, test.getOffset(createInstant(2008, 10, 30, ZoneOffset.UTC))); + assertEquals(OFFSET_PONE, test.getOffset(createInstant(2008, 10, 31, ZoneOffset.UTC))); // cutover at 01:00Z - assertEquals(test.getOffset(createInstant(2008, 10, 26, 0, 59, 59, 999999999, ZoneOffset.UTC)), OFFSET_PTWO); - assertEquals(test.getOffset(createInstant(2008, 10, 26, 1, 0, 0, 0, ZoneOffset.UTC)), OFFSET_PONE); + assertEquals(OFFSET_PTWO, test.getOffset(createInstant(2008, 10, 26, 0, 59, 59, 999999999, ZoneOffset.UTC))); + assertEquals(OFFSET_PONE, test.getOffset(createInstant(2008, 10, 26, 1, 0, 0, 0, ZoneOffset.UTC))); } @Test @@ -632,15 +632,15 @@ public class TCKZoneRules { ZoneRules test = europeParis(); final LocalDateTime dateTime = LocalDateTime.of(2008, 3, 30, 2, 0, 0, 0); ZoneOffsetTransition trans = checkOffset(test, dateTime, OFFSET_PONE, GAP); - assertEquals(trans.isGap(), true); - assertEquals(trans.isOverlap(), false); - assertEquals(trans.getOffsetBefore(), OFFSET_PONE); - assertEquals(trans.getOffsetAfter(), OFFSET_PTWO); - assertEquals(trans.getInstant(), createInstant(2008, 3, 30, 1, 0, ZoneOffset.UTC)); - assertEquals(trans.isValidOffset(OFFSET_ZERO), false); - assertEquals(trans.isValidOffset(OFFSET_PONE), false); - assertEquals(trans.isValidOffset(OFFSET_PTWO), false); - assertEquals(trans.toString(), "Transition[Gap at 2008-03-30T02:00+01:00 to +02:00]"); + assertEquals(true, trans.isGap()); + assertEquals(false, trans.isOverlap()); + assertEquals(OFFSET_PONE, trans.getOffsetBefore()); + assertEquals(OFFSET_PTWO, trans.getOffsetAfter()); + assertEquals(createInstant(2008, 3, 30, 1, 0, ZoneOffset.UTC), trans.getInstant()); + assertEquals(false, trans.isValidOffset(OFFSET_ZERO)); + assertEquals(false, trans.isValidOffset(OFFSET_PONE)); + assertEquals(false, trans.isValidOffset(OFFSET_PTWO)); + assertEquals("Transition[Gap at 2008-03-30T02:00+01:00 to +02:00]", trans.toString()); assertFalse(trans.equals(null)); assertFalse(trans.equals(OFFSET_PONE)); @@ -648,7 +648,7 @@ public class TCKZoneRules { final ZoneOffsetTransition otherTrans = test.getTransition(dateTime); assertTrue(trans.equals(otherTrans)); - assertEquals(trans.hashCode(), otherTrans.hashCode()); + assertEquals(otherTrans.hashCode(), trans.hashCode()); } @Test @@ -656,16 +656,16 @@ public class TCKZoneRules { ZoneRules test = europeParis(); final LocalDateTime dateTime = LocalDateTime.of(2008, 10, 26, 2, 0, 0, 0); ZoneOffsetTransition trans = checkOffset(test, dateTime, OFFSET_PTWO, OVERLAP); - assertEquals(trans.isGap(), false); - assertEquals(trans.isOverlap(), true); - assertEquals(trans.getOffsetBefore(), OFFSET_PTWO); - assertEquals(trans.getOffsetAfter(), OFFSET_PONE); - assertEquals(trans.getInstant(), createInstant(2008, 10, 26, 1, 0, ZoneOffset.UTC)); - assertEquals(trans.isValidOffset(OFFSET_ZERO), false); - assertEquals(trans.isValidOffset(OFFSET_PONE), true); - assertEquals(trans.isValidOffset(OFFSET_PTWO), true); - assertEquals(trans.isValidOffset(ZoneOffset.ofHours(3)), false); - assertEquals(trans.toString(), "Transition[Overlap at 2008-10-26T03:00+02:00 to +01:00]"); + assertEquals(false, trans.isGap()); + assertEquals(true, trans.isOverlap()); + assertEquals(OFFSET_PTWO, trans.getOffsetBefore()); + assertEquals(OFFSET_PONE, trans.getOffsetAfter()); + assertEquals(createInstant(2008, 10, 26, 1, 0, ZoneOffset.UTC), trans.getInstant()); + assertEquals(false, trans.isValidOffset(OFFSET_ZERO)); + assertEquals(true, trans.isValidOffset(OFFSET_PONE)); + assertEquals(true, trans.isValidOffset(OFFSET_PTWO)); + assertEquals(false, trans.isValidOffset(ZoneOffset.ofHours(3))); + assertEquals("Transition[Overlap at 2008-10-26T03:00+02:00 to +01:00]", trans.toString()); assertFalse(trans.equals(null)); assertFalse(trans.equals(OFFSET_PTWO)); @@ -673,7 +673,7 @@ public class TCKZoneRules { final ZoneOffsetTransition otherTrans = test.getTransition(dateTime); assertTrue(trans.equals(otherTrans)); - assertEquals(trans.hashCode(), otherTrans.hashCode()); + assertEquals(otherTrans.hashCode(), trans.hashCode()); } @Test @@ -683,15 +683,15 @@ public class TCKZoneRules { while (zdt.getYear() < 2010) { Instant instant = zdt.toInstant(); if (zdt.toLocalDate().isBefore(LocalDate.of(1911, 3, 11))) { - assertEquals(test.getStandardOffset(instant), ZoneOffset.ofHoursMinutesSeconds(0, 9, 21)); + assertEquals(ZoneOffset.ofHoursMinutesSeconds(0, 9, 21), test.getStandardOffset(instant)); } else if (zdt.toLocalDate().isBefore(LocalDate.of(1940, 6, 14))) { - assertEquals(test.getStandardOffset(instant), OFFSET_ZERO); + assertEquals(OFFSET_ZERO, test.getStandardOffset(instant)); } else if (zdt.toLocalDate().isBefore(LocalDate.of(1944, 8, 25))) { - assertEquals(test.getStandardOffset(instant), OFFSET_PONE); + assertEquals(OFFSET_PONE, test.getStandardOffset(instant)); } else if (zdt.toLocalDate().isBefore(LocalDate.of(1945, 9, 16))) { - assertEquals(test.getStandardOffset(instant), OFFSET_ZERO); + assertEquals(OFFSET_ZERO, test.getStandardOffset(instant)); } else { - assertEquals(test.getStandardOffset(instant), OFFSET_PONE); + assertEquals(OFFSET_PONE, test.getStandardOffset(instant)); } zdt = zdt.plusMonths(6); } @@ -707,7 +707,7 @@ public class TCKZoneRules { @Test public void test_NewYork() { ZoneRules test = americaNewYork(); - assertEquals(test.isFixedOffset(), false); + assertEquals(false, test.isFixedOffset()); } @Test @@ -716,73 +716,73 @@ public class TCKZoneRules { ZonedDateTime old = createZDT(1800, 1, 1, ZoneOffset.UTC); Instant instant = old.toInstant(); ZoneOffset offset = ZoneOffset.of("-04:56:02"); - assertEquals(test.getOffset(instant), offset); + assertEquals(offset, test.getOffset(instant)); checkOffset(test, old.toLocalDateTime(), offset, 1); - assertEquals(test.getStandardOffset(instant), offset); - assertEquals(test.getDaylightSavings(instant), Duration.ZERO); - assertEquals(test.isDaylightSavings(instant), false); + assertEquals(offset, test.getStandardOffset(instant)); + assertEquals(Duration.ZERO, test.getDaylightSavings(instant)); + assertEquals(false, test.isDaylightSavings(instant)); } @Test public void test_NewYork_getOffset() { ZoneRules test = americaNewYork(); ZoneOffset offset = ZoneOffset.ofHours(-5); - assertEquals(test.getOffset(createInstant(2008, 1, 1, offset)), ZoneOffset.ofHours(-5)); - assertEquals(test.getOffset(createInstant(2008, 2, 1, offset)), ZoneOffset.ofHours(-5)); - assertEquals(test.getOffset(createInstant(2008, 3, 1, offset)), ZoneOffset.ofHours(-5)); - assertEquals(test.getOffset(createInstant(2008, 4, 1, offset)), ZoneOffset.ofHours(-4)); - assertEquals(test.getOffset(createInstant(2008, 5, 1, offset)), ZoneOffset.ofHours(-4)); - assertEquals(test.getOffset(createInstant(2008, 6, 1, offset)), ZoneOffset.ofHours(-4)); - assertEquals(test.getOffset(createInstant(2008, 7, 1, offset)), ZoneOffset.ofHours(-4)); - assertEquals(test.getOffset(createInstant(2008, 8, 1, offset)), ZoneOffset.ofHours(-4)); - assertEquals(test.getOffset(createInstant(2008, 9, 1, offset)), ZoneOffset.ofHours(-4)); - assertEquals(test.getOffset(createInstant(2008, 10, 1, offset)), ZoneOffset.ofHours(-4)); - assertEquals(test.getOffset(createInstant(2008, 11, 1, offset)), ZoneOffset.ofHours(-4)); - assertEquals(test.getOffset(createInstant(2008, 12, 1, offset)), ZoneOffset.ofHours(-5)); - assertEquals(test.getOffset(createInstant(2008, 1, 28, offset)), ZoneOffset.ofHours(-5)); - assertEquals(test.getOffset(createInstant(2008, 2, 28, offset)), ZoneOffset.ofHours(-5)); - assertEquals(test.getOffset(createInstant(2008, 3, 28, offset)), ZoneOffset.ofHours(-4)); - assertEquals(test.getOffset(createInstant(2008, 4, 28, offset)), ZoneOffset.ofHours(-4)); - assertEquals(test.getOffset(createInstant(2008, 5, 28, offset)), ZoneOffset.ofHours(-4)); - assertEquals(test.getOffset(createInstant(2008, 6, 28, offset)), ZoneOffset.ofHours(-4)); - assertEquals(test.getOffset(createInstant(2008, 7, 28, offset)), ZoneOffset.ofHours(-4)); - assertEquals(test.getOffset(createInstant(2008, 8, 28, offset)), ZoneOffset.ofHours(-4)); - assertEquals(test.getOffset(createInstant(2008, 9, 28, offset)), ZoneOffset.ofHours(-4)); - assertEquals(test.getOffset(createInstant(2008, 10, 28, offset)), ZoneOffset.ofHours(-4)); - assertEquals(test.getOffset(createInstant(2008, 11, 28, offset)), ZoneOffset.ofHours(-5)); - assertEquals(test.getOffset(createInstant(2008, 12, 28, offset)), ZoneOffset.ofHours(-5)); + assertEquals(ZoneOffset.ofHours(-5), test.getOffset(createInstant(2008, 1, 1, offset))); + assertEquals(ZoneOffset.ofHours(-5), test.getOffset(createInstant(2008, 2, 1, offset))); + assertEquals(ZoneOffset.ofHours(-5), test.getOffset(createInstant(2008, 3, 1, offset))); + assertEquals(ZoneOffset.ofHours(-4), test.getOffset(createInstant(2008, 4, 1, offset))); + assertEquals(ZoneOffset.ofHours(-4), test.getOffset(createInstant(2008, 5, 1, offset))); + assertEquals(ZoneOffset.ofHours(-4), test.getOffset(createInstant(2008, 6, 1, offset))); + assertEquals(ZoneOffset.ofHours(-4), test.getOffset(createInstant(2008, 7, 1, offset))); + assertEquals(ZoneOffset.ofHours(-4), test.getOffset(createInstant(2008, 8, 1, offset))); + assertEquals(ZoneOffset.ofHours(-4), test.getOffset(createInstant(2008, 9, 1, offset))); + assertEquals(ZoneOffset.ofHours(-4), test.getOffset(createInstant(2008, 10, 1, offset))); + assertEquals(ZoneOffset.ofHours(-4), test.getOffset(createInstant(2008, 11, 1, offset))); + assertEquals(ZoneOffset.ofHours(-5), test.getOffset(createInstant(2008, 12, 1, offset))); + assertEquals(ZoneOffset.ofHours(-5), test.getOffset(createInstant(2008, 1, 28, offset))); + assertEquals(ZoneOffset.ofHours(-5), test.getOffset(createInstant(2008, 2, 28, offset))); + assertEquals(ZoneOffset.ofHours(-4), test.getOffset(createInstant(2008, 3, 28, offset))); + assertEquals(ZoneOffset.ofHours(-4), test.getOffset(createInstant(2008, 4, 28, offset))); + assertEquals(ZoneOffset.ofHours(-4), test.getOffset(createInstant(2008, 5, 28, offset))); + assertEquals(ZoneOffset.ofHours(-4), test.getOffset(createInstant(2008, 6, 28, offset))); + assertEquals(ZoneOffset.ofHours(-4), test.getOffset(createInstant(2008, 7, 28, offset))); + assertEquals(ZoneOffset.ofHours(-4), test.getOffset(createInstant(2008, 8, 28, offset))); + assertEquals(ZoneOffset.ofHours(-4), test.getOffset(createInstant(2008, 9, 28, offset))); + assertEquals(ZoneOffset.ofHours(-4), test.getOffset(createInstant(2008, 10, 28, offset))); + assertEquals(ZoneOffset.ofHours(-5), test.getOffset(createInstant(2008, 11, 28, offset))); + assertEquals(ZoneOffset.ofHours(-5), test.getOffset(createInstant(2008, 12, 28, offset))); } @Test public void test_NewYork_getOffset_toDST() { ZoneRules test = americaNewYork(); ZoneOffset offset = ZoneOffset.ofHours(-5); - assertEquals(test.getOffset(createInstant(2008, 3, 8, offset)), ZoneOffset.ofHours(-5)); - assertEquals(test.getOffset(createInstant(2008, 3, 9, offset)), ZoneOffset.ofHours(-5)); - assertEquals(test.getOffset(createInstant(2008, 3, 10, offset)), ZoneOffset.ofHours(-4)); - assertEquals(test.getOffset(createInstant(2008, 3, 11, offset)), ZoneOffset.ofHours(-4)); - assertEquals(test.getOffset(createInstant(2008, 3, 12, offset)), ZoneOffset.ofHours(-4)); - assertEquals(test.getOffset(createInstant(2008, 3, 13, offset)), ZoneOffset.ofHours(-4)); - assertEquals(test.getOffset(createInstant(2008, 3, 14, offset)), ZoneOffset.ofHours(-4)); + assertEquals(ZoneOffset.ofHours(-5), test.getOffset(createInstant(2008, 3, 8, offset))); + assertEquals(ZoneOffset.ofHours(-5), test.getOffset(createInstant(2008, 3, 9, offset))); + assertEquals(ZoneOffset.ofHours(-4), test.getOffset(createInstant(2008, 3, 10, offset))); + assertEquals(ZoneOffset.ofHours(-4), test.getOffset(createInstant(2008, 3, 11, offset))); + assertEquals(ZoneOffset.ofHours(-4), test.getOffset(createInstant(2008, 3, 12, offset))); + assertEquals(ZoneOffset.ofHours(-4), test.getOffset(createInstant(2008, 3, 13, offset))); + assertEquals(ZoneOffset.ofHours(-4), test.getOffset(createInstant(2008, 3, 14, offset))); // cutover at 02:00 local - assertEquals(test.getOffset(createInstant(2008, 3, 9, 1, 59, 59, 999999999, offset)), ZoneOffset.ofHours(-5)); - assertEquals(test.getOffset(createInstant(2008, 3, 9, 2, 0, 0, 0, offset)), ZoneOffset.ofHours(-4)); + assertEquals(ZoneOffset.ofHours(-5), test.getOffset(createInstant(2008, 3, 9, 1, 59, 59, 999999999, offset))); + assertEquals(ZoneOffset.ofHours(-4), test.getOffset(createInstant(2008, 3, 9, 2, 0, 0, 0, offset))); } @Test public void test_NewYork_getOffset_fromDST() { ZoneRules test = americaNewYork(); ZoneOffset offset = ZoneOffset.ofHours(-4); - assertEquals(test.getOffset(createInstant(2008, 11, 1, offset)), ZoneOffset.ofHours(-4)); - assertEquals(test.getOffset(createInstant(2008, 11, 2, offset)), ZoneOffset.ofHours(-4)); - assertEquals(test.getOffset(createInstant(2008, 11, 3, offset)), ZoneOffset.ofHours(-5)); - assertEquals(test.getOffset(createInstant(2008, 11, 4, offset)), ZoneOffset.ofHours(-5)); - assertEquals(test.getOffset(createInstant(2008, 11, 5, offset)), ZoneOffset.ofHours(-5)); - assertEquals(test.getOffset(createInstant(2008, 11, 6, offset)), ZoneOffset.ofHours(-5)); - assertEquals(test.getOffset(createInstant(2008, 11, 7, offset)), ZoneOffset.ofHours(-5)); + assertEquals(ZoneOffset.ofHours(-4), test.getOffset(createInstant(2008, 11, 1, offset))); + assertEquals(ZoneOffset.ofHours(-4), test.getOffset(createInstant(2008, 11, 2, offset))); + assertEquals(ZoneOffset.ofHours(-5), test.getOffset(createInstant(2008, 11, 3, offset))); + assertEquals(ZoneOffset.ofHours(-5), test.getOffset(createInstant(2008, 11, 4, offset))); + assertEquals(ZoneOffset.ofHours(-5), test.getOffset(createInstant(2008, 11, 5, offset))); + assertEquals(ZoneOffset.ofHours(-5), test.getOffset(createInstant(2008, 11, 6, offset))); + assertEquals(ZoneOffset.ofHours(-5), test.getOffset(createInstant(2008, 11, 7, offset))); // cutover at 02:00 local - assertEquals(test.getOffset(createInstant(2008, 11, 2, 1, 59, 59, 999999999, offset)), ZoneOffset.ofHours(-4)); - assertEquals(test.getOffset(createInstant(2008, 11, 2, 2, 0, 0, 0, offset)), ZoneOffset.ofHours(-5)); + assertEquals(ZoneOffset.ofHours(-4), test.getOffset(createInstant(2008, 11, 2, 1, 59, 59, 999999999, offset))); + assertEquals(ZoneOffset.ofHours(-5), test.getOffset(createInstant(2008, 11, 2, 2, 0, 0, 0, offset))); } @Test @@ -849,15 +849,15 @@ public class TCKZoneRules { ZoneRules test = americaNewYork(); final LocalDateTime dateTime = LocalDateTime.of(2008, 3, 9, 2, 0, 0, 0); ZoneOffsetTransition trans = checkOffset(test, dateTime, ZoneOffset.ofHours(-5), GAP); - assertEquals(trans.isGap(), true); - assertEquals(trans.isOverlap(), false); - assertEquals(trans.getOffsetBefore(), ZoneOffset.ofHours(-5)); - assertEquals(trans.getOffsetAfter(), ZoneOffset.ofHours(-4)); - assertEquals(trans.getInstant(), createInstant(2008, 3, 9, 2, 0, ZoneOffset.ofHours(-5))); - assertEquals(trans.isValidOffset(OFFSET_PTWO), false); - assertEquals(trans.isValidOffset(ZoneOffset.ofHours(-5)), false); - assertEquals(trans.isValidOffset(ZoneOffset.ofHours(-4)), false); - assertEquals(trans.toString(), "Transition[Gap at 2008-03-09T02:00-05:00 to -04:00]"); + assertEquals(true, trans.isGap()); + assertEquals(false, trans.isOverlap()); + assertEquals(ZoneOffset.ofHours(-5), trans.getOffsetBefore()); + assertEquals(ZoneOffset.ofHours(-4), trans.getOffsetAfter()); + assertEquals(createInstant(2008, 3, 9, 2, 0, ZoneOffset.ofHours(-5)), trans.getInstant()); + assertEquals(false, trans.isValidOffset(OFFSET_PTWO)); + assertEquals(false, trans.isValidOffset(ZoneOffset.ofHours(-5))); + assertEquals(false, trans.isValidOffset(ZoneOffset.ofHours(-4))); + assertEquals("Transition[Gap at 2008-03-09T02:00-05:00 to -04:00]", trans.toString()); assertFalse(trans.equals(null)); assertFalse(trans.equals(ZoneOffset.ofHours(-5))); @@ -865,7 +865,7 @@ public class TCKZoneRules { final ZoneOffsetTransition otherTrans = test.getTransition(dateTime); assertTrue(trans.equals(otherTrans)); - assertEquals(trans.hashCode(), otherTrans.hashCode()); + assertEquals(otherTrans.hashCode(), trans.hashCode()); } @Test @@ -873,16 +873,16 @@ public class TCKZoneRules { ZoneRules test = americaNewYork(); final LocalDateTime dateTime = LocalDateTime.of(2008, 11, 2, 1, 0, 0, 0); ZoneOffsetTransition trans = checkOffset(test, dateTime, ZoneOffset.ofHours(-4), OVERLAP); - assertEquals(trans.isGap(), false); - assertEquals(trans.isOverlap(), true); - assertEquals(trans.getOffsetBefore(), ZoneOffset.ofHours(-4)); - assertEquals(trans.getOffsetAfter(), ZoneOffset.ofHours(-5)); - assertEquals(trans.getInstant(), createInstant(2008, 11, 2, 2, 0, ZoneOffset.ofHours(-4))); - assertEquals(trans.isValidOffset(ZoneOffset.ofHours(-1)), false); - assertEquals(trans.isValidOffset(ZoneOffset.ofHours(-5)), true); - assertEquals(trans.isValidOffset(ZoneOffset.ofHours(-4)), true); - assertEquals(trans.isValidOffset(OFFSET_PTWO), false); - assertEquals(trans.toString(), "Transition[Overlap at 2008-11-02T02:00-04:00 to -05:00]"); + assertEquals(false, trans.isGap()); + assertEquals(true, trans.isOverlap()); + assertEquals(ZoneOffset.ofHours(-4), trans.getOffsetBefore()); + assertEquals(ZoneOffset.ofHours(-5), trans.getOffsetAfter()); + assertEquals(createInstant(2008, 11, 2, 2, 0, ZoneOffset.ofHours(-4)), trans.getInstant()); + assertEquals(false, trans.isValidOffset(ZoneOffset.ofHours(-1))); + assertEquals(true, trans.isValidOffset(ZoneOffset.ofHours(-5))); + assertEquals(true, trans.isValidOffset(ZoneOffset.ofHours(-4))); + assertEquals(false, trans.isValidOffset(OFFSET_PTWO)); + assertEquals("Transition[Overlap at 2008-11-02T02:00-04:00 to -05:00]", trans.toString()); assertFalse(trans.equals(null)); assertFalse(trans.equals(ZoneOffset.ofHours(-4))); @@ -890,7 +890,7 @@ public class TCKZoneRules { final ZoneOffsetTransition otherTrans = test.getTransition(dateTime); assertTrue(trans.equals(otherTrans)); - assertEquals(trans.hashCode(), otherTrans.hashCode()); + assertEquals(otherTrans.hashCode(), trans.hashCode()); } @Test @@ -900,9 +900,9 @@ public class TCKZoneRules { while (dateTime.getYear() < 2010) { Instant instant = dateTime.toInstant(); if (dateTime.toLocalDate().isBefore(LocalDate.of(1883, 11, 18))) { - assertEquals(test.getStandardOffset(instant), ZoneOffset.of("-04:56:02")); + assertEquals(ZoneOffset.of("-04:56:02"), test.getStandardOffset(instant)); } else { - assertEquals(test.getStandardOffset(instant), ZoneOffset.ofHours(-5)); + assertEquals(ZoneOffset.ofHours(-5), test.getStandardOffset(instant)); } dateTime = dateTime.plusMonths(6); } @@ -921,14 +921,14 @@ public class TCKZoneRules { List trans = test.getTransitions(); ZoneOffsetTransition first = trans.get(0); - assertEquals(test.nextTransition(first.getInstant().minusNanos(1)), first); + assertEquals(first, test.nextTransition(first.getInstant().minusNanos(1))); for (int i = 0; i < trans.size() - 1; i++) { ZoneOffsetTransition cur = trans.get(i); ZoneOffsetTransition next = trans.get(i + 1); - assertEquals(test.nextTransition(cur.getInstant()), next); - assertEquals(test.nextTransition(next.getInstant().minusNanos(1)), next); + assertEquals(next, test.nextTransition(cur.getInstant())); + assertEquals(next, test.nextTransition(next.getInstant().minusNanos(1))); } } @@ -938,7 +938,7 @@ public class TCKZoneRules { List trans = test.getTransitions(); ZoneOffsetTransition last = trans.get(trans.size() - 1); - assertEquals(test.nextTransition(last.getInstant()), null); + assertEquals(null, test.nextTransition(last.getInstant())); } //----------------------------------------------------------------------- @@ -954,14 +954,14 @@ public class TCKZoneRules { List trans = test.getTransitions(); ZoneOffsetTransition first = trans.get(0); - assertEquals(test.nextTransition(first.getInstant().minusNanos(1)), first); + assertEquals(first, test.nextTransition(first.getInstant().minusNanos(1))); for (int i = 0; i < trans.size() - 1; i++) { ZoneOffsetTransition cur = trans.get(i); ZoneOffsetTransition next = trans.get(i + 1); - assertEquals(test.nextTransition(cur.getInstant()), next); - assertEquals(test.nextTransition(next.getInstant().minusNanos(1)), next); + assertEquals(next, test.nextTransition(cur.getInstant())); + assertEquals(next, test.nextTransition(next.getInstant().minusNanos(1))); } } @@ -971,17 +971,17 @@ public class TCKZoneRules { ZoneRules test = pacificApia(); Instant instantBefore = LocalDate.of(2011, 12, 27).atStartOfDay(ZoneOffset.UTC).toInstant(); ZoneOffsetTransition trans = test.nextTransition(instantBefore); - assertEquals(trans.getDateTimeBefore(), LocalDateTime.of(2011, 12, 30, 0, 0)); - assertEquals(trans.getDateTimeAfter(), LocalDateTime.of(2011, 12, 31, 0, 0)); - assertEquals(trans.isGap(), true); - assertEquals(trans.isOverlap(), false); - assertEquals(trans.isValidOffset(ZoneOffset.ofHours(-10)), false); - assertEquals(trans.isValidOffset(ZoneOffset.ofHours(+14)), false); - assertEquals(trans.getDuration(), Duration.ofHours(24)); - assertEquals(trans.getInstant(), LocalDateTime.of(2011, 12, 31, 0, 0).toInstant(ZoneOffset.ofHours(+14))); + assertEquals(LocalDateTime.of(2011, 12, 30, 0, 0), trans.getDateTimeBefore()); + assertEquals(LocalDateTime.of(2011, 12, 31, 0, 0), trans.getDateTimeAfter()); + assertEquals(true, trans.isGap()); + assertEquals(false, trans.isOverlap()); + assertEquals(false, trans.isValidOffset(ZoneOffset.ofHours(-10))); + assertEquals(false, trans.isValidOffset(ZoneOffset.ofHours(+14))); + assertEquals(Duration.ofHours(24), trans.getDuration()); + assertEquals(LocalDateTime.of(2011, 12, 31, 0, 0).toInstant(ZoneOffset.ofHours(+14)), trans.getInstant()); ZonedDateTime zdt = ZonedDateTime.of(2011, 12, 29, 23, 0, 0, 0, ZoneId.of("Pacific/Apia")); - assertEquals(zdt.plusHours(2).toLocalDateTime(), LocalDateTime.of(2011, 12, 31, 1, 0)); + assertEquals(LocalDateTime.of(2011, 12, 31, 1, 0), zdt.plusHours(2).toLocalDateTime()); } @Test @@ -990,30 +990,34 @@ public class TCKZoneRules { ZoneRules test = pacificApia(); Instant instantBefore = LocalDate.of(1892, 7, 2).atStartOfDay(ZoneOffset.UTC).toInstant(); ZoneOffsetTransition trans = test.nextTransition(instantBefore); - assertEquals(trans.getDateTimeBefore(), LocalDateTime.of(1892, 7, 5, 0, 0)); - assertEquals(trans.getDateTimeAfter(), LocalDateTime.of(1892, 7, 4, 0, 0)); - assertEquals(trans.isGap(), false); - assertEquals(trans.isOverlap(), true); - assertEquals(trans.isValidOffset(ZoneOffset.ofHoursMinutesSeconds(+12, 33, 4)), true); - assertEquals(trans.isValidOffset(ZoneOffset.ofHoursMinutesSeconds(-11, -26, -56)), true); - assertEquals(trans.getDuration(), Duration.ofHours(-24)); - assertEquals(trans.getInstant(), LocalDateTime.of(1892, 7, 4, 0, 0).toInstant(ZoneOffset.ofHoursMinutesSeconds(-11, -26, -56))); + assertEquals(LocalDateTime.of(1892, 7, 5, 0, 0), trans.getDateTimeBefore()); + assertEquals(LocalDateTime.of(1892, 7, 4, 0, 0), trans.getDateTimeAfter()); + assertEquals(false, trans.isGap()); + assertEquals(true, trans.isOverlap()); + assertEquals(true, trans.isValidOffset(ZoneOffset.ofHoursMinutesSeconds(+12, 33, 4))); + assertEquals(true, trans.isValidOffset(ZoneOffset.ofHoursMinutesSeconds(-11, -26, -56))); + assertEquals(Duration.ofHours(-24), trans.getDuration()); + assertEquals(LocalDateTime.of(1892, 7, 4, 0, 0).toInstant(ZoneOffset.ofHoursMinutesSeconds(-11, -26, -56)), trans.getInstant()); ZonedDateTime zdt = ZonedDateTime.of(1892, 7, 4, 23, 0, 0, 0, ZoneId.of("Pacific/Apia")); - assertEquals(zdt.plusHours(2).toLocalDateTime(), LocalDateTime.of(1892, 7, 4, 1, 0, 0)); + assertEquals(LocalDateTime.of(1892, 7, 4, 1, 0, 0), zdt.plusHours(2).toLocalDateTime()); } //------------------------------------------------------------------------- - @Test(expectedExceptions=UnsupportedOperationException.class) + @Test public void test_getTransitions_immutable() { - ZoneRules test = europeParis(); - test.getTransitions().clear(); + Assertions.assertThrows(UnsupportedOperationException.class, () -> { + ZoneRules test = europeParis(); + test.getTransitions().clear(); + }); } - @Test(expectedExceptions=UnsupportedOperationException.class) + @Test public void test_getTransitionRules_immutable() { - ZoneRules test = europeParis(); - test.getTransitionRules().clear(); + Assertions.assertThrows(UnsupportedOperationException.class, () -> { + ZoneRules test = europeParis(); + test.getTransitionRules().clear(); + }); } //----------------------------------------------------------------------- @@ -1073,23 +1077,23 @@ public class TCKZoneRules { OffsetDateTime before_time_of_stdOffsetTransition1 = OffsetDateTime.of(time_of_stdOffsetTransition1, stdOffset1).minusSeconds(1); OffsetDateTime after_time_of_stdOffsetTransition1 = OffsetDateTime.of(time_of_stdOffsetTransition1, stdOffset1).plusSeconds(1); - assertEquals(zoneRule.getStandardOffset(before_time_of_stdOffsetTransition1.toInstant()), stdOffset1); - assertEquals(zoneRule.getStandardOffset(after_time_of_stdOffsetTransition1.toInstant()), stdOffset2); + assertEquals(stdOffset1, zoneRule.getStandardOffset(before_time_of_stdOffsetTransition1.toInstant())); + assertEquals(stdOffset2, zoneRule.getStandardOffset(after_time_of_stdOffsetTransition1.toInstant())); OffsetDateTime before_time_of_wallOffsetTransition1 = OffsetDateTime.of(time_of_wallOffsetTransition1, wallOffset1).minusSeconds(1); OffsetDateTime after_time_of_wallOffsetTransition1 = OffsetDateTime.of(time_of_wallOffsetTransition1, wallOffset1).plusSeconds(1); - assertEquals(zoneRule.nextTransition(before_time_of_wallOffsetTransition1.toInstant()), wallOffsetTransition1); - assertEquals(zoneRule.nextTransition(after_time_of_wallOffsetTransition1.toInstant()), wallOffsetTransition2); + assertEquals(wallOffsetTransition1, zoneRule.nextTransition(before_time_of_wallOffsetTransition1.toInstant())); + assertEquals(wallOffsetTransition2, zoneRule.nextTransition(after_time_of_wallOffsetTransition1.toInstant())); OffsetDateTime before_time_of_wallOffsetTransition2 = OffsetDateTime.of(time_of_wallOffsetTransition2, wallOffset2).minusSeconds(1); OffsetDateTime after_time_of_wallOffsetTransition2 = OffsetDateTime.of(time_of_wallOffsetTransition2, wallOffset2).plusSeconds(1); - assertEquals(zoneRule.nextTransition(before_time_of_wallOffsetTransition2.toInstant()), wallOffsetTransition2); - assertEquals(zoneRule.nextTransition(after_time_of_wallOffsetTransition2.toInstant()), wallOffsetTransition3); + assertEquals(wallOffsetTransition2, zoneRule.nextTransition(before_time_of_wallOffsetTransition2.toInstant())); + assertEquals(wallOffsetTransition3, zoneRule.nextTransition(after_time_of_wallOffsetTransition2.toInstant())); OffsetDateTime before_time_of_wallOffsetTransition3 = OffsetDateTime.of(time_of_wallOffsetTransition3, wallOffset3).minusSeconds(1); OffsetDateTime after_time_of_wallOffsetTransition3 = OffsetDateTime.of(time_of_wallOffsetTransition3, wallOffset3).plusSeconds(1); - assertEquals(zoneRule.nextTransition(before_time_of_wallOffsetTransition3.toInstant()), wallOffsetTransition3); - assertEquals(zoneRule.nextTransition(after_time_of_wallOffsetTransition3.toInstant()), rule1.createTransition(2014)); + assertEquals(wallOffsetTransition3, zoneRule.nextTransition(before_time_of_wallOffsetTransition3.toInstant())); + assertEquals(rule1.createTransition(2014), zoneRule.nextTransition(after_time_of_wallOffsetTransition3.toInstant())); } //----------------------------------------------------------------------- @@ -1100,31 +1104,31 @@ public class TCKZoneRules { ZoneRules test1 = europeLondon(); ZoneRules test2 = europeParis(); ZoneRules test2b = europeParis(); - assertEquals(test1.equals(test2), false); - assertEquals(test2.equals(test1), false); + assertEquals(false, test1.equals(test2)); + assertEquals(false, test2.equals(test1)); - assertEquals(test1.equals(test1), true); - assertEquals(test2.equals(test2), true); - assertEquals(test2.equals(test2b), true); + assertEquals(true, test1.equals(test1)); + assertEquals(true, test2.equals(test2)); + assertEquals(true, test2.equals(test2b)); - assertEquals(test1.hashCode() == test1.hashCode(), true); - assertEquals(test2.hashCode() == test2.hashCode(), true); - assertEquals(test2.hashCode() == test2b.hashCode(), true); + assertEquals(true, test1.hashCode() == test1.hashCode()); + assertEquals(true, test2.hashCode() == test2.hashCode()); + assertEquals(true, test2.hashCode() == test2b.hashCode()); } @Test public void test_equals_null() { - assertEquals(europeLondon().equals(null), false); + assertEquals(false, europeLondon().equals(null)); } @Test public void test_equals_notZoneRules() { - assertEquals(europeLondon().equals("Europe/London"), false); + assertEquals(false, europeLondon().equals("Europe/London")); } @Test public void test_toString() { - assertEquals(europeLondon().toString().contains("ZoneRules"), true); + assertEquals(true, europeLondon().toString().contains("ZoneRules")); } //----------------------------------------------------------------------- @@ -1152,17 +1156,17 @@ public class TCKZoneRules { private ZoneOffsetTransition checkOffset(ZoneRules rules, LocalDateTime dateTime, ZoneOffset offset, int type) { List validOffsets = rules.getValidOffsets(dateTime); - assertEquals(validOffsets.size(), type); - assertEquals(rules.getOffset(dateTime), offset); + assertEquals(type, validOffsets.size()); + assertEquals(offset, rules.getOffset(dateTime)); if (type == 1) { - assertEquals(validOffsets.get(0), offset); + assertEquals(offset, validOffsets.get(0)); return null; } else { ZoneOffsetTransition zot = rules.getTransition(dateTime); assertNotNull(zot); - assertEquals(zot.isOverlap(), type == 2); - assertEquals(zot.isGap(), type == 0); - assertEquals(zot.isValidOffset(offset), type == 2); + assertEquals(type == 2, zot.isOverlap()); + assertEquals(type == 0, zot.isGap()); + assertEquals(type == 2, zot.isValidOffset(offset)); return zot; } } diff --git a/test/jdk/java/time/tck/java/time/zone/TCKZoneRulesProvider.java b/test/jdk/java/time/tck/java/time/zone/TCKZoneRulesProvider.java index f51bb396f50..32b1a688b54 100644 --- a/test/jdk/java/time/tck/java/time/zone/TCKZoneRulesProvider.java +++ b/test/jdk/java/time/tck/java/time/zone/TCKZoneRulesProvider.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2012, 2016, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2012, 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 @@ -59,9 +59,9 @@ */ package tck.java.time.zone; -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 java.time.ZoneId; import java.time.ZoneOffset; @@ -74,12 +74,12 @@ import java.util.NavigableMap; import java.util.Set; import java.util.TreeMap; -import org.testng.annotations.Test; +import org.junit.jupiter.api.Assertions; +import org.junit.jupiter.api.Test; /** * Test ZoneRulesProvider. */ -@Test public class TCKZoneRulesProvider { private static String TZDB_VERSION = "2012i"; @@ -90,12 +90,12 @@ public class TCKZoneRulesProvider { @Test public void test_getAvailableGroupIds() { Set zoneIds = ZoneRulesProvider.getAvailableZoneIds(); - assertEquals(zoneIds.contains("Europe/London"), true); + assertEquals(true, zoneIds.contains("Europe/London")); } - @Test(expectedExceptions=UnsupportedOperationException.class) + @Test public void test_getAvailableGroupIds_modifyZoneId() { - ZoneRulesProvider.getAvailableZoneIds().clear(); + Assertions.assertThrows(UnsupportedOperationException.class, () -> ZoneRulesProvider.getAvailableZoneIds().clear()); } //----------------------------------------------------------------------- @@ -106,17 +106,17 @@ public class TCKZoneRulesProvider { ZoneRules rules = ZoneRulesProvider.getRules("Europe/London", false); assertNotNull(rules); ZoneRules rules2 = ZoneRulesProvider.getRules("Europe/London", false); - assertEquals(rules2, rules); + assertEquals(rules, rules2); } - @Test(expectedExceptions=ZoneRulesException.class) + @Test public void test_getRules_StringBoolean_unknownId() { - ZoneRulesProvider.getRules("Europe/Lon", false); + Assertions.assertThrows(ZoneRulesException.class, () -> ZoneRulesProvider.getRules("Europe/Lon", false)); } - @Test(expectedExceptions=NullPointerException.class) + @Test public void test_getRules_StringBoolean_null() { - ZoneRulesProvider.getRules(null, false); + Assertions.assertThrows(NullPointerException.class, () -> ZoneRulesProvider.getRules(null, false)); } @Test @@ -124,13 +124,13 @@ public class TCKZoneRulesProvider { MockDynamicProvider dynamicProvider = new MockDynamicProvider(); ZoneRulesProvider.registerProvider(dynamicProvider); - assertEquals(dynamicProvider.count, 0); + assertEquals(0, dynamicProvider.count); ZoneRules rules1 = ZoneId.of("DynamicLocation").getRules(); - assertEquals(dynamicProvider.count, 2); - assertEquals(rules1, dynamicProvider.BASE); + assertEquals(2, dynamicProvider.count); + assertEquals(dynamicProvider.BASE, rules1); ZoneRules rules2 = ZoneId.of("DynamicLocation").getRules(); - assertEquals(dynamicProvider.count, 4); - assertEquals(rules2, dynamicProvider.ALTERNATE); + assertEquals(4, dynamicProvider.count); + assertEquals(dynamicProvider.ALTERNATE, rules2); } //----------------------------------------------------------------------- @@ -141,23 +141,23 @@ public class TCKZoneRulesProvider { NavigableMap versions = ZoneRulesProvider.getVersions("Europe/London"); assertTrue(versions.size() >= 1); ZoneRules rules = ZoneRulesProvider.getRules("Europe/London", false); - assertEquals(versions.lastEntry().getValue(), rules); + assertEquals(rules, versions.lastEntry().getValue()); NavigableMap copy = new TreeMap<>(versions); versions.clear(); - assertEquals(versions.size(), 0); + assertEquals(0, versions.size()); NavigableMap versions2 = ZoneRulesProvider.getVersions("Europe/London"); - assertEquals(versions2, copy); + assertEquals(copy, versions2); } - @Test(expectedExceptions=ZoneRulesException.class) + @Test public void test_getVersions_String_unknownId() { - ZoneRulesProvider.getVersions("Europe/Lon"); + Assertions.assertThrows(ZoneRulesException.class, () -> ZoneRulesProvider.getVersions("Europe/Lon")); } - @Test(expectedExceptions=NullPointerException.class) + @Test public void test_getVersions_String_null() { - ZoneRulesProvider.getVersions(null); + Assertions.assertThrows(NullPointerException.class, () -> ZoneRulesProvider.getVersions(null)); } //----------------------------------------------------------------------- @@ -165,7 +165,7 @@ public class TCKZoneRulesProvider { //----------------------------------------------------------------------- @Test public void test_refresh() { - assertEquals(ZoneRulesProvider.refresh(), false); + assertEquals(false, ZoneRulesProvider.refresh()); } //----------------------------------------------------------------------- @@ -174,12 +174,12 @@ public class TCKZoneRulesProvider { @Test public void test_registerProvider() { Set pre = ZoneRulesProvider.getAvailableZoneIds(); - assertEquals(pre.contains("FooLocation"), false); + assertEquals(false, pre.contains("FooLocation")); ZoneRulesProvider.registerProvider(new MockTempProvider()); - assertEquals(pre.contains("FooLocation"), false); + assertEquals(false, pre.contains("FooLocation")); Set post = ZoneRulesProvider.getAvailableZoneIds(); - assertEquals(post.contains("FooLocation"), true); - assertEquals(ZoneRulesProvider.getRules("FooLocation", false), ZoneOffset.of("+01:45").getRules()); + assertEquals(true, post.contains("FooLocation")); + assertEquals(ZoneOffset.of("+01:45").getRules(), ZoneRulesProvider.getRules("FooLocation", false)); } static class MockTempProvider extends ZoneRulesProvider { diff --git a/test/jdk/java/time/tck/java/time/zone/serial/TCKFixedZoneRulesSerialization.java b/test/jdk/java/time/tck/java/time/zone/serial/TCKFixedZoneRulesSerialization.java index 790e54fbb6d..719d5aab5f7 100644 --- a/test/jdk/java/time/tck/java/time/zone/serial/TCKFixedZoneRulesSerialization.java +++ b/test/jdk/java/time/tck/java/time/zone/serial/TCKFixedZoneRulesSerialization.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2012, 2013, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2012, 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 @@ -59,8 +59,6 @@ */ package tck.java.time.zone.serial; -import org.testng.annotations.DataProvider; -import org.testng.annotations.Test; import java.io.ByteArrayInputStream; import java.io.ByteArrayOutputStream; @@ -69,12 +67,15 @@ import java.io.ObjectOutputStream; import java.time.ZoneOffset; import java.time.zone.ZoneRules; -import static org.testng.Assert.assertEquals; +import static org.junit.jupiter.api.Assertions.assertEquals; +import org.junit.jupiter.api.TestInstance; +import org.junit.jupiter.params.ParameterizedTest; +import org.junit.jupiter.params.provider.MethodSource; /** * Test serialization of ZoneRules for fixed offset time-zones. */ -@Test +@TestInstance(TestInstance.Lifecycle.PER_CLASS) public class TCKFixedZoneRulesSerialization { private static final ZoneOffset OFFSET_PONE = ZoneOffset.ofHours(1); @@ -85,7 +86,6 @@ public class TCKFixedZoneRulesSerialization { return offset.getRules(); } - @DataProvider(name="rules") Object[][] data_rules() { return new Object[][] { {make(OFFSET_PONE), OFFSET_PONE}, @@ -97,7 +97,8 @@ public class TCKFixedZoneRulesSerialization { //----------------------------------------------------------------------- // Basics //----------------------------------------------------------------------- - @Test(dataProvider="rules") + @ParameterizedTest + @MethodSource("data_rules") public void test_serialization(ZoneRules test, ZoneOffset expectedOffset) throws Exception { ByteArrayOutputStream baos = new ByteArrayOutputStream(); ObjectOutputStream out = new ObjectOutputStream(baos); @@ -109,8 +110,8 @@ public class TCKFixedZoneRulesSerialization { ObjectInputStream in = new ObjectInputStream(bais); ZoneRules result = (ZoneRules) in.readObject(); - assertEquals(result, test); - assertEquals(result.getClass(), test.getClass()); + assertEquals(test, result); + assertEquals(test.getClass(), result.getClass()); } diff --git a/test/jdk/java/time/tck/java/time/zone/serial/TCKZoneOffsetTransitionRuleSerialization.java b/test/jdk/java/time/tck/java/time/zone/serial/TCKZoneOffsetTransitionRuleSerialization.java index 42796f66f8f..ded4772cd9f 100644 --- a/test/jdk/java/time/tck/java/time/zone/serial/TCKZoneOffsetTransitionRuleSerialization.java +++ b/test/jdk/java/time/tck/java/time/zone/serial/TCKZoneOffsetTransitionRuleSerialization.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2012, 2013, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2012, 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 @@ -66,13 +66,13 @@ import java.time.ZoneOffset; import java.time.zone.ZoneOffsetTransitionRule; import java.time.zone.ZoneOffsetTransitionRule.TimeDefinition; -import org.testng.annotations.Test; +import org.junit.jupiter.api.Test; + import tck.java.time.AbstractTCKTest; /** * Test ZoneOffsetTransitionRule serialization. */ -@Test public class TCKZoneOffsetTransitionRuleSerialization extends AbstractTCKTest { private static final LocalTime TIME_0100 = LocalTime.of(1, 0); diff --git a/test/jdk/java/time/tck/java/time/zone/serial/TCKZoneOffsetTransitionSerialization.java b/test/jdk/java/time/tck/java/time/zone/serial/TCKZoneOffsetTransitionSerialization.java index 01ffefe09df..b6ae7dae76b 100644 --- a/test/jdk/java/time/tck/java/time/zone/serial/TCKZoneOffsetTransitionSerialization.java +++ b/test/jdk/java/time/tck/java/time/zone/serial/TCKZoneOffsetTransitionSerialization.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2012, 2013, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2012, 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 @@ -62,7 +62,6 @@ package tck.java.time.zone.serial; import static java.time.temporal.ChronoUnit.HOURS; import java.time.Duration; -import org.testng.annotations.Test; import tck.java.time.AbstractTCKTest; import java.time.LocalDateTime; @@ -70,10 +69,11 @@ import java.time.Year; import java.time.ZoneOffset; import java.time.zone.ZoneOffsetTransition; +import org.junit.jupiter.api.Test; + /** * Test serialization of ZoneOffsetTransition. */ -@Test public class TCKZoneOffsetTransitionSerialization extends AbstractTCKTest { private static final ZoneOffset OFFSET_0200 = ZoneOffset.ofHours(2); diff --git a/test/jdk/java/time/tck/java/time/zone/serial/TCKZoneRulesSerialization.java b/test/jdk/java/time/tck/java/time/zone/serial/TCKZoneRulesSerialization.java index 5262d68eea0..1ba549ba916 100644 --- a/test/jdk/java/time/tck/java/time/zone/serial/TCKZoneRulesSerialization.java +++ b/test/jdk/java/time/tck/java/time/zone/serial/TCKZoneRulesSerialization.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2012, 2013, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2012, 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 @@ -59,7 +59,6 @@ */ package tck.java.time.zone.serial; -import org.testng.annotations.Test; import java.io.ByteArrayInputStream; import java.io.ByteArrayOutputStream; @@ -68,16 +67,17 @@ import java.io.ObjectOutputStream; import java.time.ZoneId; import java.time.zone.ZoneRules; -import static org.testng.Assert.assertEquals; +import static org.junit.jupiter.api.Assertions.assertEquals; +import org.junit.jupiter.api.Test; import tck.java.time.AbstractTCKTest; /** * Test serialization of ZoneRules. */ -@Test public class TCKZoneRulesSerialization extends AbstractTCKTest{ + @Test public void test_serialization_loaded() throws Exception { assertSerialization(europeLondon()); assertSerialization(europeParis()); @@ -95,7 +95,7 @@ public class TCKZoneRulesSerialization extends AbstractTCKTest{ ObjectInputStream in = new ObjectInputStream(bais); ZoneRules result = (ZoneRules) in.readObject(); - assertEquals(result, test); + assertEquals(test, result); } //----------------------------------------------------------------------- diff --git a/test/jdk/java/time/test/TEST.properties b/test/jdk/java/time/test/TEST.properties index 4cc5775e862..e2ecb3e5dc3 100644 --- a/test/jdk/java/time/test/TEST.properties +++ b/test/jdk/java/time/test/TEST.properties @@ -1,5 +1,5 @@ -# java.time tests use TestNG -TestNG.dirs = .. +# java.time tests use JUnit +JUnit.dirs = .. othervm.dirs = java/time lib.dirs = /test/lib /test/jdk/tools/lib lib.build = jdk.test.lib.RandomFactory diff --git a/test/jdk/java/time/test/java/time/AbstractTest.java b/test/jdk/java/time/test/java/time/AbstractTest.java index 6e4734b8e4c..2a117011533 100644 --- a/test/jdk/java/time/test/java/time/AbstractTest.java +++ b/test/jdk/java/time/test/java/time/AbstractTest.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2012, 2022, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2012, 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 @@ -59,9 +59,7 @@ */ package test.java.time; -import static org.testng.Assert.assertEquals; -import static org.testng.Assert.assertSame; -import static org.testng.Assert.assertTrue; +import static org.junit.jupiter.api.Assertions.assertTrue; import java.lang.reflect.Constructor; import java.lang.reflect.Field; diff --git a/test/jdk/java/time/test/java/time/TestClock_Fixed.java b/test/jdk/java/time/test/java/time/TestClock_Fixed.java index cf07ceea07b..1c82a092c6a 100644 --- a/test/jdk/java/time/test/java/time/TestClock_Fixed.java +++ b/test/jdk/java/time/test/java/time/TestClock_Fixed.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2012, 2013, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2012, 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 @@ -59,8 +59,8 @@ */ package test.java.time; -import static org.testng.Assert.assertEquals; -import static org.testng.Assert.assertSame; +import static org.junit.jupiter.api.Assertions.assertEquals; +import static org.junit.jupiter.api.Assertions.assertSame; import java.time.Clock; import java.time.Instant; @@ -68,18 +68,18 @@ import java.time.LocalDateTime; import java.time.ZoneId; import java.time.ZoneOffset; -import org.testng.annotations.Test; +import org.junit.jupiter.api.Test; /** * Test fixed clock. */ -@Test public class TestClock_Fixed { private static final ZoneId PARIS = ZoneId.of("Europe/Paris"); private static final Instant INSTANT = LocalDateTime.of(2008, 6, 30, 11, 30, 10, 500).atZone(ZoneOffset.ofHours(2)).toInstant(); //------------------------------------------------------------------------- + @Test public void test_withZone_same() { Clock test = Clock.fixed(INSTANT, PARIS); Clock changed = test.withZone(PARIS); @@ -87,9 +87,10 @@ public class TestClock_Fixed { } //----------------------------------------------------------------------- + @Test public void test_toString() { Clock test = Clock.fixed(INSTANT, PARIS); - assertEquals(test.toString(), "FixedClock[2008-06-30T09:30:10.000000500Z,Europe/Paris]"); + assertEquals("FixedClock[2008-06-30T09:30:10.000000500Z,Europe/Paris]", test.toString()); } } diff --git a/test/jdk/java/time/test/java/time/TestClock_Offset.java b/test/jdk/java/time/test/java/time/TestClock_Offset.java index ed62300e681..03fc2974955 100644 --- a/test/jdk/java/time/test/java/time/TestClock_Offset.java +++ b/test/jdk/java/time/test/java/time/TestClock_Offset.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2012, 2013, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2012, 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 @@ -59,25 +59,25 @@ */ package test.java.time; -import static org.testng.Assert.assertEquals; -import static org.testng.Assert.assertSame; +import static org.junit.jupiter.api.Assertions.assertEquals; +import static org.junit.jupiter.api.Assertions.assertSame; import java.time.Clock; import java.time.Duration; import java.time.ZoneId; -import org.testng.annotations.Test; +import org.junit.jupiter.api.Test; /** * Test offset clock. */ -@Test public class TestClock_Offset { private static final ZoneId PARIS = ZoneId.of("Europe/Paris"); private static final Duration OFFSET = Duration.ofSeconds(2); //------------------------------------------------------------------------- + @Test public void test_withZone_same() { Clock test = Clock.offset(Clock.system(PARIS), OFFSET); Clock changed = test.withZone(PARIS); @@ -85,9 +85,10 @@ public class TestClock_Offset { } //----------------------------------------------------------------------- + @Test public void test_toString() { Clock test = Clock.offset(Clock.systemUTC(), OFFSET); - assertEquals(test.toString(), "OffsetClock[SystemClock[Z],PT2S]"); + assertEquals("OffsetClock[SystemClock[Z],PT2S]", test.toString()); } } diff --git a/test/jdk/java/time/test/java/time/TestClock_System.java b/test/jdk/java/time/test/java/time/TestClock_System.java index 05d235e3b3c..4d685e78cc1 100644 --- a/test/jdk/java/time/test/java/time/TestClock_System.java +++ b/test/jdk/java/time/test/java/time/TestClock_System.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2012, 2022, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2012, 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 @@ -59,8 +59,8 @@ */ package test.java.time; -import static org.testng.Assert.assertEquals; -import static org.testng.Assert.assertSame; +import static org.junit.jupiter.api.Assertions.assertEquals; +import static org.junit.jupiter.api.Assertions.assertSame; import java.lang.reflect.Field; import java.time.Clock; @@ -68,18 +68,21 @@ import java.time.Instant; import java.time.ZoneId; import java.time.ZoneOffset; -import org.testng.annotations.DataProvider; -import org.testng.annotations.Test; +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 system clock. */ -@Test +@TestInstance(TestInstance.Lifecycle.PER_CLASS) public class TestClock_System { private static final ZoneId PARIS = ZoneId.of("Europe/Paris"); private static final Clock systemUTC = Clock.systemUTC(); + @Test public void test_withZone_same() { Clock test = Clock.system(PARIS); Clock changed = test.withZone(PARIS); @@ -87,13 +90,13 @@ public class TestClock_System { } //----------------------------------------------------------------------- + @Test public void test_toString() { Clock test = Clock.system(PARIS); - assertEquals(test.toString(), "SystemClock[Europe/Paris]"); + assertEquals("SystemClock[Europe/Paris]", test.toString()); } //----------------------------------------------------------------------- - @DataProvider(name="sampleSystemUTC") Object[][] provider_sampleSystemUTC() { return new Object[][] { {"Clock.systemUTC()#1", Clock.systemUTC()}, @@ -104,7 +107,8 @@ public class TestClock_System { } // Test for 8073394 - @Test(dataProvider="sampleSystemUTC") + @ParameterizedTest + @MethodSource("provider_sampleSystemUTC") public void test_systemUTC(String s, Clock clock) { if (clock != systemUTC) { throw new RuntimeException("Unexpected clock instance for " + s + ": " @@ -126,6 +130,7 @@ public class TestClock_System { + time.getNano(); } + @Test public void test_ClockResolution() { Clock highestUTC = Clock.systemUTC(); @@ -392,6 +397,7 @@ public class TestClock_System { } } + @Test public void test_OffsetRegular() throws IllegalAccessException { System.out.println("*** Testing regular cases ***"); SystemClockOffset.testWithOffset("System.currentTimeMillis()/1000", @@ -402,6 +408,7 @@ public class TestClock_System { System.currentTimeMillis()/1000 + 1024); } + @Test public void test_OffsetLimits() throws IllegalAccessException { System.out.println("*** Testing limits ***"); SystemClockOffset.testWithOffset("System.currentTimeMillis()/1000 - MAX_OFFSET + 1", diff --git a/test/jdk/java/time/test/java/time/TestClock_Tick.java b/test/jdk/java/time/test/java/time/TestClock_Tick.java index 53e27541764..5e23ed74ca2 100644 --- a/test/jdk/java/time/test/java/time/TestClock_Tick.java +++ b/test/jdk/java/time/test/java/time/TestClock_Tick.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2012, 2023, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2012, 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 @@ -59,8 +59,8 @@ */ package test.java.time; -import static org.testng.Assert.assertEquals; -import static org.testng.Assert.assertSame; +import static org.junit.jupiter.api.Assertions.assertEquals; +import static org.junit.jupiter.api.Assertions.assertSame; import java.time.Clock; import java.time.Duration; @@ -69,12 +69,11 @@ import java.time.ZoneId; import java.time.ZoneOffset; import java.time.ZonedDateTime; -import org.testng.annotations.Test; +import org.junit.jupiter.api.Test; /** * Test tick clock. */ -@Test public class TestClock_Tick { private static final ZoneId MOSCOW = ZoneId.of("Europe/Moscow"); @@ -82,6 +81,7 @@ public class TestClock_Tick { private static final ZonedDateTime ZDT = LocalDateTime.of(2008, 6, 30, 11, 30, 10, 500).atZone(ZoneOffset.ofHours(2)); //------------------------------------------------------------------------- + @Test public void test_withZone_same() { Clock test = Clock.tick(Clock.system(PARIS), Duration.ofMillis(500)); Clock changed = test.withZone(PARIS); @@ -89,14 +89,16 @@ public class TestClock_Tick { } //----------------------------------------------------------------------- + @Test public void test_toString() { Clock test = Clock.tick(Clock.systemUTC(), Duration.ofMillis(500)); - assertEquals(test.toString(), "TickClock[SystemClock[Z],PT0.5S]"); + assertEquals("TickClock[SystemClock[Z],PT0.5S]", test.toString()); } //----------------------------------------------------------------------- // Ensure divide-by-zero will not be thrown // @bug 8310232 + @Test public void test_millis() { var test = Clock.tick(Clock.systemUTC(), Duration.ofNanos(1000)); test.millis(); diff --git a/test/jdk/java/time/test/java/time/TestDuration.java b/test/jdk/java/time/test/java/time/TestDuration.java index 2b2043377f3..37147687511 100644 --- a/test/jdk/java/time/test/java/time/TestDuration.java +++ b/test/jdk/java/time/test/java/time/TestDuration.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2012, 2013, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2012, 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 @@ -59,18 +59,16 @@ */ package test.java.time; -import static org.testng.Assert.assertEquals; -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.assertSame; import java.time.Duration; -import org.testng.annotations.Test; +import org.junit.jupiter.api.Test; /** * Test Duration. */ -@Test public class TestDuration extends AbstractTest { //----------------------------------------------------------------------- @@ -187,14 +185,14 @@ public class TestDuration extends AbstractTest { for (int j = 0; j < durations.length; j++) { Duration b = durations[j]; if (i < j) { - assertEquals(a.compareTo(b)< 0, true, a + " <=> " + b); - assertEquals(a.equals(b), false, a + " <=> " + b); + assertEquals(true, a.compareTo(b)< 0, a + " <=> " + b); + assertEquals(false, a.equals(b), a + " <=> " + b); } else if (i > j) { - assertEquals(a.compareTo(b) > 0, true, a + " <=> " + b); - assertEquals(a.equals(b), false, a + " <=> " + b); + assertEquals(true, a.compareTo(b) > 0, a + " <=> " + b); + assertEquals(false, a.equals(b), a + " <=> " + b); } else { - assertEquals(a.compareTo(b), 0, a + " <=> " + b); - assertEquals(a.equals(b), true, a + " <=> " + b); + assertEquals(0, a.compareTo(b), a + " <=> " + b); + assertEquals(true, a.equals(b), a + " <=> " + b); } } } diff --git a/test/jdk/java/time/test/java/time/TestInstant.java b/test/jdk/java/time/test/java/time/TestInstant.java index 8dbd951bde1..40f3138ac28 100644 --- a/test/jdk/java/time/test/java/time/TestInstant.java +++ b/test/jdk/java/time/test/java/time/TestInstant.java @@ -66,16 +66,18 @@ import java.time.ZoneOffset; import java.time.format.DateTimeParseException; import java.time.temporal.ChronoUnit; -import org.testng.annotations.Test; -import org.testng.annotations.DataProvider; -import static org.testng.Assert.assertEquals; -import static org.testng.Assert.assertThrows; +import static org.junit.jupiter.api.Assertions.assertEquals; +import static org.junit.jupiter.api.Assertions.assertThrows; +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 Instant. * @bug 8273369 8331202 8364752 */ -@Test +@TestInstance(TestInstance.Lifecycle.PER_CLASS) public class TestInstant extends AbstractTest { @Test @@ -83,7 +85,6 @@ public class TestInstant extends AbstractTest { assertImmutable(Instant.class); } - @DataProvider(name="sampleEpochMillis") private Object[][] provider_sampleEpochMillis() { return new Object[][] { {"Long.MAX_VALUE", Long.MAX_VALUE}, @@ -96,11 +97,12 @@ public class TestInstant extends AbstractTest { }; } - @Test(dataProvider="sampleEpochMillis") + @ParameterizedTest + @MethodSource("provider_sampleEpochMillis") public void test_epochMillis(String name, long millis) { Instant t1 = Instant.ofEpochMilli(millis); long m = t1.toEpochMilli(); - assertEquals(millis, m, name); + assertEquals(m, millis, name); } /** @@ -113,7 +115,7 @@ public class TestInstant extends AbstractTest { var nanoMax = Instant.EPOCH.plusNanos(Long.MAX_VALUE); var totalMicros = Instant.EPOCH.until(nanoMax, ChronoUnit.MICROS); var plusOneMicro = Instant.EPOCH.until(nanoMax.plusNanos(1000), ChronoUnit.MICROS); - assertEquals(plusOneMicro - totalMicros, 1L); + assertEquals(1L, plusOneMicro - totalMicros); } /** @@ -122,11 +124,10 @@ public class TestInstant extends AbstractTest { */ @Test public void test_millisUntil() { - assertEquals(Instant.MIN.until(Instant.MIN.plusSeconds(1), ChronoUnit.MILLIS), 1000L); - assertEquals(Instant.MAX.plusSeconds(-1).until(Instant.MAX, ChronoUnit.MILLIS), 1000L); + assertEquals(1000L, Instant.MIN.until(Instant.MIN.plusSeconds(1), ChronoUnit.MILLIS)); + assertEquals(1000L, Instant.MAX.plusSeconds(-1).until(Instant.MAX, ChronoUnit.MILLIS)); } - @DataProvider private Object[][] provider_until_1arg() { Instant t1 = Instant.ofEpochSecond(0, 10); Instant t2 = Instant.ofEpochSecond(10, -20); @@ -138,24 +139,22 @@ public class TestInstant extends AbstractTest { }; } - @Test(dataProvider = "provider_until_1arg") + @ParameterizedTest + @MethodSource("provider_until_1arg") public void test_until_1arg(Instant start, Instant end) { Duration result = start.until(end); Duration expected = Duration.ofSeconds(end.getEpochSecond() - start.getEpochSecond(), end.getNano() - start.getNano()); - assertEquals(result, expected); + assertEquals(expected, result); expected = Duration.between(start, end); - assertEquals(result, expected); + assertEquals(expected, result); } @Test public void test_until_1arg_NPE() { - assertThrows(NullPointerException.class, () -> { - Instant.now().until(null); - }); + assertThrows(NullPointerException.class, () -> Instant.now().until(null)); } - @DataProvider private Object[][] valid_instants() { var I1 = OffsetDateTime.of(2017, 1, 1, 0, 0, 0, 0, ZoneOffset.of("+02")).toInstant(); var I2 = OffsetDateTime.of(2017, 1, 1, 0, 0, 0, 0, ZoneOffset.of("+02:02")).toInstant(); @@ -178,12 +177,12 @@ public class TestInstant extends AbstractTest { }; } - @Test(dataProvider = "valid_instants") + @ParameterizedTest + @MethodSource("valid_instants") public void test_parse_valid(String instant, Instant expected) { - assertEquals(Instant.parse(instant), expected); + assertEquals(expected, Instant.parse(instant)); } - @DataProvider private Object[][] invalid_instants() { return new Object[][] { {"2017-01-01T00:00:00.000"}, @@ -204,7 +203,8 @@ public class TestInstant extends AbstractTest { }; } - @Test(dataProvider = "invalid_instants") + @ParameterizedTest + @MethodSource("invalid_instants") public void test_parse_invalid(String instant) { assertThrows(DateTimeParseException.class, () -> Instant.parse(instant)); } diff --git a/test/jdk/java/time/test/java/time/TestInstantSource.java b/test/jdk/java/time/test/java/time/TestInstantSource.java index 31fe7874e62..e0f70047718 100644 --- a/test/jdk/java/time/test/java/time/TestInstantSource.java +++ b/test/jdk/java/time/test/java/time/TestInstantSource.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2021, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2021, 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 @@ -23,9 +23,10 @@ package test.java.time; import static java.time.temporal.ChronoUnit.SECONDS; -import static org.testng.Assert.assertEquals; -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.assertSame; +import static org.junit.jupiter.api.Assertions.assertTrue; import java.time.Clock; import java.time.Duration; @@ -34,67 +35,70 @@ import java.time.InstantSource; import java.time.ZoneId; import java.time.ZoneOffset; -import org.testng.annotations.Test; +import org.junit.jupiter.api.Test; /** * Test instant source. */ -@Test public class TestInstantSource { private static final ZoneId PARIS = ZoneId.of("Europe/Paris"); + @Test public void test_system() { // main tests for Clock.currentInstant() are in TestClock_System var test = InstantSource.system(); assertSame(test.withZone(ZoneOffset.UTC), Clock.systemUTC()); - assertEquals(test.withZone(PARIS), Clock.system(PARIS)); + assertEquals(Clock.system(PARIS), test.withZone(PARIS)); var millis = System.currentTimeMillis(); var testMillis = test.millis(); var testInstantMillis = test.instant().toEpochMilli(); assertTrue(Math.abs(testMillis - millis) < 1000); assertTrue(Math.abs(testInstantMillis - millis) < 1000); assertSame(test, InstantSource.system()); - assertEquals(test.hashCode(), InstantSource.system().hashCode()); - assertEquals(test.toString(), "SystemInstantSource"); + assertEquals(InstantSource.system().hashCode(), test.hashCode()); + assertEquals("SystemInstantSource", test.toString()); } + @Test public void test_tick() { var millis = 257265861691L; var instant = Instant.ofEpochMilli(millis); var duration = Duration.ofSeconds(1); var test = InstantSource.tick(InstantSource.fixed(instant), duration); - assertEquals(test.withZone(ZoneOffset.UTC), Clock.tick(Clock.fixed(instant, ZoneOffset.UTC), duration)); - assertEquals(test.withZone(PARIS), Clock.tick(Clock.fixed(instant, PARIS), duration)); - assertEquals(test.millis(), (millis / 1000) * 1000); - assertEquals(test.instant(), instant.truncatedTo(SECONDS)); - assertEquals(test, InstantSource.tick(InstantSource.fixed(instant), duration)); - assertEquals(test.hashCode(), InstantSource.tick(InstantSource.fixed(instant), duration).hashCode()); + assertEquals(Clock.tick(Clock.fixed(instant, ZoneOffset.UTC), duration), test.withZone(ZoneOffset.UTC)); + assertEquals(Clock.tick(Clock.fixed(instant, PARIS), duration), test.withZone(PARIS)); + assertEquals((millis / 1000) * 1000, test.millis()); + assertEquals(instant.truncatedTo(SECONDS), test.instant()); + assertEquals(InstantSource.tick(InstantSource.fixed(instant), duration), test); + assertEquals(InstantSource.tick(InstantSource.fixed(instant), duration).hashCode(), test.hashCode()); } + @Test public void test_fixed() { var millis = 257265861691L; var instant = Instant.ofEpochMilli(millis); var test = InstantSource.fixed(instant); - assertEquals(test.withZone(ZoneOffset.UTC), Clock.fixed(instant, ZoneOffset.UTC)); - assertEquals(test.withZone(PARIS), Clock.fixed(instant, PARIS)); - assertEquals(test.millis(), millis); - assertEquals(test.instant(), instant); - assertEquals(test, InstantSource.fixed(instant)); - assertEquals(test.hashCode(), InstantSource.fixed(instant).hashCode()); + assertEquals(Clock.fixed(instant, ZoneOffset.UTC), test.withZone(ZoneOffset.UTC)); + assertEquals(Clock.fixed(instant, PARIS), test.withZone(PARIS)); + assertEquals(millis, test.millis()); + assertEquals(instant, test.instant()); + assertEquals(InstantSource.fixed(instant), test); + assertEquals(InstantSource.fixed(instant).hashCode(), test.hashCode()); } + @Test public void test_offset() { var millis = 257265861691L; var instant = Instant.ofEpochMilli(millis); var duration = Duration.ofSeconds(120); var test = InstantSource.offset(InstantSource.fixed(instant), duration); - assertEquals(test.withZone(ZoneOffset.UTC), Clock.offset(Clock.fixed(instant, ZoneOffset.UTC), duration)); - assertEquals(test.withZone(PARIS), Clock.offset(Clock.fixed(instant, PARIS), duration)); - assertEquals(test.millis(), millis + 120_000); - assertEquals(test.instant(), instant.plusSeconds(120)); - assertEquals(test, InstantSource.offset(InstantSource.fixed(instant), duration)); - assertEquals(test.hashCode(), InstantSource.offset(InstantSource.fixed(instant), duration).hashCode()); + assertEquals(Clock.offset(Clock.fixed(instant, ZoneOffset.UTC), duration), test.withZone(ZoneOffset.UTC)); + assertEquals(Clock.offset(Clock.fixed(instant, PARIS), duration), test.withZone(PARIS)); + assertEquals(millis + 120_000, test.millis()); + assertEquals(instant.plusSeconds(120), test.instant()); + assertEquals(InstantSource.offset(InstantSource.fixed(instant), duration), test); + assertEquals(InstantSource.offset(InstantSource.fixed(instant), duration).hashCode(), test.hashCode()); } static class MockInstantSource implements InstantSource { @@ -106,13 +110,14 @@ public class TestInstantSource { } } + @Test public void test_mock() { var test = new MockInstantSource(); - assertEquals(test.withZone(ZoneOffset.UTC).getZone(), ZoneOffset.UTC); - assertEquals(test.withZone(PARIS).getZone(), PARIS); - assertEquals(test.withZone(ZoneOffset.UTC).withZone(PARIS).getZone(), PARIS); - assertEquals(test.millis(), MockInstantSource.FIXED.toEpochMilli()); - assertEquals(test.instant(), MockInstantSource.FIXED); + assertEquals(ZoneOffset.UTC, test.withZone(ZoneOffset.UTC).getZone()); + assertEquals(PARIS, test.withZone(PARIS).getZone()); + assertEquals(PARIS, test.withZone(ZoneOffset.UTC).withZone(PARIS).getZone()); + assertEquals(MockInstantSource.FIXED.toEpochMilli(), test.millis()); + assertEquals(MockInstantSource.FIXED, test.instant()); assertEquals(test.withZone(ZoneOffset.UTC), test.withZone(ZoneOffset.UTC)); assertEquals(test.withZone(ZoneOffset.UTC).hashCode(), test.withZone(ZoneOffset.UTC).hashCode()); } diff --git a/test/jdk/java/time/test/java/time/TestLocalDate.java b/test/jdk/java/time/test/java/time/TestLocalDate.java index ef7a10ac687..b7f232665d0 100644 --- a/test/jdk/java/time/test/java/time/TestLocalDate.java +++ b/test/jdk/java/time/test/java/time/TestLocalDate.java @@ -60,10 +60,11 @@ package test.java.time; import static java.time.temporal.ChronoField.YEAR; -import static org.testng.Assert.assertEquals; -import static org.testng.Assert.assertSame; -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.assertSame; +import static org.junit.jupiter.api.Assertions.assertTrue; +import static org.junit.jupiter.api.Assertions.fail; import java.io.ObjectStreamClass; import java.io.ObjectStreamField; @@ -74,19 +75,21 @@ import java.time.temporal.ChronoField; import java.time.temporal.ChronoUnit; import java.time.temporal.IsoFields; -import org.testng.annotations.BeforeMethod; -import org.testng.annotations.DataProvider; -import org.testng.annotations.Test; +import org.junit.jupiter.api.BeforeEach; +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 LocalDate. */ -@Test +@TestInstance(TestInstance.Lifecycle.PER_CLASS) public class TestLocalDate extends AbstractTest { private LocalDate TEST_2007_07_15; - @BeforeMethod + @BeforeEach public void setUp() { TEST_2007_07_15 = LocalDate.of(2007, 7, 15); } @@ -180,7 +183,6 @@ public class TestLocalDate extends AbstractTest { //----------------------------------------------------------------------- // plusWeeks() //----------------------------------------------------------------------- - @DataProvider(name="samplePlusWeeksSymmetry") Object[][] provider_samplePlusWeeksSymmetry() { return new Object[][] { {LocalDate.of(-1, 1, 1)}, @@ -212,14 +214,15 @@ public class TestLocalDate extends AbstractTest { }; } - @Test(dataProvider="samplePlusWeeksSymmetry") + @ParameterizedTest + @MethodSource("provider_samplePlusWeeksSymmetry") public void test_plusWeeks_symmetry(LocalDate reference) { for (int weeks = 0; weeks < 365 * 8; weeks++) { LocalDate t = reference.plusWeeks(weeks).plusWeeks(-weeks); - assertEquals(t, reference); + assertEquals(reference, t); t = reference.plusWeeks(-weeks).plusWeeks(weeks); - assertEquals(t, reference); + assertEquals(reference, t); } } @@ -232,7 +235,6 @@ public class TestLocalDate extends AbstractTest { //----------------------------------------------------------------------- // plusDays() //----------------------------------------------------------------------- - @DataProvider(name="samplePlusDaysSymmetry") Object[][] provider_samplePlusDaysSymmetry() { return new Object[][] { {LocalDate.of(-1, 1, 1)}, @@ -264,14 +266,15 @@ public class TestLocalDate extends AbstractTest { }; } - @Test(dataProvider="samplePlusDaysSymmetry") + @ParameterizedTest + @MethodSource("provider_samplePlusDaysSymmetry") public void test_plusDays_symmetry(LocalDate reference) { for (int days = 0; days < 365 * 8; days++) { LocalDate t = reference.plusDays(days).plusDays(-days); - assertEquals(t, reference); + assertEquals(reference, t); t = reference.plusDays(-days).plusDays(days); - assertEquals(t, reference); + assertEquals(reference, t); } } @@ -308,7 +311,6 @@ public class TestLocalDate extends AbstractTest { //----------------------------------------------------------------------- // minusWeeks() //----------------------------------------------------------------------- - @DataProvider(name="sampleMinusWeeksSymmetry") Object[][] provider_sampleMinusWeeksSymmetry() { return new Object[][] { {LocalDate.of(-1, 1, 1)}, @@ -340,14 +342,15 @@ public class TestLocalDate extends AbstractTest { }; } - @Test(dataProvider="sampleMinusWeeksSymmetry") + @ParameterizedTest + @MethodSource("provider_sampleMinusWeeksSymmetry") public void test_minusWeeks_symmetry(LocalDate reference) { for (int weeks = 0; weeks < 365 * 8; weeks++) { LocalDate t = reference.minusWeeks(weeks).minusWeeks(-weeks); - assertEquals(t, reference); + assertEquals(reference, t); t = reference.minusWeeks(-weeks).minusWeeks(weeks); - assertEquals(t, reference); + assertEquals(reference, t); } } @@ -360,7 +363,6 @@ public class TestLocalDate extends AbstractTest { //----------------------------------------------------------------------- // minusDays() //----------------------------------------------------------------------- - @DataProvider(name="sampleMinusDaysSymmetry") Object[][] provider_sampleMinusDaysSymmetry() { return new Object[][] { {LocalDate.of(-1, 1, 1)}, @@ -392,14 +394,15 @@ public class TestLocalDate extends AbstractTest { }; } - @Test(dataProvider="sampleMinusDaysSymmetry") + @ParameterizedTest + @MethodSource("provider_sampleMinusDaysSymmetry") public void test_minusDays_symmetry(LocalDate reference) { for (int days = 0; days < 365 * 8; days++) { LocalDate t = reference.minusDays(days).minusDays(-days); - assertEquals(t, reference); + assertEquals(reference, t); t = reference.minusDays(-days).minusDays(days); - assertEquals(t, reference); + assertEquals(reference, t); } } @@ -415,12 +418,12 @@ public class TestLocalDate extends AbstractTest { LocalDate test = LocalDate.of(0, 1, 1); for (long i = date_0000_01_01; i < 700000; i++) { - assertEquals(LocalDate.ofEpochDay(test.toEpochDay()), test); + assertEquals(test, LocalDate.ofEpochDay(test.toEpochDay())); test = next(test); } test = LocalDate.of(0, 1, 1); for (long i = date_0000_01_01; i > -2000000; i--) { - assertEquals(LocalDate.ofEpochDay(test.toEpochDay()), test); + assertEquals(test, LocalDate.ofEpochDay(test.toEpochDay())); test = previous(test); } } @@ -434,11 +437,11 @@ public class TestLocalDate extends AbstractTest { int[] offsets = new int[] { 0, 1, 2, 3, 28, 29, 30, 31, 32, 363, 364, 365, 366, 367 }; for (int offset : offsets) { LocalDate minDate = LocalDate.ofEpochDay(minDay + offset); - assertEquals(minDate, LocalDate.MIN.plusDays(offset)); + assertEquals(LocalDate.MIN.plusDays(offset), minDate); assertTrue(ChronoField.YEAR.range().isValidValue(minDate.getYear())); LocalDate maxDate = LocalDate.ofEpochDay(maxDay - offset); - assertEquals(maxDate, LocalDate.MAX.minusDays(offset)); + assertEquals(LocalDate.MAX.minusDays(offset), maxDate); assertTrue(ChronoField.YEAR.range().isValidValue(maxDate.getYear())); try { @@ -463,25 +466,24 @@ public class TestLocalDate extends AbstractTest { LocalDate b = localDates[j]; if (i < j) { assertTrue(a.compareTo(b) < 0, a + " <=> " + b); - assertEquals(a.isBefore(b), true, a + " <=> " + b); - assertEquals(a.isAfter(b), false, a + " <=> " + b); - assertEquals(a.equals(b), false, a + " <=> " + b); + assertEquals(true, a.isBefore(b), a + " <=> " + b); + assertEquals(false, a.isAfter(b), a + " <=> " + b); + assertEquals(false, a.equals(b), a + " <=> " + b); } else if (i > j) { assertTrue(a.compareTo(b) > 0, a + " <=> " + b); - assertEquals(a.isBefore(b), false, a + " <=> " + b); - assertEquals(a.isAfter(b), true, a + " <=> " + b); - assertEquals(a.equals(b), false, a + " <=> " + b); + assertEquals(false, a.isBefore(b), a + " <=> " + b); + assertEquals(true, a.isAfter(b), a + " <=> " + b); + assertEquals(false, a.equals(b), a + " <=> " + b); } else { - assertEquals(a.compareTo(b), 0, a + " <=> " + b); - assertEquals(a.isBefore(b), false, a + " <=> " + b); - assertEquals(a.isAfter(b), false, a + " <=> " + b); - assertEquals(a.equals(b), true, a + " <=> " + b); + assertEquals(0, a.compareTo(b), a + " <=> " + b); + assertEquals(false, a.isBefore(b), a + " <=> " + b); + assertEquals(false, a.isAfter(b), a + " <=> " + b); + assertEquals(true, a.equals(b), a + " <=> " + b); } } } } - @DataProvider(name="quarterYearsToAdd") Object[][] provider_quarterYearsToAdd() { return new Object[][] { {Long.valueOf(-1000000000)}, @@ -496,7 +498,8 @@ public class TestLocalDate extends AbstractTest { }; } - @Test(dataProvider="quarterYearsToAdd") + @ParameterizedTest + @MethodSource("provider_quarterYearsToAdd") public void test_plus_QuarterYears(long quarterYears) { LocalDate t0 = TEST_2007_07_15 .plus(quarterYears, IsoFields.QUARTER_YEARS); @@ -504,10 +507,11 @@ public class TestLocalDate extends AbstractTest { .plus(quarterYears, ChronoUnit.MONTHS) .plus(quarterYears, ChronoUnit.MONTHS) .plus(quarterYears, ChronoUnit.MONTHS); - assertEquals(t0, t1); + assertEquals(t1, t0); } - @Test(dataProvider="quarterYearsToAdd") + @ParameterizedTest + @MethodSource("provider_quarterYearsToAdd") public void test_minus_QuarterYears(long quarterYears) { LocalDate t0 = TEST_2007_07_15 .minus(quarterYears, IsoFields.QUARTER_YEARS); @@ -515,7 +519,7 @@ public class TestLocalDate extends AbstractTest { .minus(quarterYears, ChronoUnit.MONTHS) .minus(quarterYears, ChronoUnit.MONTHS) .minus(quarterYears, ChronoUnit.MONTHS); - assertEquals(t0, t1); + assertEquals(t1, t0); } // Verify serialized fields types are backward compatible @@ -524,9 +528,9 @@ public class TestLocalDate extends AbstractTest { var osc = ObjectStreamClass.lookup(LocalDate.class); for (ObjectStreamField f : osc.getFields()) { switch (f.getName()) { - case "year" -> assertEquals(f.getType(), int.class, f.getName()); + case "year" -> assertEquals(int.class, f.getType(), f.getName()); case "month", - "day" -> assertEquals(f.getType(), short.class); + "day" -> assertEquals(short.class, f.getType()); default -> fail("unknown field in LocalDate: " + f.getName()); } } diff --git a/test/jdk/java/time/test/java/time/TestLocalDateTime.java b/test/jdk/java/time/test/java/time/TestLocalDateTime.java index 80469ed0621..fb53ec70ede 100644 --- a/test/jdk/java/time/test/java/time/TestLocalDateTime.java +++ b/test/jdk/java/time/test/java/time/TestLocalDateTime.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2012, 2013, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2012, 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 @@ -59,9 +59,9 @@ */ package test.java.time; -import static org.testng.Assert.assertEquals; -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.assertSame; +import static org.junit.jupiter.api.Assertions.assertTrue; import java.time.LocalDate; import java.time.LocalDateTime; @@ -69,13 +69,15 @@ import java.time.LocalTime; import java.time.Period; import java.time.temporal.ChronoUnit; -import org.testng.annotations.DataProvider; -import org.testng.annotations.Test; +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 LocalDateTime. */ -@Test +@TestInstance(TestInstance.Lifecycle.PER_CLASS) public class TestLocalDateTime extends AbstractTest { private LocalDateTime TEST_2007_07_15_12_30_40_987654321 = LocalDateTime.of(2007, 7, 15, 12, 30, 40, 987654321); @@ -87,7 +89,6 @@ public class TestLocalDateTime extends AbstractTest { } //----------------------------------------------------------------------- - @DataProvider(name="sampleDates") Object[][] provider_sampleDates() { return new Object[][] { {2008, 7, 5}, @@ -99,7 +100,6 @@ public class TestLocalDateTime extends AbstractTest { }; } - @DataProvider(name="sampleTimes") Object[][] provider_sampleTimes() { return new Object[][] { {0, 0, 0, 0}, @@ -444,7 +444,7 @@ public class TestLocalDateTime extends AbstractTest { @Test public void test_minusSeconds_noChange_oneDay() { LocalDateTime t = TEST_2007_07_15_12_30_40_987654321.minusSeconds(24 * 60 * 60); - assertEquals(t.toLocalDate(), TEST_2007_07_15_12_30_40_987654321.toLocalDate().minusDays(1)); + assertEquals(TEST_2007_07_15_12_30_40_987654321.toLocalDate().minusDays(1), t.toLocalDate()); assertSame(t.toLocalTime(), TEST_2007_07_15_12_30_40_987654321.toLocalTime()); } @@ -469,7 +469,7 @@ public class TestLocalDateTime extends AbstractTest { @Test public void test_minusNanos_noChange_oneDay() { LocalDateTime t = TEST_2007_07_15_12_30_40_987654321.minusNanos(24 * 60 * 60 * 1000000000L); - assertEquals(t.toLocalDate(), TEST_2007_07_15_12_30_40_987654321.toLocalDate().minusDays(1)); + assertEquals(TEST_2007_07_15_12_30_40_987654321.toLocalDate().minusDays(1), t.toLocalDate()); assertSame(t.toLocalTime(), TEST_2007_07_15_12_30_40_987654321.toLocalTime()); } @@ -488,7 +488,8 @@ public class TestLocalDateTime extends AbstractTest { //----------------------------------------------------------------------- // toLocalDate() //----------------------------------------------------------------------- - @Test(dataProvider="sampleDates") + @ParameterizedTest + @MethodSource("provider_sampleDates") public void test_getDate(int year, int month, int day) { LocalDate d = LocalDate.of(year, month, day); LocalDateTime dt = LocalDateTime.of(d, LocalTime.MIDNIGHT); @@ -498,7 +499,8 @@ public class TestLocalDateTime extends AbstractTest { //----------------------------------------------------------------------- // toLocalTime() //----------------------------------------------------------------------- - @Test(dataProvider="sampleTimes") + @ParameterizedTest + @MethodSource("provider_sampleTimes") public void test_getTime(int h, int m, int s, int ns) { LocalTime t = LocalTime.of(h, m, s, ns); LocalDateTime dt = LocalDateTime.of(LocalDate.of(2011, 7, 30), t); @@ -549,19 +551,19 @@ public class TestLocalDateTime extends AbstractTest { LocalDateTime b = localDateTimes[j]; if (i < j) { assertTrue(a.compareTo(b) < 0, a + " <=> " + b); - assertEquals(a.isBefore(b), true, a + " <=> " + b); - assertEquals(a.isAfter(b), false, a + " <=> " + b); - assertEquals(a.equals(b), false, a + " <=> " + b); + assertEquals(true, a.isBefore(b), a + " <=> " + b); + assertEquals(false, a.isAfter(b), a + " <=> " + b); + assertEquals(false, a.equals(b), a + " <=> " + b); } else if (i > j) { assertTrue(a.compareTo(b) > 0, a + " <=> " + b); - assertEquals(a.isBefore(b), false, a + " <=> " + b); - assertEquals(a.isAfter(b), true, a + " <=> " + b); - assertEquals(a.equals(b), false, a + " <=> " + b); + assertEquals(false, a.isBefore(b), a + " <=> " + b); + assertEquals(true, a.isAfter(b), a + " <=> " + b); + assertEquals(false, a.equals(b), a + " <=> " + b); } else { - assertEquals(a.compareTo(b), 0, a + " <=> " + b); - assertEquals(a.isBefore(b), false, a + " <=> " + b); - assertEquals(a.isAfter(b), false, a + " <=> " + b); - assertEquals(a.equals(b), true, a + " <=> " + b); + assertEquals(0, a.compareTo(b), a + " <=> " + b); + assertEquals(false, a.isBefore(b), a + " <=> " + b); + assertEquals(false, a.isAfter(b), a + " <=> " + b); + assertEquals(true, a.equals(b), a + " <=> " + b); } } } diff --git a/test/jdk/java/time/test/java/time/TestLocalTime.java b/test/jdk/java/time/test/java/time/TestLocalTime.java index 8e25a85f198..24a456683fd 100644 --- a/test/jdk/java/time/test/java/time/TestLocalTime.java +++ b/test/jdk/java/time/test/java/time/TestLocalTime.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2012, 2013, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2012, 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 @@ -59,19 +59,18 @@ */ package test.java.time; -import static org.testng.Assert.assertEquals; -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.assertSame; +import static org.junit.jupiter.api.Assertions.assertTrue; import java.time.Clock; import java.time.LocalTime; -import org.testng.annotations.Test; +import org.junit.jupiter.api.Test; /** * Test LocalTime. */ -@Test public class TestLocalTime extends AbstractTest { static final long NANOS_PER_SECOND = 1_000_000_000L; static final long NANOS_PER_MINUTE = 60 * NANOS_PER_SECOND; @@ -85,10 +84,10 @@ public class TestLocalTime extends AbstractTest { //----------------------------------------------------------------------- private void check(LocalTime time, int h, int m, int s, int n) { - assertEquals(time.getHour(), h); - assertEquals(time.getMinute(), m); - assertEquals(time.getSecond(), s); - assertEquals(time.getNano(), n); + assertEquals(h, time.getHour()); + assertEquals(m, time.getMinute()); + assertEquals(s, time.getSecond()); + assertEquals(n, time.getNano()); } //----------------------------------------------------------------------- @@ -184,8 +183,8 @@ public class TestLocalTime extends AbstractTest { //----------------------------------------------------------------------- // now() //----------------------------------------------------------------------- - @Test @SuppressWarnings("unused") + @Test public void now() { // Warmup the TimeZone data so the following test does not include // one-time initialization diff --git a/test/jdk/java/time/test/java/time/TestMonthDay.java b/test/jdk/java/time/test/java/time/TestMonthDay.java index 311a40030c1..a5195387d2b 100644 --- a/test/jdk/java/time/test/java/time/TestMonthDay.java +++ b/test/jdk/java/time/test/java/time/TestMonthDay.java @@ -59,10 +59,10 @@ */ package test.java.time; -import static org.testng.Assert.assertEquals; -import static org.testng.Assert.assertSame; -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.assertSame; +import static org.junit.jupiter.api.Assertions.assertTrue; +import static org.junit.jupiter.api.Assertions.fail; import java.io.ObjectStreamClass; import java.io.ObjectStreamField; @@ -70,18 +70,17 @@ import java.time.LocalDate; import java.time.Month; import java.time.MonthDay; -import org.testng.annotations.BeforeMethod; -import org.testng.annotations.Test; +import org.junit.jupiter.api.BeforeEach; +import org.junit.jupiter.api.Test; /** * Test MonthDay. */ -@Test public class TestMonthDay extends AbstractTest { private MonthDay TEST_07_15; - @BeforeMethod + @BeforeEach public void setUp() { TEST_07_15 = MonthDay.of(7, 15); } @@ -94,8 +93,8 @@ public class TestMonthDay extends AbstractTest { //----------------------------------------------------------------------- void check(MonthDay test, int m, int d) { - assertEquals(test.getMonth().getValue(), m); - assertEquals(test.getDayOfMonth(), d); + assertEquals(m, test.getMonth().getValue()); + assertEquals(d, test.getDayOfMonth()); } @Test @@ -129,19 +128,19 @@ public class TestMonthDay extends AbstractTest { MonthDay b = localDates[j]; if (i < j) { assertTrue(a.compareTo(b) < 0, a + " <=> " + b); - assertEquals(a.isBefore(b), true, a + " <=> " + b); - assertEquals(a.isAfter(b), false, a + " <=> " + b); - assertEquals(a.equals(b), false, a + " <=> " + b); + assertEquals(true, a.isBefore(b), a + " <=> " + b); + assertEquals(false, a.isAfter(b), a + " <=> " + b); + assertEquals(false, a.equals(b), a + " <=> " + b); } else if (i > j) { assertTrue(a.compareTo(b) > 0, a + " <=> " + b); - assertEquals(a.isBefore(b), false, a + " <=> " + b); - assertEquals(a.isAfter(b), true, a + " <=> " + b); - assertEquals(a.equals(b), false, a + " <=> " + b); + assertEquals(false, a.isBefore(b), a + " <=> " + b); + assertEquals(true, a.isAfter(b), a + " <=> " + b); + assertEquals(false, a.equals(b), a + " <=> " + b); } else { - assertEquals(a.compareTo(b), 0, a + " <=> " + b); - assertEquals(a.isBefore(b), false, a + " <=> " + b); - assertEquals(a.isAfter(b), false, a + " <=> " + b); - assertEquals(a.equals(b), true, a + " <=> " + b); + assertEquals(0, a.compareTo(b), a + " <=> " + b); + assertEquals(false, a.isBefore(b), a + " <=> " + b); + assertEquals(false, a.isAfter(b), a + " <=> " + b); + assertEquals(true, a.equals(b), a + " <=> " + b); } } } @@ -155,7 +154,7 @@ public class TestMonthDay extends AbstractTest { for (ObjectStreamField f : osc.getFields()) { switch (f.getName()) { case "month", - "day" -> assertEquals(f.getType(), int.class, f.getName()); + "day" -> assertEquals(int.class, f.getType(), f.getName()); default -> fail("unknown field in MonthDay: " + f.getName()); } } diff --git a/test/jdk/java/time/test/java/time/TestOffsetDateTime.java b/test/jdk/java/time/test/java/time/TestOffsetDateTime.java index bd145fa9663..3caf4d13c88 100644 --- a/test/jdk/java/time/test/java/time/TestOffsetDateTime.java +++ b/test/jdk/java/time/test/java/time/TestOffsetDateTime.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2012, 2019, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2012, 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 @@ -59,8 +59,8 @@ */ package test.java.time; -import static org.testng.Assert.assertSame; -import static org.testng.Assert.assertEquals; +import static org.junit.jupiter.api.Assertions.assertSame; +import static org.junit.jupiter.api.Assertions.assertEquals; import java.time.Duration; import java.time.LocalDate; @@ -69,23 +69,25 @@ import java.time.LocalTime; import java.time.OffsetDateTime; import java.time.ZoneOffset; -import org.testng.annotations.BeforeMethod; -import org.testng.annotations.DataProvider; -import org.testng.annotations.Test; +import org.junit.jupiter.api.BeforeEach; +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 OffsetDateTime. * * @bug 8211990 */ -@Test +@TestInstance(TestInstance.Lifecycle.PER_CLASS) public class TestOffsetDateTime extends AbstractTest { private static final ZoneOffset OFFSET_PONE = ZoneOffset.ofHours(1); private static final ZoneOffset OFFSET_PTWO = ZoneOffset.ofHours(2); private OffsetDateTime TEST_2008_6_30_11_30_59_000000500; - @BeforeMethod + @BeforeEach public void setUp() { TEST_2008_6_30_11_30_59_000000500 = OffsetDateTime.of(LocalDate.of(2008, 6, 30), LocalTime.of(11, 30, 59, 500), OFFSET_PONE); } @@ -98,7 +100,6 @@ public class TestOffsetDateTime extends AbstractTest { //----------------------------------------------------------------------- // basics //----------------------------------------------------------------------- - @DataProvider(name="sampleTimes") Object[][] provider_sampleTimes() { return new Object[][] { {2008, 6, 30, 11, 30, 20, 500, OFFSET_PONE}, @@ -108,7 +109,8 @@ public class TestOffsetDateTime extends AbstractTest { }; } - @Test(dataProvider="sampleTimes") + @ParameterizedTest + @MethodSource("provider_sampleTimes") public void test_get_same(int y, int o, int d, int h, int m, int s, int n, ZoneOffset offset) { LocalDate localDate = LocalDate.of(y, o, d); LocalTime localTime = LocalTime.of(h, m, s, n); @@ -329,6 +331,6 @@ public class TestOffsetDateTime extends AbstractTest { OffsetDateTime start = OffsetDateTime.MAX .withOffsetSameLocal(ZoneOffset.ofHours(-17)); OffsetDateTime end = OffsetDateTime.MAX; - assertEquals(Duration.between(start, end), Duration.ofHours(1)); + assertEquals(Duration.ofHours(1), Duration.between(start, end)); } } diff --git a/test/jdk/java/time/test/java/time/TestOffsetDateTime_instants.java b/test/jdk/java/time/test/java/time/TestOffsetDateTime_instants.java index 28b32ba2811..9131a7b02b6 100644 --- a/test/jdk/java/time/test/java/time/TestOffsetDateTime_instants.java +++ b/test/jdk/java/time/test/java/time/TestOffsetDateTime_instants.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2012, 2013, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2012, 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 @@ -59,7 +59,7 @@ */ package test.java.time; -import static org.testng.Assert.assertEquals; +import static org.junit.jupiter.api.Assertions.assertEquals; import java.time.DateTimeException; import java.time.Instant; @@ -70,12 +70,12 @@ import java.time.OffsetDateTime; import java.time.Year; import java.time.ZoneOffset; -import org.testng.annotations.Test; +import org.junit.jupiter.api.Assertions; +import org.junit.jupiter.api.Test; /** * Test OffsetDateTime creation. */ -@Test public class TestOffsetDateTime_instants { private static final ZoneOffset OFFSET_PONE = ZoneOffset.ofHours(1); @@ -83,148 +83,167 @@ public class TestOffsetDateTime_instants { private static final ZoneOffset OFFSET_MIN = ZoneOffset.ofHours(-18); //----------------------------------------------------------------------- - @Test(expectedExceptions=NullPointerException.class) + @Test public void factory_ofInstant_nullInstant() { - OffsetDateTime.ofInstant((Instant) null, OFFSET_PONE); + Assertions.assertThrows(NullPointerException.class, () -> OffsetDateTime.ofInstant((Instant) null, OFFSET_PONE)); } - @Test(expectedExceptions=NullPointerException.class) + @Test public void factory_ofInstant_nullOffset() { - Instant instant = Instant.ofEpochSecond(0L); - OffsetDateTime.ofInstant(instant, (ZoneOffset) null); + Assertions.assertThrows(NullPointerException.class, () -> { + Instant instant = Instant.ofEpochSecond(0L); + OffsetDateTime.ofInstant(instant, (ZoneOffset) null); + }); } + @Test public void factory_ofInstant_allSecsInDay() { for (int i = 0; i < (24 * 60 * 60); i++) { Instant instant = Instant.ofEpochSecond(i); OffsetDateTime test = OffsetDateTime.ofInstant(instant, OFFSET_PONE); - assertEquals(test.getYear(), 1970); - assertEquals(test.getMonth(), Month.JANUARY); - assertEquals(test.getDayOfMonth(), 1 + (i >= 23 * 60 * 60 ? 1 : 0)); - assertEquals(test.getHour(), ((i / (60 * 60)) + 1) % 24); - assertEquals(test.getMinute(), (i / 60) % 60); - assertEquals(test.getSecond(), i % 60); + assertEquals(1970, test.getYear()); + assertEquals(Month.JANUARY, test.getMonth()); + assertEquals(1 + (i >= 23 * 60 * 60 ? 1 : 0), test.getDayOfMonth()); + assertEquals(((i / (60 * 60)) + 1) % 24, test.getHour()); + assertEquals((i / 60) % 60, test.getMinute()); + assertEquals(i % 60, test.getSecond()); } } + @Test public void factory_ofInstant_allDaysInCycle() { // sanity check using different algorithm OffsetDateTime expected = OffsetDateTime.of(LocalDate.of(1970, 1, 1), LocalTime.of(0, 0, 0, 0), ZoneOffset.UTC); for (long i = 0; i < 146097; i++) { Instant instant = Instant.ofEpochSecond(i * 24L * 60L * 60L); OffsetDateTime test = OffsetDateTime.ofInstant(instant, ZoneOffset.UTC); - assertEquals(test, expected); + assertEquals(expected, test); expected = expected.plusDays(1); } } + @Test public void factory_ofInstant_history() { doTest_factory_ofInstant_all(-2820, 2820); } //----------------------------------------------------------------------- + @Test public void factory_ofInstant_minYear() { doTest_factory_ofInstant_all(Year.MIN_VALUE, Year.MIN_VALUE + 420); } - @Test(expectedExceptions=DateTimeException.class) + @Test public void factory_ofInstant_tooLow() { - long days_0000_to_1970 = (146097 * 5) - (30 * 365 + 7); - int year = Year.MIN_VALUE - 1; - long days = (year * 365L + (year / 4 - year / 100 + year / 400)) - days_0000_to_1970; - Instant instant = Instant.ofEpochSecond(days * 24L * 60L * 60L); - OffsetDateTime.ofInstant(instant, ZoneOffset.UTC); + Assertions.assertThrows(DateTimeException.class, () -> { + long days_0000_to_1970 = (146097 * 5) - (30 * 365 + 7); + int year = Year.MIN_VALUE - 1; + long days = (year * 365L + (year / 4 - year / 100 + year / 400)) - days_0000_to_1970; + Instant instant = Instant.ofEpochSecond(days * 24L * 60L * 60L); + OffsetDateTime.ofInstant(instant, ZoneOffset.UTC); + }); } + @Test public void factory_ofInstant_maxYear() { doTest_factory_ofInstant_all(Year.MAX_VALUE - 420, Year.MAX_VALUE); } - @Test(expectedExceptions=DateTimeException.class) + @Test public void factory_ofInstant_tooBig() { - long days_0000_to_1970 = (146097 * 5) - (30 * 365 + 7); - long year = Year.MAX_VALUE + 1L; - long days = (year * 365L + (year / 4 - year / 100 + year / 400)) - days_0000_to_1970; - Instant instant = Instant.ofEpochSecond(days * 24L * 60L * 60L); - OffsetDateTime.ofInstant(instant, ZoneOffset.UTC); + Assertions.assertThrows(DateTimeException.class, () -> { + long days_0000_to_1970 = (146097 * 5) - (30 * 365 + 7); + long year = Year.MAX_VALUE + 1L; + long days = (year * 365L + (year / 4 - year / 100 + year / 400)) - days_0000_to_1970; + Instant instant = Instant.ofEpochSecond(days * 24L * 60L * 60L); + OffsetDateTime.ofInstant(instant, ZoneOffset.UTC); + }); } //----------------------------------------------------------------------- + @Test public void factory_ofInstant_minWithMinOffset() { long days_0000_to_1970 = (146097 * 5) - (30 * 365 + 7); int year = Year.MIN_VALUE; long days = (year * 365L + (year / 4 - year / 100 + year / 400)) - days_0000_to_1970; Instant instant = Instant.ofEpochSecond(days * 24L * 60L * 60L - OFFSET_MIN.getTotalSeconds()); OffsetDateTime test = OffsetDateTime.ofInstant(instant, OFFSET_MIN); - assertEquals(test.getYear(), Year.MIN_VALUE); - assertEquals(test.getMonth().getValue(), 1); - assertEquals(test.getDayOfMonth(), 1); - assertEquals(test.getOffset(), OFFSET_MIN); - assertEquals(test.getHour(), 0); - assertEquals(test.getMinute(), 0); - assertEquals(test.getSecond(), 0); - assertEquals(test.getNano(), 0); + assertEquals(Year.MIN_VALUE, test.getYear()); + assertEquals(1, test.getMonth().getValue()); + assertEquals(1, test.getDayOfMonth()); + assertEquals(OFFSET_MIN, test.getOffset()); + assertEquals(0, test.getHour()); + assertEquals(0, test.getMinute()); + assertEquals(0, test.getSecond()); + assertEquals(0, test.getNano()); } + @Test public void factory_ofInstant_minWithMaxOffset() { long days_0000_to_1970 = (146097 * 5) - (30 * 365 + 7); int year = Year.MIN_VALUE; long days = (year * 365L + (year / 4 - year / 100 + year / 400)) - days_0000_to_1970; Instant instant = Instant.ofEpochSecond(days * 24L * 60L * 60L - OFFSET_MAX.getTotalSeconds()); OffsetDateTime test = OffsetDateTime.ofInstant(instant, OFFSET_MAX); - assertEquals(test.getYear(), Year.MIN_VALUE); - assertEquals(test.getMonth().getValue(), 1); - assertEquals(test.getDayOfMonth(), 1); - assertEquals(test.getOffset(), OFFSET_MAX); - assertEquals(test.getHour(), 0); - assertEquals(test.getMinute(), 0); - assertEquals(test.getSecond(), 0); - assertEquals(test.getNano(), 0); + assertEquals(Year.MIN_VALUE, test.getYear()); + assertEquals(1, test.getMonth().getValue()); + assertEquals(1, test.getDayOfMonth()); + assertEquals(OFFSET_MAX, test.getOffset()); + assertEquals(0, test.getHour()); + assertEquals(0, test.getMinute()); + assertEquals(0, test.getSecond()); + assertEquals(0, test.getNano()); } + @Test public void factory_ofInstant_maxWithMinOffset() { long days_0000_to_1970 = (146097 * 5) - (30 * 365 + 7); int year = Year.MAX_VALUE; long days = (year * 365L + (year / 4 - year / 100 + year / 400)) + 365 - days_0000_to_1970; Instant instant = Instant.ofEpochSecond((days + 1) * 24L * 60L * 60L - 1 - OFFSET_MIN.getTotalSeconds()); OffsetDateTime test = OffsetDateTime.ofInstant(instant, OFFSET_MIN); - assertEquals(test.getYear(), Year.MAX_VALUE); - assertEquals(test.getMonth().getValue(), 12); - assertEquals(test.getDayOfMonth(), 31); - assertEquals(test.getOffset(), OFFSET_MIN); - assertEquals(test.getHour(), 23); - assertEquals(test.getMinute(), 59); - assertEquals(test.getSecond(), 59); - assertEquals(test.getNano(), 0); + assertEquals(Year.MAX_VALUE, test.getYear()); + assertEquals(12, test.getMonth().getValue()); + assertEquals(31, test.getDayOfMonth()); + assertEquals(OFFSET_MIN, test.getOffset()); + assertEquals(23, test.getHour()); + assertEquals(59, test.getMinute()); + assertEquals(59, test.getSecond()); + assertEquals(0, test.getNano()); } + @Test public void factory_ofInstant_maxWithMaxOffset() { long days_0000_to_1970 = (146097 * 5) - (30 * 365 + 7); int year = Year.MAX_VALUE; long days = (year * 365L + (year / 4 - year / 100 + year / 400)) + 365 - days_0000_to_1970; Instant instant = Instant.ofEpochSecond((days + 1) * 24L * 60L * 60L - 1 - OFFSET_MAX.getTotalSeconds()); OffsetDateTime test = OffsetDateTime.ofInstant(instant, OFFSET_MAX); - assertEquals(test.getYear(), Year.MAX_VALUE); - assertEquals(test.getMonth().getValue(), 12); - assertEquals(test.getDayOfMonth(), 31); - assertEquals(test.getOffset(), OFFSET_MAX); - assertEquals(test.getHour(), 23); - assertEquals(test.getMinute(), 59); - assertEquals(test.getSecond(), 59); - assertEquals(test.getNano(), 0); + assertEquals(Year.MAX_VALUE, test.getYear()); + assertEquals(12, test.getMonth().getValue()); + assertEquals(31, test.getDayOfMonth()); + assertEquals(OFFSET_MAX, test.getOffset()); + assertEquals(23, test.getHour()); + assertEquals(59, test.getMinute()); + assertEquals(59, test.getSecond()); + assertEquals(0, test.getNano()); } //----------------------------------------------------------------------- - @Test(expectedExceptions=DateTimeException.class) + @Test public void factory_ofInstant_maxInstantWithMaxOffset() { - Instant instant = Instant.ofEpochSecond(Long.MAX_VALUE); - OffsetDateTime.ofInstant(instant, OFFSET_MAX); + Assertions.assertThrows(DateTimeException.class, () -> { + Instant instant = Instant.ofEpochSecond(Long.MAX_VALUE); + OffsetDateTime.ofInstant(instant, OFFSET_MAX); + }); } - @Test(expectedExceptions=DateTimeException.class) + @Test public void factory_ofInstant_maxInstantWithMinOffset() { - Instant instant = Instant.ofEpochSecond(Long.MAX_VALUE); - OffsetDateTime.ofInstant(instant, OFFSET_MIN); + Assertions.assertThrows(DateTimeException.class, () -> { + Instant instant = Instant.ofEpochSecond(Long.MAX_VALUE); + OffsetDateTime.ofInstant(instant, OFFSET_MIN); + }); } //----------------------------------------------------------------------- @@ -241,7 +260,7 @@ public class TestOffsetDateTime_instants { Instant instant = Instant.ofEpochSecond(i * 24L * 60L * 60L); try { OffsetDateTime test = OffsetDateTime.ofInstant(instant, ZoneOffset.UTC); - assertEquals(test, expected); + assertEquals(expected, test); if (expected.toLocalDate().equals(maxDate) == false) { expected = expected.plusDays(1); } @@ -282,65 +301,75 @@ public class TestOffsetDateTime_instants { // } //----------------------------------------------------------------------- + @Test public void test_toInstant_19700101() { OffsetDateTime dt = OffsetDateTime.of(LocalDate.of(1970, 1, 1), LocalTime.of(0, 0, 0, 0), ZoneOffset.UTC); Instant test = dt.toInstant(); - assertEquals(test.getEpochSecond(), 0); - assertEquals(test.getNano(), 0); + assertEquals(0, test.getEpochSecond()); + assertEquals(0, test.getNano()); } + @Test public void test_toInstant_19700101_oneNano() { OffsetDateTime dt = OffsetDateTime.of(LocalDate.of(1970, 1, 1), LocalTime.of(0, 0, 0, 1), ZoneOffset.UTC); Instant test = dt.toInstant(); - assertEquals(test.getEpochSecond(), 0); - assertEquals(test.getNano(), 1); + assertEquals(0, test.getEpochSecond()); + assertEquals(1, test.getNano()); } + @Test public void test_toInstant_19700101_minusOneNano() { OffsetDateTime dt = OffsetDateTime.of(LocalDate.of(1969, 12, 31), LocalTime.of(23, 59, 59, 999999999), ZoneOffset.UTC); Instant test = dt.toInstant(); - assertEquals(test.getEpochSecond(), -1); - assertEquals(test.getNano(), 999999999); + assertEquals(-1, test.getEpochSecond()); + assertEquals(999999999, test.getNano()); } + @Test public void test_toInstant_19700102() { OffsetDateTime dt = OffsetDateTime.of(LocalDate.of(1970, 1, 2), LocalTime.of(0, 0, 0, 0), ZoneOffset.UTC); Instant test = dt.toInstant(); - assertEquals(test.getEpochSecond(), 24L * 60L * 60L); - assertEquals(test.getNano(), 0); + assertEquals(24L * 60L * 60L, test.getEpochSecond()); + assertEquals(0, test.getNano()); } + @Test public void test_toInstant_19691231() { OffsetDateTime dt = OffsetDateTime.of(LocalDate.of(1969, 12, 31), LocalTime.of(0, 0, 0, 0), ZoneOffset.UTC); Instant test = dt.toInstant(); - assertEquals(test.getEpochSecond(), -24L * 60L * 60L); - assertEquals(test.getNano(), 0); + assertEquals(-24L * 60L * 60L, test.getEpochSecond()); + assertEquals(0, test.getNano()); } //----------------------------------------------------------------------- + @Test public void test_toEpochSecond_19700101() { OffsetDateTime dt = OffsetDateTime.of(LocalDate.of(1970, 1, 1), LocalTime.of(0, 0, 0, 0), ZoneOffset.UTC); - assertEquals(dt.toEpochSecond(), 0); + assertEquals(0, dt.toEpochSecond()); } + @Test public void test_toEpochSecond_19700101_oneNano() { OffsetDateTime dt = OffsetDateTime.of(LocalDate.of(1970, 1, 1), LocalTime.of( 0, 0, 0, 1), ZoneOffset.UTC); - assertEquals(dt.toEpochSecond(), 0); + assertEquals(0, dt.toEpochSecond()); } + @Test public void test_toEpochSecond_19700101_minusOneNano() { OffsetDateTime dt = OffsetDateTime.of(LocalDate.of(1969, 12, 31), LocalTime.of(23, 59, 59, 999999999), ZoneOffset.UTC); - assertEquals(dt.toEpochSecond(), -1); + assertEquals(-1, dt.toEpochSecond()); } + @Test public void test_toEpochSecond_19700102() { OffsetDateTime dt = OffsetDateTime.of(LocalDate.of(1970, 1, 2), LocalTime.of(0, 0, 0, 0), ZoneOffset.UTC); - assertEquals(dt.toEpochSecond(), 24L * 60L * 60L); + assertEquals(24L * 60L * 60L, dt.toEpochSecond()); } + @Test public void test_toEpochSecond_19691231() { OffsetDateTime dt = OffsetDateTime.of(LocalDate.of(1969, 12, 31), LocalTime.of(0, 0, 0, 0), ZoneOffset.UTC); - assertEquals(dt.toEpochSecond(), -24L * 60L * 60L); + assertEquals(-24L * 60L * 60L, dt.toEpochSecond()); } } diff --git a/test/jdk/java/time/test/java/time/TestOffsetTime.java b/test/jdk/java/time/test/java/time/TestOffsetTime.java index 41116a7c964..ce3a73aa987 100644 --- a/test/jdk/java/time/test/java/time/TestOffsetTime.java +++ b/test/jdk/java/time/test/java/time/TestOffsetTime.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2012, 2013, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2012, 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 @@ -61,12 +61,11 @@ package test.java.time; import java.time.OffsetTime; -import org.testng.annotations.Test; +import org.junit.jupiter.api.Test; /** * Test OffsetTime. */ -@Test public class TestOffsetTime extends AbstractTest { @Test diff --git a/test/jdk/java/time/test/java/time/TestPeriod.java b/test/jdk/java/time/test/java/time/TestPeriod.java index 2c6d4030d84..a74fbf4c8d2 100644 --- a/test/jdk/java/time/test/java/time/TestPeriod.java +++ b/test/jdk/java/time/test/java/time/TestPeriod.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2012, 2013, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2012, 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 @@ -59,17 +59,16 @@ */ package test.java.time; -import static org.testng.Assert.assertEquals; -import static org.testng.Assert.assertSame; +import static org.junit.jupiter.api.Assertions.assertEquals; +import static org.junit.jupiter.api.Assertions.assertSame; import java.time.Period; -import org.testng.annotations.Test; +import org.junit.jupiter.api.Test; /** * Test. */ -@Test public class TestPeriod extends AbstractTest { @Test @@ -98,10 +97,10 @@ public class TestPeriod extends AbstractTest { Period test6 = Period.ofDays(6); Period test5M = Period.ofMonths(5); Period test5Y = Period.ofYears(5); - assertEquals(test5.hashCode() == test5.hashCode(), true); - assertEquals(test5.hashCode() == test6.hashCode(), false); - assertEquals(test5.hashCode() == test5M.hashCode(), false); - assertEquals(test5.hashCode() == test5Y.hashCode(), false); + assertEquals(true, test5.hashCode() == test5.hashCode()); + assertEquals(false, test5.hashCode() == test6.hashCode()); + assertEquals(false, test5.hashCode() == test5M.hashCode()); + assertEquals(false, test5.hashCode() == test5Y.hashCode()); } } diff --git a/test/jdk/java/time/test/java/time/TestYear.java b/test/jdk/java/time/test/java/time/TestYear.java index 71791ab5fa7..ddb82d91b26 100644 --- a/test/jdk/java/time/test/java/time/TestYear.java +++ b/test/jdk/java/time/test/java/time/TestYear.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2012, 2013, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2012, 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 @@ -61,12 +61,11 @@ package test.java.time; import java.time.Year; -import org.testng.annotations.Test; +import org.junit.jupiter.api.Test; /** * Test Year. */ -@Test public class TestYear extends AbstractTest { @Test diff --git a/test/jdk/java/time/test/java/time/TestYearMonth.java b/test/jdk/java/time/test/java/time/TestYearMonth.java index 0552994b8c2..51202c902f9 100644 --- a/test/jdk/java/time/test/java/time/TestYearMonth.java +++ b/test/jdk/java/time/test/java/time/TestYearMonth.java @@ -64,15 +64,13 @@ import java.io.ObjectStreamField; import java.time.LocalDate; import java.time.YearMonth; -import org.testng.annotations.Test; - -import static org.testng.Assert.assertEquals; -import static org.testng.Assert.fail; +import static org.junit.jupiter.api.Assertions.assertEquals; +import static org.junit.jupiter.api.Assertions.fail; +import org.junit.jupiter.api.Test; /** * Test YearMonth. */ -@Test public class TestYearMonth extends AbstractTest { //----------------------------------------------------------------------- @@ -87,8 +85,8 @@ public class TestYearMonth extends AbstractTest { var osc = ObjectStreamClass.lookup(YearMonth.class); for (ObjectStreamField f : osc.getFields()) { switch (f.getName()) { - case "year" -> assertEquals(f.getType(), int.class, f.getName()); - case "month" -> assertEquals(f.getType(), int.class, f.getName()); + case "year" -> assertEquals(int.class, f.getType(), f.getName()); + case "month" -> assertEquals(int.class, f.getType(), f.getName()); default -> fail("unknown field in YearMonth: " + f.getName()); } } diff --git a/test/jdk/java/time/test/java/time/TestZoneId.java b/test/jdk/java/time/test/java/time/TestZoneId.java index df2bbbc519e..fa8727560af 100644 --- a/test/jdk/java/time/test/java/time/TestZoneId.java +++ b/test/jdk/java/time/test/java/time/TestZoneId.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2012, 2013, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2012, 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 @@ -59,10 +59,10 @@ */ package test.java.time; -import static org.testng.Assert.assertEquals; -import static org.testng.Assert.assertFalse; -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.assertFalse; +import static org.junit.jupiter.api.Assertions.assertNotNull; +import static org.junit.jupiter.api.Assertions.assertTrue; import java.lang.reflect.Field; import java.lang.reflect.Modifier; @@ -81,12 +81,12 @@ import java.util.Locale; import java.util.SimpleTimeZone; import java.util.TimeZone; -import org.testng.annotations.Test; +import org.junit.jupiter.api.Assertions; +import org.junit.jupiter.api.Test; /** * Test ZoneId. */ -@Test public class TestZoneId extends AbstractTest { private static final int OVERLAP = 2; @@ -95,6 +95,7 @@ public class TestZoneId extends AbstractTest { //----------------------------------------------------------------------- // Basics //----------------------------------------------------------------------- + @Test public void test_immutable() { // cannot use standard test as ZoneId is abstract Class cls = ZoneId.class; @@ -112,100 +113,111 @@ public class TestZoneId extends AbstractTest { //----------------------------------------------------------------------- // UTC //----------------------------------------------------------------------- + @Test public void test_constant_UTC() { ZoneId test = ZoneOffset.UTC; - assertEquals(test.getId(), "Z"); - assertEquals(test.getDisplayName(TextStyle.FULL, Locale.UK), "Z"); - assertEquals(test.getRules().isFixedOffset(), true); - assertEquals(test.getRules().getOffset(Instant.ofEpochSecond(0L)), ZoneOffset.UTC); + assertEquals("Z", test.getId()); + assertEquals("Z", test.getDisplayName(TextStyle.FULL, Locale.UK)); + assertEquals(true, test.getRules().isFixedOffset()); + assertEquals(ZoneOffset.UTC, test.getRules().getOffset(Instant.ofEpochSecond(0L))); checkOffset(test.getRules(), createLDT(2008, 6, 30), ZoneOffset.UTC, 1); } //----------------------------------------------------------------------- // system default //----------------------------------------------------------------------- + @Test public void test_systemDefault() { ZoneId test = ZoneId.systemDefault(); - assertEquals(test.getId(), TimeZone.getDefault().getID()); + assertEquals(TimeZone.getDefault().getID(), test.getId()); } - @Test(expectedExceptions = DateTimeException.class) + @Test public void test_systemDefault_unableToConvert_badFormat() { - TimeZone current = TimeZone.getDefault(); - try { - TimeZone.setDefault(new SimpleTimeZone(127, "Something Weird")); - ZoneId.systemDefault(); - } finally { - TimeZone.setDefault(current); - } + Assertions.assertThrows(DateTimeException.class, () -> { + TimeZone current = TimeZone.getDefault(); + try { + TimeZone.setDefault(new SimpleTimeZone(127, "Something Weird")); + ZoneId.systemDefault(); + } finally { + TimeZone.setDefault(current); + } + }); } - @Test(expectedExceptions = ZoneRulesException.class) + @Test public void test_systemDefault_unableToConvert_unknownId() { - TimeZone current = TimeZone.getDefault(); - try { - TimeZone.setDefault(new SimpleTimeZone(127, "SomethingWeird")); - ZoneId.systemDefault(); - } finally { - TimeZone.setDefault(current); - } + Assertions.assertThrows(ZoneRulesException.class, () -> { + TimeZone current = TimeZone.getDefault(); + try { + TimeZone.setDefault(new SimpleTimeZone(127, "SomethingWeird")); + ZoneId.systemDefault(); + } finally { + TimeZone.setDefault(current); + } + }); } //----------------------------------------------------------------------- // Europe/London //----------------------------------------------------------------------- + @Test public void test_London() { ZoneId test = ZoneId.of("Europe/London"); - assertEquals(test.getId(), "Europe/London"); - assertEquals(test.getRules().isFixedOffset(), false); + assertEquals("Europe/London", test.getId()); + assertEquals(false, test.getRules().isFixedOffset()); } + @Test public void test_London_getOffset() { ZoneId test = ZoneId.of("Europe/London"); - assertEquals(test.getRules().getOffset(createInstant(2008, 1, 1, ZoneOffset.UTC)), ZoneOffset.ofHours(0)); - assertEquals(test.getRules().getOffset(createInstant(2008, 2, 1, ZoneOffset.UTC)), ZoneOffset.ofHours(0)); - assertEquals(test.getRules().getOffset(createInstant(2008, 3, 1, ZoneOffset.UTC)), ZoneOffset.ofHours(0)); - assertEquals(test.getRules().getOffset(createInstant(2008, 4, 1, ZoneOffset.UTC)), ZoneOffset.ofHours(1)); - assertEquals(test.getRules().getOffset(createInstant(2008, 5, 1, ZoneOffset.UTC)), ZoneOffset.ofHours(1)); - assertEquals(test.getRules().getOffset(createInstant(2008, 6, 1, ZoneOffset.UTC)), ZoneOffset.ofHours(1)); - assertEquals(test.getRules().getOffset(createInstant(2008, 7, 1, ZoneOffset.UTC)), ZoneOffset.ofHours(1)); - assertEquals(test.getRules().getOffset(createInstant(2008, 8, 1, ZoneOffset.UTC)), ZoneOffset.ofHours(1)); - assertEquals(test.getRules().getOffset(createInstant(2008, 9, 1, ZoneOffset.UTC)), ZoneOffset.ofHours(1)); - assertEquals(test.getRules().getOffset(createInstant(2008, 10, 1, ZoneOffset.UTC)), ZoneOffset.ofHours(1)); - assertEquals(test.getRules().getOffset(createInstant(2008, 11, 1, ZoneOffset.UTC)), ZoneOffset.ofHours(0)); - assertEquals(test.getRules().getOffset(createInstant(2008, 12, 1, ZoneOffset.UTC)), ZoneOffset.ofHours(0)); + assertEquals(ZoneOffset.ofHours(0), test.getRules().getOffset(createInstant(2008, 1, 1, ZoneOffset.UTC))); + assertEquals(ZoneOffset.ofHours(0), test.getRules().getOffset(createInstant(2008, 2, 1, ZoneOffset.UTC))); + assertEquals(ZoneOffset.ofHours(0), test.getRules().getOffset(createInstant(2008, 3, 1, ZoneOffset.UTC))); + assertEquals(ZoneOffset.ofHours(1), test.getRules().getOffset(createInstant(2008, 4, 1, ZoneOffset.UTC))); + assertEquals(ZoneOffset.ofHours(1), test.getRules().getOffset(createInstant(2008, 5, 1, ZoneOffset.UTC))); + assertEquals(ZoneOffset.ofHours(1), test.getRules().getOffset(createInstant(2008, 6, 1, ZoneOffset.UTC))); + assertEquals(ZoneOffset.ofHours(1), test.getRules().getOffset(createInstant(2008, 7, 1, ZoneOffset.UTC))); + assertEquals(ZoneOffset.ofHours(1), test.getRules().getOffset(createInstant(2008, 8, 1, ZoneOffset.UTC))); + assertEquals(ZoneOffset.ofHours(1), test.getRules().getOffset(createInstant(2008, 9, 1, ZoneOffset.UTC))); + assertEquals(ZoneOffset.ofHours(1), test.getRules().getOffset(createInstant(2008, 10, 1, ZoneOffset.UTC))); + assertEquals(ZoneOffset.ofHours(0), test.getRules().getOffset(createInstant(2008, 11, 1, ZoneOffset.UTC))); + assertEquals(ZoneOffset.ofHours(0), test.getRules().getOffset(createInstant(2008, 12, 1, ZoneOffset.UTC))); } + @Test public void test_London_getOffset_toDST() { ZoneId test = ZoneId.of("Europe/London"); - assertEquals(test.getRules().getOffset(createInstant(2008, 3, 24, ZoneOffset.UTC)), ZoneOffset.ofHours(0)); - assertEquals(test.getRules().getOffset(createInstant(2008, 3, 25, ZoneOffset.UTC)), ZoneOffset.ofHours(0)); - assertEquals(test.getRules().getOffset(createInstant(2008, 3, 26, ZoneOffset.UTC)), ZoneOffset.ofHours(0)); - assertEquals(test.getRules().getOffset(createInstant(2008, 3, 27, ZoneOffset.UTC)), ZoneOffset.ofHours(0)); - assertEquals(test.getRules().getOffset(createInstant(2008, 3, 28, ZoneOffset.UTC)), ZoneOffset.ofHours(0)); - assertEquals(test.getRules().getOffset(createInstant(2008, 3, 29, ZoneOffset.UTC)), ZoneOffset.ofHours(0)); - assertEquals(test.getRules().getOffset(createInstant(2008, 3, 30, ZoneOffset.UTC)), ZoneOffset.ofHours(0)); - assertEquals(test.getRules().getOffset(createInstant(2008, 3, 31, ZoneOffset.UTC)), ZoneOffset.ofHours(1)); + assertEquals(ZoneOffset.ofHours(0), test.getRules().getOffset(createInstant(2008, 3, 24, ZoneOffset.UTC))); + assertEquals(ZoneOffset.ofHours(0), test.getRules().getOffset(createInstant(2008, 3, 25, ZoneOffset.UTC))); + assertEquals(ZoneOffset.ofHours(0), test.getRules().getOffset(createInstant(2008, 3, 26, ZoneOffset.UTC))); + assertEquals(ZoneOffset.ofHours(0), test.getRules().getOffset(createInstant(2008, 3, 27, ZoneOffset.UTC))); + assertEquals(ZoneOffset.ofHours(0), test.getRules().getOffset(createInstant(2008, 3, 28, ZoneOffset.UTC))); + assertEquals(ZoneOffset.ofHours(0), test.getRules().getOffset(createInstant(2008, 3, 29, ZoneOffset.UTC))); + assertEquals(ZoneOffset.ofHours(0), test.getRules().getOffset(createInstant(2008, 3, 30, ZoneOffset.UTC))); + assertEquals(ZoneOffset.ofHours(1), test.getRules().getOffset(createInstant(2008, 3, 31, ZoneOffset.UTC))); // cutover at 01:00Z - assertEquals(test.getRules().getOffset(createInstant(2008, 3, 30, 0, 59, 59, 999999999, ZoneOffset.UTC)), ZoneOffset.ofHours(0)); - assertEquals(test.getRules().getOffset(createInstant(2008, 3, 30, 1, 0, 0, 0, ZoneOffset.UTC)), ZoneOffset.ofHours(1)); + assertEquals(ZoneOffset.ofHours(0), test.getRules().getOffset(createInstant(2008, 3, 30, 0, 59, 59, 999999999, ZoneOffset.UTC))); + assertEquals(ZoneOffset.ofHours(1), test.getRules().getOffset(createInstant(2008, 3, 30, 1, 0, 0, 0, ZoneOffset.UTC))); } + @Test public void test_London_getOffset_fromDST() { ZoneId test = ZoneId.of("Europe/London"); - assertEquals(test.getRules().getOffset(createInstant(2008, 10, 24, ZoneOffset.UTC)), ZoneOffset.ofHours(1)); - assertEquals(test.getRules().getOffset(createInstant(2008, 10, 25, ZoneOffset.UTC)), ZoneOffset.ofHours(1)); - assertEquals(test.getRules().getOffset(createInstant(2008, 10, 26, ZoneOffset.UTC)), ZoneOffset.ofHours(1)); - assertEquals(test.getRules().getOffset(createInstant(2008, 10, 27, ZoneOffset.UTC)), ZoneOffset.ofHours(0)); - assertEquals(test.getRules().getOffset(createInstant(2008, 10, 28, ZoneOffset.UTC)), ZoneOffset.ofHours(0)); - assertEquals(test.getRules().getOffset(createInstant(2008, 10, 29, ZoneOffset.UTC)), ZoneOffset.ofHours(0)); - assertEquals(test.getRules().getOffset(createInstant(2008, 10, 30, ZoneOffset.UTC)), ZoneOffset.ofHours(0)); - assertEquals(test.getRules().getOffset(createInstant(2008, 10, 31, ZoneOffset.UTC)), ZoneOffset.ofHours(0)); + assertEquals(ZoneOffset.ofHours(1), test.getRules().getOffset(createInstant(2008, 10, 24, ZoneOffset.UTC))); + assertEquals(ZoneOffset.ofHours(1), test.getRules().getOffset(createInstant(2008, 10, 25, ZoneOffset.UTC))); + assertEquals(ZoneOffset.ofHours(1), test.getRules().getOffset(createInstant(2008, 10, 26, ZoneOffset.UTC))); + assertEquals(ZoneOffset.ofHours(0), test.getRules().getOffset(createInstant(2008, 10, 27, ZoneOffset.UTC))); + assertEquals(ZoneOffset.ofHours(0), test.getRules().getOffset(createInstant(2008, 10, 28, ZoneOffset.UTC))); + assertEquals(ZoneOffset.ofHours(0), test.getRules().getOffset(createInstant(2008, 10, 29, ZoneOffset.UTC))); + assertEquals(ZoneOffset.ofHours(0), test.getRules().getOffset(createInstant(2008, 10, 30, ZoneOffset.UTC))); + assertEquals(ZoneOffset.ofHours(0), test.getRules().getOffset(createInstant(2008, 10, 31, ZoneOffset.UTC))); // cutover at 01:00Z - assertEquals(test.getRules().getOffset(createInstant(2008, 10, 26, 0, 59, 59, 999999999, ZoneOffset.UTC)), ZoneOffset.ofHours(1)); - assertEquals(test.getRules().getOffset(createInstant(2008, 10, 26, 1, 0, 0, 0, ZoneOffset.UTC)), ZoneOffset.ofHours(0)); + assertEquals(ZoneOffset.ofHours(1), test.getRules().getOffset(createInstant(2008, 10, 26, 0, 59, 59, 999999999, ZoneOffset.UTC))); + assertEquals(ZoneOffset.ofHours(0), test.getRules().getOffset(createInstant(2008, 10, 26, 1, 0, 0, 0, ZoneOffset.UTC))); } + @Test public void test_London_getOffsetInfo() { ZoneId test = ZoneId.of("Europe/London"); checkOffset(test.getRules(), createLDT(2008, 1, 1), ZoneOffset.ofHours(0), 1); @@ -222,6 +234,7 @@ public class TestZoneId extends AbstractTest { checkOffset(test.getRules(), createLDT(2008, 12, 1), ZoneOffset.ofHours(0), 1); } + @Test public void test_London_getOffsetInfo_toDST() { ZoneId test = ZoneId.of("Europe/London"); checkOffset(test.getRules(), createLDT(2008, 3, 24), ZoneOffset.ofHours(0), 1); @@ -238,6 +251,7 @@ public class TestZoneId extends AbstractTest { checkOffset(test.getRules(), LocalDateTime.of(2008, 3, 30, 2, 0, 0, 0), ZoneOffset.ofHours(1), 1); } + @Test public void test_London_getOffsetInfo_fromDST() { ZoneId test = ZoneId.of("Europe/London"); checkOffset(test.getRules(), createLDT(2008, 10, 24), ZoneOffset.ofHours(1), 1); @@ -254,22 +268,23 @@ public class TestZoneId extends AbstractTest { checkOffset(test.getRules(), LocalDateTime.of(2008, 10, 26, 2, 0, 0, 0), ZoneOffset.ofHours(0), 1); } + @Test public void test_London_getOffsetInfo_gap() { ZoneId test = ZoneId.of("Europe/London"); final LocalDateTime dateTime = LocalDateTime.of(2008, 3, 30, 1, 0, 0, 0); ZoneOffsetTransition trans = checkOffset(test.getRules(), dateTime, ZoneOffset.ofHours(0), GAP); - assertEquals(trans.isGap(), true); - assertEquals(trans.isOverlap(), false); - assertEquals(trans.getOffsetBefore(), ZoneOffset.ofHours(0)); - assertEquals(trans.getOffsetAfter(), ZoneOffset.ofHours(1)); - assertEquals(trans.getInstant(), dateTime.toInstant(ZoneOffset.UTC)); - assertEquals(trans.getDateTimeBefore(), LocalDateTime.of(2008, 3, 30, 1, 0)); - assertEquals(trans.getDateTimeAfter(), LocalDateTime.of(2008, 3, 30, 2, 0)); - assertEquals(trans.isValidOffset(ZoneOffset.ofHours(-1)), false); - assertEquals(trans.isValidOffset(ZoneOffset.ofHours(0)), false); - assertEquals(trans.isValidOffset(ZoneOffset.ofHours(1)), false); - assertEquals(trans.isValidOffset(ZoneOffset.ofHours(2)), false); - assertEquals(trans.toString(), "Transition[Gap at 2008-03-30T01:00Z to +01:00]"); + assertEquals(true, trans.isGap()); + assertEquals(false, trans.isOverlap()); + assertEquals(ZoneOffset.ofHours(0), trans.getOffsetBefore()); + assertEquals(ZoneOffset.ofHours(1), trans.getOffsetAfter()); + assertEquals(dateTime.toInstant(ZoneOffset.UTC), trans.getInstant()); + assertEquals(LocalDateTime.of(2008, 3, 30, 1, 0), trans.getDateTimeBefore()); + assertEquals(LocalDateTime.of(2008, 3, 30, 2, 0), trans.getDateTimeAfter()); + assertEquals(false, trans.isValidOffset(ZoneOffset.ofHours(-1))); + assertEquals(false, trans.isValidOffset(ZoneOffset.ofHours(0))); + assertEquals(false, trans.isValidOffset(ZoneOffset.ofHours(1))); + assertEquals(false, trans.isValidOffset(ZoneOffset.ofHours(2))); + assertEquals("Transition[Gap at 2008-03-30T01:00Z to +01:00]", trans.toString()); assertFalse(trans.equals(null)); assertFalse(trans.equals(ZoneOffset.ofHours(0))); @@ -277,25 +292,26 @@ public class TestZoneId extends AbstractTest { final ZoneOffsetTransition otherTrans = test.getRules().getTransition(dateTime); assertTrue(trans.equals(otherTrans)); - assertEquals(trans.hashCode(), otherTrans.hashCode()); + assertEquals(otherTrans.hashCode(), trans.hashCode()); } + @Test public void test_London_getOffsetInfo_overlap() { ZoneId test = ZoneId.of("Europe/London"); final LocalDateTime dateTime = LocalDateTime.of(2008, 10, 26, 1, 0, 0, 0); ZoneOffsetTransition trans = checkOffset(test.getRules(), dateTime, ZoneOffset.ofHours(1), OVERLAP); - assertEquals(trans.isGap(), false); - assertEquals(trans.isOverlap(), true); - assertEquals(trans.getOffsetBefore(), ZoneOffset.ofHours(1)); - assertEquals(trans.getOffsetAfter(), ZoneOffset.ofHours(0)); - assertEquals(trans.getInstant(), dateTime.toInstant(ZoneOffset.UTC)); - assertEquals(trans.getDateTimeBefore(), LocalDateTime.of(2008, 10, 26, 2, 0)); - assertEquals(trans.getDateTimeAfter(), LocalDateTime.of(2008, 10, 26, 1, 0)); - assertEquals(trans.isValidOffset(ZoneOffset.ofHours(-1)), false); - assertEquals(trans.isValidOffset(ZoneOffset.ofHours(0)), true); - assertEquals(trans.isValidOffset(ZoneOffset.ofHours(1)), true); - assertEquals(trans.isValidOffset(ZoneOffset.ofHours(2)), false); - assertEquals(trans.toString(), "Transition[Overlap at 2008-10-26T02:00+01:00 to Z]"); + assertEquals(false, trans.isGap()); + assertEquals(true, trans.isOverlap()); + assertEquals(ZoneOffset.ofHours(1), trans.getOffsetBefore()); + assertEquals(ZoneOffset.ofHours(0), trans.getOffsetAfter()); + assertEquals(dateTime.toInstant(ZoneOffset.UTC), trans.getInstant()); + assertEquals(LocalDateTime.of(2008, 10, 26, 2, 0), trans.getDateTimeBefore()); + assertEquals(LocalDateTime.of(2008, 10, 26, 1, 0), trans.getDateTimeAfter()); + assertEquals(false, trans.isValidOffset(ZoneOffset.ofHours(-1))); + assertEquals(true, trans.isValidOffset(ZoneOffset.ofHours(0))); + assertEquals(true, trans.isValidOffset(ZoneOffset.ofHours(1))); + assertEquals(false, trans.isValidOffset(ZoneOffset.ofHours(2))); + assertEquals("Transition[Overlap at 2008-10-26T02:00+01:00 to Z]", trans.toString()); assertFalse(trans.equals(null)); assertFalse(trans.equals(ZoneOffset.ofHours(1))); @@ -303,64 +319,69 @@ public class TestZoneId extends AbstractTest { final ZoneOffsetTransition otherTrans = test.getRules().getTransition(dateTime); assertTrue(trans.equals(otherTrans)); - assertEquals(trans.hashCode(), otherTrans.hashCode()); + assertEquals(otherTrans.hashCode(), trans.hashCode()); } //----------------------------------------------------------------------- // Europe/Paris //----------------------------------------------------------------------- + @Test public void test_Paris() { ZoneId test = ZoneId.of("Europe/Paris"); - assertEquals(test.getId(), "Europe/Paris"); - assertEquals(test.getRules().isFixedOffset(), false); + assertEquals("Europe/Paris", test.getId()); + assertEquals(false, test.getRules().isFixedOffset()); } + @Test public void test_Paris_getOffset() { ZoneId test = ZoneId.of("Europe/Paris"); - assertEquals(test.getRules().getOffset(createInstant(2008, 1, 1, ZoneOffset.UTC)), ZoneOffset.ofHours(1)); - assertEquals(test.getRules().getOffset(createInstant(2008, 2, 1, ZoneOffset.UTC)), ZoneOffset.ofHours(1)); - assertEquals(test.getRules().getOffset(createInstant(2008, 3, 1, ZoneOffset.UTC)), ZoneOffset.ofHours(1)); - assertEquals(test.getRules().getOffset(createInstant(2008, 4, 1, ZoneOffset.UTC)), ZoneOffset.ofHours(2)); - assertEquals(test.getRules().getOffset(createInstant(2008, 5, 1, ZoneOffset.UTC)), ZoneOffset.ofHours(2)); - assertEquals(test.getRules().getOffset(createInstant(2008, 6, 1, ZoneOffset.UTC)), ZoneOffset.ofHours(2)); - assertEquals(test.getRules().getOffset(createInstant(2008, 7, 1, ZoneOffset.UTC)), ZoneOffset.ofHours(2)); - assertEquals(test.getRules().getOffset(createInstant(2008, 8, 1, ZoneOffset.UTC)), ZoneOffset.ofHours(2)); - assertEquals(test.getRules().getOffset(createInstant(2008, 9, 1, ZoneOffset.UTC)), ZoneOffset.ofHours(2)); - assertEquals(test.getRules().getOffset(createInstant(2008, 10, 1, ZoneOffset.UTC)), ZoneOffset.ofHours(2)); - assertEquals(test.getRules().getOffset(createInstant(2008, 11, 1, ZoneOffset.UTC)), ZoneOffset.ofHours(1)); - assertEquals(test.getRules().getOffset(createInstant(2008, 12, 1, ZoneOffset.UTC)), ZoneOffset.ofHours(1)); + assertEquals(ZoneOffset.ofHours(1), test.getRules().getOffset(createInstant(2008, 1, 1, ZoneOffset.UTC))); + assertEquals(ZoneOffset.ofHours(1), test.getRules().getOffset(createInstant(2008, 2, 1, ZoneOffset.UTC))); + assertEquals(ZoneOffset.ofHours(1), test.getRules().getOffset(createInstant(2008, 3, 1, ZoneOffset.UTC))); + assertEquals(ZoneOffset.ofHours(2), test.getRules().getOffset(createInstant(2008, 4, 1, ZoneOffset.UTC))); + assertEquals(ZoneOffset.ofHours(2), test.getRules().getOffset(createInstant(2008, 5, 1, ZoneOffset.UTC))); + assertEquals(ZoneOffset.ofHours(2), test.getRules().getOffset(createInstant(2008, 6, 1, ZoneOffset.UTC))); + assertEquals(ZoneOffset.ofHours(2), test.getRules().getOffset(createInstant(2008, 7, 1, ZoneOffset.UTC))); + assertEquals(ZoneOffset.ofHours(2), test.getRules().getOffset(createInstant(2008, 8, 1, ZoneOffset.UTC))); + assertEquals(ZoneOffset.ofHours(2), test.getRules().getOffset(createInstant(2008, 9, 1, ZoneOffset.UTC))); + assertEquals(ZoneOffset.ofHours(2), test.getRules().getOffset(createInstant(2008, 10, 1, ZoneOffset.UTC))); + assertEquals(ZoneOffset.ofHours(1), test.getRules().getOffset(createInstant(2008, 11, 1, ZoneOffset.UTC))); + assertEquals(ZoneOffset.ofHours(1), test.getRules().getOffset(createInstant(2008, 12, 1, ZoneOffset.UTC))); } + @Test public void test_Paris_getOffset_toDST() { ZoneId test = ZoneId.of("Europe/Paris"); - assertEquals(test.getRules().getOffset(createInstant(2008, 3, 24, ZoneOffset.UTC)), ZoneOffset.ofHours(1)); - assertEquals(test.getRules().getOffset(createInstant(2008, 3, 25, ZoneOffset.UTC)), ZoneOffset.ofHours(1)); - assertEquals(test.getRules().getOffset(createInstant(2008, 3, 26, ZoneOffset.UTC)), ZoneOffset.ofHours(1)); - assertEquals(test.getRules().getOffset(createInstant(2008, 3, 27, ZoneOffset.UTC)), ZoneOffset.ofHours(1)); - assertEquals(test.getRules().getOffset(createInstant(2008, 3, 28, ZoneOffset.UTC)), ZoneOffset.ofHours(1)); - assertEquals(test.getRules().getOffset(createInstant(2008, 3, 29, ZoneOffset.UTC)), ZoneOffset.ofHours(1)); - assertEquals(test.getRules().getOffset(createInstant(2008, 3, 30, ZoneOffset.UTC)), ZoneOffset.ofHours(1)); - assertEquals(test.getRules().getOffset(createInstant(2008, 3, 31, ZoneOffset.UTC)), ZoneOffset.ofHours(2)); + assertEquals(ZoneOffset.ofHours(1), test.getRules().getOffset(createInstant(2008, 3, 24, ZoneOffset.UTC))); + assertEquals(ZoneOffset.ofHours(1), test.getRules().getOffset(createInstant(2008, 3, 25, ZoneOffset.UTC))); + assertEquals(ZoneOffset.ofHours(1), test.getRules().getOffset(createInstant(2008, 3, 26, ZoneOffset.UTC))); + assertEquals(ZoneOffset.ofHours(1), test.getRules().getOffset(createInstant(2008, 3, 27, ZoneOffset.UTC))); + assertEquals(ZoneOffset.ofHours(1), test.getRules().getOffset(createInstant(2008, 3, 28, ZoneOffset.UTC))); + assertEquals(ZoneOffset.ofHours(1), test.getRules().getOffset(createInstant(2008, 3, 29, ZoneOffset.UTC))); + assertEquals(ZoneOffset.ofHours(1), test.getRules().getOffset(createInstant(2008, 3, 30, ZoneOffset.UTC))); + assertEquals(ZoneOffset.ofHours(2), test.getRules().getOffset(createInstant(2008, 3, 31, ZoneOffset.UTC))); // cutover at 01:00Z - assertEquals(test.getRules().getOffset(createInstant(2008, 3, 30, 0, 59, 59, 999999999, ZoneOffset.UTC)), ZoneOffset.ofHours(1)); - assertEquals(test.getRules().getOffset(createInstant(2008, 3, 30, 1, 0, 0, 0, ZoneOffset.UTC)), ZoneOffset.ofHours(2)); + assertEquals(ZoneOffset.ofHours(1), test.getRules().getOffset(createInstant(2008, 3, 30, 0, 59, 59, 999999999, ZoneOffset.UTC))); + assertEquals(ZoneOffset.ofHours(2), test.getRules().getOffset(createInstant(2008, 3, 30, 1, 0, 0, 0, ZoneOffset.UTC))); } + @Test public void test_Paris_getOffset_fromDST() { ZoneId test = ZoneId.of("Europe/Paris"); - assertEquals(test.getRules().getOffset(createInstant(2008, 10, 24, ZoneOffset.UTC)), ZoneOffset.ofHours(2)); - assertEquals(test.getRules().getOffset(createInstant(2008, 10, 25, ZoneOffset.UTC)), ZoneOffset.ofHours(2)); - assertEquals(test.getRules().getOffset(createInstant(2008, 10, 26, ZoneOffset.UTC)), ZoneOffset.ofHours(2)); - assertEquals(test.getRules().getOffset(createInstant(2008, 10, 27, ZoneOffset.UTC)), ZoneOffset.ofHours(1)); - assertEquals(test.getRules().getOffset(createInstant(2008, 10, 28, ZoneOffset.UTC)), ZoneOffset.ofHours(1)); - assertEquals(test.getRules().getOffset(createInstant(2008, 10, 29, ZoneOffset.UTC)), ZoneOffset.ofHours(1)); - assertEquals(test.getRules().getOffset(createInstant(2008, 10, 30, ZoneOffset.UTC)), ZoneOffset.ofHours(1)); - assertEquals(test.getRules().getOffset(createInstant(2008, 10, 31, ZoneOffset.UTC)), ZoneOffset.ofHours(1)); + assertEquals(ZoneOffset.ofHours(2), test.getRules().getOffset(createInstant(2008, 10, 24, ZoneOffset.UTC))); + assertEquals(ZoneOffset.ofHours(2), test.getRules().getOffset(createInstant(2008, 10, 25, ZoneOffset.UTC))); + assertEquals(ZoneOffset.ofHours(2), test.getRules().getOffset(createInstant(2008, 10, 26, ZoneOffset.UTC))); + assertEquals(ZoneOffset.ofHours(1), test.getRules().getOffset(createInstant(2008, 10, 27, ZoneOffset.UTC))); + assertEquals(ZoneOffset.ofHours(1), test.getRules().getOffset(createInstant(2008, 10, 28, ZoneOffset.UTC))); + assertEquals(ZoneOffset.ofHours(1), test.getRules().getOffset(createInstant(2008, 10, 29, ZoneOffset.UTC))); + assertEquals(ZoneOffset.ofHours(1), test.getRules().getOffset(createInstant(2008, 10, 30, ZoneOffset.UTC))); + assertEquals(ZoneOffset.ofHours(1), test.getRules().getOffset(createInstant(2008, 10, 31, ZoneOffset.UTC))); // cutover at 01:00Z - assertEquals(test.getRules().getOffset(createInstant(2008, 10, 26, 0, 59, 59, 999999999, ZoneOffset.UTC)), ZoneOffset.ofHours(2)); - assertEquals(test.getRules().getOffset(createInstant(2008, 10, 26, 1, 0, 0, 0, ZoneOffset.UTC)), ZoneOffset.ofHours(1)); + assertEquals(ZoneOffset.ofHours(2), test.getRules().getOffset(createInstant(2008, 10, 26, 0, 59, 59, 999999999, ZoneOffset.UTC))); + assertEquals(ZoneOffset.ofHours(1), test.getRules().getOffset(createInstant(2008, 10, 26, 1, 0, 0, 0, ZoneOffset.UTC))); } + @Test public void test_Paris_getOffsetInfo() { ZoneId test = ZoneId.of("Europe/Paris"); checkOffset(test.getRules(), createLDT(2008, 1, 1), ZoneOffset.ofHours(1), 1); @@ -377,6 +398,7 @@ public class TestZoneId extends AbstractTest { checkOffset(test.getRules(), createLDT(2008, 12, 1), ZoneOffset.ofHours(1), 1); } + @Test public void test_Paris_getOffsetInfo_toDST() { ZoneId test = ZoneId.of("Europe/Paris"); checkOffset(test.getRules(), createLDT(2008, 3, 24), ZoneOffset.ofHours(1), 1); @@ -393,6 +415,7 @@ public class TestZoneId extends AbstractTest { checkOffset(test.getRules(), LocalDateTime.of(2008, 3, 30, 3, 0, 0, 0), ZoneOffset.ofHours(2), 1); } + @Test public void test_Paris_getOffsetInfo_fromDST() { ZoneId test = ZoneId.of("Europe/Paris"); checkOffset(test.getRules(), createLDT(2008, 10, 24), ZoneOffset.ofHours(2), 1); @@ -409,20 +432,21 @@ public class TestZoneId extends AbstractTest { checkOffset(test.getRules(), LocalDateTime.of(2008, 10, 26, 3, 0, 0, 0), ZoneOffset.ofHours(1), 1); } + @Test public void test_Paris_getOffsetInfo_gap() { ZoneId test = ZoneId.of("Europe/Paris"); final LocalDateTime dateTime = LocalDateTime.of(2008, 3, 30, 2, 0, 0, 0); ZoneOffsetTransition trans = checkOffset(test.getRules(), dateTime, ZoneOffset.ofHours(1), GAP); - assertEquals(trans.isGap(), true); - assertEquals(trans.isOverlap(), false); - assertEquals(trans.getOffsetBefore(), ZoneOffset.ofHours(1)); - assertEquals(trans.getOffsetAfter(), ZoneOffset.ofHours(2)); - assertEquals(trans.getInstant(), createInstant(2008, 3, 30, 1, 0, 0, 0, ZoneOffset.UTC)); - assertEquals(trans.isValidOffset(ZoneOffset.ofHours(0)), false); - assertEquals(trans.isValidOffset(ZoneOffset.ofHours(1)), false); - assertEquals(trans.isValidOffset(ZoneOffset.ofHours(2)), false); - assertEquals(trans.isValidOffset(ZoneOffset.ofHours(3)), false); - assertEquals(trans.toString(), "Transition[Gap at 2008-03-30T02:00+01:00 to +02:00]"); + assertEquals(true, trans.isGap()); + assertEquals(false, trans.isOverlap()); + assertEquals(ZoneOffset.ofHours(1), trans.getOffsetBefore()); + assertEquals(ZoneOffset.ofHours(2), trans.getOffsetAfter()); + assertEquals(createInstant(2008, 3, 30, 1, 0, 0, 0, ZoneOffset.UTC), trans.getInstant()); + assertEquals(false, trans.isValidOffset(ZoneOffset.ofHours(0))); + assertEquals(false, trans.isValidOffset(ZoneOffset.ofHours(1))); + assertEquals(false, trans.isValidOffset(ZoneOffset.ofHours(2))); + assertEquals(false, trans.isValidOffset(ZoneOffset.ofHours(3))); + assertEquals("Transition[Gap at 2008-03-30T02:00+01:00 to +02:00]", trans.toString()); assertFalse(trans.equals(null)); assertFalse(trans.equals(ZoneOffset.ofHours(1))); @@ -430,23 +454,24 @@ public class TestZoneId extends AbstractTest { final ZoneOffsetTransition otherDis = test.getRules().getTransition(dateTime); assertTrue(trans.equals(otherDis)); - assertEquals(trans.hashCode(), otherDis.hashCode()); + assertEquals(otherDis.hashCode(), trans.hashCode()); } + @Test public void test_Paris_getOffsetInfo_overlap() { ZoneId test = ZoneId.of("Europe/Paris"); final LocalDateTime dateTime = LocalDateTime.of(2008, 10, 26, 2, 0, 0, 0); ZoneOffsetTransition trans = checkOffset(test.getRules(), dateTime, ZoneOffset.ofHours(2), OVERLAP); - assertEquals(trans.isGap(), false); - assertEquals(trans.isOverlap(), true); - assertEquals(trans.getOffsetBefore(), ZoneOffset.ofHours(2)); - assertEquals(trans.getOffsetAfter(), ZoneOffset.ofHours(1)); - assertEquals(trans.getInstant(), createInstant(2008, 10, 26, 1, 0, 0, 0, ZoneOffset.UTC)); - assertEquals(trans.isValidOffset(ZoneOffset.ofHours(0)), false); - assertEquals(trans.isValidOffset(ZoneOffset.ofHours(1)), true); - assertEquals(trans.isValidOffset(ZoneOffset.ofHours(2)), true); - assertEquals(trans.isValidOffset(ZoneOffset.ofHours(3)), false); - assertEquals(trans.toString(), "Transition[Overlap at 2008-10-26T03:00+02:00 to +01:00]"); + assertEquals(false, trans.isGap()); + assertEquals(true, trans.isOverlap()); + assertEquals(ZoneOffset.ofHours(2), trans.getOffsetBefore()); + assertEquals(ZoneOffset.ofHours(1), trans.getOffsetAfter()); + assertEquals(createInstant(2008, 10, 26, 1, 0, 0, 0, ZoneOffset.UTC), trans.getInstant()); + assertEquals(false, trans.isValidOffset(ZoneOffset.ofHours(0))); + assertEquals(true, trans.isValidOffset(ZoneOffset.ofHours(1))); + assertEquals(true, trans.isValidOffset(ZoneOffset.ofHours(2))); + assertEquals(false, trans.isValidOffset(ZoneOffset.ofHours(3))); + assertEquals("Transition[Overlap at 2008-10-26T03:00+02:00 to +01:00]", trans.toString()); assertFalse(trans.equals(null)); assertFalse(trans.equals(ZoneOffset.ofHours(2))); @@ -454,77 +479,82 @@ public class TestZoneId extends AbstractTest { final ZoneOffsetTransition otherDis = test.getRules().getTransition(dateTime); assertTrue(trans.equals(otherDis)); - assertEquals(trans.hashCode(), otherDis.hashCode()); + assertEquals(otherDis.hashCode(), trans.hashCode()); } //----------------------------------------------------------------------- // America/New_York //----------------------------------------------------------------------- + @Test public void test_NewYork() { ZoneId test = ZoneId.of("America/New_York"); - assertEquals(test.getId(), "America/New_York"); - assertEquals(test.getRules().isFixedOffset(), false); + assertEquals("America/New_York", test.getId()); + assertEquals(false, test.getRules().isFixedOffset()); } + @Test public void test_NewYork_getOffset() { ZoneId test = ZoneId.of("America/New_York"); ZoneOffset offset = ZoneOffset.ofHours(-5); - assertEquals(test.getRules().getOffset(createInstant(2008, 1, 1, offset)), ZoneOffset.ofHours(-5)); - assertEquals(test.getRules().getOffset(createInstant(2008, 2, 1, offset)), ZoneOffset.ofHours(-5)); - assertEquals(test.getRules().getOffset(createInstant(2008, 3, 1, offset)), ZoneOffset.ofHours(-5)); - assertEquals(test.getRules().getOffset(createInstant(2008, 4, 1, offset)), ZoneOffset.ofHours(-4)); - assertEquals(test.getRules().getOffset(createInstant(2008, 5, 1, offset)), ZoneOffset.ofHours(-4)); - assertEquals(test.getRules().getOffset(createInstant(2008, 6, 1, offset)), ZoneOffset.ofHours(-4)); - assertEquals(test.getRules().getOffset(createInstant(2008, 7, 1, offset)), ZoneOffset.ofHours(-4)); - assertEquals(test.getRules().getOffset(createInstant(2008, 8, 1, offset)), ZoneOffset.ofHours(-4)); - assertEquals(test.getRules().getOffset(createInstant(2008, 9, 1, offset)), ZoneOffset.ofHours(-4)); - assertEquals(test.getRules().getOffset(createInstant(2008, 10, 1, offset)), ZoneOffset.ofHours(-4)); - assertEquals(test.getRules().getOffset(createInstant(2008, 11, 1, offset)), ZoneOffset.ofHours(-4)); - assertEquals(test.getRules().getOffset(createInstant(2008, 12, 1, offset)), ZoneOffset.ofHours(-5)); - assertEquals(test.getRules().getOffset(createInstant(2008, 1, 28, offset)), ZoneOffset.ofHours(-5)); - assertEquals(test.getRules().getOffset(createInstant(2008, 2, 28, offset)), ZoneOffset.ofHours(-5)); - assertEquals(test.getRules().getOffset(createInstant(2008, 3, 28, offset)), ZoneOffset.ofHours(-4)); - assertEquals(test.getRules().getOffset(createInstant(2008, 4, 28, offset)), ZoneOffset.ofHours(-4)); - assertEquals(test.getRules().getOffset(createInstant(2008, 5, 28, offset)), ZoneOffset.ofHours(-4)); - assertEquals(test.getRules().getOffset(createInstant(2008, 6, 28, offset)), ZoneOffset.ofHours(-4)); - assertEquals(test.getRules().getOffset(createInstant(2008, 7, 28, offset)), ZoneOffset.ofHours(-4)); - assertEquals(test.getRules().getOffset(createInstant(2008, 8, 28, offset)), ZoneOffset.ofHours(-4)); - assertEquals(test.getRules().getOffset(createInstant(2008, 9, 28, offset)), ZoneOffset.ofHours(-4)); - assertEquals(test.getRules().getOffset(createInstant(2008, 10, 28, offset)), ZoneOffset.ofHours(-4)); - assertEquals(test.getRules().getOffset(createInstant(2008, 11, 28, offset)), ZoneOffset.ofHours(-5)); - assertEquals(test.getRules().getOffset(createInstant(2008, 12, 28, offset)), ZoneOffset.ofHours(-5)); + assertEquals(ZoneOffset.ofHours(-5), test.getRules().getOffset(createInstant(2008, 1, 1, offset))); + assertEquals(ZoneOffset.ofHours(-5), test.getRules().getOffset(createInstant(2008, 2, 1, offset))); + assertEquals(ZoneOffset.ofHours(-5), test.getRules().getOffset(createInstant(2008, 3, 1, offset))); + assertEquals(ZoneOffset.ofHours(-4), test.getRules().getOffset(createInstant(2008, 4, 1, offset))); + assertEquals(ZoneOffset.ofHours(-4), test.getRules().getOffset(createInstant(2008, 5, 1, offset))); + assertEquals(ZoneOffset.ofHours(-4), test.getRules().getOffset(createInstant(2008, 6, 1, offset))); + assertEquals(ZoneOffset.ofHours(-4), test.getRules().getOffset(createInstant(2008, 7, 1, offset))); + assertEquals(ZoneOffset.ofHours(-4), test.getRules().getOffset(createInstant(2008, 8, 1, offset))); + assertEquals(ZoneOffset.ofHours(-4), test.getRules().getOffset(createInstant(2008, 9, 1, offset))); + assertEquals(ZoneOffset.ofHours(-4), test.getRules().getOffset(createInstant(2008, 10, 1, offset))); + assertEquals(ZoneOffset.ofHours(-4), test.getRules().getOffset(createInstant(2008, 11, 1, offset))); + assertEquals(ZoneOffset.ofHours(-5), test.getRules().getOffset(createInstant(2008, 12, 1, offset))); + assertEquals(ZoneOffset.ofHours(-5), test.getRules().getOffset(createInstant(2008, 1, 28, offset))); + assertEquals(ZoneOffset.ofHours(-5), test.getRules().getOffset(createInstant(2008, 2, 28, offset))); + assertEquals(ZoneOffset.ofHours(-4), test.getRules().getOffset(createInstant(2008, 3, 28, offset))); + assertEquals(ZoneOffset.ofHours(-4), test.getRules().getOffset(createInstant(2008, 4, 28, offset))); + assertEquals(ZoneOffset.ofHours(-4), test.getRules().getOffset(createInstant(2008, 5, 28, offset))); + assertEquals(ZoneOffset.ofHours(-4), test.getRules().getOffset(createInstant(2008, 6, 28, offset))); + assertEquals(ZoneOffset.ofHours(-4), test.getRules().getOffset(createInstant(2008, 7, 28, offset))); + assertEquals(ZoneOffset.ofHours(-4), test.getRules().getOffset(createInstant(2008, 8, 28, offset))); + assertEquals(ZoneOffset.ofHours(-4), test.getRules().getOffset(createInstant(2008, 9, 28, offset))); + assertEquals(ZoneOffset.ofHours(-4), test.getRules().getOffset(createInstant(2008, 10, 28, offset))); + assertEquals(ZoneOffset.ofHours(-5), test.getRules().getOffset(createInstant(2008, 11, 28, offset))); + assertEquals(ZoneOffset.ofHours(-5), test.getRules().getOffset(createInstant(2008, 12, 28, offset))); } + @Test public void test_NewYork_getOffset_toDST() { ZoneId test = ZoneId.of("America/New_York"); ZoneOffset offset = ZoneOffset.ofHours(-5); - assertEquals(test.getRules().getOffset(createInstant(2008, 3, 8, offset)), ZoneOffset.ofHours(-5)); - assertEquals(test.getRules().getOffset(createInstant(2008, 3, 9, offset)), ZoneOffset.ofHours(-5)); - assertEquals(test.getRules().getOffset(createInstant(2008, 3, 10, offset)), ZoneOffset.ofHours(-4)); - assertEquals(test.getRules().getOffset(createInstant(2008, 3, 11, offset)), ZoneOffset.ofHours(-4)); - assertEquals(test.getRules().getOffset(createInstant(2008, 3, 12, offset)), ZoneOffset.ofHours(-4)); - assertEquals(test.getRules().getOffset(createInstant(2008, 3, 13, offset)), ZoneOffset.ofHours(-4)); - assertEquals(test.getRules().getOffset(createInstant(2008, 3, 14, offset)), ZoneOffset.ofHours(-4)); + assertEquals(ZoneOffset.ofHours(-5), test.getRules().getOffset(createInstant(2008, 3, 8, offset))); + assertEquals(ZoneOffset.ofHours(-5), test.getRules().getOffset(createInstant(2008, 3, 9, offset))); + assertEquals(ZoneOffset.ofHours(-4), test.getRules().getOffset(createInstant(2008, 3, 10, offset))); + assertEquals(ZoneOffset.ofHours(-4), test.getRules().getOffset(createInstant(2008, 3, 11, offset))); + assertEquals(ZoneOffset.ofHours(-4), test.getRules().getOffset(createInstant(2008, 3, 12, offset))); + assertEquals(ZoneOffset.ofHours(-4), test.getRules().getOffset(createInstant(2008, 3, 13, offset))); + assertEquals(ZoneOffset.ofHours(-4), test.getRules().getOffset(createInstant(2008, 3, 14, offset))); // cutover at 02:00 local - assertEquals(test.getRules().getOffset(createInstant(2008, 3, 9, 1, 59, 59, 999999999, offset)), ZoneOffset.ofHours(-5)); - assertEquals(test.getRules().getOffset(createInstant(2008, 3, 9, 2, 0, 0, 0, offset)), ZoneOffset.ofHours(-4)); + assertEquals(ZoneOffset.ofHours(-5), test.getRules().getOffset(createInstant(2008, 3, 9, 1, 59, 59, 999999999, offset))); + assertEquals(ZoneOffset.ofHours(-4), test.getRules().getOffset(createInstant(2008, 3, 9, 2, 0, 0, 0, offset))); } + @Test public void test_NewYork_getOffset_fromDST() { ZoneId test = ZoneId.of("America/New_York"); ZoneOffset offset = ZoneOffset.ofHours(-4); - assertEquals(test.getRules().getOffset(createInstant(2008, 11, 1, offset)), ZoneOffset.ofHours(-4)); - assertEquals(test.getRules().getOffset(createInstant(2008, 11, 2, offset)), ZoneOffset.ofHours(-4)); - assertEquals(test.getRules().getOffset(createInstant(2008, 11, 3, offset)), ZoneOffset.ofHours(-5)); - assertEquals(test.getRules().getOffset(createInstant(2008, 11, 4, offset)), ZoneOffset.ofHours(-5)); - assertEquals(test.getRules().getOffset(createInstant(2008, 11, 5, offset)), ZoneOffset.ofHours(-5)); - assertEquals(test.getRules().getOffset(createInstant(2008, 11, 6, offset)), ZoneOffset.ofHours(-5)); - assertEquals(test.getRules().getOffset(createInstant(2008, 11, 7, offset)), ZoneOffset.ofHours(-5)); + assertEquals(ZoneOffset.ofHours(-4), test.getRules().getOffset(createInstant(2008, 11, 1, offset))); + assertEquals(ZoneOffset.ofHours(-4), test.getRules().getOffset(createInstant(2008, 11, 2, offset))); + assertEquals(ZoneOffset.ofHours(-5), test.getRules().getOffset(createInstant(2008, 11, 3, offset))); + assertEquals(ZoneOffset.ofHours(-5), test.getRules().getOffset(createInstant(2008, 11, 4, offset))); + assertEquals(ZoneOffset.ofHours(-5), test.getRules().getOffset(createInstant(2008, 11, 5, offset))); + assertEquals(ZoneOffset.ofHours(-5), test.getRules().getOffset(createInstant(2008, 11, 6, offset))); + assertEquals(ZoneOffset.ofHours(-5), test.getRules().getOffset(createInstant(2008, 11, 7, offset))); // cutover at 02:00 local - assertEquals(test.getRules().getOffset(createInstant(2008, 11, 2, 1, 59, 59, 999999999, offset)), ZoneOffset.ofHours(-4)); - assertEquals(test.getRules().getOffset(createInstant(2008, 11, 2, 2, 0, 0, 0, offset)), ZoneOffset.ofHours(-5)); + assertEquals(ZoneOffset.ofHours(-4), test.getRules().getOffset(createInstant(2008, 11, 2, 1, 59, 59, 999999999, offset))); + assertEquals(ZoneOffset.ofHours(-5), test.getRules().getOffset(createInstant(2008, 11, 2, 2, 0, 0, 0, offset))); } + @Test public void test_NewYork_getOffsetInfo() { ZoneId test = ZoneId.of("America/New_York"); checkOffset(test.getRules(), createLDT(2008, 1, 1), ZoneOffset.ofHours(-5), 1); @@ -553,6 +583,7 @@ public class TestZoneId extends AbstractTest { checkOffset(test.getRules(), createLDT(2008, 12, 28), ZoneOffset.ofHours(-5), 1); } + @Test public void test_NewYork_getOffsetInfo_toDST() { ZoneId test = ZoneId.of("America/New_York"); checkOffset(test.getRules(), createLDT(2008, 3, 8), ZoneOffset.ofHours(-5), 1); @@ -568,6 +599,7 @@ public class TestZoneId extends AbstractTest { checkOffset(test.getRules(), LocalDateTime.of(2008, 3, 9, 3, 0, 0, 0), ZoneOffset.ofHours(-4), 1); } + @Test public void test_NewYork_getOffsetInfo_fromDST() { ZoneId test = ZoneId.of("America/New_York"); checkOffset(test.getRules(), createLDT(2008, 11, 1), ZoneOffset.ofHours(-4), 1); @@ -583,18 +615,19 @@ public class TestZoneId extends AbstractTest { checkOffset(test.getRules(), LocalDateTime.of(2008, 11, 2, 2, 0, 0, 0), ZoneOffset.ofHours(-5), 1); } + @Test public void test_NewYork_getOffsetInfo_gap() { ZoneId test = ZoneId.of("America/New_York"); final LocalDateTime dateTime = LocalDateTime.of(2008, 3, 9, 2, 0, 0, 0); ZoneOffsetTransition trans = checkOffset(test.getRules(), dateTime, ZoneOffset.ofHours(-5), GAP); - assertEquals(trans.getOffsetBefore(), ZoneOffset.ofHours(-5)); - assertEquals(trans.getOffsetAfter(), ZoneOffset.ofHours(-4)); - assertEquals(trans.getInstant(), createInstant(2008, 3, 9, 2, 0, 0, 0, ZoneOffset.ofHours(-5))); - assertEquals(trans.isValidOffset(ZoneOffset.ofHours(-6)), false); - assertEquals(trans.isValidOffset(ZoneOffset.ofHours(-5)), false); - assertEquals(trans.isValidOffset(ZoneOffset.ofHours(-4)), false); - assertEquals(trans.isValidOffset(ZoneOffset.ofHours(-3)), false); - assertEquals(trans.toString(), "Transition[Gap at 2008-03-09T02:00-05:00 to -04:00]"); + assertEquals(ZoneOffset.ofHours(-5), trans.getOffsetBefore()); + assertEquals(ZoneOffset.ofHours(-4), trans.getOffsetAfter()); + assertEquals(createInstant(2008, 3, 9, 2, 0, 0, 0, ZoneOffset.ofHours(-5)), trans.getInstant()); + assertEquals(false, trans.isValidOffset(ZoneOffset.ofHours(-6))); + assertEquals(false, trans.isValidOffset(ZoneOffset.ofHours(-5))); + assertEquals(false, trans.isValidOffset(ZoneOffset.ofHours(-4))); + assertEquals(false, trans.isValidOffset(ZoneOffset.ofHours(-3))); + assertEquals("Transition[Gap at 2008-03-09T02:00-05:00 to -04:00]", trans.toString()); assertFalse(trans.equals(null)); assertFalse(trans.equals(ZoneOffset.ofHours(-5))); @@ -603,21 +636,22 @@ public class TestZoneId extends AbstractTest { final ZoneOffsetTransition otherTrans = test.getRules().getTransition(dateTime); assertTrue(trans.equals(otherTrans)); - assertEquals(trans.hashCode(), otherTrans.hashCode()); + assertEquals(otherTrans.hashCode(), trans.hashCode()); } + @Test public void test_NewYork_getOffsetInfo_overlap() { ZoneId test = ZoneId.of("America/New_York"); final LocalDateTime dateTime = LocalDateTime.of(2008, 11, 2, 1, 0, 0, 0); ZoneOffsetTransition trans = checkOffset(test.getRules(), dateTime, ZoneOffset.ofHours(-4), OVERLAP); - assertEquals(trans.getOffsetBefore(), ZoneOffset.ofHours(-4)); - assertEquals(trans.getOffsetAfter(), ZoneOffset.ofHours(-5)); - assertEquals(trans.getInstant(), createInstant(2008, 11, 2, 2, 0, 0, 0, ZoneOffset.ofHours(-4))); - assertEquals(trans.isValidOffset(ZoneOffset.ofHours(-1)), false); - assertEquals(trans.isValidOffset(ZoneOffset.ofHours(-5)), true); - assertEquals(trans.isValidOffset(ZoneOffset.ofHours(-4)), true); - assertEquals(trans.isValidOffset(ZoneOffset.ofHours(2)), false); - assertEquals(trans.toString(), "Transition[Overlap at 2008-11-02T02:00-04:00 to -05:00]"); + assertEquals(ZoneOffset.ofHours(-4), trans.getOffsetBefore()); + assertEquals(ZoneOffset.ofHours(-5), trans.getOffsetAfter()); + assertEquals(createInstant(2008, 11, 2, 2, 0, 0, 0, ZoneOffset.ofHours(-4)), trans.getInstant()); + assertEquals(false, trans.isValidOffset(ZoneOffset.ofHours(-1))); + assertEquals(true, trans.isValidOffset(ZoneOffset.ofHours(-5))); + assertEquals(true, trans.isValidOffset(ZoneOffset.ofHours(-4))); + assertEquals(false, trans.isValidOffset(ZoneOffset.ofHours(2))); + assertEquals("Transition[Overlap at 2008-11-02T02:00-04:00 to -05:00]", trans.toString()); assertFalse(trans.equals(null)); assertFalse(trans.equals(ZoneOffset.ofHours(-4))); @@ -626,22 +660,24 @@ public class TestZoneId extends AbstractTest { final ZoneOffsetTransition otherTrans = test.getRules().getTransition(dateTime); assertTrue(trans.equals(otherTrans)); - assertEquals(trans.hashCode(), otherTrans.hashCode()); + assertEquals(otherTrans.hashCode(), trans.hashCode()); } //----------------------------------------------------------------------- // getXxx() isXxx() //----------------------------------------------------------------------- + @Test public void test_get_Tzdb() { ZoneId test = ZoneId.of("Europe/London"); - assertEquals(test.getId(), "Europe/London"); - assertEquals(test.getRules().isFixedOffset(), false); + assertEquals("Europe/London", test.getId()); + assertEquals(false, test.getRules().isFixedOffset()); } + @Test public void test_get_TzdbFixed() { ZoneId test = ZoneId.of("+01:30"); - assertEquals(test.getId(), "+01:30"); - assertEquals(test.getRules().isFixedOffset(), true); + assertEquals("+01:30", test.getId()); + assertEquals(true, test.getRules().isFixedOffset()); } //----------------------------------------------------------------------- @@ -665,17 +701,17 @@ public class TestZoneId extends AbstractTest { private ZoneOffsetTransition checkOffset(ZoneRules rules, LocalDateTime dateTime, ZoneOffset offset, int type) { List validOffsets = rules.getValidOffsets(dateTime); - assertEquals(validOffsets.size(), type); - assertEquals(rules.getOffset(dateTime), offset); + assertEquals(type, validOffsets.size()); + assertEquals(offset, rules.getOffset(dateTime)); if (type == 1) { - assertEquals(validOffsets.get(0), offset); + assertEquals(offset, validOffsets.get(0)); return null; } else { ZoneOffsetTransition zot = rules.getTransition(dateTime); assertNotNull(zot); - assertEquals(zot.isOverlap(), type == 2); - assertEquals(zot.isGap(), type == 0); - assertEquals(zot.isValidOffset(offset), type == 2); + assertEquals(type == 2, zot.isOverlap()); + assertEquals(type == 0, zot.isGap()); + assertEquals(type == 2, zot.isValidOffset(offset)); return zot; } } diff --git a/test/jdk/java/time/test/java/time/TestZoneOffset.java b/test/jdk/java/time/test/java/time/TestZoneOffset.java index b85a629aefc..8a42fe2a0ab 100644 --- a/test/jdk/java/time/test/java/time/TestZoneOffset.java +++ b/test/jdk/java/time/test/java/time/TestZoneOffset.java @@ -60,17 +60,16 @@ */ package test.java.time; -import static org.testng.Assert.assertSame; +import static org.junit.jupiter.api.Assertions.assertSame; import java.util.Set; import java.time.ZoneOffset; -import org.testng.annotations.Test; +import org.junit.jupiter.api.Test; /** * Test ZoneOffset. */ -@Test public class TestZoneOffset extends AbstractTest { @Test diff --git a/test/jdk/java/time/test/java/time/TestZonedDateTime.java b/test/jdk/java/time/test/java/time/TestZonedDateTime.java index 15a95d1f3bc..436187cf3d0 100644 --- a/test/jdk/java/time/test/java/time/TestZonedDateTime.java +++ b/test/jdk/java/time/test/java/time/TestZonedDateTime.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2012, 2019, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2012, 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 @@ -59,21 +59,20 @@ */ package test.java.time; -import static org.testng.Assert.assertEquals; +import static org.junit.jupiter.api.Assertions.assertEquals; import java.time.Duration; import java.time.LocalDateTime; import java.time.ZonedDateTime; import java.time.ZoneId; -import org.testng.annotations.Test; +import org.junit.jupiter.api.Test; /** * Test ZonedDateTime. * * @bug 8211990 */ -@Test public class TestZonedDateTime extends AbstractTest { @Test @@ -89,6 +88,6 @@ public class TestZonedDateTime extends AbstractTest { ZonedDateTime end = ZonedDateTime.of(LocalDateTime.MAX, sanJose); ZonedDateTime start = end.withZoneSameLocal(tokyo); - assertEquals(Duration.between(start, end), Duration.ofHours(17)); + assertEquals(Duration.ofHours(17), Duration.between(start, end)); } } diff --git a/test/jdk/java/time/test/java/time/chrono/TestChronoLocalDate.java b/test/jdk/java/time/test/java/time/chrono/TestChronoLocalDate.java index 79410941206..bb738feee05 100644 --- a/test/jdk/java/time/test/java/time/chrono/TestChronoLocalDate.java +++ b/test/jdk/java/time/test/java/time/chrono/TestChronoLocalDate.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2012, 2013, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2012, 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 @@ -54,8 +54,8 @@ */ package test.java.time.chrono; -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 java.time.LocalDate; import java.time.LocalDateTime; @@ -69,16 +69,16 @@ import java.util.ArrayList; import java.util.Collections; import java.util.List; -import org.testng.annotations.Test; +import org.junit.jupiter.api.Test; /** * Test chrono local date. */ -@Test public class TestChronoLocalDate { // this class primarily tests whether the generics work OK //----------------------------------------------------------------------- + @Test public void test_date_comparator_checkGenerics_ISO() { List dates = new ArrayList<>(); ChronoLocalDate date = LocalDate.of(2013, 1, 1); @@ -99,10 +99,11 @@ public class TestChronoLocalDate { List copy = new ArrayList<>(dates); Collections.shuffle(copy); Collections.sort(copy, ChronoLocalDate.timeLineOrder()); - assertEquals(copy, dates); + assertEquals(dates, copy); assertTrue(ChronoLocalDate.timeLineOrder().compare(copy.get(0), copy.get(1)) < 0); } + @Test public void test_date_comparator_checkGenerics_LocalDate() { List dates = new ArrayList<>(); LocalDate date = LocalDate.of(2013, 1, 1); @@ -123,11 +124,12 @@ public class TestChronoLocalDate { List copy = new ArrayList<>(dates); Collections.shuffle(copy); Collections.sort(copy, ChronoLocalDate.timeLineOrder()); - assertEquals(copy, dates); + assertEquals(dates, copy); assertTrue(ChronoLocalDate.timeLineOrder().compare(copy.get(0), copy.get(1)) < 0); } //----------------------------------------------------------------------- + @Test public void test_date_checkGenerics_genericsMethod() { Chronology chrono = ThaiBuddhistChronology.INSTANCE; ChronoLocalDate date = chrono.dateNow(); @@ -138,6 +140,7 @@ public class TestChronoLocalDate { date = processClassWeird(ThaiBuddhistDate.class); } + @Test public void test_date_checkGenerics_genericsMethod_concreteType() { ThaiBuddhistChronology chrono = ThaiBuddhistChronology.INSTANCE; ThaiBuddhistDate date = chrono.dateNow(); @@ -149,6 +152,7 @@ public class TestChronoLocalDate { // date = processClassWeird(ThaiBuddhistDate.class); // does not compile (correct) } + @Test public void test_date_checkGenerics_genericsMethod_withType() { Chronology chrono = ThaiBuddhistChronology.INSTANCE; @SuppressWarnings("unchecked") @@ -180,6 +184,7 @@ public class TestChronoLocalDate { return null; } + @Test public void test_date_checkGenerics_chronoLocalDateTime1() { LocalDateTime now = LocalDateTime.now(); Chronology chrono = ThaiBuddhistChronology.INSTANCE; @@ -187,6 +192,7 @@ public class TestChronoLocalDate { ldt = processCLDT(ldt); } + @Test public void test_date_checkGenerics_chronoLocalDateTime2() { LocalDateTime now = LocalDateTime.now(); Chronology chrono = ThaiBuddhistChronology.INSTANCE; diff --git a/test/jdk/java/time/test/java/time/chrono/TestChronologyPerf.java b/test/jdk/java/time/test/java/time/chrono/TestChronologyPerf.java index 5026ebf1700..ab6bdd7ee1d 100644 --- a/test/jdk/java/time/test/java/time/chrono/TestChronologyPerf.java +++ b/test/jdk/java/time/test/java/time/chrono/TestChronologyPerf.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2013, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2013, 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 @@ -29,7 +29,7 @@ import java.time.chrono.HijrahDate; import java.time.temporal.ChronoUnit; import java.util.Set; -import org.testng.annotations.Test; +import org.junit.jupiter.api.Test; /** * Test the speed of initializing all calendars. diff --git a/test/jdk/java/time/test/java/time/chrono/TestEraDisplayName.java b/test/jdk/java/time/test/java/time/chrono/TestEraDisplayName.java index 4e20ceb5495..99cd7499adb 100644 --- a/test/jdk/java/time/test/java/time/chrono/TestEraDisplayName.java +++ b/test/jdk/java/time/test/java/time/chrono/TestEraDisplayName.java @@ -30,10 +30,11 @@ import java.util.Arrays; import java.util.Locale; 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.assertFalse; +import static org.junit.jupiter.api.Assertions.assertEquals; +import static org.junit.jupiter.api.Assertions.assertFalse; +import org.junit.jupiter.api.TestInstance; +import org.junit.jupiter.params.ParameterizedTest; +import org.junit.jupiter.params.provider.MethodSource; /** * Tests Era.getDisplayName() correctly returns the name based on each @@ -42,7 +43,7 @@ import static org.testng.Assert.assertFalse; * * @bug 8171049 8224105 8240626 8354548 */ -@Test +@TestInstance(TestInstance.Lifecycle.PER_CLASS) public class TestEraDisplayName { private static final Locale THAI = Locale.forLanguageTag("th-TH"); private static final Locale EGYPT = Locale.forLanguageTag("ar-EG"); @@ -52,7 +53,6 @@ public class TestEraDisplayName { DateTimeFormatter.ofPattern("yyyy MM dd GGGG G GGGGG") .withChronology(JapaneseChronology.INSTANCE); - @DataProvider(name="eraDisplayName") Object[][] eraDisplayName() { return new Object[][] { // Era, text style, displyay locale, expected name @@ -141,7 +141,6 @@ public class TestEraDisplayName { }; } - @DataProvider Object[][] allLocales() { return Arrays.stream(Locale.getAvailableLocales()) .map(Stream::of) @@ -149,7 +148,6 @@ public class TestEraDisplayName { .toArray(Object[][]::new); } - @DataProvider Object[][] allEras() { return Stream.of(IsoEra.values(), JapaneseEra.values(), @@ -162,29 +160,28 @@ public class TestEraDisplayName { .toArray(Object[][]::new); } - @Test(dataProvider="eraDisplayName") + @ParameterizedTest + @MethodSource("eraDisplayName") public void test_eraDisplayName(Era era, TextStyle style, Locale locale, String expected) { - assertEquals(era.getDisplayName(style, locale), expected); + assertEquals(expected, era.getDisplayName(style, locale)); } - @Test(dataProvider="allLocales") + @ParameterizedTest + @MethodSource("allLocales") public void test_reiwaNames(Locale locale) throws DateTimeParseException { DateTimeFormatter f = JAPANESE_FORMATTER.withLocale(locale); - assertEquals(LocalDate.parse(REIWA_1ST.format(f), f), REIWA_1ST); + assertEquals(REIWA_1ST, LocalDate.parse(REIWA_1ST.format(f), f)); } // Make sure era display names aren't empty // @bug 8240626 - @Test(dataProvider="allEras") + @ParameterizedTest + @MethodSource("allEras") public void test_noEmptyEraNames(Era era) { Arrays.stream(Locale.getAvailableLocales()) - .forEach(l -> { - Arrays.stream(TextStyle.values()) - .forEach(s -> { - assertFalse(era.getDisplayName(s, l).isEmpty(), - "getDisplayName() returns empty display name for era: " + era - + ", style: " + s + ", locale: " + l); - }); - }); + .forEach(l -> Arrays.stream(TextStyle.values()) + .forEach(s -> assertFalse(era.getDisplayName(s, l).isEmpty(), + "getDisplayName() returns empty display name for era: " + era + + ", style: " + s + ", locale: " + l))); } } diff --git a/test/jdk/java/time/test/java/time/chrono/TestExampleCode.java b/test/jdk/java/time/test/java/time/chrono/TestExampleCode.java index 5258a0b8062..b4e3c41d5e3 100644 --- a/test/jdk/java/time/test/java/time/chrono/TestExampleCode.java +++ b/test/jdk/java/time/test/java/time/chrono/TestExampleCode.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2012, 2013, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2012, 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 @@ -55,7 +55,7 @@ package test.java.time.chrono; -import static org.testng.Assert.assertEquals; +import static org.junit.jupiter.api.Assertions.assertEquals; import java.time.LocalDate; import java.time.LocalTime; @@ -72,13 +72,16 @@ import java.time.temporal.ChronoUnit; import java.util.Locale; import java.util.Set; -import org.testng.annotations.DataProvider; -import org.testng.annotations.Test; +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 case verify that the example code in the package-info.java compiles * and runs. */ +@TestInstance(TestInstance.Lifecycle.PER_CLASS) public class TestExampleCode { @Test @@ -113,14 +116,14 @@ public class TestExampleCode { //----------------------------------------------------------------------- // Data provider for Hijrah Type names //----------------------------------------------------------------------- - @DataProvider(name = "HijrahTypeNames") Object[][] data_of_ummalqura() { return new Object[][]{ { "Hijrah-umalqura", "islamic-umalqura"}, }; } - @Test(dataProvider= "HijrahTypeNames") + @ParameterizedTest + @MethodSource("data_of_ummalqura") public void test_HijrahTypeViaLocale(String calendarId, String calendarType) { Locale.Builder builder = new Locale.Builder(); builder.setLanguage("en").setRegion("US"); @@ -130,7 +133,7 @@ public class TestExampleCode { System.out.printf(" Locale language tag: %s, Chronology ID: %s, type: %s%n", locale.toLanguageTag(), chrono, chrono.getCalendarType()); Chronology expected = Chronology.of(calendarId); - assertEquals(chrono, expected, "Expected chronology not found"); + assertEquals(expected, chrono, "Expected chronology not found"); } @Test diff --git a/test/jdk/java/time/test/java/time/chrono/TestIsoChronoImpl.java b/test/jdk/java/time/test/java/time/chrono/TestIsoChronoImpl.java index 59f5016a6fc..adc8949e61e 100644 --- a/test/jdk/java/time/test/java/time/chrono/TestIsoChronoImpl.java +++ b/test/jdk/java/time/test/java/time/chrono/TestIsoChronoImpl.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2012, 2013, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2012, 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 @@ -58,7 +58,8 @@ import static java.time.temporal.ChronoField.DAY_OF_MONTH; import static java.time.temporal.ChronoField.MONTH_OF_YEAR; import static java.time.temporal.ChronoField.YEAR; import static java.time.temporal.ChronoField.YEAR_OF_ERA; -import static org.testng.Assert.assertEquals; + +import static org.junit.jupiter.api.Assertions.assertEquals; import java.time.DayOfWeek; import java.time.LocalDate; @@ -69,16 +70,16 @@ import java.util.Calendar; import java.util.GregorianCalendar; import java.util.TimeZone; -import org.testng.annotations.DataProvider; -import org.testng.annotations.Test; +import org.junit.jupiter.api.TestInstance; +import org.junit.jupiter.params.ParameterizedTest; +import org.junit.jupiter.params.provider.MethodSource; /** * Test. */ -@Test +@TestInstance(TestInstance.Lifecycle.PER_CLASS) public class TestIsoChronoImpl { - @DataProvider(name = "RangeVersusCalendar") Object[][] provider_rangeVersusCalendar() { return new Object[][]{ {LocalDate.of(1583, 1, 1), LocalDate.of(2100, 1, 1)}, @@ -88,10 +89,11 @@ public class TestIsoChronoImpl { //----------------------------------------------------------------------- // Verify ISO Calendar matches java.util.Calendar for range //----------------------------------------------------------------------- - @Test(dataProvider = "RangeVersusCalendar") + @ParameterizedTest + @MethodSource("provider_rangeVersusCalendar") public void test_IsoChrono_vsCalendar(LocalDate isoStartDate, LocalDate isoEndDate) { GregorianCalendar cal = new GregorianCalendar(); - assertEquals(cal.getCalendarType(), "gregory", "Unexpected calendar type"); + assertEquals("gregory", cal.getCalendarType(), "Unexpected calendar type"); LocalDate isoDate = IsoChronology.INSTANCE.date(isoStartDate); cal.setTimeZone(TimeZone.getTimeZone("GMT+00")); @@ -100,9 +102,9 @@ public class TestIsoChronoImpl { cal.set(Calendar.DAY_OF_MONTH, isoDate.get(DAY_OF_MONTH)); while (isoDate.isBefore(isoEndDate)) { - assertEquals(isoDate.get(DAY_OF_MONTH), cal.get(Calendar.DAY_OF_MONTH), "Day mismatch in " + isoDate + "; cal: " + cal); - assertEquals(isoDate.get(MONTH_OF_YEAR), cal.get(Calendar.MONTH) + 1, "Month mismatch in " + isoDate); - assertEquals(isoDate.get(YEAR_OF_ERA), cal.get(Calendar.YEAR), "Year mismatch in " + isoDate); + assertEquals(cal.get(Calendar.DAY_OF_MONTH), isoDate.get(DAY_OF_MONTH), "Day mismatch in " + isoDate + "; cal: " + cal); + assertEquals(cal.get(Calendar.MONTH) + 1, isoDate.get(MONTH_OF_YEAR), "Month mismatch in " + isoDate); + assertEquals(cal.get(Calendar.YEAR), isoDate.get(YEAR_OF_ERA), "Year mismatch in " + isoDate); isoDate = isoDate.plus(1, ChronoUnit.DAYS); cal.add(Calendar.DAY_OF_MONTH, 1); @@ -113,10 +115,11 @@ public class TestIsoChronoImpl { // Verify ISO Calendar matches java.util.Calendar // DayOfWeek, WeekOfMonth, WeekOfYear for range //----------------------------------------------------------------------- - @Test(dataProvider = "RangeVersusCalendar") + @ParameterizedTest + @MethodSource("provider_rangeVersusCalendar") public void test_DayOfWeek_IsoChronology_vsCalendar(LocalDate isoStartDate, LocalDate isoEndDate) { GregorianCalendar cal = new GregorianCalendar(); - assertEquals(cal.getCalendarType(), "gregory", "Unexpected calendar type"); + assertEquals("gregory", cal.getCalendarType(), "Unexpected calendar type"); LocalDate isoDate = IsoChronology.INSTANCE.date(isoStartDate); for (DayOfWeek firstDayOfWeek : DayOfWeek.values()) { @@ -132,29 +135,29 @@ public class TestIsoChronoImpl { // For every date in the range while (isoDate.isBefore(isoEndDate)) { - assertEquals(isoDate.get(DAY_OF_MONTH), cal.get(Calendar.DAY_OF_MONTH), "Day mismatch in " + isoDate + "; cal: " + cal); - assertEquals(isoDate.get(MONTH_OF_YEAR), cal.get(Calendar.MONTH) + 1, "Month mismatch in " + isoDate); - assertEquals(isoDate.get(YEAR_OF_ERA), cal.get(Calendar.YEAR), "Year mismatch in " + isoDate); + assertEquals(cal.get(Calendar.DAY_OF_MONTH), isoDate.get(DAY_OF_MONTH), "Day mismatch in " + isoDate + "; cal: " + cal); + assertEquals(cal.get(Calendar.MONTH) + 1, isoDate.get(MONTH_OF_YEAR), "Month mismatch in " + isoDate); + assertEquals(cal.get(Calendar.YEAR), isoDate.get(YEAR_OF_ERA), "Year mismatch in " + isoDate); int jdow = Math.floorMod(cal.get(Calendar.DAY_OF_WEEK) - 2, 7) + 1; int dow = isoDate.get(weekDef.dayOfWeek()); - assertEquals(jdow, dow, "Calendar DayOfWeek does not match ISO DayOfWeek"); + assertEquals(dow, jdow, "Calendar DayOfWeek does not match ISO DayOfWeek"); int jweekOfMonth = cal.get(Calendar.WEEK_OF_MONTH); int isoWeekOfMonth = isoDate.get(weekDef.weekOfMonth()); - assertEquals(jweekOfMonth, isoWeekOfMonth, "Calendar WeekOfMonth does not match ISO WeekOfMonth"); + assertEquals(isoWeekOfMonth, jweekOfMonth, "Calendar WeekOfMonth does not match ISO WeekOfMonth"); int jweekOfYear = cal.get(Calendar.WEEK_OF_YEAR); int weekOfYear = isoDate.get(weekDef.weekOfWeekBasedYear()); - assertEquals(jweekOfYear, weekOfYear, "GregorianCalendar WeekOfYear does not match WeekOfWeekBasedYear"); + assertEquals(weekOfYear, jweekOfYear, "GregorianCalendar WeekOfYear does not match WeekOfWeekBasedYear"); int jWeekYear = cal.getWeekYear(); int weekBasedYear = isoDate.get(weekDef.weekBasedYear()); - assertEquals(jWeekYear, weekBasedYear, "GregorianCalendar getWeekYear does not match YearOfWeekBasedYear"); + assertEquals(weekBasedYear, jWeekYear, "GregorianCalendar getWeekYear does not match YearOfWeekBasedYear"); int jweeksInWeekyear = cal.getWeeksInWeekYear(); int weeksInWeekBasedYear = (int)isoDate.range(weekDef.weekOfWeekBasedYear()).getMaximum(); - assertEquals(jweeksInWeekyear, weeksInWeekBasedYear, "length of weekBasedYear"); + assertEquals(weeksInWeekBasedYear, jweeksInWeekyear, "length of weekBasedYear"); isoDate = isoDate.plus(1, ChronoUnit.DAYS); cal.add(Calendar.DAY_OF_MONTH, 1); diff --git a/test/jdk/java/time/test/java/time/chrono/TestJapaneseChronoImpl.java b/test/jdk/java/time/test/java/time/chrono/TestJapaneseChronoImpl.java index fc2fa9798af..6ed24d579dd 100644 --- a/test/jdk/java/time/test/java/time/chrono/TestJapaneseChronoImpl.java +++ b/test/jdk/java/time/test/java/time/chrono/TestJapaneseChronoImpl.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2012, 2013, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2012, 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 @@ -54,7 +54,7 @@ */ package test.java.time.chrono; -import static org.testng.Assert.assertEquals; +import static org.junit.jupiter.api.Assertions.assertEquals; import java.time.LocalDate; import java.time.LocalTime; @@ -71,19 +71,20 @@ import java.util.GregorianCalendar; import java.util.Locale; import java.util.TimeZone; -import org.testng.annotations.DataProvider; -import org.testng.annotations.Test; +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. */ -@Test +@TestInstance(TestInstance.Lifecycle.PER_CLASS) public class TestJapaneseChronoImpl { /** * Range of years to check consistency with java.util.Calendar */ - @DataProvider(name="RangeVersusCalendar") Object[][] provider_rangeVersusCalendar() { return new Object[][] { {LocalDate.of(1873, 1, 1), LocalDate.of(2100, 1, 1)}, @@ -93,13 +94,14 @@ public class TestJapaneseChronoImpl { //----------------------------------------------------------------------- // Verify Japanese Calendar matches java.util.Calendar for range //----------------------------------------------------------------------- - @Test(dataProvider="RangeVersusCalendar") + @ParameterizedTest + @MethodSource("provider_rangeVersusCalendar") public void test_JapaneseChrono_vsCalendar(LocalDate isoStartDate, LocalDate isoEndDate) { Locale locale = Locale.forLanguageTag("ja-JP-u-ca-japanese"); - assertEquals(locale.toString(), "ja_JP_#u-ca-japanese", "Unexpected locale"); + assertEquals("ja_JP_#u-ca-japanese", locale.toString(), "Unexpected locale"); Calendar cal = java.util.Calendar.getInstance(locale); - assertEquals(cal.getCalendarType(), "japanese", "Unexpected calendar type"); + assertEquals("japanese", cal.getCalendarType(), "Unexpected calendar type"); JapaneseDate jDate = JapaneseChronology.INSTANCE.date(isoStartDate); @@ -110,9 +112,9 @@ public class TestJapaneseChronoImpl { cal.setTimeInMillis(millis); while (jDate.isBefore(isoEndDate)) { - assertEquals(jDate.get(ChronoField.DAY_OF_MONTH), cal.get(Calendar.DAY_OF_MONTH), "Day mismatch in " + jDate + "; cal: " + cal); - assertEquals(jDate.get(ChronoField.MONTH_OF_YEAR), cal.get(Calendar.MONTH) + 1, "Month mismatch in " + jDate); - assertEquals(jDate.get(ChronoField.YEAR_OF_ERA), cal.get(Calendar.YEAR), "Year mismatch in " + jDate); + assertEquals(cal.get(Calendar.DAY_OF_MONTH), jDate.get(ChronoField.DAY_OF_MONTH), "Day mismatch in " + jDate + "; cal: " + cal); + assertEquals(cal.get(Calendar.MONTH) + 1, jDate.get(ChronoField.MONTH_OF_YEAR), "Month mismatch in " + jDate); + assertEquals(cal.get(Calendar.YEAR), jDate.get(ChronoField.YEAR_OF_ERA), "Year mismatch in " + jDate); jDate = jDate.plus(1, ChronoUnit.DAYS); cal.add(Calendar.DAY_OF_MONTH, 1); @@ -136,11 +138,11 @@ public class TestJapaneseChronoImpl { cal.setTimeZone(TimeZone.getTimeZone("GMT+00")); cal.setTimeInMillis(millis); - assertEquals(jd.get(ChronoField.DAY_OF_YEAR), cal.get(Calendar.DAY_OF_YEAR), + assertEquals(cal.get(Calendar.DAY_OF_YEAR), jd.get(ChronoField.DAY_OF_YEAR), "different DAY_OF_YEAR values in " + era + ", year: " + year); - assertEquals(jd.range(ChronoField.DAY_OF_YEAR).getMaximum(), cal.getActualMaximum(Calendar.DAY_OF_YEAR), + assertEquals(cal.getActualMaximum(Calendar.DAY_OF_YEAR), jd.range(ChronoField.DAY_OF_YEAR).getMaximum(), "different maximum for DAY_OF_YEAR in " + era + ", year: " + year); - assertEquals(jd.range(ChronoField.DAY_OF_YEAR).getMinimum(), cal.getActualMinimum(Calendar.DAY_OF_YEAR), + assertEquals(cal.getActualMinimum(Calendar.DAY_OF_YEAR), jd.range(ChronoField.DAY_OF_YEAR).getMinimum(), "different minimum for DAY_OF_YEAR in " + era + ", year: " + year); } } diff --git a/test/jdk/java/time/test/java/time/chrono/TestJapaneseChronology.java b/test/jdk/java/time/test/java/time/chrono/TestJapaneseChronology.java index 6e7df8638f9..85c33a964a3 100644 --- a/test/jdk/java/time/test/java/time/chrono/TestJapaneseChronology.java +++ b/test/jdk/java/time/test/java/time/chrono/TestJapaneseChronology.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2013, 2019, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2013, 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 @@ -29,20 +29,22 @@ import java.time.temporal.*; import java.util.List; import java.util.Locale; -import org.testng.annotations.DataProvider; -import org.testng.annotations.Test; -import static org.testng.Assert.assertEquals; -import static org.testng.Assert.assertTrue; +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.Test; +import org.junit.jupiter.api.TestInstance; +import org.junit.jupiter.params.ParameterizedTest; +import org.junit.jupiter.params.provider.MethodSource; /** * Tests for the Japanese chronology */ -@Test +@TestInstance(TestInstance.Lifecycle.PER_CLASS) public class TestJapaneseChronology { private static final JapaneseChronology JAPANESE = JapaneseChronology.INSTANCE; private static final Locale jaJPJP = Locale.forLanguageTag("ja-JP-u-ca-japanese"); - @DataProvider(name="transitions") Object[][] transitionData() { return new Object[][] { // Japanese era, yearOfEra, month, dayOfMonth, gregorianYear @@ -62,7 +64,6 @@ public class TestJapaneseChronology { }; } - @DataProvider(name="day_year_data") Object[][] dayYearData() { return new Object[][] { // Japanese era, yearOfEra, dayOfYear, month, dayOfMonth @@ -80,7 +81,6 @@ public class TestJapaneseChronology { }; } - @DataProvider(name="range_data") Object[][] rangeData() { return new Object[][] { // field, minSmallest, minLargest, maxSmallest, maxLargest @@ -91,7 +91,6 @@ public class TestJapaneseChronology { }; } - @DataProvider(name="invalid_dates") Object[][] invalidDatesData() { return new Object[][] { // Japanese era, yearOfEra, month, dayOfMonth @@ -114,7 +113,6 @@ public class TestJapaneseChronology { }; } - @DataProvider(name="invalid_eraYear") Object[][] invalidEraYearData() { return new Object[][] { // Japanese era, yearOfEra @@ -136,7 +134,6 @@ public class TestJapaneseChronology { }; } - @DataProvider(name="invalid_day_year_data") Object[][] invalidDayYearData() { return new Object[][] { // Japanese era, yearOfEra, dayOfYear @@ -155,7 +152,6 @@ public class TestJapaneseChronology { }; } - @DataProvider Object[][] eraNameData() { return new Object[][] { // Japanese era, name, exception @@ -171,56 +167,69 @@ public class TestJapaneseChronology { @Test public void test_ofLocale() { // must be a singleton - assertEquals(Chronology.ofLocale(jaJPJP) == JAPANESE, true); + assertEquals(true, Chronology.ofLocale(jaJPJP) == JAPANESE); } - @Test(dataProvider="transitions") + @ParameterizedTest + @MethodSource("transitionData") public void test_transitions(JapaneseEra era, int yearOfEra, int month, int dayOfMonth, int gregorianYear) { - assertEquals(JAPANESE.prolepticYear(era, yearOfEra), gregorianYear); + assertEquals(gregorianYear, JAPANESE.prolepticYear(era, yearOfEra)); JapaneseDate jdate1 = JapaneseDate.of(era, yearOfEra, month, dayOfMonth); JapaneseDate jdate2 = JapaneseDate.of(gregorianYear, month, dayOfMonth); - assertEquals(jdate1, jdate2); + assertEquals(jdate2, jdate1); } - @Test(dataProvider="range_data") + @ParameterizedTest + @MethodSource("rangeData") public void test_range(ChronoField field, int minSmallest, int minLargest, int maxSmallest, int maxLargest) { ValueRange range = JAPANESE.range(field); - assertEquals(range.getMinimum(), minSmallest); - assertEquals(range.getLargestMinimum(), minLargest); - assertEquals(range.getSmallestMaximum(), maxSmallest); - assertEquals(range.getMaximum(), maxLargest); + assertEquals(minSmallest, range.getMinimum()); + assertEquals(minLargest, range.getLargestMinimum()); + assertEquals(maxSmallest, range.getSmallestMaximum()); + assertEquals(maxLargest, range.getMaximum()); } - @Test(dataProvider="day_year_data") + @ParameterizedTest + @MethodSource("dayYearData") public void test_firstDayOfEra(JapaneseEra era, int yearOfEra, int dayOfYear, int month, int dayOfMonth) { JapaneseDate date1 = JAPANESE.dateYearDay(era, yearOfEra, dayOfYear); JapaneseDate date2 = JAPANESE.date(era, yearOfEra, month, dayOfMonth); - assertEquals(date1, date2); + assertEquals(date2, date1); } - @Test(dataProvider="invalid_dates", expectedExceptions=DateTimeException.class) + @ParameterizedTest + @MethodSource("invalidDatesData") public void test_invalidDate(JapaneseEra era, int yearOfEra, int month, int dayOfMonth) { - JapaneseDate jdate = JapaneseDate.of(era, yearOfEra, month, dayOfMonth); - System.out.printf("No DateTimeException with %s %d.%02d.%02d%n", era, yearOfEra, month, dayOfMonth); + Assertions.assertThrows(DateTimeException.class, () -> { + JapaneseDate jdate = JapaneseDate.of(era, yearOfEra, month, dayOfMonth); + System.out.printf("No DateTimeException with %s %d.%02d.%02d%n", era, yearOfEra, month, dayOfMonth); + }); } - @Test(dataProvider="invalid_eraYear", expectedExceptions=DateTimeException.class) + @ParameterizedTest + @MethodSource("invalidEraYearData") public void test_invalidEraYear(JapaneseEra era, int yearOfEra) { - int year = JAPANESE.prolepticYear(era, yearOfEra); - System.out.printf("No DateTimeException with era=%s, year=%d%n", era, yearOfEra); + Assertions.assertThrows(DateTimeException.class, () -> { + int year = JAPANESE.prolepticYear(era, yearOfEra); + System.out.printf("No DateTimeException with era=%s, year=%d%n", era, yearOfEra); + }); } - @Test(dataProvider="invalid_day_year_data", expectedExceptions=DateTimeException.class) + @ParameterizedTest + @MethodSource("invalidDayYearData") public void test_invalidDayYear(JapaneseEra era, int yearOfEra, int dayOfYear) { - JapaneseDate date = JAPANESE.dateYearDay(era, yearOfEra, dayOfYear); - System.out.printf("No DateTimeException with era=%s, year=%d, dayOfYear=%d%n", era, yearOfEra, dayOfYear); + Assertions.assertThrows(DateTimeException.class, () -> { + JapaneseDate date = JAPANESE.dateYearDay(era, yearOfEra, dayOfYear); + System.out.printf("No DateTimeException with era=%s, year=%d, dayOfYear=%d%n", era, yearOfEra, dayOfYear); + }); } - @Test(dataProvider="eraNameData") + @ParameterizedTest + @MethodSource("eraNameData") public void test_eraName(String eraName, JapaneseEra era, Class expectedEx) { try { - assertEquals(JapaneseEra.valueOf(eraName), era); + assertEquals(era, JapaneseEra.valueOf(eraName)); } catch (Exception ex) { assertTrue(expectedEx.isInstance(ex)); } diff --git a/test/jdk/java/time/test/java/time/chrono/TestServiceLoader.java b/test/jdk/java/time/test/java/time/chrono/TestServiceLoader.java index 3eaa4253681..93e00b48b7a 100644 --- a/test/jdk/java/time/test/java/time/chrono/TestServiceLoader.java +++ b/test/jdk/java/time/test/java/time/chrono/TestServiceLoader.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2012, 2022, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2012, 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 @@ -59,21 +59,20 @@ */ package test.java.time.chrono; -import static org.testng.Assert.assertEquals; -import static org.testng.Assert.assertNotNull; +import static org.junit.jupiter.api.Assertions.assertEquals; +import static org.junit.jupiter.api.Assertions.assertNotNull; import java.time.chrono.Chronology; import java.util.HashMap; import java.util.Map; import java.util.ServiceLoader; -import org.testng.annotations.Test; +import org.junit.jupiter.api.Test; /** * Tests that a custom Chronology is available via the ServiceLoader. * The CopticChronology is configured via META-INF/services/java.time.chrono.Chronology. */ -@Test public class TestServiceLoader { @Test @@ -85,7 +84,7 @@ public class TestServiceLoader { } var coptic = chronos.get("Coptic"); assertNotNull(coptic, "CopticChronology not found"); - assertEquals(coptic.isIsoBased(), false); + assertEquals(false, coptic.isIsoBased()); } } diff --git a/test/jdk/java/time/test/java/time/chrono/TestThaiBuddhistChronoImpl.java b/test/jdk/java/time/test/java/time/chrono/TestThaiBuddhistChronoImpl.java index e878ac0dcb3..bb32a9e7d65 100644 --- a/test/jdk/java/time/test/java/time/chrono/TestThaiBuddhistChronoImpl.java +++ b/test/jdk/java/time/test/java/time/chrono/TestThaiBuddhistChronoImpl.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2012, 2013, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2012, 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 @@ -54,7 +54,7 @@ */ package test.java.time.chrono; -import static org.testng.Assert.assertEquals; +import static org.junit.jupiter.api.Assertions.assertEquals; import java.time.LocalDate; import java.time.chrono.ThaiBuddhistChronology; @@ -65,19 +65,19 @@ import java.util.Calendar; import java.util.Locale; import java.util.TimeZone; -import org.testng.annotations.DataProvider; -import org.testng.annotations.Test; +import org.junit.jupiter.api.TestInstance; +import org.junit.jupiter.params.ParameterizedTest; +import org.junit.jupiter.params.provider.MethodSource; /** * Test. */ -@Test +@TestInstance(TestInstance.Lifecycle.PER_CLASS) public class TestThaiBuddhistChronoImpl { /** * Range of years to check consistency with java.util.Calendar */ - @DataProvider(name="RangeVersusCalendar") Object[][] provider_rangeVersusCalendar() { return new Object[][] { {LocalDate.of(1583, 1, 1), LocalDate.of(2100, 1, 1)}, @@ -87,12 +87,13 @@ public class TestThaiBuddhistChronoImpl { //----------------------------------------------------------------------- // Verify ThaiBuddhist Calendar matches java.util.Calendar for range //----------------------------------------------------------------------- - @Test(dataProvider="RangeVersusCalendar") + @ParameterizedTest + @MethodSource("provider_rangeVersusCalendar") public void test_ThaiBuddhistChrono_vsCalendar(LocalDate isoStartDate, LocalDate isoEndDate) { Locale locale = Locale.forLanguageTag("th-TH--u-ca-buddhist"); - assertEquals(locale.toString(), "th_TH", "Unexpected locale"); + assertEquals("th_TH", locale.toString(), "Unexpected locale"); Calendar cal = java.util.Calendar.getInstance(locale); - assertEquals(cal.getCalendarType(), "buddhist", "Unexpected calendar type"); + assertEquals("buddhist", cal.getCalendarType(), "Unexpected calendar type"); ThaiBuddhistDate thaiDate = ThaiBuddhistChronology.INSTANCE.date(isoStartDate); @@ -102,9 +103,9 @@ public class TestThaiBuddhistChronoImpl { cal.set(Calendar.DAY_OF_MONTH, thaiDate.get(ChronoField.DAY_OF_MONTH)); while (thaiDate.isBefore(isoEndDate)) { - assertEquals(thaiDate.get(ChronoField.DAY_OF_MONTH), cal.get(Calendar.DAY_OF_MONTH), "Day mismatch in " + thaiDate + "; cal: " + cal); - assertEquals(thaiDate.get(ChronoField.MONTH_OF_YEAR), cal.get(Calendar.MONTH) + 1, "Month mismatch in " + thaiDate); - assertEquals(thaiDate.get(ChronoField.YEAR_OF_ERA), cal.get(Calendar.YEAR), "Year mismatch in " + thaiDate); + assertEquals(cal.get(Calendar.DAY_OF_MONTH), thaiDate.get(ChronoField.DAY_OF_MONTH), "Day mismatch in " + thaiDate + "; cal: " + cal); + assertEquals(cal.get(Calendar.MONTH) + 1, thaiDate.get(ChronoField.MONTH_OF_YEAR), "Month mismatch in " + thaiDate); + assertEquals(cal.get(Calendar.YEAR), thaiDate.get(ChronoField.YEAR_OF_ERA), "Year mismatch in " + thaiDate); thaiDate = thaiDate.plus(1, ChronoUnit.DAYS); cal.add(Calendar.DAY_OF_MONTH, 1); diff --git a/test/jdk/java/time/test/java/time/chrono/TestUmmAlQuraChronology.java b/test/jdk/java/time/test/java/time/chrono/TestUmmAlQuraChronology.java index 8d68abfd227..2dfd112596b 100644 --- a/test/jdk/java/time/test/java/time/chrono/TestUmmAlQuraChronology.java +++ b/test/jdk/java/time/test/java/time/chrono/TestUmmAlQuraChronology.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2013, 2019, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2013, 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 @@ -27,10 +27,11 @@ import static java.time.temporal.ChronoField.DAY_OF_MONTH; import static java.time.temporal.ChronoField.DAY_OF_YEAR; import static java.time.temporal.ChronoField.MONTH_OF_YEAR; import static java.time.temporal.ChronoField.YEAR; -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.time.DateTimeException; import java.time.DayOfWeek; @@ -64,15 +65,18 @@ import java.time.temporal.ValueRange; import java.time.temporal.WeekFields; import java.util.Locale; -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.api.TestInstance; +import org.junit.jupiter.params.ParameterizedTest; +import org.junit.jupiter.params.provider.MethodSource; /** * Tests for the Umm alQura chronology and data. * Note: The dates used for testing are just a sample of calendar data. * @bug 8067800 */ -@Test +@TestInstance(TestInstance.Lifecycle.PER_CLASS) public class TestUmmAlQuraChronology { private static final ZoneOffset OFFSET_PTWO = ZoneOffset.ofHours(2); @@ -82,21 +86,22 @@ public class TestUmmAlQuraChronology { @Test public void test_aliases() { HijrahChronology hc = (HijrahChronology) Chronology.of("Hijrah"); - assertEquals(hc, HijrahChronology.INSTANCE, "Alias for Hijrah-umalqura"); + assertEquals(HijrahChronology.INSTANCE, hc, "Alias for Hijrah-umalqura"); hc = (HijrahChronology) Chronology.of("islamic"); - assertEquals(hc, HijrahChronology.INSTANCE, "Alias for Hijrah-umalqura"); + assertEquals(HijrahChronology.INSTANCE, hc, "Alias for Hijrah-umalqura"); } // Test to check if the exception is thrown for an incorrect chronology id - @Test(expectedExceptions=DateTimeException.class) + @Test public void test_badChronology() { - Chronology test = Chronology.of("Hijrah-ummalqura"); + Assertions.assertThrows(DateTimeException.class, () -> { + Chronology test = Chronology.of("Hijrah-ummalqura"); + }); } //-------------------------------------------------------------------------- // regular data factory for Umm alQura dates and the corresponding ISO dates //-------------------------------------------------------------------------- - @DataProvider(name = "UmmAlQuraVsISODates") Object[][] data_UmmAlQuraVsISODates() { return new Object[][] { {HijrahDate.of(1318, 1, 1), LocalDate.of(1900, 04, 30)}, @@ -110,9 +115,10 @@ public class TestUmmAlQuraChronology { } // Test to verify the epoch days for given Hijrah & ISO date instances - @Test(dataProvider="UmmAlQuraVsISODates") + @ParameterizedTest + @MethodSource("data_UmmAlQuraVsISODates") public void Test_UmmAlQuraVsISODates(HijrahDate hd, LocalDate ld) { - assertEquals(hd.toEpochDay(), ld.toEpochDay(), "Umm alQura date and ISO date should have same epochDay"); + assertEquals(ld.toEpochDay(), hd.toEpochDay(), "Umm alQura date and ISO date should have same epochDay"); } // UmmAlQura chronology ranges for year, month and days for the HijrahChronology @@ -120,28 +126,27 @@ public class TestUmmAlQuraChronology { public void Test_UmmAlQuraChronoRange() { HijrahChronology chrono = HijrahChronology.INSTANCE; ValueRange year = chrono.range(YEAR); - assertEquals(year.getMinimum(), 1300, "Minimum year"); - assertEquals(year.getLargestMinimum(), 1300, "Largest minimum year"); - assertEquals(year.getMaximum(), 1600, "Largest year"); - assertEquals(year.getSmallestMaximum(), 1600, "Smallest Maximum year"); + assertEquals(1300, year.getMinimum(), "Minimum year"); + assertEquals(1300, year.getLargestMinimum(), "Largest minimum year"); + assertEquals(1600, year.getMaximum(), "Largest year"); + assertEquals(1600, year.getSmallestMaximum(), "Smallest Maximum year"); ValueRange month = chrono.range(MONTH_OF_YEAR); - assertEquals(month.getMinimum(), 1, "Minimum month"); - assertEquals(month.getLargestMinimum(), 1, "Largest minimum month"); - assertEquals(month.getMaximum(), 12, "Largest month"); - assertEquals(month.getSmallestMaximum(), 12, "Smallest Maximum month"); + assertEquals(1, month.getMinimum(), "Minimum month"); + assertEquals(1, month.getLargestMinimum(), "Largest minimum month"); + assertEquals(12, month.getMaximum(), "Largest month"); + assertEquals(12, month.getSmallestMaximum(), "Smallest Maximum month"); ValueRange day = chrono.range(DAY_OF_MONTH); - assertEquals(day.getMinimum(), 1, "Minimum day"); - assertEquals(day.getLargestMinimum(), 1, "Largest minimum day"); - assertEquals(day.getMaximum(), 30, "Largest day"); - assertEquals(day.getSmallestMaximum(), 29, "Smallest Maximum day"); + assertEquals(1, day.getMinimum(), "Minimum day"); + assertEquals(1, day.getLargestMinimum(), "Largest minimum day"); + assertEquals(30, day.getMaximum(), "Largest day"); + assertEquals(29, day.getSmallestMaximum(), "Smallest Maximum day"); } //----------------------------------------------------------------------- // regular data factory for dates and the corresponding range values //----------------------------------------------------------------------- - @DataProvider(name = "dates") Object[][] data_dates() { return new Object[][]{ {HijrahDate.of(1300, 5, 1), 1300, 1600, 1, 12, 1, 30, 30}, @@ -153,7 +158,8 @@ public class TestUmmAlQuraChronology { } // Test to verify the min/max field ranges for given dates - @Test(dataProvider="dates") + @ParameterizedTest + @MethodSource("data_dates") public void Test_UmmAlQuraRanges(HijrahDate date, int minYear, int maxYear, int minMonth, int maxMonth, @@ -161,33 +167,33 @@ public class TestUmmAlQuraChronology { // Check the chronology ranges HijrahChronology chrono = date.getChronology(); ValueRange yearRange = chrono.range(YEAR); - assertEquals(yearRange.getMinimum(), minYear, "Minimum year for Hijrah chronology"); - assertEquals(yearRange.getLargestMinimum(), minYear, "Largest minimum year for Hijrah chronology"); - assertEquals(yearRange.getMaximum(), maxYear, "Maximum year for Hijrah chronology"); - assertEquals(yearRange.getSmallestMaximum(), maxYear, "Smallest Maximum year for Hijrah chronology"); + assertEquals(minYear, yearRange.getMinimum(), "Minimum year for Hijrah chronology"); + assertEquals(minYear, yearRange.getLargestMinimum(), "Largest minimum year for Hijrah chronology"); + assertEquals(maxYear, yearRange.getMaximum(), "Maximum year for Hijrah chronology"); + assertEquals(maxYear, yearRange.getSmallestMaximum(), "Smallest Maximum year for Hijrah chronology"); ValueRange monthRange = chrono.range(MONTH_OF_YEAR); - assertEquals(monthRange.getMinimum(), minMonth, "Minimum month for Hijrah chronology"); - assertEquals(monthRange.getMaximum(), maxMonth, "Maximum month for Hijrah chronology"); + assertEquals(minMonth, monthRange.getMinimum(), "Minimum month for Hijrah chronology"); + assertEquals(maxMonth, monthRange.getMaximum(), "Maximum month for Hijrah chronology"); ValueRange daysRange = chrono.range(DAY_OF_MONTH); - assertEquals(daysRange.getMinimum(), minDay, "Minimum day for chronology"); - assertEquals(daysRange.getMaximum(), maxChronoDay, "Maximum day for Hijrah chronology"); + assertEquals(minDay, daysRange.getMinimum(), "Minimum day for chronology"); + assertEquals(maxChronoDay, daysRange.getMaximum(), "Maximum day for Hijrah chronology"); // Check the date ranges yearRange = date.range(YEAR); - assertEquals(yearRange.getMinimum(), minYear, "Minimum year for Hijrah date"); - assertEquals(yearRange.getLargestMinimum(), minYear, "Largest minimum year for Hijrah date"); - assertEquals(yearRange.getMaximum(), maxYear, "Maximum year for Hijrah date"); - assertEquals(yearRange.getSmallestMaximum(), maxYear, "Smallest maximum year for Hijrah date"); + assertEquals(minYear, yearRange.getMinimum(), "Minimum year for Hijrah date"); + assertEquals(minYear, yearRange.getLargestMinimum(), "Largest minimum year for Hijrah date"); + assertEquals(maxYear, yearRange.getMaximum(), "Maximum year for Hijrah date"); + assertEquals(maxYear, yearRange.getSmallestMaximum(), "Smallest maximum year for Hijrah date"); monthRange = date.range(MONTH_OF_YEAR); - assertEquals(monthRange.getMinimum(), minMonth, "Minimum month for HijrahDate"); - assertEquals(monthRange.getMaximum(), maxMonth, "Maximum month for HijrahDate"); + assertEquals(minMonth, monthRange.getMinimum(), "Minimum month for HijrahDate"); + assertEquals(maxMonth, monthRange.getMaximum(), "Maximum month for HijrahDate"); daysRange = date.range(DAY_OF_MONTH); - assertEquals(daysRange.getMinimum(), minDay, "Minimum day for HijrahDate"); - assertEquals(daysRange.getMaximum(), maxDay, "Maximum day for HijrahDate"); + assertEquals(minDay, daysRange.getMinimum(), "Minimum day for HijrahDate"); + assertEquals(maxDay, daysRange.getMaximum(), "Maximum day for HijrahDate"); } @@ -223,7 +229,6 @@ public class TestUmmAlQuraChronology { } // Data provider to verify the dateYearDay() method - @DataProvider(name="dateYearDay") Object[][] data_dateYearDay() { return new Object[][] { {HijrahChronology.INSTANCE.dateYearDay(1434, 42), HijrahChronology.INSTANCE.date(1434, 02, 13)}, @@ -236,9 +241,10 @@ public class TestUmmAlQuraChronology { } // Test to verify the dateYearDay() method - @Test(dataProvider="dateYearDay") + @ParameterizedTest + @MethodSource("data_dateYearDay") public void test_DateYearDay(ChronoLocalDate date1, ChronoLocalDate date2) { - assertEquals(date1, date2); + assertEquals(date2, date1); } //----------------------------------------------------------------------- @@ -250,7 +256,7 @@ public class TestUmmAlQuraChronology { for (int i = 1; i <= hd1.lengthOfYear(); i++) { HijrahDate hd = HijrahChronology.INSTANCE.dateYearDay(1434, i); int doy = hd.get(DAY_OF_YEAR); - assertEquals(doy, i, "get(DAY_OF_YEAR) incorrect for " + i); + assertEquals(i, doy, "get(DAY_OF_YEAR) incorrect for " + i); } } @@ -260,54 +266,57 @@ public class TestUmmAlQuraChronology { for (int i = 1; i <= hd.lengthOfYear(); i++) { HijrahDate hd2 = hd.with(DAY_OF_YEAR, i); int doy = hd2.get(DAY_OF_YEAR); - assertEquals(doy, i, "with(DAY_OF_YEAR) incorrect for " + i + " " + hd2); + assertEquals(i, doy, "with(DAY_OF_YEAR) incorrect for " + i + " " + hd2); } } - @Test(expectedExceptions=java.time.DateTimeException.class) + @Test public void test_withDayOfYearTooSmall() { - HijrahDate hd = HijrahChronology.INSTANCE.dateYearDay(1435, 1); - HijrahDate hd2 = hd.with(DAY_OF_YEAR, 0); + Assertions.assertThrows(DateTimeException.class, () -> { + HijrahDate hd = HijrahChronology.INSTANCE.dateYearDay(1435, 1); + HijrahDate hd2 = hd.with(DAY_OF_YEAR, 0); + }); } - @Test(expectedExceptions=java.time.DateTimeException.class) + @Test public void test_withDayOfYearTooLarge() { - HijrahDate hd = HijrahChronology.INSTANCE.dateYearDay(1435, 1); - HijrahDate hd2 = hd.with(DAY_OF_YEAR, hd.lengthOfYear() + 1); + Assertions.assertThrows(DateTimeException.class, () -> { + HijrahDate hd = HijrahChronology.INSTANCE.dateYearDay(1435, 1); + HijrahDate hd2 = hd.with(DAY_OF_YEAR, hd.lengthOfYear() + 1); + }); } // Test to verify the with() method with ChronoField is set to DAY_OF_WEEK @Test public void test_adjustWithDayOfWeek() { - assertEquals(HijrahChronology.INSTANCE.date(1320, 1, 15).with(ChronoField.DAY_OF_WEEK, 4), HijrahDate.of(1320, 1, 15)); - assertEquals(HijrahChronology.INSTANCE.date(1421, 11, 15).with(ChronoField.DAY_OF_WEEK, 1), HijrahDate.of(1421, 11, 11)); - assertEquals(HijrahChronology.INSTANCE.date(1529, 7, 18).with(ChronoField.DAY_OF_WEEK, 6), HijrahDate.of(1529, 7, 20)); - assertEquals(HijrahChronology.INSTANCE.date(1534, 2, 10).with(ChronoField.DAY_OF_WEEK, 5), HijrahDate.of(1534, 2, 12)); - assertEquals(HijrahChronology.INSTANCE.date(1552, 4, 1).with(ChronoField.DAY_OF_WEEK, 2), HijrahDate.of(1552, 3, 26)); + assertEquals(HijrahDate.of(1320, 1, 15), HijrahChronology.INSTANCE.date(1320, 1, 15).with(ChronoField.DAY_OF_WEEK, 4)); + assertEquals(HijrahDate.of(1421, 11, 11), HijrahChronology.INSTANCE.date(1421, 11, 15).with(ChronoField.DAY_OF_WEEK, 1)); + assertEquals(HijrahDate.of(1529, 7, 20), HijrahChronology.INSTANCE.date(1529, 7, 18).with(ChronoField.DAY_OF_WEEK, 6)); + assertEquals(HijrahDate.of(1534, 2, 12), HijrahChronology.INSTANCE.date(1534, 2, 10).with(ChronoField.DAY_OF_WEEK, 5)); + assertEquals(HijrahDate.of(1552, 3, 26), HijrahChronology.INSTANCE.date(1552, 4, 1).with(ChronoField.DAY_OF_WEEK, 2)); } // Test to verify the with() method with ChronoField is set to DAY_OF_MONTH @Test public void test_adjustWithDayOfMonth() { - assertEquals(HijrahChronology.INSTANCE.date(1320, 1, 15).with(ChronoField.DAY_OF_MONTH, 2), HijrahDate.of(1320, 1, 2)); - assertEquals(HijrahChronology.INSTANCE.date(1421, 11, 15).with(ChronoField.DAY_OF_MONTH, 9), HijrahDate.of(1421, 11, 9)); - assertEquals(HijrahChronology.INSTANCE.date(1529, 7, 18).with(ChronoField.DAY_OF_MONTH, 13), HijrahDate.of(1529, 7, 13)); - assertEquals(HijrahChronology.INSTANCE.date(1534, 12, 10).with(ChronoField.DAY_OF_MONTH, 29), HijrahDate.of(1534, 12, 29)); - assertEquals(HijrahChronology.INSTANCE.date(1552, 4, 1).with(ChronoField.DAY_OF_MONTH, 6), HijrahDate.of(1552, 4, 6)); + assertEquals(HijrahDate.of(1320, 1, 2), HijrahChronology.INSTANCE.date(1320, 1, 15).with(ChronoField.DAY_OF_MONTH, 2)); + assertEquals(HijrahDate.of(1421, 11, 9), HijrahChronology.INSTANCE.date(1421, 11, 15).with(ChronoField.DAY_OF_MONTH, 9)); + assertEquals(HijrahDate.of(1529, 7, 13), HijrahChronology.INSTANCE.date(1529, 7, 18).with(ChronoField.DAY_OF_MONTH, 13)); + assertEquals(HijrahDate.of(1534, 12, 29), HijrahChronology.INSTANCE.date(1534, 12, 10).with(ChronoField.DAY_OF_MONTH, 29)); + assertEquals(HijrahDate.of(1552, 4, 6), HijrahChronology.INSTANCE.date(1552, 4, 1).with(ChronoField.DAY_OF_MONTH, 6)); } // Test to verify the with() method with ChronoField is set to DAY_OF_YEAR @Test public void test_adjustWithDayOfYear() { - assertEquals(HijrahChronology.INSTANCE.date(1320, 1, 15).with(ChronoField.DAY_OF_YEAR, 24), HijrahDate.of(1320, 1, 24)); - assertEquals(HijrahChronology.INSTANCE.date(1421, 11, 15).with(ChronoField.DAY_OF_YEAR, 135), HijrahDate.of(1421, 5, 18)); - assertEquals(HijrahChronology.INSTANCE.date(1529, 7, 18).with(ChronoField.DAY_OF_YEAR, 64), HijrahDate.of(1529, 3, 5)); - assertEquals(HijrahChronology.INSTANCE.date(1534, 2, 10).with(ChronoField.DAY_OF_YEAR, 354), HijrahDate.of(1534, 12, 29)); - assertEquals(HijrahChronology.INSTANCE.date(1552, 4, 1).with(ChronoField.DAY_OF_YEAR, 291), HijrahDate.of(1552, 10, 26)); + assertEquals(HijrahDate.of(1320, 1, 24), HijrahChronology.INSTANCE.date(1320, 1, 15).with(ChronoField.DAY_OF_YEAR, 24)); + assertEquals(HijrahDate.of(1421, 5, 18), HijrahChronology.INSTANCE.date(1421, 11, 15).with(ChronoField.DAY_OF_YEAR, 135)); + assertEquals(HijrahDate.of(1529, 3, 5), HijrahChronology.INSTANCE.date(1529, 7, 18).with(ChronoField.DAY_OF_YEAR, 64)); + assertEquals(HijrahDate.of(1534, 12, 29), HijrahChronology.INSTANCE.date(1534, 2, 10).with(ChronoField.DAY_OF_YEAR, 354)); + assertEquals(HijrahDate.of(1552, 10, 26), HijrahChronology.INSTANCE.date(1552, 4, 1).with(ChronoField.DAY_OF_YEAR, 291)); } // Data provider to get the difference between two dates in terms of days, months and years - @DataProvider(name="datesForDiff") Object[][] data_datesForDiffs() { return new Object[][] { {HijrahDate.of(1350, 5, 15), HijrahDate.of(1351, 12, 29), 574, 19, 1}, @@ -319,15 +328,15 @@ public class TestUmmAlQuraChronology { } // Test to verify the difference between two given dates in terms of days, months and years - @Test(dataProvider="datesForDiff") + @ParameterizedTest + @MethodSource("data_datesForDiffs") public void test_diffBetweenDates(ChronoLocalDate from, ChronoLocalDate to, long days, long months, long years) { - assertEquals(from.until(to, ChronoUnit.DAYS), days); - assertEquals(from.until(to, ChronoUnit.MONTHS), months); - assertEquals(from.until(to, ChronoUnit.YEARS), years); + assertEquals(days, from.until(to, ChronoUnit.DAYS)); + assertEquals(months, from.until(to, ChronoUnit.MONTHS)); + assertEquals(years, from.until(to, ChronoUnit.YEARS)); } // Data provider to get the difference between two dates as a period - @DataProvider(name="datesForPeriod") Object[][] data_Period() { return new Object[][] { {HijrahDate.of(1350, 5, 15), HijrahDate.of(1434, 7, 20), HijrahChronology.INSTANCE.period(84, 2, 5)}, @@ -339,34 +348,35 @@ public class TestUmmAlQuraChronology { } // Test to get the Period between two given dates - @Test(dataProvider="datesForPeriod") + @ParameterizedTest + @MethodSource("data_Period") public void test_until(HijrahDate h1, HijrahDate h2, ChronoPeriod p) { ChronoPeriod period = h1.until(h2); - assertEquals(period, p); + assertEquals(p, period); } // Test to get the Period between dates in different chronologies - @Test(dataProvider="datesForPeriod") + @ParameterizedTest + @MethodSource("data_Period") public void test_periodUntilDiffChrono(HijrahDate h1, HijrahDate h2, ChronoPeriod p) { MinguoDate m = MinguoChronology.INSTANCE.date(h2); ChronoPeriod period = h1.until(m); - assertEquals(period, p); + assertEquals(p, period); } // Test to get the adjusted date from a given date using TemporalAdjuster methods @Test public void test_temporalDayAdjustments() { HijrahDate date = HijrahDate.of(1554, 7, 21); - assertEquals(date.with(TemporalAdjusters.firstDayOfMonth()), HijrahDate.of(1554, 7, 1)); - assertEquals(date.with(TemporalAdjusters.lastDayOfMonth()), HijrahDate.of(1554, 7, 29)); - assertEquals(date.with(TemporalAdjusters.firstDayOfNextMonth()), HijrahDate.of(1554, 8, 1)); - assertEquals(date.with(TemporalAdjusters.firstDayOfNextYear()), HijrahDate.of(1555, 1, 1)); - assertEquals(date.with(TemporalAdjusters.firstDayOfYear()), HijrahDate.of(1554, 1, 1)); - assertEquals(date.with(TemporalAdjusters.lastDayOfYear()), HijrahDate.of(1554, 12, 30)); + assertEquals(HijrahDate.of(1554, 7, 1), date.with(TemporalAdjusters.firstDayOfMonth())); + assertEquals(HijrahDate.of(1554, 7, 29), date.with(TemporalAdjusters.lastDayOfMonth())); + assertEquals(HijrahDate.of(1554, 8, 1), date.with(TemporalAdjusters.firstDayOfNextMonth())); + assertEquals(HijrahDate.of(1555, 1, 1), date.with(TemporalAdjusters.firstDayOfNextYear())); + assertEquals(HijrahDate.of(1554, 1, 1), date.with(TemporalAdjusters.firstDayOfYear())); + assertEquals(HijrahDate.of(1554, 12, 30), date.with(TemporalAdjusters.lastDayOfYear())); } // Data provider for string representation of the date instances - @DataProvider(name="toString") Object[][] data_toString() { return new Object[][] { {HijrahChronology.INSTANCE.date(1320, 1, 1), "Hijrah-umalqura AH 1320-01-01"}, @@ -378,13 +388,13 @@ public class TestUmmAlQuraChronology { } // Test to verify the returned string value of a given date instance - @Test(dataProvider="toString") + @ParameterizedTest + @MethodSource("data_toString") public void test_toString(ChronoLocalDate hijrahDate, String expected) { - assertEquals(hijrahDate.toString(), expected); + assertEquals(expected, hijrahDate.toString()); } // Data provider for maximum number of days - @DataProvider(name="monthDays") Object[][] data_monthDays() { return new Object[][] { {1432, 1, 29}, @@ -397,27 +407,28 @@ public class TestUmmAlQuraChronology { } // Test to verify the maximum number of days by adding one month to a given date - @Test (dataProvider="monthDays") + @ParameterizedTest + @MethodSource("data_monthDays") public void test_valueRange_monthDays(int year, int month, int maxlength) { ChronoLocalDate date = HijrahChronology.INSTANCE.date(year, month, 1); ValueRange range = null; for (int i=1; i<=12; i++) { range = date.range(ChronoField.DAY_OF_MONTH); date = date.plus(1, ChronoUnit.MONTHS); - assertEquals(range.getMaximum(), month, maxlength); + assertEquals(month, range.getMaximum(), maxlength); } } // Test to get the last day of the month by adjusting the date with lastDayOfMonth() method - @Test(dataProvider="monthDays") + @ParameterizedTest + @MethodSource("data_monthDays") public void test_lastDayOfMonth(int year, int month, int numDays) { HijrahDate hDate = HijrahChronology.INSTANCE.date(year, month, 1); hDate = hDate.with(TemporalAdjusters.lastDayOfMonth()); - assertEquals(hDate.get(ChronoField.DAY_OF_MONTH), numDays); + assertEquals(numDays, hDate.get(ChronoField.DAY_OF_MONTH)); } // Data provider for the 12 islamic month names in a formatted date - @DataProvider(name="patternMonthNames") Object[][] data_patternMonthNames() { return new Object[][] { {1434, 1, 1, "01 AH Thu Muharram 1434"}, @@ -436,15 +447,15 @@ public class TestUmmAlQuraChronology { } // Test to verify the formatted dates - @Test(dataProvider="patternMonthNames") + @ParameterizedTest + @MethodSource("data_patternMonthNames") public void test_ofPattern(int year, int month, int day, String expected) { DateTimeFormatter test = DateTimeFormatter.ofPattern("dd G E MMMM yyyy", Locale.US); - assertEquals(test.format(HijrahDate.of(year, month, day)), expected); + assertEquals(expected, test.format(HijrahDate.of(year, month, day))); } // Data provider for localized dates - @DataProvider(name="chronoDateTimes") - Object[][] data_chronodatetimes() { + Object[][] data_chronodatetimes() { return new Object[][] { {1432, 12, 29, "Safar 1, 1434 AH"}, {1433, 1, 30, "Safar 30, 1434 AH"}, @@ -453,7 +464,8 @@ public class TestUmmAlQuraChronology { } // Test to verify the localized dates using ofLocalizedDate() method - @Test(dataProvider="chronoDateTimes") + @ParameterizedTest + @MethodSource("data_chronodatetimes") public void test_formatterOfLocalizedDate(int year, int month, int day, String expected) { HijrahDate hd = HijrahChronology.INSTANCE.date(year, month, day); ChronoLocalDateTime hdt = hd.atTime(LocalTime.NOON); @@ -464,12 +476,11 @@ public class TestUmmAlQuraChronology { hdt = hdt.plus(1, ChronoUnit.MINUTES); hdt = hdt.plus(1, ChronoUnit.SECONDS); DateTimeFormatter df = DateTimeFormatter.ofLocalizedDate(FormatStyle.LONG).withChronology(Chronology.of("Hijrah-umalqura")).withLocale(Locale.US); - assertEquals(df.format(hdt), expected); + assertEquals(expected, df.format(hdt)); } // Data provider to get the day of the week in a given date // The day of the week varies if the week starts with a saturday or sunday - @DataProvider(name="dayOfWeek") Object[][] data_dayOfweek() { return new Object[][] { {HijrahDate.of(1434, 6, 24), 1, 7}, @@ -481,14 +492,14 @@ public class TestUmmAlQuraChronology { } // Test to get the day of the week based on a Saturday/Sunday as the first day of the week - @Test(dataProvider="dayOfWeek") + @ParameterizedTest + @MethodSource("data_dayOfweek") public void test_dayOfWeek(HijrahDate date, int satStart, int sunStart) { - assertEquals(date.get(WeekFields.of(DayOfWeek.SATURDAY, 7).dayOfWeek()), satStart); - assertEquals(date.get(WeekFields.of(DayOfWeek.SUNDAY, 7).dayOfWeek()), sunStart); + assertEquals(satStart, date.get(WeekFields.of(DayOfWeek.SATURDAY, 7).dayOfWeek())); + assertEquals(sunStart, date.get(WeekFields.of(DayOfWeek.SUNDAY, 7).dayOfWeek())); } // Data sample to get the epoch days of a date instance - @DataProvider(name="epochDays") Object[][] data_epochdays() { return new Object[][] { {1332, -20486}, @@ -502,14 +513,14 @@ public class TestUmmAlQuraChronology { } // Test to verify the number of epoch days of a date instance - @Test(dataProvider="epochDays") + @ParameterizedTest + @MethodSource("data_epochdays") public void test_epochDays(int y, long epoch) { HijrahDate date = HijrahDate.of(y, 1, 1); - assertEquals(date.toEpochDay(), epoch); + assertEquals(epoch, date.toEpochDay()); } // Data provider to verify whether a given hijrah year is a leap year or not - @DataProvider(name="leapYears") Object[][] data_leapyears() { return new Object[][] { {1302, true}, @@ -524,15 +535,15 @@ public class TestUmmAlQuraChronology { } // Test to verify whether a given hijrah year is a leap year or not - @Test(dataProvider="leapYears") + @ParameterizedTest + @MethodSource("data_leapyears") public void test_leapYears(int y, boolean leapyear) { HijrahDate date = HijrahDate.of(y, 1, 1); - assertEquals(date.isLeapYear(), leapyear); + assertEquals(leapyear, date.isLeapYear()); } // Data provider to verify that a given hijrah year is outside the range of supported years // The values are dependent on the currently configured UmmAlQura calendar data - @DataProvider(name="OutOfRangeLeapYears") Object[][] data_invalid_leapyears() { return new Object[][] { {1299}, @@ -542,14 +553,14 @@ public class TestUmmAlQuraChronology { }; } - @Test(dataProvider="OutOfRangeLeapYears") + @ParameterizedTest + @MethodSource("data_invalid_leapyears") public void test_notLeapYears(int y) { assertFalse(HijrahChronology.INSTANCE.isLeapYear(y), "Out of range leap year"); } // Date samples to convert HijrahDate to LocalDate and vice versa - @DataProvider(name="samples") Object[][] data_samples() { return new Object[][] { {HijrahChronology.INSTANCE.date(1319, 12, 30), LocalDate.of(1902, 4, 9)}, @@ -562,45 +573,50 @@ public class TestUmmAlQuraChronology { } // Test to get LocalDate instance from a given HijrahDate - @Test(dataProvider="samples") + @ParameterizedTest + @MethodSource("data_samples") public void test_toLocalDate(ChronoLocalDate hijrahDate, LocalDate iso) { - assertEquals(LocalDate.from(hijrahDate), iso); + assertEquals(iso, LocalDate.from(hijrahDate)); } // Test to adjust HijrahDate with a given LocalDate - @Test(dataProvider="samples") + @ParameterizedTest + @MethodSource("data_samples") public void test_adjust_toLocalDate(ChronoLocalDate hijrahDate, LocalDate iso) { - assertEquals(hijrahDate.with(iso), hijrahDate); + assertEquals(hijrahDate, hijrahDate.with(iso)); } // Test to get a HijrahDate from a calendrical - @Test(dataProvider="samples") + @ParameterizedTest + @MethodSource("data_samples") public void test_fromCalendrical(ChronoLocalDate hijrahDate, LocalDate iso) { - assertEquals(HijrahChronology.INSTANCE.date(iso), hijrahDate); + assertEquals(hijrahDate, HijrahChronology.INSTANCE.date(iso)); } // Test to verify the day of week of a given HijrahDate and LocalDate - @Test(dataProvider="samples") + @ParameterizedTest + @MethodSource("data_samples") public void test_dayOfWeekEqualIsoDayOfWeek(ChronoLocalDate hijrahDate, LocalDate iso) { - assertEquals(hijrahDate.get(ChronoField.DAY_OF_WEEK), iso.get(ChronoField.DAY_OF_WEEK), "Hijrah day of week should be same as ISO day of week"); + assertEquals(iso.get(ChronoField.DAY_OF_WEEK), hijrahDate.get(ChronoField.DAY_OF_WEEK), "Hijrah day of week should be same as ISO day of week"); } // Test to get the local date by applying the MIN adjustment with hijrah date - @Test(dataProvider="samples") + @ParameterizedTest + @MethodSource("data_samples") public void test_LocalDate_adjustToHijrahDate(ChronoLocalDate hijrahDate, LocalDate localDate) { LocalDate test = LocalDate.MIN.with(hijrahDate); - assertEquals(test, localDate); + assertEquals(localDate, test); } // Test to get the local date time by applying the MIN adjustment with hijrah date - @Test(dataProvider="samples") + @ParameterizedTest + @MethodSource("data_samples") public void test_LocalDateTime_adjustToHijrahDate(ChronoLocalDate hijrahDate, LocalDate localDate) { LocalDateTime test = LocalDateTime.MIN.with(hijrahDate); - assertEquals(test, LocalDateTime.of(localDate, LocalTime.MIDNIGHT)); + assertEquals(LocalDateTime.of(localDate, LocalTime.MIDNIGHT), test); } // Sample dates for comparison - @DataProvider(name="datesForComparison") Object[][] data_datesForComparison() { return new Object[][] { {HijrahChronology.INSTANCE.date(1434, 6, 26), LocalDate.of(2013, 5, 5), -1, 1}, @@ -612,42 +628,42 @@ public class TestUmmAlQuraChronology { } // Test to compare dates in both forward and reverse order - @Test(dataProvider="datesForComparison") + @ParameterizedTest + @MethodSource("data_datesForComparison") public void test_compareDates(HijrahDate hdate, LocalDate ldate, int result1, int result2) { - assertEquals(ldate.compareTo(hdate), result1); - assertEquals(hdate.compareTo(ldate), result2); + assertEquals(result1, ldate.compareTo(hdate)); + assertEquals(result2, hdate.compareTo(ldate)); } // Test to verify the values of various chrono fields for a given hijrah date instance @Test public void test_chronoFields() { ChronoLocalDate hdate = HijrahChronology.INSTANCE.date(1434, 6, 28); - assertEquals(hdate.get(ChronoField.ALIGNED_DAY_OF_WEEK_IN_MONTH), 7); - assertEquals(hdate.get(ChronoField.ALIGNED_DAY_OF_WEEK_IN_YEAR), 7); - assertEquals(hdate.get(ChronoField.ALIGNED_WEEK_OF_MONTH), 4); - assertEquals(hdate.get(ChronoField.ALIGNED_WEEK_OF_YEAR), 25); - assertEquals(hdate.get(ChronoField.ERA), 1); - assertEquals(hdate.get(ChronoField.YEAR_OF_ERA), 1434); - assertEquals(hdate.get(ChronoField.MONTH_OF_YEAR), 6); - assertEquals(hdate.get(ChronoField.DAY_OF_MONTH), 28); - assertEquals(hdate.get(ChronoField.DAY_OF_WEEK), 3); - assertEquals(hdate.get(ChronoField.DAY_OF_YEAR), 175); + assertEquals(7, hdate.get(ChronoField.ALIGNED_DAY_OF_WEEK_IN_MONTH)); + assertEquals(7, hdate.get(ChronoField.ALIGNED_DAY_OF_WEEK_IN_YEAR)); + assertEquals(4, hdate.get(ChronoField.ALIGNED_WEEK_OF_MONTH)); + assertEquals(25, hdate.get(ChronoField.ALIGNED_WEEK_OF_YEAR)); + assertEquals(1, hdate.get(ChronoField.ERA)); + assertEquals(1434, hdate.get(ChronoField.YEAR_OF_ERA)); + assertEquals(6, hdate.get(ChronoField.MONTH_OF_YEAR)); + assertEquals(28, hdate.get(ChronoField.DAY_OF_MONTH)); + assertEquals(3, hdate.get(ChronoField.DAY_OF_WEEK)); + assertEquals(175, hdate.get(ChronoField.DAY_OF_YEAR)); } // Test to verify the returned hijrah date after adjusting the day of week as Saturday @Test public void test_adjustInto() { - assertEquals(DayOfWeek.SATURDAY.adjustInto(HijrahDate.of(1434, 6, 28)), HijrahDate.of(1434, 7, 1)); - assertEquals(DayOfWeek.SATURDAY.adjustInto(HijrahDate.of(1432, 4, 13)), HijrahDate.of(1432, 4, 14)); - assertEquals(DayOfWeek.SATURDAY.adjustInto(HijrahDate.of(1433, 11, 29)), HijrahDate.of(1433, 12, 4)); - assertEquals(DayOfWeek.SATURDAY.adjustInto(HijrahDate.of(1434, 5, 10)), HijrahDate.of(1434, 5, 11)); - assertEquals(DayOfWeek.SATURDAY.adjustInto(HijrahDate.of(1434, 9, 11)), HijrahDate.of(1434, 9, 12)); + assertEquals(HijrahDate.of(1434, 7, 1), DayOfWeek.SATURDAY.adjustInto(HijrahDate.of(1434, 6, 28))); + assertEquals(HijrahDate.of(1432, 4, 14), DayOfWeek.SATURDAY.adjustInto(HijrahDate.of(1432, 4, 13))); + assertEquals(HijrahDate.of(1433, 12, 4), DayOfWeek.SATURDAY.adjustInto(HijrahDate.of(1433, 11, 29))); + assertEquals(HijrahDate.of(1434, 5, 11), DayOfWeek.SATURDAY.adjustInto(HijrahDate.of(1434, 5, 10))); + assertEquals(HijrahDate.of(1434, 9, 12), DayOfWeek.SATURDAY.adjustInto(HijrahDate.of(1434, 9, 11))); } //----------------------------------------------------------------------- // zonedDateTime(TemporalAccessor) //----------------------------------------------------------------------- - @DataProvider(name="zonedDateTime") Object[][] data_zonedDateTime() { return new Object[][] { {ZonedDateTime.of(2012, 2, 29, 2, 7, 1, 1, ZONE_RIYADH), HijrahChronology.INSTANCE.date(1433, 4, 7), LocalTime.of(2, 7, 1, 1), null}, @@ -661,13 +677,14 @@ public class TestUmmAlQuraChronology { } // Test to check the zoned date times - @Test(dataProvider="zonedDateTime") + @ParameterizedTest + @MethodSource("data_zonedDateTime") public void test_zonedDateTime(TemporalAccessor accessor, HijrahDate expectedDate, LocalTime expectedTime, Class expectedEx) { if (expectedEx == null) { ChronoZonedDateTime result = HijrahChronology.INSTANCE.zonedDateTime(accessor); - assertEquals(result.toLocalDate(), expectedDate); - assertEquals(HijrahDate.from(accessor), expectedDate); - assertEquals(result.toLocalTime(), expectedTime); + assertEquals(expectedDate, result.toLocalDate()); + assertEquals(expectedDate, HijrahDate.from(accessor)); + assertEquals(expectedTime, result.toLocalTime()); } else { try { @@ -688,18 +705,17 @@ public class TestUmmAlQuraChronology { ZonedDateTime zonedDateTime = ZonedDateTime.of(2012, 2, 29, 2, 7, 1, 1, ZONE_RIYADH); ChronoZonedDateTime result = HijrahChronology.INSTANCE.zonedDateTime(offsetDateTime.toInstant(), offsetDateTime.getOffset()); - assertEquals(result.toLocalDate(), HijrahChronology.INSTANCE.date(1433, 4, 7)); - assertEquals(result.toLocalTime(), LocalTime.of(2, 7, 1, 1)); + assertEquals(HijrahChronology.INSTANCE.date(1433, 4, 7), result.toLocalDate()); + assertEquals(LocalTime.of(2, 7, 1, 1), result.toLocalTime()); result = HijrahChronology.INSTANCE.zonedDateTime(zonedDateTime.toInstant(), zonedDateTime.getOffset()); - assertEquals(result.toLocalDate(), HijrahChronology.INSTANCE.date(1433, 4, 7)); - assertEquals(result.toLocalTime(), LocalTime.of(2, 7, 1, 1)); + assertEquals(HijrahChronology.INSTANCE.date(1433, 4, 7), result.toLocalDate()); + assertEquals(LocalTime.of(2, 7, 1, 1), result.toLocalTime()); } //----------------------------------------------------------------------- // localDateTime() //----------------------------------------------------------------------- - @DataProvider(name="localDateTime") Object[][] data_localDateTime() { return new Object[][] { {LocalDateTime.of(2012, 2, 29, 2, 7), HijrahChronology.INSTANCE.date(1433, 4, 7), LocalTime.of(2, 7), null}, @@ -713,13 +729,14 @@ public class TestUmmAlQuraChronology { } // Test to verify local date time values from various date instances defined in the localDateTime data provider - @Test(dataProvider="localDateTime") + @ParameterizedTest + @MethodSource("data_localDateTime") public void test_localDateTime(TemporalAccessor accessor, HijrahDate expectedDate, LocalTime expectedTime, Class expectedEx) { if (expectedEx == null) { ChronoLocalDateTime result = HijrahChronology.INSTANCE.localDateTime(accessor); - assertEquals(result.toLocalDate(), expectedDate); - assertEquals(HijrahDate.from(accessor), expectedDate); - assertEquals(result.toLocalTime(), expectedTime); + assertEquals(expectedDate, result.toLocalDate()); + assertEquals(expectedDate, HijrahDate.from(accessor)); + assertEquals(expectedTime, result.toLocalTime()); } else { try { ChronoLocalDateTime result = HijrahChronology.INSTANCE.localDateTime(accessor); @@ -731,7 +748,6 @@ public class TestUmmAlQuraChronology { } // Sample Hijrah & Minguo Dates - @DataProvider(name="hijrahToMinguo") Object[][] data_hijrahToMinguo() { return new Object[][] { {HijrahDate.of(1350,5,15), MinguoDate.of(20,9,28)}, @@ -743,13 +759,13 @@ public class TestUmmAlQuraChronology { } // Test to verify the date conversion from Hijrah to Minguo chronology - @Test(dataProvider="hijrahToMinguo") + @ParameterizedTest + @MethodSource("data_hijrahToMinguo") public void test_hijrahToMinguo(HijrahDate hijrah, MinguoDate minguo) { - assertEquals(MinguoChronology.INSTANCE.date(hijrah), minguo); + assertEquals(minguo, MinguoChronology.INSTANCE.date(hijrah)); } // Sample Hijrah & Thai Dates - @DataProvider(name="hijrahToThai") Object[][] data_hijrahToThai() { return new Object[][] { {HijrahDate.of(1350,5,15), ThaiBuddhistDate.of(2474,9,28)}, @@ -761,13 +777,13 @@ public class TestUmmAlQuraChronology { } // Test to verify the date conversion from Hijrah to Thai chronology - @Test(dataProvider="hijrahToThai") + @ParameterizedTest + @MethodSource("data_hijrahToThai") public void test_hijrahToThai(HijrahDate hijrah, ThaiBuddhistDate thai) { - assertEquals(ThaiBuddhistChronology.INSTANCE.date(hijrah), thai); + assertEquals(thai, ThaiBuddhistChronology.INSTANCE.date(hijrah)); } // Sample Hijrah & Japanese Dates - @DataProvider(name="hijrahToJapanese") Object[][] data_hijrahToJapanese() { return new Object[][] { {HijrahDate.of(1350,5,15), "Japanese Showa 6-09-28"}, @@ -781,12 +797,12 @@ public class TestUmmAlQuraChronology { } // Test to verify the date conversion from Hijrah to Japanese chronology - @Test(dataProvider="hijrahToJapanese") + @ParameterizedTest + @MethodSource("data_hijrahToJapanese") public void test_hijrahToJapanese(HijrahDate hijrah, String japanese) { - assertEquals(JapaneseChronology.INSTANCE.date(hijrah).toString(), japanese); + assertEquals(japanese, JapaneseChronology.INSTANCE.date(hijrah).toString()); } - @DataProvider(name="alignedDayOfWeekInMonthTestDates") Object[][] data_alignedDayOfWeekInMonth() { return new Object[][] { {1437, 9, 1, 1, 1}, @@ -799,18 +815,20 @@ public class TestUmmAlQuraChronology { //----------------------------------------------------------------------- // Test for aligned-week-of-month calculation based on the day-of-month //----------------------------------------------------------------------- - @Test(dataProvider="alignedDayOfWeekInMonthTestDates") + @ParameterizedTest + @MethodSource("data_alignedDayOfWeekInMonth") public void test_alignedWeekOfMonth(int year, int month, int dom, int wom, int dowm) { HijrahDate date = HijrahChronology.INSTANCE.date(year, month, dom); - assertEquals(date.getLong(ChronoField.ALIGNED_WEEK_OF_MONTH), wom); + assertEquals(wom, date.getLong(ChronoField.ALIGNED_WEEK_OF_MONTH)); } //----------------------------------------------------------------------- // Test for aligned-day-of-week calculation based on the day-of-month //----------------------------------------------------------------------- - @Test(dataProvider="alignedDayOfWeekInMonthTestDates") + @ParameterizedTest + @MethodSource("data_alignedDayOfWeekInMonth") public void test_alignedDayOfWeekInMonth(int year, int month, int dom, int wom, int dowm) { HijrahDate date = HijrahChronology.INSTANCE.date(year, month, dom); - assertEquals(date.getLong(ChronoField.ALIGNED_DAY_OF_WEEK_IN_MONTH), dowm); + assertEquals(dowm, date.getLong(ChronoField.ALIGNED_DAY_OF_WEEK_IN_MONTH)); } } diff --git a/test/jdk/java/time/test/java/time/format/AbstractTestPrinterParser.java b/test/jdk/java/time/test/java/time/format/AbstractTestPrinterParser.java index 023f5c190ad..b4e9590c23d 100644 --- a/test/jdk/java/time/test/java/time/format/AbstractTestPrinterParser.java +++ b/test/jdk/java/time/test/java/time/format/AbstractTestPrinterParser.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2012, 2013, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2012, 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 @@ -72,13 +72,11 @@ import java.time.temporal.TemporalAccessor; import java.time.temporal.TemporalField; import java.util.Locale; -import org.testng.annotations.BeforeMethod; -import org.testng.annotations.Test; +import org.junit.jupiter.api.BeforeEach; /** * Abstract PrinterParser test. */ -@Test public class AbstractTestPrinterParser { protected StringBuilder buf; @@ -88,7 +86,7 @@ public class AbstractTestPrinterParser { protected DecimalStyle decimalStyle; - @BeforeMethod + @BeforeEach public void setUp() { buf = new StringBuilder(); builder = new DateTimeFormatterBuilder(); diff --git a/test/jdk/java/time/test/java/time/format/TestCharLiteralParser.java b/test/jdk/java/time/test/java/time/format/TestCharLiteralParser.java index 696aab0f539..d1896c865e1 100644 --- a/test/jdk/java/time/test/java/time/format/TestCharLiteralParser.java +++ b/test/jdk/java/time/test/java/time/format/TestCharLiteralParser.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2012, 2013, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2012, 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 @@ -60,24 +60,25 @@ package test.java.time.format; import static java.time.temporal.ChronoField.YEAR; -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 java.text.ParsePosition; import java.time.temporal.TemporalAccessor; import java.time.temporal.TemporalQueries; -import org.testng.annotations.DataProvider; -import org.testng.annotations.Test; +import org.junit.jupiter.api.TestInstance; +import org.junit.jupiter.params.ParameterizedTest; +import org.junit.jupiter.params.provider.MethodSource; /** * Test CharLiteralPrinterParser. */ -@Test +@TestInstance(TestInstance.Lifecycle.PER_CLASS) public class TestCharLiteralParser extends AbstractTestPrinterParser { - @DataProvider(name="success") Object[][] data_success() { return new Object[][] { // match @@ -100,24 +101,24 @@ public class TestCharLiteralParser extends AbstractTestPrinterParser { }; } - @Test(dataProvider="success") + @ParameterizedTest + @MethodSource("data_success") public void test_parse_success(char c, boolean caseSensitive, String text, int pos, int expectedPos) { setCaseSensitive(caseSensitive); ParsePosition ppos = new ParsePosition(pos); TemporalAccessor parsed = getFormatter(c).parseUnresolved(text, ppos); if (ppos.getErrorIndex() != -1) { - assertEquals(ppos.getIndex(), expectedPos); + assertEquals(expectedPos, ppos.getIndex()); } else { - assertEquals(ppos.getIndex(), expectedPos); - assertEquals(parsed.isSupported(YEAR), false); - assertEquals(parsed.query(TemporalQueries.chronology()), null); - assertEquals(parsed.query(TemporalQueries.zoneId()), null); + assertEquals(expectedPos, ppos.getIndex()); + assertEquals(false, parsed.isSupported(YEAR)); + assertEquals(null, parsed.query(TemporalQueries.chronology())); + assertEquals(null, parsed.query(TemporalQueries.zoneId())); } } //----------------------------------------------------------------------- - @DataProvider(name="error") Object[][] data_error() { return new Object[][] { {'a', "a", -1, IndexOutOfBoundsException.class}, @@ -125,7 +126,8 @@ public class TestCharLiteralParser extends AbstractTestPrinterParser { }; } - @Test(dataProvider="error") + @ParameterizedTest + @MethodSource("data_error") public void test_parse_error(char c, String text, int pos, Class expected) { try { ParsePosition ppos = new ParsePosition(pos); diff --git a/test/jdk/java/time/test/java/time/format/TestCharLiteralPrinter.java b/test/jdk/java/time/test/java/time/format/TestCharLiteralPrinter.java index 6aaf6a5b97d..71b7c7bed53 100644 --- a/test/jdk/java/time/test/java/time/format/TestCharLiteralPrinter.java +++ b/test/jdk/java/time/test/java/time/format/TestCharLiteralPrinter.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2012, 2013, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2012, 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 @@ -59,42 +59,45 @@ */ package test.java.time.format; -import static org.testng.Assert.assertEquals; - -import org.testng.annotations.Test; +import static org.junit.jupiter.api.Assertions.assertEquals; +import org.junit.jupiter.api.Test; /** * Test CharLiteralPrinterParser. */ -@Test public class TestCharLiteralPrinter extends AbstractTestPrinterParser { //----------------------------------------------------------------------- + @Test public void test_print_emptyCalendrical() throws Exception { buf.append("EXISTING"); getFormatter('a').formatTo(EMPTY_DTA, buf); - assertEquals(buf.toString(), "EXISTINGa"); + assertEquals("EXISTINGa", buf.toString()); } + @Test public void test_print_dateTime() throws Exception { buf.append("EXISTING"); getFormatter('a').formatTo(dta, buf); - assertEquals(buf.toString(), "EXISTINGa"); + assertEquals("EXISTINGa", buf.toString()); } + @Test public void test_print_emptyAppendable() throws Exception { getFormatter('a').formatTo(dta, buf); - assertEquals(buf.toString(), "a"); + assertEquals("a", buf.toString()); } //----------------------------------------------------------------------- + @Test public void test_toString() throws Exception { - assertEquals(getFormatter('a').toString(), "'a'"); + assertEquals("'a'", getFormatter('a').toString()); } //----------------------------------------------------------------------- + @Test public void test_toString_apos() throws Exception { - assertEquals(getFormatter('\'').toString(), "''"); + assertEquals("''", getFormatter('\'').toString()); } } diff --git a/test/jdk/java/time/test/java/time/format/TestDateTimeFormatter.java b/test/jdk/java/time/test/java/time/format/TestDateTimeFormatter.java index f6c1b253573..2ccc0da8f58 100644 --- a/test/jdk/java/time/test/java/time/format/TestDateTimeFormatter.java +++ b/test/jdk/java/time/test/java/time/format/TestDateTimeFormatter.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2012, 2022, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2012, 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 @@ -60,11 +60,12 @@ package test.java.time.format; import static java.time.temporal.ChronoField.DAY_OF_MONTH; -import static org.testng.Assert.assertEquals; -import static org.testng.Assert.assertSame; -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.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; import java.time.DateTimeException; import java.time.DayOfWeek; @@ -93,14 +94,16 @@ import java.time.temporal.TemporalAccessor; import java.util.Locale; import java.util.function.Function; -import org.testng.annotations.DataProvider; -import org.testng.annotations.Test; +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 DateTimeFormatter. * @bug 8085887 8293146 */ -@Test +@TestInstance(TestInstance.Lifecycle.PER_CLASS) public class TestDateTimeFormatter { @Test @@ -203,7 +206,6 @@ public class TestDateTimeFormatter { assertTrue(msg.contains("11:30:56"), msg); } - @DataProvider(name="nozone_exception_cases") Object[][] exceptionCases() { return new Object[][] { {LocalDateTime.of(2000, 1, 1, 1, 1), "z", "ZoneId"}, @@ -213,7 +215,8 @@ public class TestDateTimeFormatter { // Test cases that should throw an exception with a cogent message // containing the Type being queried and the Temporal being queried. - @Test(dataProvider="nozone_exception_cases") + @ParameterizedTest + @MethodSource("exceptionCases") public void test_throws_message(Temporal temporal, String pattern, String queryName) { DateTimeFormatter fmt = DateTimeFormatter.ofPattern(pattern); try { @@ -277,7 +280,6 @@ public class TestDateTimeFormatter { private static final DateTimeFormatter STRICT_WEEK = DateTimeFormatter.ofPattern("YYYY-'W'ww-e") .withResolverStyle(ResolverStyle.STRICT); private static final Locale EGYPT = Locale.forLanguageTag("en-EG"); - @DataProvider(name = "week53Dates") Object[][] data_week53Dates() { return new Object[][] { // WeekFields[SUNDAY,1] @@ -321,15 +323,14 @@ public class TestDateTimeFormatter { }; } - @Test (dataProvider = "week53Dates") + @ParameterizedTest + @MethodSource("data_week53Dates") public void test_week_53(String weekDate, Locale locale, LocalDate expected) { var f = STRICT_WEEK.withLocale(locale); if (expected != null) { - assertEquals(LocalDate.parse(weekDate, f), expected); + assertEquals(expected, LocalDate.parse(weekDate, f)); } else { - assertThrows(DateTimeException.class, () -> { - LocalDate.parse(weekDate, f); - }); + assertThrows(DateTimeException.class, () -> LocalDate.parse(weekDate, f)); } } } diff --git a/test/jdk/java/time/test/java/time/format/TestDateTimeFormatterBuilder.java b/test/jdk/java/time/test/java/time/format/TestDateTimeFormatterBuilder.java index 6d62dfe1265..294d204a216 100644 --- a/test/jdk/java/time/test/java/time/format/TestDateTimeFormatterBuilder.java +++ b/test/jdk/java/time/test/java/time/format/TestDateTimeFormatterBuilder.java @@ -66,9 +66,10 @@ import static java.time.temporal.ChronoField.HOUR_OF_DAY; import static java.time.temporal.ChronoField.MINUTE_OF_HOUR; import static java.time.temporal.ChronoField.MONTH_OF_YEAR; import static java.time.temporal.ChronoField.YEAR; -import static org.testng.Assert.assertEquals; -import static org.testng.Assert.assertNotNull; -import static org.testng.Assert.fail; + +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 java.text.ParsePosition; import java.time.LocalDate; @@ -95,19 +96,22 @@ import java.util.HashMap; import java.util.Locale; import java.util.Map; -import org.testng.annotations.BeforeMethod; -import org.testng.annotations.DataProvider; -import org.testng.annotations.Test; +import org.junit.jupiter.api.Assertions; +import org.junit.jupiter.api.BeforeEach; +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 DateTimeFormatterBuilder. */ -@Test +@TestInstance(TestInstance.Lifecycle.PER_CLASS) public class TestDateTimeFormatterBuilder { private DateTimeFormatterBuilder builder; - @BeforeMethod + @BeforeEach public void setUp() { builder = new DateTimeFormatterBuilder(); } @@ -116,7 +120,7 @@ public class TestDateTimeFormatterBuilder { @Test public void test_toFormatter_empty() throws Exception { DateTimeFormatter f = builder.toFormatter(); - assertEquals(f.toString(), ""); + assertEquals("", f.toString()); } //----------------------------------------------------------------------- @@ -124,14 +128,14 @@ public class TestDateTimeFormatterBuilder { public void test_parseCaseSensitive() throws Exception { builder.parseCaseSensitive(); DateTimeFormatter f = builder.toFormatter(); - assertEquals(f.toString(), "ParseCaseSensitive(true)"); + assertEquals("ParseCaseSensitive(true)", f.toString()); } @Test public void test_parseCaseInsensitive() throws Exception { builder.parseCaseInsensitive(); DateTimeFormatter f = builder.toFormatter(); - assertEquals(f.toString(), "ParseCaseSensitive(false)"); + assertEquals("ParseCaseSensitive(false)", f.toString()); } //----------------------------------------------------------------------- @@ -139,14 +143,14 @@ public class TestDateTimeFormatterBuilder { public void test_parseStrict() throws Exception { builder.parseStrict(); DateTimeFormatter f = builder.toFormatter(); - assertEquals(f.toString(), "ParseStrict(true)"); + assertEquals("ParseStrict(true)", f.toString()); } @Test public void test_parseLenient() throws Exception { builder.parseLenient(); DateTimeFormatter f = builder.toFormatter(); - assertEquals(f.toString(), "ParseStrict(false)"); + assertEquals("ParseStrict(false)", f.toString()); } //----------------------------------------------------------------------- @@ -154,12 +158,12 @@ public class TestDateTimeFormatterBuilder { public void test_appendValue_1arg() throws Exception { builder.appendValue(DAY_OF_MONTH); DateTimeFormatter f = builder.toFormatter(); - assertEquals(f.toString(), "Value(DayOfMonth)"); + assertEquals("Value(DayOfMonth)", f.toString()); } - @Test(expectedExceptions=NullPointerException.class) + @Test public void test_appendValue_1arg_null() throws Exception { - builder.appendValue(null); + Assertions.assertThrows(NullPointerException.class, () -> builder.appendValue(null)); } //----------------------------------------------------------------------- @@ -167,22 +171,22 @@ public class TestDateTimeFormatterBuilder { public void test_appendValue_2arg() throws Exception { builder.appendValue(DAY_OF_MONTH, 3); DateTimeFormatter f = builder.toFormatter(); - assertEquals(f.toString(), "Value(DayOfMonth,3)"); + assertEquals("Value(DayOfMonth,3)", f.toString()); } - @Test(expectedExceptions=NullPointerException.class) + @Test public void test_appendValue_2arg_null() throws Exception { - builder.appendValue(null, 3); + Assertions.assertThrows(NullPointerException.class, () -> builder.appendValue(null, 3)); } - @Test(expectedExceptions=IllegalArgumentException.class) + @Test public void test_appendValue_2arg_widthTooSmall() throws Exception { - builder.appendValue(DAY_OF_MONTH, 0); + Assertions.assertThrows(IllegalArgumentException.class, () -> builder.appendValue(DAY_OF_MONTH, 0)); } - @Test(expectedExceptions=IllegalArgumentException.class) + @Test public void test_appendValue_2arg_widthTooBig() throws Exception { - builder.appendValue(DAY_OF_MONTH, 20); + Assertions.assertThrows(IllegalArgumentException.class, () -> builder.appendValue(DAY_OF_MONTH, 20)); } //----------------------------------------------------------------------- @@ -190,42 +194,42 @@ public class TestDateTimeFormatterBuilder { public void test_appendValue_3arg() throws Exception { builder.appendValue(DAY_OF_MONTH, 2, 3, SignStyle.NORMAL); DateTimeFormatter f = builder.toFormatter(); - assertEquals(f.toString(), "Value(DayOfMonth,2,3,NORMAL)"); + assertEquals("Value(DayOfMonth,2,3,NORMAL)", f.toString()); } - @Test(expectedExceptions=NullPointerException.class) + @Test public void test_appendValue_3arg_nullField() throws Exception { - builder.appendValue(null, 2, 3, SignStyle.NORMAL); + Assertions.assertThrows(NullPointerException.class, () -> builder.appendValue(null, 2, 3, SignStyle.NORMAL)); } - @Test(expectedExceptions=IllegalArgumentException.class) + @Test public void test_appendValue_3arg_minWidthTooSmall() throws Exception { - builder.appendValue(DAY_OF_MONTH, 0, 2, SignStyle.NORMAL); + Assertions.assertThrows(IllegalArgumentException.class, () -> builder.appendValue(DAY_OF_MONTH, 0, 2, SignStyle.NORMAL)); } - @Test(expectedExceptions=IllegalArgumentException.class) + @Test public void test_appendValue_3arg_minWidthTooBig() throws Exception { - builder.appendValue(DAY_OF_MONTH, 20, 2, SignStyle.NORMAL); + Assertions.assertThrows(IllegalArgumentException.class, () -> builder.appendValue(DAY_OF_MONTH, 20, 2, SignStyle.NORMAL)); } - @Test(expectedExceptions=IllegalArgumentException.class) + @Test public void test_appendValue_3arg_maxWidthTooSmall() throws Exception { - builder.appendValue(DAY_OF_MONTH, 2, 0, SignStyle.NORMAL); + Assertions.assertThrows(IllegalArgumentException.class, () -> builder.appendValue(DAY_OF_MONTH, 2, 0, SignStyle.NORMAL)); } - @Test(expectedExceptions=IllegalArgumentException.class) + @Test public void test_appendValue_3arg_maxWidthTooBig() throws Exception { - builder.appendValue(DAY_OF_MONTH, 2, 20, SignStyle.NORMAL); + Assertions.assertThrows(IllegalArgumentException.class, () -> builder.appendValue(DAY_OF_MONTH, 2, 20, SignStyle.NORMAL)); } - @Test(expectedExceptions=IllegalArgumentException.class) + @Test public void test_appendValue_3arg_maxWidthMinWidth() throws Exception { - builder.appendValue(DAY_OF_MONTH, 4, 2, SignStyle.NORMAL); + Assertions.assertThrows(IllegalArgumentException.class, () -> builder.appendValue(DAY_OF_MONTH, 4, 2, SignStyle.NORMAL)); } - @Test(expectedExceptions=NullPointerException.class) + @Test public void test_appendValue_3arg_nullSignStyle() throws Exception { - builder.appendValue(DAY_OF_MONTH, 2, 3, null); + Assertions.assertThrows(NullPointerException.class, () -> builder.appendValue(DAY_OF_MONTH, 2, 3, null)); } //----------------------------------------------------------------------- @@ -233,30 +237,30 @@ public class TestDateTimeFormatterBuilder { public void test_appendValue_subsequent2_parse3() throws Exception { builder.appendValue(MONTH_OF_YEAR, 1, 2, SignStyle.NORMAL).appendValue(DAY_OF_MONTH, 2); DateTimeFormatter f = builder.toFormatter(); - assertEquals(f.toString(), "Value(MonthOfYear,1,2,NORMAL)Value(DayOfMonth,2)"); + assertEquals("Value(MonthOfYear,1,2,NORMAL)Value(DayOfMonth,2)", f.toString()); TemporalAccessor parsed = f.parseUnresolved("123", new ParsePosition(0)); - assertEquals(parsed.getLong(MONTH_OF_YEAR), 1L); - assertEquals(parsed.getLong(DAY_OF_MONTH), 23L); + assertEquals(1L, parsed.getLong(MONTH_OF_YEAR)); + assertEquals(23L, parsed.getLong(DAY_OF_MONTH)); } @Test public void test_appendValue_subsequent2_parse4() throws Exception { builder.appendValue(MONTH_OF_YEAR, 1, 2, SignStyle.NORMAL).appendValue(DAY_OF_MONTH, 2); DateTimeFormatter f = builder.toFormatter(); - assertEquals(f.toString(), "Value(MonthOfYear,1,2,NORMAL)Value(DayOfMonth,2)"); + assertEquals("Value(MonthOfYear,1,2,NORMAL)Value(DayOfMonth,2)", f.toString()); TemporalAccessor parsed = f.parseUnresolved("0123", new ParsePosition(0)); - assertEquals(parsed.getLong(MONTH_OF_YEAR), 1L); - assertEquals(parsed.getLong(DAY_OF_MONTH), 23L); + assertEquals(1L, parsed.getLong(MONTH_OF_YEAR)); + assertEquals(23L, parsed.getLong(DAY_OF_MONTH)); } @Test public void test_appendValue_subsequent2_parse5() throws Exception { builder.appendValue(MONTH_OF_YEAR, 1, 2, SignStyle.NORMAL).appendValue(DAY_OF_MONTH, 2).appendLiteral('4'); DateTimeFormatter f = builder.toFormatter(); - assertEquals(f.toString(), "Value(MonthOfYear,1,2,NORMAL)Value(DayOfMonth,2)'4'"); + assertEquals("Value(MonthOfYear,1,2,NORMAL)Value(DayOfMonth,2)'4'", f.toString()); TemporalAccessor parsed = f.parseUnresolved("01234", new ParsePosition(0)); - assertEquals(parsed.getLong(MONTH_OF_YEAR), 1L); - assertEquals(parsed.getLong(DAY_OF_MONTH), 23L); + assertEquals(1L, parsed.getLong(MONTH_OF_YEAR)); + assertEquals(23L, parsed.getLong(DAY_OF_MONTH)); } @Test @@ -266,38 +270,38 @@ public class TestDateTimeFormatterBuilder { .appendValue(MONTH_OF_YEAR, 2) .appendValue(DAY_OF_MONTH, 2); DateTimeFormatter f = builder.toFormatter(); - assertEquals(f.toString(), "Value(Year,4,10,EXCEEDS_PAD)Value(MonthOfYear,2)Value(DayOfMonth,2)"); + assertEquals("Value(Year,4,10,EXCEEDS_PAD)Value(MonthOfYear,2)Value(DayOfMonth,2)", f.toString()); TemporalAccessor parsed = f.parseUnresolved("20090630", new ParsePosition(0)); - assertEquals(parsed.getLong(YEAR), 2009L); - assertEquals(parsed.getLong(MONTH_OF_YEAR), 6L); - assertEquals(parsed.getLong(DAY_OF_MONTH), 30L); + assertEquals(2009L, parsed.getLong(YEAR)); + assertEquals(6L, parsed.getLong(MONTH_OF_YEAR)); + assertEquals(30L, parsed.getLong(DAY_OF_MONTH)); } //----------------------------------------------------------------------- - @Test(expectedExceptions=NullPointerException.class) + @Test public void test_appendValueReduced_null() throws Exception { - builder.appendValueReduced(null, 2, 2, 2000); + Assertions.assertThrows(NullPointerException.class, () -> builder.appendValueReduced(null, 2, 2, 2000)); } @Test public void test_appendValueReduced() throws Exception { builder.appendValueReduced(YEAR, 2, 2, 2000); DateTimeFormatter f = builder.toFormatter(); - assertEquals(f.toString(), "ReducedValue(Year,2,2,2000)"); + assertEquals("ReducedValue(Year,2,2,2000)", f.toString()); TemporalAccessor parsed = f.parseUnresolved("12", new ParsePosition(0)); - assertEquals(parsed.getLong(YEAR), 2012L); + assertEquals(2012L, parsed.getLong(YEAR)); } @Test public void test_appendValueReduced_subsequent_parse() throws Exception { builder.appendValue(MONTH_OF_YEAR, 1, 2, SignStyle.NORMAL).appendValueReduced(YEAR, 2, 2, 2000); DateTimeFormatter f = builder.toFormatter(); - assertEquals(f.toString(), "Value(MonthOfYear,1,2,NORMAL)ReducedValue(Year,2,2,2000)"); + assertEquals("Value(MonthOfYear,1,2,NORMAL)ReducedValue(Year,2,2,2000)", f.toString()); ParsePosition ppos = new ParsePosition(0); TemporalAccessor parsed = f.parseUnresolved("123", ppos); assertNotNull(parsed, "Parse failed: " + ppos.toString()); - assertEquals(parsed.getLong(MONTH_OF_YEAR), 1L); - assertEquals(parsed.getLong(YEAR), 2023L); + assertEquals(1L, parsed.getLong(MONTH_OF_YEAR)); + assertEquals(2023L, parsed.getLong(YEAR)); } //----------------------------------------------------------------------- @@ -307,42 +311,42 @@ public class TestDateTimeFormatterBuilder { public void test_appendFraction_4arg() throws Exception { builder.appendFraction(MINUTE_OF_HOUR, 1, 9, false); DateTimeFormatter f = builder.toFormatter(); - assertEquals(f.toString(), "Fraction(MinuteOfHour,1,9)"); + assertEquals("Fraction(MinuteOfHour,1,9)", f.toString()); } - @Test(expectedExceptions=NullPointerException.class) + @Test public void test_appendFraction_4arg_nullRule() throws Exception { - builder.appendFraction(null, 1, 9, false); + Assertions.assertThrows(NullPointerException.class, () -> builder.appendFraction(null, 1, 9, false)); } - @Test(expectedExceptions=IllegalArgumentException.class) + @Test public void test_appendFraction_4arg_invalidRuleNotFixedSet() throws Exception { - builder.appendFraction(DAY_OF_MONTH, 1, 9, false); + Assertions.assertThrows(IllegalArgumentException.class, () -> builder.appendFraction(DAY_OF_MONTH, 1, 9, false)); } - @Test(expectedExceptions=IllegalArgumentException.class) + @Test public void test_appendFraction_4arg_minTooSmall() throws Exception { - builder.appendFraction(MINUTE_OF_HOUR, -1, 9, false); + Assertions.assertThrows(IllegalArgumentException.class, () -> builder.appendFraction(MINUTE_OF_HOUR, -1, 9, false)); } - @Test(expectedExceptions=IllegalArgumentException.class) + @Test public void test_appendFraction_4arg_minTooBig() throws Exception { - builder.appendFraction(MINUTE_OF_HOUR, 10, 9, false); + Assertions.assertThrows(IllegalArgumentException.class, () -> builder.appendFraction(MINUTE_OF_HOUR, 10, 9, false)); } - @Test(expectedExceptions=IllegalArgumentException.class) + @Test public void test_appendFraction_4arg_maxTooSmall() throws Exception { - builder.appendFraction(MINUTE_OF_HOUR, 0, -1, false); + Assertions.assertThrows(IllegalArgumentException.class, () -> builder.appendFraction(MINUTE_OF_HOUR, 0, -1, false)); } - @Test(expectedExceptions=IllegalArgumentException.class) + @Test public void test_appendFraction_4arg_maxTooBig() throws Exception { - builder.appendFraction(MINUTE_OF_HOUR, 1, 10, false); + Assertions.assertThrows(IllegalArgumentException.class, () -> builder.appendFraction(MINUTE_OF_HOUR, 1, 10, false)); } - @Test(expectedExceptions=IllegalArgumentException.class) + @Test public void test_appendFraction_4arg_maxWidthMinWidth() throws Exception { - builder.appendFraction(MINUTE_OF_HOUR, 9, 3, false); + Assertions.assertThrows(IllegalArgumentException.class, () -> builder.appendFraction(MINUTE_OF_HOUR, 9, 3, false)); } //----------------------------------------------------------------------- @@ -352,12 +356,12 @@ public class TestDateTimeFormatterBuilder { public void test_appendText_1arg() throws Exception { builder.appendText(MONTH_OF_YEAR); DateTimeFormatter f = builder.toFormatter(); - assertEquals(f.toString(), "Text(MonthOfYear)"); + assertEquals("Text(MonthOfYear)", f.toString()); } - @Test(expectedExceptions=NullPointerException.class) + @Test public void test_appendText_1arg_null() throws Exception { - builder.appendText(null); + Assertions.assertThrows(NullPointerException.class, () -> builder.appendText(null)); } //----------------------------------------------------------------------- @@ -365,17 +369,17 @@ public class TestDateTimeFormatterBuilder { public void test_appendText_2arg() throws Exception { builder.appendText(MONTH_OF_YEAR, TextStyle.SHORT); DateTimeFormatter f = builder.toFormatter(); - assertEquals(f.toString(), "Text(MonthOfYear,SHORT)"); + assertEquals("Text(MonthOfYear,SHORT)", f.toString()); } - @Test(expectedExceptions=NullPointerException.class) + @Test public void test_appendText_2arg_nullRule() throws Exception { - builder.appendText(null, TextStyle.SHORT); + Assertions.assertThrows(NullPointerException.class, () -> builder.appendText(null, TextStyle.SHORT)); } - @Test(expectedExceptions=NullPointerException.class) + @Test public void test_appendText_2arg_nullStyle() throws Exception { - builder.appendText(MONTH_OF_YEAR, (TextStyle) null); + Assertions.assertThrows(NullPointerException.class, () -> builder.appendText(MONTH_OF_YEAR, (TextStyle) null)); } //----------------------------------------------------------------------- @@ -396,17 +400,17 @@ public class TestDateTimeFormatterBuilder { map.put(12L, "DBR"); builder.appendText(MONTH_OF_YEAR, map); DateTimeFormatter f = builder.toFormatter(); - assertEquals(f.toString(), "Text(MonthOfYear)"); // TODO: toString should be different? + assertEquals("Text(MonthOfYear)", f.toString()); // TODO: toString should be different? } - @Test(expectedExceptions=NullPointerException.class) + @Test public void test_appendTextMap_nullRule() throws Exception { - builder.appendText(null, new HashMap()); + Assertions.assertThrows(NullPointerException.class, () -> builder.appendText(null, new HashMap())); } - @Test(expectedExceptions=NullPointerException.class) + @Test public void test_appendTextMap_nullStyle() throws Exception { - builder.appendText(MONTH_OF_YEAR, (Map) null); + Assertions.assertThrows(NullPointerException.class, () -> builder.appendText(MONTH_OF_YEAR, (Map) null)); } //----------------------------------------------------------------------- @@ -416,10 +420,9 @@ public class TestDateTimeFormatterBuilder { public void test_appendOffsetId() throws Exception { builder.appendOffsetId(); DateTimeFormatter f = builder.toFormatter(); - assertEquals(f.toString(), "Offset(+HH:MM:ss,'Z')"); + assertEquals("Offset(+HH:MM:ss,'Z')", f.toString()); } - @DataProvider(name="offsetPatterns") Object[][] data_offsetPatterns() { return new Object[][] { {"+HH", 2, 0, 0, "+02"}, @@ -466,24 +469,25 @@ public class TestDateTimeFormatterBuilder { }; } - @Test(dataProvider="offsetPatterns") + @ParameterizedTest + @MethodSource("data_offsetPatterns") public void test_appendOffset_format(String pattern, int h, int m, int s, String expected) throws Exception { builder.appendOffset(pattern, "Z"); DateTimeFormatter f = builder.toFormatter(); ZoneOffset offset = ZoneOffset.ofHoursMinutesSeconds(h, m, s); - assertEquals(f.format(offset), expected); + assertEquals(expected, f.format(offset)); } - @Test(dataProvider="offsetPatterns") + @ParameterizedTest + @MethodSource("data_offsetPatterns") public void test_appendOffset_parse(String pattern, int h, int m, int s, String expected) throws Exception { builder.appendOffset(pattern, "Z"); DateTimeFormatter f = builder.toFormatter(); ZoneOffset offset = ZoneOffset.ofHoursMinutesSeconds(h, m, s); ZoneOffset parsed = f.parse(expected, ZoneOffset::from); - assertEquals(f.format(parsed), expected); + assertEquals(expected, f.format(parsed)); } - @DataProvider(name="badOffsetPatterns") Object[][] data_badOffsetPatterns() { return new Object[][] { {"HH"}, @@ -498,19 +502,20 @@ public class TestDateTimeFormatterBuilder { }; } - @Test(dataProvider="badOffsetPatterns", expectedExceptions=IllegalArgumentException.class) + @ParameterizedTest + @MethodSource("data_badOffsetPatterns") public void test_appendOffset_badPattern(String pattern) throws Exception { - builder.appendOffset(pattern, "Z"); + Assertions.assertThrows(IllegalArgumentException.class, () -> builder.appendOffset(pattern, "Z")); } - @Test(expectedExceptions=NullPointerException.class) + @Test public void test_appendOffset_3arg_nullText() throws Exception { - builder.appendOffset("+HH:MM", null); + Assertions.assertThrows(NullPointerException.class, () -> builder.appendOffset("+HH:MM", null)); } - @Test(expectedExceptions=NullPointerException.class) + @Test public void test_appendOffset_3arg_nullPattern() throws Exception { - builder.appendOffset(null, "Z"); + Assertions.assertThrows(NullPointerException.class, () -> builder.appendOffset(null, "Z")); } //----------------------------------------------------------------------- @@ -520,19 +525,19 @@ public class TestDateTimeFormatterBuilder { public void test_appendZoneId() throws Exception { builder.appendZoneId(); DateTimeFormatter f = builder.toFormatter(); - assertEquals(f.toString(), "ZoneId()"); + assertEquals("ZoneId()", f.toString()); } @Test public void test_appendZoneText_1arg() throws Exception { builder.appendZoneText(TextStyle.FULL); DateTimeFormatter f = builder.toFormatter(); - assertEquals(f.toString(), "ZoneText(FULL)"); + assertEquals("ZoneText(FULL)", f.toString()); } - @Test(expectedExceptions=NullPointerException.class) + @Test public void test_appendZoneText_1arg_nullText() throws Exception { - builder.appendZoneText(null); + Assertions.assertThrows(NullPointerException.class, () -> builder.appendZoneText(null)); } //----------------------------------------------------------------------- @@ -542,15 +547,14 @@ public class TestDateTimeFormatterBuilder { public void test_appendDayPeriodText_1arg() throws Exception { builder.appendDayPeriodText(TextStyle.FULL); DateTimeFormatter f = builder.toFormatter(); - assertEquals(f.toString(), "DayPeriod(FULL)"); + assertEquals("DayPeriod(FULL)", f.toString()); } - @Test(expectedExceptions=NullPointerException.class) + @Test public void test_appendDayPeriodText_1arg_nullText() throws Exception { - builder.appendDayPeriodText(null); + Assertions.assertThrows(NullPointerException.class, () -> builder.appendDayPeriodText(null)); } - @DataProvider(name="dayPeriodFormat") Object[][] data_dayPeriodFormat() { return new Object[][] { {0, 0, TextStyle.FULL, Locale.US, "midnight"}, @@ -588,15 +592,15 @@ public class TestDateTimeFormatterBuilder { {23, 0, TextStyle.NARROW, Locale.JAPAN, "\u591c\u4e2d"}, }; } - @Test (dataProvider="dayPeriodFormat") + @ParameterizedTest + @MethodSource("data_dayPeriodFormat") public void test_dayPeriodFormat(int hod, int moh, TextStyle ts, Locale l, String expected) throws Exception { builder.appendDayPeriodText(ts); LocalTime t = LocalTime.of(hod, moh); DateTimeFormatter f = builder.toFormatter().withLocale(l); - assertEquals(f.format(t), expected); + assertEquals(expected, f.format(t)); } - @DataProvider(name="dayPeriodParse") Object[][] data_dayPeriodParse() { return new Object[][] { {TextStyle.FULL, Locale.US, 0, 0, "midnight"}, @@ -638,16 +642,16 @@ public class TestDateTimeFormatterBuilder { {TextStyle.NARROW, Locale.JAPAN, 21, 0, "\u591c"}, }; } - @Test (dataProvider="dayPeriodParse") + @ParameterizedTest + @MethodSource("data_dayPeriodParse") public void test_dayPeriodParse(TextStyle ts, Locale l, long hod, long moh, String dayPeriod) throws Exception { builder.appendDayPeriodText(ts); DateTimeFormatter f = builder.toFormatter().withLocale(l); var p = f.parse(dayPeriod); - assertEquals(p.getLong(HOUR_OF_DAY), hod); - assertEquals(p.getLong(MINUTE_OF_HOUR), moh); + assertEquals(hod, p.getLong(HOUR_OF_DAY)); + assertEquals(moh, p.getLong(MINUTE_OF_HOUR)); } - @DataProvider(name="dayPeriodParsePattern") Object[][] data_dayPeriodParsePattern() { return new Object[][] { {"H B", "23 at night", 23}, @@ -663,15 +667,15 @@ public class TestDateTimeFormatterBuilder { }; } - @Test (dataProvider="dayPeriodParsePattern") + @ParameterizedTest + @MethodSource("data_dayPeriodParsePattern") public void test_dayPeriodParsePattern(String pattern, String hourDayPeriod, long expected) throws Exception { builder.appendPattern(pattern); DateTimeFormatter f = builder.toFormatter().withLocale(Locale.US); var p = f.parse(hourDayPeriod); - assertEquals(p.getLong(HOUR_OF_DAY), expected); + assertEquals(expected, p.getLong(HOUR_OF_DAY)); } - @DataProvider(name="dayPeriodParseMidnight") Object[][] data_dayPeriodParseMidnight() { return new Object[][] { {"u-M-d H:m B", "2020-11-07 00:00 midnight", 7, 0}, @@ -679,16 +683,16 @@ public class TestDateTimeFormatterBuilder { }; } - @Test (dataProvider="dayPeriodParseMidnight") + @ParameterizedTest + @MethodSource("data_dayPeriodParseMidnight") public void test_dayPeriodParseMidnight(String pattern, String dateTime, long expectedDOM, long expectedHOD) throws Exception { builder.appendPattern(pattern); DateTimeFormatter f = builder.toFormatter().withLocale(Locale.US); var p = f.parse(dateTime); - assertEquals(p.getLong(DAY_OF_MONTH), expectedDOM); - assertEquals(p.getLong(HOUR_OF_DAY), expectedHOD); + assertEquals(expectedDOM, p.getLong(DAY_OF_MONTH)); + assertEquals(expectedHOD, p.getLong(HOUR_OF_DAY)); } - @DataProvider(name="dayPeriodParseInvalid") Object[][] data_dayPeriodParseInvalid() { return new Object[][] { {TextStyle.FULL, ResolverStyle.SMART, Locale.US, "00:01 midnight", "00:00"}, @@ -748,7 +752,8 @@ public class TestDateTimeFormatterBuilder { {TextStyle.NARROW, ResolverStyle.LENIENT, Locale.JAPAN, "23:00 \u591c", "19:00-23:00"}, }; } - @Test (dataProvider="dayPeriodParseInvalid") + @ParameterizedTest + @MethodSource("data_dayPeriodParseInvalid") public void test_dayPeriodParseInvalid(TextStyle ts, ResolverStyle rs, Locale l, String dayPeriod, String periodRange) throws Exception { try { builder.append(ISO_LOCAL_TIME).appendLiteral(' ').appendDayPeriodText(ts) @@ -759,13 +764,11 @@ public class TestDateTimeFormatterBuilder { throw new RuntimeException("DateTimeParseException should be thrown"); } } catch (DateTimeParseException e) { - assertEquals(e.getCause().getMessage(), - "Conflict found: Resolved time " + dayPeriod.substring(0, 5) + " conflicts with " + - "DayPeriod(" + periodRange + ")"); + assertEquals("Conflict found: Resolved time " + dayPeriod.substring(0, 5) + " conflicts with " + + "DayPeriod(" + periodRange + ")", e.getCause().getMessage()); } } - @DataProvider(name="dayPeriodParsePatternInvalid") Object[][] data_dayPeriodParsePatternInvalid() { return new Object[][] { {"H B", ResolverStyle.SMART, "47 at night", 23, null}, @@ -794,7 +797,8 @@ public class TestDateTimeFormatterBuilder { }; } - @Test (dataProvider="dayPeriodParsePatternInvalid") + @ParameterizedTest + @MethodSource("data_dayPeriodParsePatternInvalid") public void test_dayPeriodParsePatternInvalid(String pattern, ResolverStyle rs, String hourDayPeriod, long expected, Period expectedExcessDays) throws Exception { try { builder.appendPattern(pattern); @@ -803,18 +807,20 @@ public class TestDateTimeFormatterBuilder { if (rs != ResolverStyle.LENIENT) { throw new RuntimeException("DateTimeParseException should be thrown"); } - assertEquals(p.getLong(HOUR_OF_DAY), expected); - assertEquals(p.query(DateTimeFormatter.parsedExcessDays()), expectedExcessDays); + assertEquals(expected, p.getLong(HOUR_OF_DAY)); + assertEquals(expectedExcessDays, p.query(DateTimeFormatter.parsedExcessDays())); } catch (DateTimeParseException e) { // exception successfully thrown } } - @Test (expectedExceptions = DateTimeParseException.class) + @Test public void test_dayPeriodParseStrictNoTime() { - builder.appendPattern("B"); - DateTimeFormatter f = builder.toFormatter().withLocale(Locale.US).withResolverStyle(ResolverStyle.STRICT); - LocalTime.parse("at night", f); + Assertions.assertThrows(DateTimeParseException.class, () -> { + builder.appendPattern("B"); + DateTimeFormatter f = builder.toFormatter().withLocale(Locale.US).withResolverStyle(ResolverStyle.STRICT); + LocalTime.parse("at night", f); + }); } @Test @@ -880,7 +886,7 @@ public class TestDateTimeFormatterBuilder { .appendPattern(" B") .toFormatter() .withLocale(Locale.US); - assertEquals((long)dtf.parse("0 in the morning").getLong(ChronoField.HOUR_OF_DAY), 6L); + assertEquals(6L, (long)dtf.parse("0 in the morning").getLong(ChronoField.HOUR_OF_DAY)); try { dtf.parse("0 at night"); fail("DateTimeParseException should be thrown"); @@ -895,24 +901,24 @@ public class TestDateTimeFormatterBuilder { @Test public void test_padNext_1arg() { builder.appendValue(MONTH_OF_YEAR).appendLiteral(':').padNext(2).appendValue(DAY_OF_MONTH); - assertEquals(builder.toFormatter().format(LocalDate.of(2013, 2, 1)), "2: 1"); + assertEquals("2: 1", builder.toFormatter().format(LocalDate.of(2013, 2, 1))); } - @Test(expectedExceptions=IllegalArgumentException.class) + @Test public void test_padNext_1arg_invalidWidth() throws Exception { - builder.padNext(0); + Assertions.assertThrows(IllegalArgumentException.class, () -> builder.padNext(0)); } //----------------------------------------------------------------------- @Test public void test_padNext_2arg_dash() throws Exception { builder.appendValue(MONTH_OF_YEAR).appendLiteral(':').padNext(2, '-').appendValue(DAY_OF_MONTH); - assertEquals(builder.toFormatter().format(LocalDate.of(2013, 2, 1)), "2:-1"); + assertEquals("2:-1", builder.toFormatter().format(LocalDate.of(2013, 2, 1))); } - @Test(expectedExceptions=IllegalArgumentException.class) + @Test public void test_padNext_2arg_invalidWidth() throws Exception { - builder.padNext(0, '-'); + Assertions.assertThrows(IllegalArgumentException.class, () -> builder.padNext(0, '-')); } //----------------------------------------------------------------------- @@ -921,8 +927,8 @@ public class TestDateTimeFormatterBuilder { builder.appendValue(MONTH_OF_YEAR).appendLiteral(':') .padNext(5).optionalStart().appendValue(DAY_OF_MONTH).optionalEnd() .appendLiteral(':').appendValue(YEAR); - assertEquals(builder.toFormatter().format(LocalDate.of(2013, 2, 1)), "2: 1:2013"); - assertEquals(builder.toFormatter().format(YearMonth.of(2013, 2)), "2: :2013"); + assertEquals("2: 1:2013", builder.toFormatter().format(LocalDate.of(2013, 2, 1))); + assertEquals("2: :2013", builder.toFormatter().format(YearMonth.of(2013, 2))); } //----------------------------------------------------------------------- @@ -932,21 +938,21 @@ public class TestDateTimeFormatterBuilder { public void test_optionalStart_noEnd() throws Exception { builder.appendValue(MONTH_OF_YEAR).optionalStart().appendValue(DAY_OF_MONTH).appendValue(DAY_OF_WEEK); DateTimeFormatter f = builder.toFormatter(); - assertEquals(f.toString(), "Value(MonthOfYear)[Value(DayOfMonth)Value(DayOfWeek)]"); + assertEquals("Value(MonthOfYear)[Value(DayOfMonth)Value(DayOfWeek)]", f.toString()); } @Test public void test_optionalStart2_noEnd() throws Exception { builder.appendValue(MONTH_OF_YEAR).optionalStart().appendValue(DAY_OF_MONTH).optionalStart().appendValue(DAY_OF_WEEK); DateTimeFormatter f = builder.toFormatter(); - assertEquals(f.toString(), "Value(MonthOfYear)[Value(DayOfMonth)[Value(DayOfWeek)]]"); + assertEquals("Value(MonthOfYear)[Value(DayOfMonth)[Value(DayOfWeek)]]", f.toString()); } @Test public void test_optionalStart_doubleStart() throws Exception { builder.appendValue(MONTH_OF_YEAR).optionalStart().optionalStart().appendValue(DAY_OF_MONTH); DateTimeFormatter f = builder.toFormatter(); - assertEquals(f.toString(), "Value(MonthOfYear)[[Value(DayOfMonth)]]"); + assertEquals("Value(MonthOfYear)[[Value(DayOfMonth)]]", f.toString()); } //----------------------------------------------------------------------- @@ -954,7 +960,7 @@ public class TestDateTimeFormatterBuilder { public void test_optionalEnd() throws Exception { builder.appendValue(MONTH_OF_YEAR).optionalStart().appendValue(DAY_OF_MONTH).optionalEnd().appendValue(DAY_OF_WEEK); DateTimeFormatter f = builder.toFormatter(); - assertEquals(f.toString(), "Value(MonthOfYear)[Value(DayOfMonth)]Value(DayOfWeek)"); + assertEquals("Value(MonthOfYear)[Value(DayOfMonth)]Value(DayOfWeek)", f.toString()); } @Test @@ -962,39 +968,38 @@ public class TestDateTimeFormatterBuilder { builder.appendValue(MONTH_OF_YEAR).optionalStart().appendValue(DAY_OF_MONTH) .optionalStart().appendValue(DAY_OF_WEEK).optionalEnd().appendValue(DAY_OF_MONTH).optionalEnd(); DateTimeFormatter f = builder.toFormatter(); - assertEquals(f.toString(), "Value(MonthOfYear)[Value(DayOfMonth)[Value(DayOfWeek)]Value(DayOfMonth)]"); + assertEquals("Value(MonthOfYear)[Value(DayOfMonth)[Value(DayOfWeek)]Value(DayOfMonth)]", f.toString()); } @Test public void test_optionalEnd_doubleStartSingleEnd() throws Exception { builder.appendValue(MONTH_OF_YEAR).optionalStart().optionalStart().appendValue(DAY_OF_MONTH).optionalEnd(); DateTimeFormatter f = builder.toFormatter(); - assertEquals(f.toString(), "Value(MonthOfYear)[[Value(DayOfMonth)]]"); + assertEquals("Value(MonthOfYear)[[Value(DayOfMonth)]]", f.toString()); } @Test public void test_optionalEnd_doubleStartDoubleEnd() throws Exception { builder.appendValue(MONTH_OF_YEAR).optionalStart().optionalStart().appendValue(DAY_OF_MONTH).optionalEnd().optionalEnd(); DateTimeFormatter f = builder.toFormatter(); - assertEquals(f.toString(), "Value(MonthOfYear)[[Value(DayOfMonth)]]"); + assertEquals("Value(MonthOfYear)[[Value(DayOfMonth)]]", f.toString()); } @Test public void test_optionalStartEnd_immediateStartEnd() throws Exception { builder.appendValue(MONTH_OF_YEAR).optionalStart().optionalEnd().appendValue(DAY_OF_MONTH); DateTimeFormatter f = builder.toFormatter(); - assertEquals(f.toString(), "Value(MonthOfYear)Value(DayOfMonth)"); + assertEquals("Value(MonthOfYear)Value(DayOfMonth)", f.toString()); } - @Test(expectedExceptions=IllegalStateException.class) + @Test public void test_optionalEnd_noStart() throws Exception { - builder.optionalEnd(); + Assertions.assertThrows(IllegalStateException.class, () -> builder.optionalEnd()); } //----------------------------------------------------------------------- //----------------------------------------------------------------------- //----------------------------------------------------------------------- - @DataProvider(name="validPatterns") Object[][] dataValid() { return new Object[][] { {"'a'", "'a'"}, @@ -1162,15 +1167,15 @@ public class TestDateTimeFormatterBuilder { }; } - @Test(dataProvider="validPatterns") + @ParameterizedTest + @MethodSource("dataValid") public void test_appendPattern_valid(String input, String expected) throws Exception { builder.appendPattern(input); DateTimeFormatter f = builder.toFormatter(); - assertEquals(f.toString(), expected); + assertEquals(expected, f.toString()); } //----------------------------------------------------------------------- - @DataProvider(name="invalidPatterns") Object[][] dataInvalid() { return new Object[][] { {"'"}, @@ -1241,17 +1246,19 @@ public class TestDateTimeFormatterBuilder { }; } - @Test(dataProvider="invalidPatterns", expectedExceptions=IllegalArgumentException.class) + @ParameterizedTest + @MethodSource("dataInvalid") public void test_appendPattern_invalid(String input) throws Exception { - try { - builder.appendPattern(input); - } catch (IllegalArgumentException ex) { - throw ex; - } + Assertions.assertThrows(IllegalArgumentException.class, () -> { + try { + builder.appendPattern(input); + } catch (IllegalArgumentException ex) { + throw ex; + } + }); } //----------------------------------------------------------------------- - @DataProvider(name="localePatterns") Object[][] localizedDateTimePatterns() { return new Object[][] { {FormatStyle.FULL, FormatStyle.FULL, IsoChronology.INSTANCE, Locale.US, "EEEE, MMMM d, y, h:mm:ss\u202fa zzzz"}, @@ -1269,26 +1276,27 @@ public class TestDateTimeFormatterBuilder { }; } - @Test(dataProvider="localePatterns") + @ParameterizedTest + @MethodSource("localizedDateTimePatterns") public void test_getLocalizedDateTimePattern(FormatStyle dateStyle, FormatStyle timeStyle, Chronology chrono, Locale locale, String expected) { String actual = DateTimeFormatterBuilder.getLocalizedDateTimePattern(dateStyle, timeStyle, chrono, locale); - assertEquals(actual, expected, "Pattern " + convertNonAscii(actual)); + assertEquals(expected, actual, "Pattern " + convertNonAscii(actual)); } - @Test(expectedExceptions=java.lang.IllegalArgumentException.class) + @Test public void test_getLocalizedDateTimePatternIAE() { - DateTimeFormatterBuilder.getLocalizedDateTimePattern(null, null, IsoChronology.INSTANCE, Locale.US); + Assertions.assertThrows(IllegalArgumentException.class, () -> DateTimeFormatterBuilder.getLocalizedDateTimePattern(null, null, IsoChronology.INSTANCE, Locale.US)); } - @Test(expectedExceptions=java.lang.NullPointerException.class) + @Test public void test_getLocalizedChronoNPE() { - DateTimeFormatterBuilder.getLocalizedDateTimePattern(FormatStyle.SHORT, FormatStyle.SHORT, null, Locale.US); + Assertions.assertThrows(NullPointerException.class, () -> DateTimeFormatterBuilder.getLocalizedDateTimePattern(FormatStyle.SHORT, FormatStyle.SHORT, null, Locale.US)); } - @Test(expectedExceptions=java.lang.NullPointerException.class) + @Test public void test_getLocalizedLocaleNPE() { - DateTimeFormatterBuilder.getLocalizedDateTimePattern(FormatStyle.SHORT, FormatStyle.SHORT, IsoChronology.INSTANCE, null); + Assertions.assertThrows(NullPointerException.class, () -> DateTimeFormatterBuilder.getLocalizedDateTimePattern(FormatStyle.SHORT, FormatStyle.SHORT, IsoChronology.INSTANCE, null)); } /** diff --git a/test/jdk/java/time/test/java/time/format/TestDateTimeFormatterBuilderWithLocale.java b/test/jdk/java/time/test/java/time/format/TestDateTimeFormatterBuilderWithLocale.java index a0981f0c4d8..ff44426dbe9 100644 --- a/test/jdk/java/time/test/java/time/format/TestDateTimeFormatterBuilderWithLocale.java +++ b/test/jdk/java/time/test/java/time/format/TestDateTimeFormatterBuilderWithLocale.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2012, 2022, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2012, 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 @@ -84,27 +84,26 @@ import java.util.HashMap; import java.util.Locale; import java.util.Map; -import static org.testng.Assert.assertEquals; - -import org.testng.annotations.BeforeMethod; -import org.testng.annotations.DataProvider; -import org.testng.annotations.Test; +import static org.junit.jupiter.api.Assertions.assertEquals; +import org.junit.jupiter.api.BeforeEach; +import org.junit.jupiter.api.TestInstance; +import org.junit.jupiter.params.ParameterizedTest; +import org.junit.jupiter.params.provider.MethodSource; /** * Test DateTimeFormatterBuilder. */ -@Test +@TestInstance(TestInstance.Lifecycle.PER_CLASS) public class TestDateTimeFormatterBuilderWithLocale { private DateTimeFormatterBuilder builder; - @BeforeMethod + @BeforeEach public void setUp() { builder = new DateTimeFormatterBuilder(); } //----------------------------------------------------------------------- - @DataProvider(name="patternPrint") Object[][] data_patternPrint() { return new Object[][] { {"Q", date(2012, 2, 10), "1"}, @@ -115,15 +114,15 @@ public class TestDateTimeFormatterBuilderWithLocale { }; } - @Test(dataProvider="patternPrint") + @ParameterizedTest + @MethodSource("data_patternPrint") public void test_appendPattern_patternPrint(String input, Temporal temporal, String expected) throws Exception { DateTimeFormatter f = builder.appendPattern(input).toFormatter(Locale.UK); String test = f.format(temporal); - assertEquals(test, expected); + assertEquals(expected, test); } //----------------------------------------------------------------------- - @DataProvider(name="mapTextLookup") Object[][] data_mapTextLookup() { return new Object[][] { {IsoChronology.INSTANCE.date(1, 1, 1), Locale.ENGLISH}, @@ -133,7 +132,8 @@ public class TestDateTimeFormatterBuilderWithLocale { }; } - @Test(dataProvider="mapTextLookup") + @ParameterizedTest + @MethodSource("data_mapTextLookup") public void test_appendText_mapTextLookup(ChronoLocalDate date, Locale locale) { final String firstYear = "firstYear"; final String firstMonth = "firstMonth"; @@ -146,16 +146,15 @@ public class TestDateTimeFormatterBuilderWithLocale { .toFormatter(locale) .withResolverStyle(ResolverStyle.STRICT); - assertEquals(date.format(formatter), firstYearMonth); + assertEquals(firstYearMonth, date.format(formatter)); TemporalAccessor ta = formatter.parse(firstYearMonth); - assertEquals(ta.getLong(ChronoField.YEAR_OF_ERA), first); - assertEquals(ta.getLong(ChronoField.MONTH_OF_YEAR), first); + assertEquals(first, ta.getLong(ChronoField.YEAR_OF_ERA)); + assertEquals(first, ta.getLong(ChronoField.MONTH_OF_YEAR)); } //----------------------------------------------------------------------- - @DataProvider(name="localePatterns") Object[][] localizedDateTimePatterns() { return new Object[][] { // French Locale and ISO Chronology @@ -202,11 +201,12 @@ public class TestDateTimeFormatterBuilderWithLocale { }; } - @Test(dataProvider="localePatterns") + @ParameterizedTest + @MethodSource("localizedDateTimePatterns") public void test_getLocalizedDateTimePattern(FormatStyle dateStyle, FormatStyle timeStyle, Chronology chrono, Locale locale, String expected) { String actual = DateTimeFormatterBuilder.getLocalizedDateTimePattern(dateStyle, timeStyle, chrono, locale); - assertEquals(actual, expected, "Pattern " + convertNonAscii(actual)); + assertEquals(expected, actual, "Pattern " + convertNonAscii(actual)); } /** diff --git a/test/jdk/java/time/test/java/time/format/TestDateTimeParsing.java b/test/jdk/java/time/test/java/time/format/TestDateTimeParsing.java index 67c91e6ad7e..f50a99f8a0e 100644 --- a/test/jdk/java/time/test/java/time/format/TestDateTimeParsing.java +++ b/test/jdk/java/time/test/java/time/format/TestDateTimeParsing.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2014, 2023, Oracle and/or its affiliates. All rights reserved. + * 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 @@ -71,8 +71,9 @@ import static java.time.temporal.ChronoField.NANO_OF_SECOND; import static java.time.temporal.ChronoField.OFFSET_SECONDS; import static java.time.temporal.ChronoField.SECOND_OF_DAY; import static java.util.Locale.US; -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 java.text.ParsePosition; import java.time.DateTimeException; @@ -88,14 +89,18 @@ import java.time.format.SignStyle; import java.time.temporal.TemporalAccessor; import java.util.Locale; -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.api.TestInstance; +import org.junit.jupiter.params.ParameterizedTest; +import org.junit.jupiter.params.provider.MethodSource; /** * @test * @summary Test parsing of edge cases. * @bug 8223773 8272473 8319640 */ +@TestInstance(TestInstance.Lifecycle.PER_CLASS) public class TestDateTimeParsing { private static final ZoneId PARIS = ZoneId.of("Europe/Paris"); @@ -132,7 +137,6 @@ public class TestDateTimeParsing { private static final String DTPE_MESSAGE = "Invalid value for HourOfAmPm (valid values 0 - 11): 12"; - @DataProvider(name = "instantZones") Object[][] data_instantZones() { return new Object[][] { {LOCALFIELDS_ZONEID, "2014-06-30 01:02:03 Europe/Paris", ZonedDateTime.of(2014, 6, 30, 1, 2, 3, 0, PARIS)}, @@ -154,37 +158,40 @@ public class TestDateTimeParsing { }; } - @Test(dataProvider = "instantZones") + @ParameterizedTest + @MethodSource("data_instantZones") public void test_parse_instantZones_ZDT(DateTimeFormatter formatter, String text, ZonedDateTime expected) { TemporalAccessor actual = formatter.parse(text); - assertEquals(ZonedDateTime.from(actual), expected); + assertEquals(expected, ZonedDateTime.from(actual)); } - @Test(dataProvider = "instantZones") + @ParameterizedTest + @MethodSource("data_instantZones") public void test_parse_instantZones_LDT(DateTimeFormatter formatter, String text, ZonedDateTime expected) { TemporalAccessor actual = formatter.parse(text); - assertEquals(LocalDateTime.from(actual), expected.toLocalDateTime()); + assertEquals(expected.toLocalDateTime(), LocalDateTime.from(actual)); } - @Test(dataProvider = "instantZones") + @ParameterizedTest + @MethodSource("data_instantZones") public void test_parse_instantZones_Instant(DateTimeFormatter formatter, String text, ZonedDateTime expected) { TemporalAccessor actual = formatter.parse(text); - assertEquals(Instant.from(actual), expected.toInstant()); + assertEquals(expected.toInstant(), Instant.from(actual)); } - @Test(dataProvider = "instantZones") + @ParameterizedTest + @MethodSource("data_instantZones") public void test_parse_instantZones_supported(DateTimeFormatter formatter, String text, ZonedDateTime expected) { TemporalAccessor actual = formatter.parse(text); - assertEquals(actual.isSupported(INSTANT_SECONDS), true); - assertEquals(actual.isSupported(EPOCH_DAY), true); - assertEquals(actual.isSupported(SECOND_OF_DAY), true); - assertEquals(actual.isSupported(NANO_OF_SECOND), true); - assertEquals(actual.isSupported(MICRO_OF_SECOND), true); - assertEquals(actual.isSupported(MILLI_OF_SECOND), true); + assertEquals(true, actual.isSupported(INSTANT_SECONDS)); + assertEquals(true, actual.isSupported(EPOCH_DAY)); + assertEquals(true, actual.isSupported(SECOND_OF_DAY)); + assertEquals(true, actual.isSupported(NANO_OF_SECOND)); + assertEquals(true, actual.isSupported(MICRO_OF_SECOND)); + assertEquals(true, actual.isSupported(MILLI_OF_SECOND)); } //----------------------------------------------------------------------- - @DataProvider(name = "instantNoZone") Object[][] data_instantNoZone() { return new Object[][] { {INSTANT, "2014-06-30T01:02:03Z", ZonedDateTime.of(2014, 6, 30, 1, 2, 3, 0, ZoneOffset.UTC).toInstant()}, @@ -193,55 +200,65 @@ public class TestDateTimeParsing { }; } - @Test(dataProvider = "instantNoZone", expectedExceptions = DateTimeException.class) + @ParameterizedTest + @MethodSource("data_instantNoZone") public void test_parse_instantNoZone_ZDT(DateTimeFormatter formatter, String text, Instant expected) { - TemporalAccessor actual = formatter.parse(text); - ZonedDateTime.from(actual); + Assertions.assertThrows(DateTimeException.class, () -> { + TemporalAccessor actual = formatter.parse(text); + ZonedDateTime.from(actual); + }); } - @Test(dataProvider = "instantNoZone", expectedExceptions = DateTimeException.class) + @ParameterizedTest + @MethodSource("data_instantNoZone") public void test_parse_instantNoZone_LDT(DateTimeFormatter formatter, String text, Instant expected) { - TemporalAccessor actual = formatter.parse(text); - LocalDateTime.from(actual); + Assertions.assertThrows(DateTimeException.class, () -> { + TemporalAccessor actual = formatter.parse(text); + LocalDateTime.from(actual); + }); } - @Test(dataProvider = "instantNoZone") + @ParameterizedTest + @MethodSource("data_instantNoZone") public void test_parse_instantNoZone_Instant(DateTimeFormatter formatter, String text, Instant expected) { TemporalAccessor actual = formatter.parse(text); - assertEquals(Instant.from(actual), expected); + assertEquals(expected, Instant.from(actual)); } - @Test(dataProvider = "instantNoZone") + @ParameterizedTest + @MethodSource("data_instantNoZone") public void test_parse_instantNoZone_supported(DateTimeFormatter formatter, String text, Instant expected) { TemporalAccessor actual = formatter.parse(text); - assertEquals(actual.isSupported(INSTANT_SECONDS), true); - assertEquals(actual.isSupported(EPOCH_DAY), false); - assertEquals(actual.isSupported(SECOND_OF_DAY), false); - assertEquals(actual.isSupported(NANO_OF_SECOND), true); - assertEquals(actual.isSupported(MICRO_OF_SECOND), true); - assertEquals(actual.isSupported(MILLI_OF_SECOND), true); + assertEquals(true, actual.isSupported(INSTANT_SECONDS)); + assertEquals(false, actual.isSupported(EPOCH_DAY)); + assertEquals(false, actual.isSupported(SECOND_OF_DAY)); + assertEquals(true, actual.isSupported(NANO_OF_SECOND)); + assertEquals(true, actual.isSupported(MICRO_OF_SECOND)); + assertEquals(true, actual.isSupported(MILLI_OF_SECOND)); } // Bug 8223773: validation check for the range of HourOfAmPm in SMART mode. // Should throw a DateTimeParseException, as 12 is out of range for HourOfAmPm. - @Test(expectedExceptions = DateTimeParseException.class) + @Test public void test_validateHourOfAmPm() { - try { - new DateTimeFormatterBuilder() - .appendValue(HOUR_OF_AMPM,2) - .appendText(AMPM_OF_DAY) - .toFormatter(US) - .parse("12PM"); - } catch (DateTimeParseException e) { - Throwable cause = e.getCause(); - if (cause == null || - !DTPE_MESSAGE.equals(cause.getMessage())) { - throw new RuntimeException( - "DateTimeParseException was thrown with different reason: " + e); - } else { - throw e; + Assertions.assertThrows(DateTimeParseException.class, () -> { + try { + new DateTimeFormatterBuilder() + .appendValue(HOUR_OF_AMPM,2) + .appendText(AMPM_OF_DAY) + .toFormatter(US) + .parse("12PM"); + } catch (DateTimeParseException e) { + Throwable cause = e.getCause(); + if (cause == null || + !DTPE_MESSAGE.equals(cause.getMessage())) { + throw new RuntimeException( + "DateTimeParseException was thrown with different reason: " + e); + } else { + throw e; + } } - } + }); } // Checks ::toFormat().parseObject(text, pos) do not throw DateTimeException diff --git a/test/jdk/java/time/test/java/time/format/TestDateTimeTextProvider.java b/test/jdk/java/time/test/java/time/format/TestDateTimeTextProvider.java index f2a14374c49..80336b7b761 100644 --- a/test/jdk/java/time/test/java/time/format/TestDateTimeTextProvider.java +++ b/test/jdk/java/time/test/java/time/format/TestDateTimeTextProvider.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2012, 2022, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2012, 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 @@ -62,7 +62,8 @@ package test.java.time.format; import static java.time.temporal.ChronoField.AMPM_OF_DAY; import static java.time.temporal.ChronoField.DAY_OF_WEEK; import static java.time.temporal.ChronoField.MONTH_OF_YEAR; -import static org.testng.Assert.assertEquals; + +import static org.junit.jupiter.api.Assertions.assertEquals; import java.time.ZonedDateTime; import java.time.format.DateTimeFormatter; @@ -70,19 +71,19 @@ import java.time.format.TextStyle; import java.time.temporal.TemporalField; import java.util.Locale; -import org.testng.annotations.DataProvider; -import org.testng.annotations.Test; +import org.junit.jupiter.api.TestInstance; +import org.junit.jupiter.params.ParameterizedTest; +import org.junit.jupiter.params.provider.MethodSource; /** * Test SimpleDateTimeTextProvider. */ -@Test +@TestInstance(TestInstance.Lifecycle.PER_CLASS) public class TestDateTimeTextProvider extends AbstractTestPrinterParser { Locale enUS = Locale.US; //----------------------------------------------------------------------- - @DataProvider(name = "Text") Object[][] data_text() { return new Object[][] { {DAY_OF_WEEK, 1, TextStyle.SHORT, enUS, "Mon"}, @@ -133,10 +134,11 @@ public class TestDateTimeTextProvider extends AbstractTestPrinterParser { }; } - @Test(dataProvider = "Text") + @ParameterizedTest + @MethodSource("data_text") public void test_getText(TemporalField field, Number value, TextStyle style, Locale locale, String expected) { DateTimeFormatter fmt = getFormatter(field, style).withLocale(locale); - assertEquals(fmt.format(ZonedDateTime.now().with(field, value.longValue())), expected); + assertEquals(expected, fmt.format(ZonedDateTime.now().with(field, value.longValue()))); } } diff --git a/test/jdk/java/time/test/java/time/format/TestDateTimeTextProviderWithLocale.java b/test/jdk/java/time/test/java/time/format/TestDateTimeTextProviderWithLocale.java index 65d65251862..35b793bb769 100644 --- a/test/jdk/java/time/test/java/time/format/TestDateTimeTextProviderWithLocale.java +++ b/test/jdk/java/time/test/java/time/format/TestDateTimeTextProviderWithLocale.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2012, 2022, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2012, 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 @@ -69,7 +69,8 @@ package test.java.time.format; import static java.time.temporal.ChronoField.AMPM_OF_DAY; import static java.time.temporal.ChronoField.DAY_OF_WEEK; import static java.time.temporal.ChronoField.MONTH_OF_YEAR; -import static org.testng.Assert.assertEquals; + +import static org.junit.jupiter.api.Assertions.assertEquals; import java.time.ZonedDateTime; import java.time.format.DateTimeFormatter; @@ -77,20 +78,20 @@ import java.time.format.TextStyle; import java.time.temporal.TemporalField; import java.util.Locale; -import org.testng.annotations.DataProvider; -import org.testng.annotations.Test; +import org.junit.jupiter.api.TestInstance; +import org.junit.jupiter.params.ParameterizedTest; +import org.junit.jupiter.params.provider.MethodSource; /** * Test SimpleDateTimeTextProviderWithLocale. */ -@Test +@TestInstance(TestInstance.Lifecycle.PER_CLASS) public class TestDateTimeTextProviderWithLocale extends AbstractTestPrinterParser { Locale enUS = Locale.US; Locale ptBR = Locale.of("pt", "BR"); //----------------------------------------------------------------------- - @DataProvider(name = "Text") Object[][] data_text() { return new Object[][] { {DAY_OF_WEEK, 1, TextStyle.SHORT, ptBR, "seg."}, @@ -138,10 +139,11 @@ public class TestDateTimeTextProviderWithLocale extends AbstractTestPrinterParse }; } - @Test(dataProvider = "Text") + @ParameterizedTest + @MethodSource("data_text") public void test_getText(TemporalField field, Number value, TextStyle style, Locale locale, String expected) { DateTimeFormatter fmt = getFormatter(field, style).withLocale(locale); - assertEquals(fmt.format(ZonedDateTime.now().with(field, value.longValue())), expected); + assertEquals(expected, fmt.format(ZonedDateTime.now().with(field, value.longValue()))); } } diff --git a/test/jdk/java/time/test/java/time/format/TestDecimalStyle.java b/test/jdk/java/time/test/java/time/format/TestDecimalStyle.java index b506d547ada..48f7da3e80c 100644 --- a/test/jdk/java/time/test/java/time/format/TestDecimalStyle.java +++ b/test/jdk/java/time/test/java/time/format/TestDecimalStyle.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2012, 2013, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2012, 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 @@ -59,17 +59,16 @@ */ package test.java.time.format; -import static org.testng.Assert.assertSame; +import static org.junit.jupiter.api.Assertions.assertSame; import java.time.format.DecimalStyle; import java.util.Locale; -import org.testng.annotations.Test; +import org.junit.jupiter.api.Test; /** * Test DecimalStyle. */ -@Test public class TestDecimalStyle { @Test diff --git a/test/jdk/java/time/test/java/time/format/TestFractionPrinterParser.java b/test/jdk/java/time/test/java/time/format/TestFractionPrinterParser.java index 4dbca06709d..0c079173d1f 100644 --- a/test/jdk/java/time/test/java/time/format/TestFractionPrinterParser.java +++ b/test/jdk/java/time/test/java/time/format/TestFractionPrinterParser.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2012, 2021, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2012, 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 @@ -60,8 +60,9 @@ package test.java.time.format; import static java.time.temporal.ChronoField.*; -import static org.testng.Assert.assertEquals; -import static org.testng.Assert.fail; + +import static org.junit.jupiter.api.Assertions.assertEquals; +import static org.junit.jupiter.api.Assertions.fail; import java.text.ParsePosition; import java.time.DateTimeException; @@ -71,8 +72,12 @@ import java.time.temporal.ChronoField; import java.time.temporal.TemporalAccessor; import java.time.temporal.TemporalField; -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.api.TestInstance; +import org.junit.jupiter.params.ParameterizedTest; +import org.junit.jupiter.params.provider.MethodSource; + import test.java.time.temporal.MockFieldValue; /** @@ -80,7 +85,7 @@ import test.java.time.temporal.MockFieldValue; * * @bug 8230136 8276220 */ -@Test +@TestInstance(TestInstance.Lifecycle.PER_CLASS) public class TestFractionPrinterParser extends AbstractTestPrinterParser { private DateTimeFormatter getFormatter(TemporalField field, int minWidth, int maxWidth, boolean decimalPoint) { @@ -90,12 +95,11 @@ public class TestFractionPrinterParser extends AbstractTestPrinterParser { //----------------------------------------------------------------------- // print //----------------------------------------------------------------------- - @Test(expectedExceptions=DateTimeException.class) + @Test public void test_print_emptyCalendrical() throws Exception { - getFormatter(NANO_OF_SECOND, 0, 9, true).formatTo(EMPTY_DTA, buf); + Assertions.assertThrows(DateTimeException.class, () -> getFormatter(NANO_OF_SECOND, 0, 9, true).formatTo(EMPTY_DTA, buf)); } - @DataProvider(name="OOB_Nanos") Object[][] provider_oob_nanos() { return new Object[][]{ {-1}, @@ -108,12 +112,12 @@ public class TestFractionPrinterParser extends AbstractTestPrinterParser { }; } - @Test(dataProvider="OOB_Nanos", expectedExceptions=DateTimeException.class) + @ParameterizedTest + @MethodSource("provider_oob_nanos") public void test_print_oob_nanos(long value) throws Exception { - getFormatter(NANO_OF_SECOND, 0, 9, true).formatTo(new MockFieldValue(NANO_OF_SECOND, value), buf); + Assertions.assertThrows(DateTimeException.class, () -> getFormatter(NANO_OF_SECOND, 0, 9, true).formatTo(new MockFieldValue(NANO_OF_SECOND, value), buf)); } - @DataProvider(name="OOB_Micros") Object[][] provider_oob_micros() { return new Object[][]{ {-1}, @@ -126,25 +130,27 @@ public class TestFractionPrinterParser extends AbstractTestPrinterParser { }; } - @Test(dataProvider="OOB_Micros", expectedExceptions=DateTimeException.class) + @ParameterizedTest + @MethodSource("provider_oob_micros") public void test_print_oob_micros(long value) throws Exception { - getFormatter(MICRO_OF_SECOND, 0, 9, true).formatTo(new MockFieldValue(MICRO_OF_SECOND, value), buf); + Assertions.assertThrows(DateTimeException.class, () -> getFormatter(MICRO_OF_SECOND, 0, 9, true).formatTo(new MockFieldValue(MICRO_OF_SECOND, value), buf)); } + @Test public void test_print_append() throws Exception { buf.append("EXISTING"); getFormatter(NANO_OF_SECOND, 0, 9, true).formatTo(LocalTime.of(12, 30, 40, 3), buf); - assertEquals(buf.toString(), "EXISTING.000000003"); + assertEquals("EXISTING.000000003", buf.toString()); } + @Test public void test_print_append_micros() throws Exception { buf.append("EXISTING"); getFormatter(MICRO_OF_SECOND, 0, 6, true).formatTo(LocalTime.of(12, 30, 40, 3000), buf); - assertEquals(buf.toString(), "EXISTING.000003"); + assertEquals("EXISTING.000003", buf.toString()); } //----------------------------------------------------------------------- - @DataProvider(name="Nanos") Object[][] provider_nanos() { return new Object[][] { {0, 9, 0, ""}, @@ -266,26 +272,27 @@ public class TestFractionPrinterParser extends AbstractTestPrinterParser { }; } - @Test(dataProvider="Nanos") + @ParameterizedTest + @MethodSource("provider_nanos") public void test_print_nanos(int minWidth, int maxWidth, int value, String result) throws Exception { getFormatter(NANO_OF_SECOND, minWidth, maxWidth, true).formatTo(new MockFieldValue(NANO_OF_SECOND, value), buf); if (result == null) { fail("Expected exception"); } - assertEquals(buf.toString(), result); + assertEquals(result, buf.toString()); } - @Test(dataProvider="Nanos") + @ParameterizedTest + @MethodSource("provider_nanos") public void test_print_nanos_noDecimalPoint(int minWidth, int maxWidth, int value, String result) throws Exception { getFormatter(NANO_OF_SECOND, minWidth, maxWidth, false).formatTo(new MockFieldValue(NANO_OF_SECOND, value), buf); if (result == null) { fail("Expected exception"); } - assertEquals(buf.toString(), (result.startsWith(".") ? result.substring(1) : result)); + assertEquals((result.startsWith(".") ? result.substring(1) : result), buf.toString()); } //----------------------------------------------------------------------- - @DataProvider(name="Micros") Object[][] provider_micros() { return new Object[][] { {0, 6, 0, ""}, @@ -342,26 +349,27 @@ public class TestFractionPrinterParser extends AbstractTestPrinterParser { }; } - @Test(dataProvider="Micros") + @ParameterizedTest + @MethodSource("provider_micros") public void test_print_micros(int minWidth, int maxWidth, int value, String result) throws Exception { getFormatter(MICRO_OF_SECOND, minWidth, maxWidth, true).formatTo(new MockFieldValue(MICRO_OF_SECOND, value), buf); if (result == null) { fail("Expected exception"); } - assertEquals(buf.toString(), result); + assertEquals(result, buf.toString()); } - @Test(dataProvider="Micros") + @ParameterizedTest + @MethodSource("provider_micros") public void test_print_micros_noDecimalPoint(int minWidth, int maxWidth, int value, String result) throws Exception { getFormatter(MICRO_OF_SECOND, minWidth, maxWidth, false).formatTo(new MockFieldValue(MICRO_OF_SECOND, value), buf); if (result == null) { fail("Expected exception"); } - assertEquals(buf.toString(), (result.startsWith(".") ? result.substring(1) : result)); + assertEquals((result.startsWith(".") ? result.substring(1) : result), buf.toString()); } //----------------------------------------------------------------------- - @DataProvider(name="Seconds") Object[][] provider_seconds() { return new Object[][] { {0, 9, 0, ""}, @@ -384,51 +392,56 @@ public class TestFractionPrinterParser extends AbstractTestPrinterParser { }; } - @Test(dataProvider="Seconds") + @ParameterizedTest + @MethodSource("provider_seconds") public void test_print_seconds(int minWidth, int maxWidth, int value, String result) throws Exception { getFormatter(SECOND_OF_MINUTE, minWidth, maxWidth, true).formatTo(new MockFieldValue(SECOND_OF_MINUTE, value), buf); if (result == null) { fail("Expected exception"); } - assertEquals(buf.toString(), result); + assertEquals(result, buf.toString()); } - @Test(dataProvider="Seconds") + @ParameterizedTest + @MethodSource("provider_seconds") public void test_print_seconds_noDecimalPoint(int minWidth, int maxWidth, int value, String result) throws Exception { getFormatter(SECOND_OF_MINUTE, minWidth, maxWidth, false).formatTo(new MockFieldValue(SECOND_OF_MINUTE, value), buf); if (result == null) { fail("Expected exception"); } - assertEquals(buf.toString(), (result.startsWith(".") ? result.substring(1) : result)); + assertEquals((result.startsWith(".") ? result.substring(1) : result), buf.toString()); } //----------------------------------------------------------------------- // parse //----------------------------------------------------------------------- - @Test(dataProvider="Nanos") + @ParameterizedTest + @MethodSource("provider_nanos") public void test_reverseParse(int minWidth, int maxWidth, int value, String result) throws Exception { ParsePosition pos = new ParsePosition(0); int expectedValue = fixParsedValue(maxWidth, value); TemporalAccessor parsed = getFormatter(NANO_OF_SECOND, minWidth, maxWidth, true).parseUnresolved(result, pos); - assertEquals(pos.getIndex(), result.length()); + assertEquals(result.length(), pos.getIndex()); assertParsed(parsed, NANO_OF_SECOND, value == 0 && minWidth == 0 ? null : (long) expectedValue); } - @Test(dataProvider="Nanos") + @ParameterizedTest + @MethodSource("provider_nanos") public void test_reverseParse_noDecimalPoint(int minWidth, int maxWidth, int value, String result) throws Exception { ParsePosition pos = new ParsePosition((result.startsWith(".") ? 1 : 0)); TemporalAccessor parsed = getFormatter(NANO_OF_SECOND, minWidth, maxWidth, false).parseUnresolved(result, pos); - assertEquals(pos.getIndex(), result.length()); + assertEquals(result.length(), pos.getIndex()); int expectedValue = fixParsedValue(maxWidth, value); assertParsed(parsed, NANO_OF_SECOND, value == 0 && minWidth == 0 ? null : (long) expectedValue); } - @Test(dataProvider="Nanos") + @ParameterizedTest + @MethodSource("provider_nanos") public void test_reverseParse_followedByNonDigit(int minWidth, int maxWidth, int value, String result) throws Exception { ParsePosition pos = new ParsePosition(0); int expectedValue = fixParsedValue(maxWidth, value); TemporalAccessor parsed = getFormatter(NANO_OF_SECOND, minWidth, maxWidth, true).parseUnresolved(result + " ", pos); - assertEquals(pos.getIndex(), result.length()); + assertEquals(result.length(), pos.getIndex()); assertParsed(parsed, NANO_OF_SECOND, value == 0 && minWidth == 0 ? null : (long) expectedValue); } @@ -441,12 +454,13 @@ public class TestFractionPrinterParser extends AbstractTestPrinterParser { // assertParsed(parseContext, NANO_OF_SECOND, value == 0 && minWidth == 0 ? null : (long) expectedValue); // } - @Test(dataProvider="Nanos") + @ParameterizedTest + @MethodSource("provider_nanos") public void test_reverseParse_preceededByNonDigit(int minWidth, int maxWidth, int value, String result) throws Exception { ParsePosition pos = new ParsePosition(1); int expectedValue = fixParsedValue(maxWidth, value); TemporalAccessor parsed = getFormatter(NANO_OF_SECOND, minWidth, maxWidth, true).parseUnresolved(" " + result, pos); - assertEquals(pos.getIndex(), result.length() + 1); + assertEquals(result.length() + 1, pos.getIndex()); assertParsed(parsed, NANO_OF_SECOND, value == 0 && minWidth == 0 ? null : (long) expectedValue); } @@ -458,25 +472,25 @@ public class TestFractionPrinterParser extends AbstractTestPrinterParser { return value; } - @Test(dataProvider="Seconds") + @ParameterizedTest + @MethodSource("provider_seconds") public void test_reverseParse_seconds(int minWidth, int maxWidth, int value, String result) throws Exception { ParsePosition pos = new ParsePosition(0); TemporalAccessor parsed = getFormatter(SECOND_OF_MINUTE, minWidth, maxWidth, true).parseUnresolved(result, pos); - assertEquals(pos.getIndex(), result.length()); + assertEquals(result.length(), pos.getIndex()); assertParsed(parsed, SECOND_OF_MINUTE, value == 0 && minWidth == 0 ? null : (long) value); } private void assertParsed(TemporalAccessor parsed, TemporalField field, Long value) { if (value == null) { - assertEquals(parsed.isSupported(field), false); + assertEquals(false, parsed.isSupported(field)); } else { - assertEquals(parsed.isSupported(field), true); - assertEquals(parsed.getLong(field), (long) value); + assertEquals(true, parsed.isSupported(field)); + assertEquals((long) value, parsed.getLong(field)); } } //----------------------------------------------------------------------- - @DataProvider(name="ParseNothing") Object[][] provider_parseNothing() { return new Object[][] { {NANO_OF_SECOND, 3, 6, true, "", 0, 0}, @@ -489,15 +503,15 @@ public class TestFractionPrinterParser extends AbstractTestPrinterParser { }; } - @Test(dataProvider = "ParseNothing") + @ParameterizedTest + @MethodSource("provider_parseNothing") public void test_parse_nothing(TemporalField field, int min, int max, boolean decimalPoint, String text, int pos, int expected) { ParsePosition ppos = new ParsePosition(pos); TemporalAccessor parsed = getFormatter(field, min, max, decimalPoint).parseUnresolved(text, ppos); - assertEquals(ppos.getErrorIndex(), expected); - assertEquals(parsed, null); + assertEquals(expected, ppos.getErrorIndex()); + assertEquals(null, parsed); } - @DataProvider(name="ParseMinWidth") Object[][] provider_parseMinWidth() { return new Object[][] { {MILLI_OF_SECOND, 3, 3, true, ".1x"}, @@ -506,22 +520,26 @@ public class TestFractionPrinterParser extends AbstractTestPrinterParser { }; } - @Test(dataProvider="ParseMinWidth", expectedExceptions=DateTimeException.class) + @ParameterizedTest + @MethodSource("provider_parseMinWidth") public void test_parse_minWidth(TemporalField field, int min, int max, boolean decimalPoint, String text) throws Exception { - builder - .appendFraction(field, min, max, decimalPoint) - .appendLiteral("x") - .toFormatter(locale) - .parse(text); + Assertions + .assertThrows(DateTimeException.class, () -> builder + .appendFraction(field, min, max, decimalPoint) + .appendLiteral("x") + .toFormatter(locale) + .parse(text)); } //----------------------------------------------------------------------- + @Test public void test_toString() throws Exception { - assertEquals(getFormatter(NANO_OF_SECOND, 3, 6, true).toString(), "Fraction(NanoOfSecond,3,6,DecimalPoint)"); + assertEquals("Fraction(NanoOfSecond,3,6,DecimalPoint)", getFormatter(NANO_OF_SECOND, 3, 6, true).toString()); } + @Test public void test_toString_noDecimalPoint() throws Exception { - assertEquals(getFormatter(NANO_OF_SECOND, 3, 6, false).toString(), "Fraction(NanoOfSecond,3,6)"); + assertEquals("Fraction(NanoOfSecond,3,6)", getFormatter(NANO_OF_SECOND, 3, 6, false).toString()); } } diff --git a/test/jdk/java/time/test/java/time/format/TestLocalizedOffsetPrinterParser.java b/test/jdk/java/time/test/java/time/format/TestLocalizedOffsetPrinterParser.java index d1b1c25ba98..36b491178a7 100644 --- a/test/jdk/java/time/test/java/time/format/TestLocalizedOffsetPrinterParser.java +++ b/test/jdk/java/time/test/java/time/format/TestLocalizedOffsetPrinterParser.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2019, 2022, Oracle and/or its affiliates. All rights reserved. + * 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 @@ -35,7 +35,7 @@ package test.java.time.format; -import static org.testng.Assert.assertEquals; +import static org.junit.jupiter.api.Assertions.assertEquals; import java.time.LocalDateTime; import java.time.OffsetDateTime; @@ -47,20 +47,20 @@ import java.time.format.TextStyle; import java.util.Locale; import java.util.Objects; -import org.testng.annotations.DataProvider; -import org.testng.annotations.Test; +import org.junit.jupiter.api.TestInstance; +import org.junit.jupiter.params.ParameterizedTest; +import org.junit.jupiter.params.provider.MethodSource; /** * Test DateTimeFormatterBuilder.appendOffset(). */ -@Test +@TestInstance(TestInstance.Lifecycle.PER_CLASS) public class TestLocalizedOffsetPrinterParser { private static final LocalDateTime DT_2012_06_30_12_30_40 = LocalDateTime.of(2012, 6, 30, 12, 30, 40); private static final Locale LOCALE_GA = Locale.of("ga"); - @DataProvider(name="print_localized_custom_locale") Object[][] data_print_localized_custom_locale() { return new Object[][] { {TextStyle.FULL, DT_2012_06_30_12_30_40, ZoneOffset.UTC, LOCALE_GA, "MAG"}, @@ -69,7 +69,8 @@ public class TestLocalizedOffsetPrinterParser { }; } - @Test(dataProvider="print_localized_custom_locale") + @ParameterizedTest + @MethodSource("data_print_localized_custom_locale") public void test_print_localized_custom_locale(TextStyle style, LocalDateTime ldt, ZoneOffset offset, Locale locale, String expected) { Objects.requireNonNull(locale, "Locale must not be null"); @@ -78,27 +79,27 @@ public class TestLocalizedOffsetPrinterParser { ZonedDateTime zdt = ldt.atZone(offset); DateTimeFormatter f = new DateTimeFormatterBuilder().appendLocalizedOffset(style).toFormatter(locale); - assertEquals(f.format(odt), expected); - assertEquals(f.format(zdt), expected); - assertEquals(f.parse(expected, ZoneOffset::from), offset); + assertEquals(expected, f.format(odt)); + assertEquals(expected, f.format(zdt)); + assertEquals(offset, f.parse(expected, ZoneOffset::from)); if (style == TextStyle.FULL) { f = new DateTimeFormatterBuilder().appendPattern("ZZZZ").toFormatter(locale); - assertEquals(f.format(odt), expected); - assertEquals(f.format(zdt), expected); - assertEquals(f.parse(expected, ZoneOffset::from), offset); + assertEquals(expected, f.format(odt)); + assertEquals(expected, f.format(zdt)); + assertEquals(offset, f.parse(expected, ZoneOffset::from)); f = new DateTimeFormatterBuilder().appendPattern("OOOO").toFormatter(locale); - assertEquals(f.format(odt), expected); - assertEquals(f.format(zdt), expected); - assertEquals(f.parse(expected, ZoneOffset::from), offset); + assertEquals(expected, f.format(odt)); + assertEquals(expected, f.format(zdt)); + assertEquals(offset, f.parse(expected, ZoneOffset::from)); } if (style == TextStyle.SHORT) { f = new DateTimeFormatterBuilder().appendPattern("O").toFormatter(locale); - assertEquals(f.format(odt), expected); - assertEquals(f.format(zdt), expected); - assertEquals(f.parse(expected, ZoneOffset::from), offset); + assertEquals(expected, f.format(odt)); + assertEquals(expected, f.format(zdt)); + assertEquals(offset, f.parse(expected, ZoneOffset::from)); } } diff --git a/test/jdk/java/time/test/java/time/format/TestLocalizedPattern.java b/test/jdk/java/time/test/java/time/format/TestLocalizedPattern.java index aa8ff763aad..1be115bc0ed 100644 --- a/test/jdk/java/time/test/java/time/format/TestLocalizedPattern.java +++ b/test/jdk/java/time/test/java/time/format/TestLocalizedPattern.java @@ -22,7 +22,7 @@ */ package test.java.time.format; -import static org.testng.Assert.assertEquals; +import static org.junit.jupiter.api.Assertions.assertEquals; import java.time.DateTimeException; import java.time.ZonedDateTime; @@ -34,14 +34,16 @@ import java.util.List; import java.util.Locale; import java.util.ResourceBundle; -import org.testng.annotations.DataProvider; -import org.testng.annotations.Test; +import org.junit.jupiter.api.Assertions; +import org.junit.jupiter.api.TestInstance; +import org.junit.jupiter.params.ParameterizedTest; +import org.junit.jupiter.params.provider.MethodSource; /** * Test DateTimeFormatter.ofLocalizedPattern() related methods. * @bug 8176706 8284840 8354548 */ -@Test +@TestInstance(TestInstance.Lifecycle.PER_CLASS) public class TestLocalizedPattern { private static final ZonedDateTime ZDT = @@ -52,7 +54,6 @@ public class TestLocalizedPattern { Locale.forLanguageTag("ja-JP-u-ca-japanese") ); - @DataProvider(name = "validSkeletons") Object[][] data_validSkeletons() { return SAMPLE_LOCALES.stream() .flatMap(l -> { @@ -63,43 +64,46 @@ public class TestLocalizedPattern { .toArray(new Object[0][0]); } - @DataProvider(name = "invalidSkeletons") Object[][] data_invalidSkeletons() { return new Object[][] { {"afo"}, {"hB"}, {"uMMM"}, {"MMMMMM"}, {"BhmsyMMM"}, }; } - @DataProvider(name = "unavailableSkeletons") Object[][] data_unavailableSkeletons() { return new Object[][] { {"yyyyyy"}, {"BBh"}, {"yMMMMEdBBh"}, }; } - @Test(dataProvider = "validSkeletons") + @ParameterizedTest + @MethodSource("data_validSkeletons") public void test_ofLocalizedPattern(String skeleton, String expected, Locale l) { var dtf = DateTimeFormatter.ofLocalizedPattern(skeleton).localizedBy(l); - assertEquals(dtf.format(ZDT), expected); + assertEquals(expected, dtf.format(ZDT)); } - @Test(dataProvider = "invalidSkeletons", expectedExceptions = IllegalArgumentException.class) + @ParameterizedTest + @MethodSource("data_invalidSkeletons") public void test_ofLocalizedPattern_invalid(String skeleton) { - DateTimeFormatter.ofLocalizedPattern(skeleton); + Assertions.assertThrows(IllegalArgumentException.class, () -> DateTimeFormatter.ofLocalizedPattern(skeleton)); } - @Test(dataProvider = "invalidSkeletons", expectedExceptions = IllegalArgumentException.class) + @ParameterizedTest + @MethodSource("data_invalidSkeletons") public void test_appendLocalized_invalid(String skeleton) { - new DateTimeFormatterBuilder().appendLocalized(skeleton); + Assertions.assertThrows(IllegalArgumentException.class, () -> new DateTimeFormatterBuilder().appendLocalized(skeleton)); } - @Test(dataProvider = "unavailableSkeletons", expectedExceptions = DateTimeException.class) + @ParameterizedTest + @MethodSource("data_unavailableSkeletons") public void test_ofLocalizedPattern_unavailable(String skeleton) { - DateTimeFormatter.ofLocalizedPattern(skeleton).format(ZDT); + Assertions.assertThrows(DateTimeException.class, () -> DateTimeFormatter.ofLocalizedPattern(skeleton).format(ZDT)); } - @Test(dataProvider = "unavailableSkeletons", expectedExceptions = DateTimeException.class) + @ParameterizedTest + @MethodSource("data_unavailableSkeletons") public void test_getLocalizedDateTimePattern_unavailable(String skeleton) { - DateTimeFormatterBuilder.getLocalizedDateTimePattern(skeleton, IsoChronology.INSTANCE, Locale.US); + Assertions.assertThrows(DateTimeException.class, () -> DateTimeFormatterBuilder.getLocalizedDateTimePattern(skeleton, IsoChronology.INSTANCE, Locale.US)); } } diff --git a/test/jdk/java/time/test/java/time/format/TestNarrowMonthNamesAndDayNames.java b/test/jdk/java/time/test/java/time/format/TestNarrowMonthNamesAndDayNames.java index 3e105665d14..92b7d1366b6 100644 --- a/test/jdk/java/time/test/java/time/format/TestNarrowMonthNamesAndDayNames.java +++ b/test/jdk/java/time/test/java/time/format/TestNarrowMonthNamesAndDayNames.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2016, 2022, Oracle and/or its affiliates. All rights reserved. + * 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 @@ -28,7 +28,7 @@ */ package test.java.time.format; -import static org.testng.Assert.assertEquals; +import static org.junit.jupiter.api.Assertions.assertEquals; import java.time.DayOfWeek; import java.time.Month; @@ -37,9 +37,11 @@ import java.util.Arrays; import java.util.List; import java.util.Locale; -import org.testng.annotations.DataProvider; -import org.testng.annotations.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 TestNarrowMonthNamesAndDayNames { static { @@ -59,7 +61,6 @@ public class TestNarrowMonthNamesAndDayNames { * Locale en_US, de_DE, fr_FR, no_NO will have same Narrow and * Narrow_Standalone month Names for COMPAT Provider. */ - @DataProvider(name = "MonthNarrows") public Object[][] monthNameData() { return new Object[][]{{new String[]{ "J", @@ -80,27 +81,23 @@ public class TestNarrowMonthNamesAndDayNames { //----------------------------------------------------------------------- // Check Narrow and Narrow_standalone month name values //----------------------------------------------------------------------- - @Test(dataProvider = "MonthNarrows") + @ParameterizedTest + @MethodSource("monthNameData") public void compareMonthNarrowValues(String[] monthNarrowExpected) { - LOCARR.forEach((loc) -> { - TEXTSTYLELIST.forEach((style) -> { - MONTHVALUES.forEach((value) -> { - String result = value.getDisplayName(style, loc); - int index = value.ordinal(); - assertEquals(result, monthNarrowExpected[index], "Test failed" - + " for COMPAT Provider for locale " - + loc + " for style " + style.name() - + " with Month value " + value.name()); - }); - }); - }); + LOCARR.forEach((loc) -> TEXTSTYLELIST.forEach((style) -> MONTHVALUES.forEach((value) -> { + String result = value.getDisplayName(style, loc); + int index = value.ordinal(); + assertEquals(monthNarrowExpected[index], result, "Test failed" + + " for COMPAT Provider for locale " + + loc + " for style " + style.name() + + " with Month value " + value.name()); + }))); } /** * Locale en_US, de_DE, fr_FR, no_NO will have different Narrow and * Narrow_Standalone Day Names for COMPAT Provider. */ - @DataProvider(name = "DayNarrows") public Object[][] dayNameData() { return new Object[][]{ {Locale.US, new String[]{"M", "T", "W", "T", "F", "S", "S"}}, @@ -112,17 +109,16 @@ public class TestNarrowMonthNamesAndDayNames { //----------------------------------------------------------------------- // Check Narrow and Narrow_standalone Day name values //----------------------------------------------------------------------- - @Test(dataProvider = "DayNarrows") + @ParameterizedTest + @MethodSource("dayNameData") public void compareDayNarrowValues(Locale locale, String[] dayNarrowExpected) { - TEXTSTYLELIST.forEach((style) -> { - DAYVALUES.forEach((value) -> { - String result = value.getDisplayName(style, locale); - int index = value.ordinal(); - assertEquals(result, dayNarrowExpected[index], "Test failed" - + " for COMPAT Provider for locale " - + locale + " for style " + style.name() - + " with Day value " + value.name()); - }); - }); + TEXTSTYLELIST.forEach((style) -> DAYVALUES.forEach((value) -> { + String result = value.getDisplayName(style, locale); + int index = value.ordinal(); + assertEquals(dayNarrowExpected[index], result, "Test failed" + + " for COMPAT Provider for locale " + + locale + " for style " + style.name() + + " with Day value " + value.name()); + })); } } diff --git a/test/jdk/java/time/test/java/time/format/TestNonIsoFormatter.java b/test/jdk/java/time/test/java/time/format/TestNonIsoFormatter.java index edca2ae8ceb..cb824e1ea7f 100644 --- a/test/jdk/java/time/test/java/time/format/TestNonIsoFormatter.java +++ b/test/jdk/java/time/test/java/time/format/TestNonIsoFormatter.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2013, 2024, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2013, 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 @@ -30,7 +30,7 @@ package test.java.time.format; -import static org.testng.Assert.assertEquals; +import static org.junit.jupiter.api.Assertions.assertEquals; import java.time.LocalDate; import java.time.chrono.ChronoLocalDate; @@ -51,9 +51,11 @@ import java.time.temporal.TemporalAccessor; import java.time.temporal.TemporalQueries; import java.util.Locale; -import org.testng.annotations.BeforeMethod; -import org.testng.annotations.DataProvider; -import org.testng.annotations.Test; +import org.junit.jupiter.api.Assertions; +import org.junit.jupiter.api.BeforeEach; +import org.junit.jupiter.api.TestInstance; +import org.junit.jupiter.params.ParameterizedTest; +import org.junit.jupiter.params.provider.MethodSource; /** * Test DateTimeFormatter with non-ISO chronology. @@ -61,7 +63,7 @@ import org.testng.annotations.Test; * Strings in test data are all dependent on CLDR data which may change * in future CLDR releases. */ -@Test +@TestInstance(TestInstance.Lifecycle.PER_CLASS) public class TestNonIsoFormatter { private static final Chronology ISO8601 = IsoChronology.INSTANCE; private static final Chronology JAPANESE = JapaneseChronology.INSTANCE; @@ -76,11 +78,10 @@ public class TestNonIsoFormatter { private static final Locale thTHTH = Locale.forLanguageTag("th-TH-u-nu-thai"); private static final Locale jaJPJP = Locale.forLanguageTag("ja-JP-u-ca-japanese"); - @BeforeMethod + @BeforeEach public void setUp() { } - @DataProvider(name="format_data") Object[][] formatData() { return new Object[][] { // Chronology, Format Locale, Numbering Locale, ChronoLocalDate, expected string @@ -102,7 +103,6 @@ public class TestNonIsoFormatter { }; } - @DataProvider(name="invalid_text") Object[][] invalidText() { return new Object[][] { // TODO: currently fixed Chronology and Locale. @@ -113,7 +113,6 @@ public class TestNonIsoFormatter { }; } - @DataProvider(name="chrono_names") Object[][] chronoNamesData() { return new Object[][] { // Chronology, Locale, Chronology Name @@ -137,7 +136,6 @@ public class TestNonIsoFormatter { }; } - @DataProvider(name="lenient_eraYear") Object[][] lenientEraYear() { return new Object[][] { // Chronology, lenient era/year, strict era/year @@ -147,17 +145,19 @@ public class TestNonIsoFormatter { }; } - @Test(dataProvider="format_data") + @ParameterizedTest + @MethodSource("formatData") public void test_formatLocalizedDate(Chronology chrono, Locale formatLocale, Locale numberingLocale, ChronoLocalDate date, String expected) { DateTimeFormatter dtf = DateTimeFormatter.ofLocalizedDate(FormatStyle.FULL) .withChronology(chrono).withLocale(formatLocale) .withDecimalStyle(DecimalStyle.of(numberingLocale)); String text = dtf.format(date); - assertEquals(text, expected); + assertEquals(expected, text); } - @Test(dataProvider="format_data") + @ParameterizedTest + @MethodSource("formatData") public void test_parseLocalizedText(Chronology chrono, Locale formatLocale, Locale numberingLocale, ChronoLocalDate expected, String text) { DateTimeFormatter dtf = DateTimeFormatter.ofLocalizedDate(FormatStyle.FULL) @@ -165,28 +165,33 @@ public class TestNonIsoFormatter { .withDecimalStyle(DecimalStyle.of(numberingLocale)); TemporalAccessor temporal = dtf.parse(text); ChronoLocalDate date = chrono.date(temporal); - assertEquals(date, expected); + assertEquals(expected, date); } - @Test(dataProvider="invalid_text", expectedExceptions=DateTimeParseException.class) + @ParameterizedTest + @MethodSource("invalidText") public void test_parseInvalidText(String text) { - DateTimeFormatter dtf = DateTimeFormatter.ofLocalizedDate(FormatStyle.FULL) - .withChronology(JAPANESE).withLocale(Locale.JAPANESE); - dtf.parse(text); + Assertions.assertThrows(DateTimeParseException.class, () -> { + DateTimeFormatter dtf = DateTimeFormatter.ofLocalizedDate(FormatStyle.FULL) + .withChronology(JAPANESE).withLocale(Locale.JAPANESE); + dtf.parse(text); + }); } - @Test(dataProvider="chrono_names") + @ParameterizedTest + @MethodSource("chronoNamesData") public void test_chronoNames(Chronology chrono, Locale locale, String expected) { DateTimeFormatter dtf = new DateTimeFormatterBuilder().appendChronologyText(TextStyle.SHORT) .toFormatter(locale); String text = dtf.format(chrono.dateNow()); - assertEquals(text, expected); + assertEquals(expected, text); TemporalAccessor ta = dtf.parse(text); Chronology cal = ta.query(TemporalQueries.chronology()); - assertEquals(cal, chrono); + assertEquals(chrono, cal); } - @Test(dataProvider="lenient_eraYear") + @ParameterizedTest + @MethodSource("lenientEraYear") public void test_lenientEraYear(Chronology chrono, String lenient, String strict) { String mdStr = "-01-01"; DateTimeFormatter dtf = new DateTimeFormatterBuilder() @@ -194,6 +199,6 @@ public class TestNonIsoFormatter { .toFormatter(Locale.ROOT) .withChronology(chrono); DateTimeFormatter dtfLenient = dtf.withResolverStyle(ResolverStyle.LENIENT); - assertEquals(LocalDate.parse(lenient+mdStr, dtfLenient), LocalDate.parse(strict+mdStr, dtf)); + assertEquals(LocalDate.parse(strict+mdStr, dtf), LocalDate.parse(lenient+mdStr, dtfLenient)); } } diff --git a/test/jdk/java/time/test/java/time/format/TestNumberParser.java b/test/jdk/java/time/test/java/time/format/TestNumberParser.java index f3ac13b791d..ea92dfcaea5 100644 --- a/test/jdk/java/time/test/java/time/format/TestNumberParser.java +++ b/test/jdk/java/time/test/java/time/format/TestNumberParser.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2012, 2013, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2012, 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 @@ -63,9 +63,10 @@ import static java.time.temporal.ChronoField.DAY_OF_MONTH; import static java.time.temporal.ChronoField.DAY_OF_WEEK; import static java.time.temporal.ChronoField.DAY_OF_YEAR; import static java.time.temporal.ChronoField.MONTH_OF_YEAR; -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 java.text.ParsePosition; import java.time.format.DateTimeFormatter; @@ -74,17 +75,17 @@ import java.time.temporal.TemporalAccessor; import java.time.temporal.TemporalField; import java.time.temporal.TemporalQueries; -import org.testng.annotations.DataProvider; -import org.testng.annotations.Test; +import org.junit.jupiter.api.TestInstance; +import org.junit.jupiter.params.ParameterizedTest; +import org.junit.jupiter.params.provider.MethodSource; /** * Test NumberPrinterParser. */ -@Test +@TestInstance(TestInstance.Lifecycle.PER_CLASS) public class TestNumberParser extends AbstractTestPrinterParser { //----------------------------------------------------------------------- - @DataProvider(name="error") Object[][] data_error() { return new Object[][] { {DAY_OF_MONTH, 1, 2, SignStyle.NEVER, "12", -1, IndexOutOfBoundsException.class}, @@ -92,7 +93,8 @@ public class TestNumberParser extends AbstractTestPrinterParser { }; } - @Test(dataProvider="error") + @ParameterizedTest + @MethodSource("data_error") public void test_parse_error(TemporalField field, int min, int max, SignStyle style, String text, int pos, Class expected) { try { getFormatter(field, min, max, style).parseUnresolved(text, new ParsePosition(pos)); @@ -103,7 +105,6 @@ public class TestNumberParser extends AbstractTestPrinterParser { } //----------------------------------------------------------------------- - @DataProvider(name="parseData") Object[][] provider_parseData() { return new Object[][] { // normal @@ -163,7 +164,8 @@ public class TestNumberParser extends AbstractTestPrinterParser { } //----------------------------------------------------------------------- - @Test(dataProvider="parseData") + @ParameterizedTest + @MethodSource("provider_parseData") public void test_parse_fresh(int minWidth, int maxWidth, SignStyle signStyle, int subsequentWidth, String text, int pos, int expectedPos, long expectedValue) { ParsePosition ppos = new ParsePosition(pos); DateTimeFormatter dtf = getFormatter(DAY_OF_MONTH, minWidth, maxWidth, signStyle); @@ -173,17 +175,18 @@ public class TestNumberParser extends AbstractTestPrinterParser { } TemporalAccessor parsed = dtf.parseUnresolved(text, ppos); if (ppos.getErrorIndex() != -1) { - assertEquals(ppos.getErrorIndex(), expectedPos); + assertEquals(expectedPos, ppos.getErrorIndex()); } else { assertTrue(subsequentWidth >= 0); - assertEquals(ppos.getIndex(), expectedPos + subsequentWidth); - assertEquals(parsed.getLong(DAY_OF_MONTH), expectedValue); - assertEquals(parsed.query(TemporalQueries.chronology()), null); - assertEquals(parsed.query(TemporalQueries.zoneId()), null); + assertEquals(expectedPos + subsequentWidth, ppos.getIndex()); + assertEquals(expectedValue, parsed.getLong(DAY_OF_MONTH)); + assertEquals(null, parsed.query(TemporalQueries.chronology())); + assertEquals(null, parsed.query(TemporalQueries.zoneId())); } } - @Test(dataProvider="parseData") + @ParameterizedTest + @MethodSource("provider_parseData") public void test_parse_textField(int minWidth, int maxWidth, SignStyle signStyle, int subsequentWidth, String text, int pos, int expectedPos, long expectedValue) { ParsePosition ppos = new ParsePosition(pos); DateTimeFormatter dtf = getFormatter(DAY_OF_WEEK, minWidth, maxWidth, signStyle); @@ -193,18 +196,17 @@ public class TestNumberParser extends AbstractTestPrinterParser { } TemporalAccessor parsed = dtf.parseUnresolved(text, ppos); if (ppos.getErrorIndex() != -1) { - assertEquals(ppos.getErrorIndex(), expectedPos); + assertEquals(expectedPos, ppos.getErrorIndex()); } else { assertTrue(subsequentWidth >= 0); - assertEquals(ppos.getIndex(), expectedPos + subsequentWidth); - assertEquals(parsed.getLong(DAY_OF_WEEK), expectedValue); - assertEquals(parsed.query(TemporalQueries.chronology()), null); - assertEquals(parsed.query(TemporalQueries.zoneId()), null); + assertEquals(expectedPos + subsequentWidth, ppos.getIndex()); + assertEquals(expectedValue, parsed.getLong(DAY_OF_WEEK)); + assertEquals(null, parsed.query(TemporalQueries.chronology())); + assertEquals(null, parsed.query(TemporalQueries.zoneId())); } } //----------------------------------------------------------------------- - @DataProvider(name="parseSignsStrict") Object[][] provider_parseSignsStrict() { return new Object[][] { // basics @@ -304,22 +306,22 @@ public class TestNumberParser extends AbstractTestPrinterParser { }; } - @Test(dataProvider="parseSignsStrict") + @ParameterizedTest + @MethodSource("provider_parseSignsStrict") public void test_parseSignsStrict(String input, int min, int max, SignStyle style, int parseLen, Integer parseVal) throws Exception { ParsePosition pos = new ParsePosition(0); TemporalAccessor parsed = getFormatter(DAY_OF_MONTH, min, max, style).parseUnresolved(input, pos); if (pos.getErrorIndex() != -1) { - assertEquals(pos.getErrorIndex(), parseLen); + assertEquals(parseLen, pos.getErrorIndex()); } else { - assertEquals(pos.getIndex(), parseLen); - assertEquals(parsed.getLong(DAY_OF_MONTH), (long)parseVal); - assertEquals(parsed.query(TemporalQueries.chronology()), null); - assertEquals(parsed.query(TemporalQueries.zoneId()), null); + assertEquals(parseLen, pos.getIndex()); + assertEquals((long)parseVal, parsed.getLong(DAY_OF_MONTH)); + assertEquals(null, parsed.query(TemporalQueries.chronology())); + assertEquals(null, parsed.query(TemporalQueries.zoneId())); } } //----------------------------------------------------------------------- - @DataProvider(name="parseSignsLenient") Object[][] provider_parseSignsLenient() { return new Object[][] { // never @@ -413,23 +415,23 @@ public class TestNumberParser extends AbstractTestPrinterParser { }; } - @Test(dataProvider="parseSignsLenient") + @ParameterizedTest + @MethodSource("provider_parseSignsLenient") public void test_parseSignsLenient(String input, int min, int max, SignStyle style, int parseLen, Integer parseVal) throws Exception { setStrict(false); ParsePosition pos = new ParsePosition(0); TemporalAccessor parsed = getFormatter(DAY_OF_MONTH, min, max, style).parseUnresolved(input, pos); if (pos.getErrorIndex() != -1) { - assertEquals(pos.getErrorIndex(), parseLen); + assertEquals(parseLen, pos.getErrorIndex()); } else { - assertEquals(pos.getIndex(), parseLen); - assertEquals(parsed.getLong(DAY_OF_MONTH), (long)parseVal); - assertEquals(parsed.query(TemporalQueries.chronology()), null); - assertEquals(parsed.query(TemporalQueries.zoneId()), null); + assertEquals(parseLen, pos.getIndex()); + assertEquals((long)parseVal, parsed.getLong(DAY_OF_MONTH)); + assertEquals(null, parsed.query(TemporalQueries.chronology())); + assertEquals(null, parsed.query(TemporalQueries.zoneId())); } } //----------------------------------------------------------------------- - @DataProvider(name="parseDigitsLenient") Object[][] provider_parseDigitsLenient() { return new Object[][] { // never @@ -504,23 +506,23 @@ public class TestNumberParser extends AbstractTestPrinterParser { }; } - @Test(dataProvider="parseDigitsLenient") + @ParameterizedTest + @MethodSource("provider_parseDigitsLenient") public void test_parseDigitsLenient(String input, int min, int max, SignStyle style, int parseLen, Integer parseVal) throws Exception { setStrict(false); ParsePosition pos = new ParsePosition(0); TemporalAccessor parsed = getFormatter(DAY_OF_MONTH, min, max, style).parseUnresolved(input, pos); if (pos.getErrorIndex() != -1) { - assertEquals(pos.getErrorIndex(), parseLen); + assertEquals(parseLen, pos.getErrorIndex()); } else { - assertEquals(pos.getIndex(), parseLen); - assertEquals(parsed.getLong(DAY_OF_MONTH), (long)parseVal); - assertEquals(parsed.query(TemporalQueries.chronology()), null); - assertEquals(parsed.query(TemporalQueries.zoneId()), null); + assertEquals(parseLen, pos.getIndex()); + assertEquals((long)parseVal, parsed.getLong(DAY_OF_MONTH)); + assertEquals(null, parsed.query(TemporalQueries.chronology())); + assertEquals(null, parsed.query(TemporalQueries.zoneId())); } } //----------------------------------------------------------------------- - @DataProvider(name="parseDigitsAdjacentLenient") Object[][] provider_parseDigitsAdjacentLenient() { return new Object[][] { // never @@ -538,7 +540,8 @@ public class TestNumberParser extends AbstractTestPrinterParser { }; } - @Test(dataProvider="parseDigitsAdjacentLenient") + @ParameterizedTest + @MethodSource("provider_parseDigitsAdjacentLenient") public void test_parseDigitsAdjacentLenient(String input, int parseLen, Integer parseMonth, Integer parsedDay) throws Exception { setStrict(false); ParsePosition pos = new ParsePosition(0); @@ -547,13 +550,13 @@ public class TestNumberParser extends AbstractTestPrinterParser { .appendValue(DAY_OF_MONTH, 2).toFormatter(locale).withDecimalStyle(decimalStyle); TemporalAccessor parsed = f.parseUnresolved(input, pos); if (pos.getErrorIndex() != -1) { - assertEquals(pos.getErrorIndex(), parseLen); + assertEquals(parseLen, pos.getErrorIndex()); } else { - assertEquals(pos.getIndex(), parseLen); - assertEquals(parsed.getLong(MONTH_OF_YEAR), (long) parseMonth); - assertEquals(parsed.getLong(DAY_OF_MONTH), (long) parsedDay); - assertEquals(parsed.query(TemporalQueries.chronology()), null); - assertEquals(parsed.query(TemporalQueries.zoneId()), null); + assertEquals(parseLen, pos.getIndex()); + assertEquals((long) parseMonth, parsed.getLong(MONTH_OF_YEAR)); + assertEquals((long) parsedDay, parsed.getLong(DAY_OF_MONTH)); + assertEquals(null, parsed.query(TemporalQueries.chronology())); + assertEquals(null, parsed.query(TemporalQueries.zoneId())); } } diff --git a/test/jdk/java/time/test/java/time/format/TestNumberPrinter.java b/test/jdk/java/time/test/java/time/format/TestNumberPrinter.java index dedcc37e2ce..59038df910f 100644 --- a/test/jdk/java/time/test/java/time/format/TestNumberPrinter.java +++ b/test/jdk/java/time/test/java/time/format/TestNumberPrinter.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2012, 2013, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2012, 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 @@ -61,37 +61,42 @@ package test.java.time.format; import static java.time.temporal.ChronoField.DAY_OF_MONTH; import static java.time.temporal.ChronoField.HOUR_OF_DAY; -import static org.testng.Assert.assertEquals; -import static org.testng.Assert.fail; + +import static org.junit.jupiter.api.Assertions.assertEquals; +import static org.junit.jupiter.api.Assertions.fail; import java.time.DateTimeException; import java.time.LocalDate; import java.time.format.SignStyle; -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.api.TestInstance; +import org.junit.jupiter.params.ParameterizedTest; +import org.junit.jupiter.params.provider.MethodSource; + import test.java.time.temporal.MockFieldValue; /** * Test SimpleNumberPrinterParser. */ -@Test +@TestInstance(TestInstance.Lifecycle.PER_CLASS) public class TestNumberPrinter extends AbstractTestPrinterParser { //----------------------------------------------------------------------- - @Test(expectedExceptions=DateTimeException.class) + @Test public void test_print_emptyCalendrical() throws Exception { - getFormatter(DAY_OF_MONTH, 1, 2, SignStyle.NEVER).formatTo(EMPTY_DTA, buf); + Assertions.assertThrows(DateTimeException.class, () -> getFormatter(DAY_OF_MONTH, 1, 2, SignStyle.NEVER).formatTo(EMPTY_DTA, buf)); } + @Test public void test_print_append() throws Exception { buf.append("EXISTING"); getFormatter(DAY_OF_MONTH, 1, 2, SignStyle.NEVER).formatTo(LocalDate.of(2012, 1, 3), buf); - assertEquals(buf.toString(), "EXISTING3"); + assertEquals("EXISTING3", buf.toString()); } //----------------------------------------------------------------------- - @DataProvider(name="Pad") Object[][] provider_pad() { return new Object[][] { {1, 1, -10, null}, @@ -181,72 +186,77 @@ public class TestNumberPrinter extends AbstractTestPrinterParser { }; } - @Test(dataProvider="Pad") + @ParameterizedTest + @MethodSource("provider_pad") public void test_pad_NOT_NEGATIVE(int minPad, int maxPad, long value, String result) throws Exception { try { getFormatter(DAY_OF_MONTH, minPad, maxPad, SignStyle.NOT_NEGATIVE).formatTo(new MockFieldValue(DAY_OF_MONTH, value), buf); if (result == null || value < 0) { fail("Expected exception"); } - assertEquals(buf.toString(), result); + assertEquals(result, buf.toString()); } catch (DateTimeException ex) { if (result == null || value < 0) { - assertEquals(ex.getMessage().contains(DAY_OF_MONTH.toString()), true); + assertEquals(true, ex.getMessage().contains(DAY_OF_MONTH.toString())); } else { throw ex; } } } - @Test(dataProvider="Pad") + @ParameterizedTest + @MethodSource("provider_pad") public void test_pad_NEVER(int minPad, int maxPad, long value, String result) throws Exception { try { getFormatter(DAY_OF_MONTH, minPad, maxPad, SignStyle.NEVER).formatTo(new MockFieldValue(DAY_OF_MONTH, value), buf); if (result == null) { fail("Expected exception"); } - assertEquals(buf.toString(), result); + assertEquals(result, buf.toString()); } catch (DateTimeException ex) { if (result != null) { throw ex; } - assertEquals(ex.getMessage().contains(DAY_OF_MONTH.toString()), true); + assertEquals(true, ex.getMessage().contains(DAY_OF_MONTH.toString())); } } - @Test(dataProvider="Pad") + @ParameterizedTest + @MethodSource("provider_pad") public void test_pad_NORMAL(int minPad, int maxPad, long value, String result) throws Exception { try { getFormatter(DAY_OF_MONTH, minPad, maxPad, SignStyle.NORMAL).formatTo(new MockFieldValue(DAY_OF_MONTH, value), buf); if (result == null) { fail("Expected exception"); } - assertEquals(buf.toString(), (value < 0 ? "-" + result : result)); + assertEquals((value < 0 ? "-" + result : result), buf.toString()); } catch (DateTimeException ex) { if (result != null) { throw ex; } - assertEquals(ex.getMessage().contains(DAY_OF_MONTH.toString()), true); + assertEquals(true, ex.getMessage().contains(DAY_OF_MONTH.toString())); } } - @Test(dataProvider="Pad") + @ParameterizedTest + @MethodSource("provider_pad") public void test_pad_ALWAYS(int minPad, int maxPad, long value, String result) throws Exception { try { getFormatter(DAY_OF_MONTH, minPad, maxPad, SignStyle.ALWAYS).formatTo(new MockFieldValue(DAY_OF_MONTH, value), buf); if (result == null) { fail("Expected exception"); } - assertEquals(buf.toString(), (value < 0 ? "-" + result : "+" + result)); + assertEquals((value < 0 ? "-" + result : "+" + result), buf.toString()); } catch (DateTimeException ex) { if (result != null) { throw ex; } - assertEquals(ex.getMessage().contains(DAY_OF_MONTH.toString()), true); + assertEquals(true, ex.getMessage().contains(DAY_OF_MONTH.toString())); } } - @Test(dataProvider="Pad") + @ParameterizedTest + @MethodSource("provider_pad") public void test_pad_EXCEEDS_PAD(int minPad, int maxPad, long value, String result) throws Exception { try { getFormatter(DAY_OF_MONTH, minPad, maxPad, SignStyle.EXCEEDS_PAD).formatTo(new MockFieldValue(DAY_OF_MONTH, value), buf); @@ -257,26 +267,29 @@ public class TestNumberPrinter extends AbstractTestPrinterParser { if (result.length() > minPad || value < 0) { result = (value < 0 ? "-" + result : "+" + result); } - assertEquals(buf.toString(), result); + assertEquals(result, buf.toString()); } catch (DateTimeException ex) { if (result != null) { throw ex; } - assertEquals(ex.getMessage().contains(DAY_OF_MONTH.toString()), true); + assertEquals(true, ex.getMessage().contains(DAY_OF_MONTH.toString())); } } //----------------------------------------------------------------------- + @Test public void test_toString1() throws Exception { - assertEquals(getFormatter(HOUR_OF_DAY, 1, 19, SignStyle.NORMAL).toString(), "Value(HourOfDay)"); + assertEquals("Value(HourOfDay)", getFormatter(HOUR_OF_DAY, 1, 19, SignStyle.NORMAL).toString()); } + @Test public void test_toString2() throws Exception { - assertEquals(getFormatter(HOUR_OF_DAY, 2, 2, SignStyle.NOT_NEGATIVE).toString(), "Value(HourOfDay,2)"); + assertEquals("Value(HourOfDay,2)", getFormatter(HOUR_OF_DAY, 2, 2, SignStyle.NOT_NEGATIVE).toString()); } + @Test public void test_toString3() throws Exception { - assertEquals(getFormatter(HOUR_OF_DAY, 1, 2, SignStyle.NOT_NEGATIVE).toString(), "Value(HourOfDay,1,2,NOT_NEGATIVE)"); + assertEquals("Value(HourOfDay,1,2,NOT_NEGATIVE)", getFormatter(HOUR_OF_DAY, 1, 2, SignStyle.NOT_NEGATIVE).toString()); } } diff --git a/test/jdk/java/time/test/java/time/format/TestPadPrinterDecorator.java b/test/jdk/java/time/test/java/time/format/TestPadPrinterDecorator.java index adb7677556a..48721e470c3 100644 --- a/test/jdk/java/time/test/java/time/format/TestPadPrinterDecorator.java +++ b/test/jdk/java/time/test/java/time/format/TestPadPrinterDecorator.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2012, 2013, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2012, 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 @@ -59,79 +59,90 @@ */ package test.java.time.format; -import static org.testng.Assert.assertEquals; +import static org.junit.jupiter.api.Assertions.assertEquals; import java.time.DateTimeException; import java.time.LocalDate; -import org.testng.annotations.Test; +import org.junit.jupiter.api.Assertions; +import org.junit.jupiter.api.Test; /** * Test PadPrinterDecorator. */ -@Test public class TestPadPrinterDecorator extends AbstractTestPrinterParser { //----------------------------------------------------------------------- + @Test public void test_print_emptyCalendrical() throws Exception { builder.padNext(3, '-').appendLiteral('Z'); getFormatter().formatTo(EMPTY_DTA, buf); - assertEquals(buf.toString(), "--Z"); + assertEquals("--Z", buf.toString()); } + @Test public void test_print_fullDateTime() throws Exception { builder.padNext(3, '-').appendLiteral('Z'); getFormatter().formatTo(LocalDate.of(2008, 12, 3), buf); - assertEquals(buf.toString(), "--Z"); + assertEquals("--Z", buf.toString()); } + @Test public void test_print_append() throws Exception { buf.append("EXISTING"); builder.padNext(3, '-').appendLiteral('Z'); getFormatter().formatTo(EMPTY_DTA, buf); - assertEquals(buf.toString(), "EXISTING--Z"); + assertEquals("EXISTING--Z", buf.toString()); } //----------------------------------------------------------------------- + @Test public void test_print_noPadRequiredSingle() throws Exception { builder.padNext(1, '-').appendLiteral('Z'); getFormatter().formatTo(EMPTY_DTA, buf); - assertEquals(buf.toString(), "Z"); + assertEquals("Z", buf.toString()); } + @Test public void test_print_padRequiredSingle() throws Exception { builder.padNext(5, '-').appendLiteral('Z'); getFormatter().formatTo(EMPTY_DTA, buf); - assertEquals(buf.toString(), "----Z"); + assertEquals("----Z", buf.toString()); } + @Test public void test_print_noPadRequiredMultiple() throws Exception { builder.padNext(4, '-').appendLiteral("WXYZ"); getFormatter().formatTo(EMPTY_DTA, buf); - assertEquals(buf.toString(), "WXYZ"); + assertEquals("WXYZ", buf.toString()); } + @Test public void test_print_padRequiredMultiple() throws Exception { builder.padNext(5, '-').appendLiteral("WXYZ"); getFormatter().formatTo(EMPTY_DTA, buf); - assertEquals(buf.toString(), "-WXYZ"); + assertEquals("-WXYZ", buf.toString()); } - @Test(expectedExceptions=DateTimeException.class) + @Test public void test_print_overPad() throws Exception { - builder.padNext(3, '-').appendLiteral("WXYZ"); - getFormatter().formatTo(EMPTY_DTA, buf); + Assertions.assertThrows(DateTimeException.class, () -> { + builder.padNext(3, '-').appendLiteral("WXYZ"); + getFormatter().formatTo(EMPTY_DTA, buf); + }); } //----------------------------------------------------------------------- + @Test public void test_toString1() throws Exception { builder.padNext(5, ' ').appendLiteral('Y'); - assertEquals(getFormatter().toString(), "Pad('Y',5)"); + assertEquals("Pad('Y',5)", getFormatter().toString()); } + @Test public void test_toString2() throws Exception { builder.padNext(5, '-').appendLiteral('Y'); - assertEquals(getFormatter().toString(), "Pad('Y',5,'-')"); + assertEquals("Pad('Y',5,'-')", getFormatter().toString()); } } diff --git a/test/jdk/java/time/test/java/time/format/TestReducedParser.java b/test/jdk/java/time/test/java/time/format/TestReducedParser.java index 3bf806563e8..2d9df7c11da 100644 --- a/test/jdk/java/time/test/java/time/format/TestReducedParser.java +++ b/test/jdk/java/time/test/java/time/format/TestReducedParser.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2012, 2013, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2012, 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 @@ -65,9 +65,10 @@ import static java.time.temporal.ChronoField.MONTH_OF_YEAR; import static java.time.temporal.ChronoField.YEAR; import static java.time.temporal.ChronoField.YEAR_OF_ERA; import static java.time.temporal.ChronoUnit.YEARS; -import static org.testng.Assert.assertEquals; -import static org.testng.Assert.assertTrue; -import static org.testng.Assert.assertNotNull; + +import static org.junit.jupiter.api.Assertions.assertEquals; +import static org.junit.jupiter.api.Assertions.assertTrue; +import static org.junit.jupiter.api.Assertions.assertNotNull; import java.text.ParsePosition; import java.time.LocalDate; @@ -85,13 +86,15 @@ import java.time.temporal.TemporalAccessor; import java.time.temporal.TemporalField; import java.time.temporal.TemporalQueries; -import org.testng.annotations.DataProvider; -import org.testng.annotations.Test; +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 ReducedPrinterParser. */ -@Test +@TestInstance(TestInstance.Lifecycle.PER_CLASS) public class TestReducedParser extends AbstractTestPrinterParser { private static final boolean STRICT = true; private static final boolean LENIENT = false; @@ -109,7 +112,6 @@ public class TestReducedParser extends AbstractTestPrinterParser { } //----------------------------------------------------------------------- - @DataProvider(name="error") Object[][] data_error() { return new Object[][] { {YEAR, 2, 2010, "12", -1, IndexOutOfBoundsException.class}, @@ -117,7 +119,8 @@ public class TestReducedParser extends AbstractTestPrinterParser { }; } - @Test(dataProvider="error") + @ParameterizedTest + @MethodSource("data_error") public void test_parse_error(TemporalField field, int width, int baseValue, String text, int pos, Class expected) { try { getFormatter0(field, width, baseValue).parseUnresolved(text, new ParsePosition(pos)); @@ -127,10 +130,11 @@ public class TestReducedParser extends AbstractTestPrinterParser { } //----------------------------------------------------------------------- + @Test public void test_parse_fieldRangeIgnored() throws Exception { ParsePosition pos = new ParsePosition(0); TemporalAccessor parsed = getFormatter0(DAY_OF_YEAR, 3, 10).parseUnresolved("456", pos); - assertEquals(pos.getIndex(), 3); + assertEquals(3, pos.getIndex()); assertParsed(parsed, DAY_OF_YEAR, 456L); // parsed dayOfYear=456 } @@ -138,7 +142,6 @@ public class TestReducedParser extends AbstractTestPrinterParser { // Parse data and values that are consistent whether strict or lenient // The data is the ChronoField, width, baseValue, text, startPos, endPos, value //----------------------------------------------------------------------- - @DataProvider(name="ParseAll") Object[][] provider_parseAll() { return new Object[][] { // negative zero @@ -182,30 +185,32 @@ public class TestReducedParser extends AbstractTestPrinterParser { }; } - @Test(dataProvider="ParseAll") + @ParameterizedTest + @MethodSource("provider_parseAll") public void test_parseAllStrict(TemporalField field, int width, int baseValue, String input, int pos, int parseLen, Integer parseVal) { ParsePosition ppos = new ParsePosition(pos); setStrict(true); TemporalAccessor parsed = getFormatter0(field, width, baseValue).parseUnresolved(input, ppos); if (ppos.getErrorIndex() != -1) { - assertEquals(ppos.getErrorIndex(), parseLen, "error case parse position"); - assertEquals(parsed, parseVal, "unexpected parse result"); + assertEquals(parseLen, ppos.getErrorIndex(), "error case parse position"); + assertEquals(parseVal, parsed, "unexpected parse result"); } else { - assertEquals(ppos.getIndex(), parseLen, "parse position"); + assertEquals(parseLen, ppos.getIndex(), "parse position"); assertParsed(parsed, YEAR, parseVal != null ? (long) parseVal : null); } } - @Test(dataProvider="ParseAll") + @ParameterizedTest + @MethodSource("provider_parseAll") public void test_parseAllLenient(TemporalField field, int width, int baseValue, String input, int pos, int parseLen, Integer parseVal) { ParsePosition ppos = new ParsePosition(pos); setStrict(false); TemporalAccessor parsed = getFormatter0(field, width, baseValue).parseUnresolved(input, ppos); if (ppos.getErrorIndex() != -1) { - assertEquals(ppos.getErrorIndex(), parseLen, "error case parse position"); - assertEquals(parsed, parseVal, "unexpected parse result"); + assertEquals(parseLen, ppos.getErrorIndex(), "error case parse position"); + assertEquals(parseVal, parsed, "unexpected parse result"); } else { - assertEquals(ppos.getIndex(), parseLen, "parse position"); + assertEquals(parseLen, ppos.getIndex(), "parse position"); assertParsed(parsed, YEAR, parseVal != null ? (long) parseVal : null); } } @@ -215,7 +220,6 @@ public class TestReducedParser extends AbstractTestPrinterParser { // The data is the ChronoField, minWidth, maxWidth, baseValue, text, startPos, // Strict Pair(endPos, value), Lenient Pair(endPos, value) //----------------------------------------------------------------------- - @DataProvider(name="ParseLenientSensitive") Object[][] provider_parseLenientSensitive() { return new Object[][] { // few digits supplied @@ -268,32 +272,34 @@ public class TestReducedParser extends AbstractTestPrinterParser { //----------------------------------------------------------------------- // Parsing tests for strict mode //----------------------------------------------------------------------- - @Test(dataProvider="ParseLenientSensitive") + @ParameterizedTest + @MethodSource("provider_parseLenientSensitive") public void test_parseStrict(TemporalField field, int minWidth, int maxWidth, int baseValue, String input, int pos, Pair strict, Pair lenient) { ParsePosition ppos = new ParsePosition(pos); setStrict(true); TemporalAccessor parsed = getFormatter0(field, minWidth, maxWidth, baseValue).parseUnresolved(input, ppos); if (ppos.getErrorIndex() != -1) { - assertEquals(ppos.getErrorIndex(), strict.parseLen, "error case parse position"); - assertEquals(parsed, strict.parseVal, "unexpected parse result"); + assertEquals(strict.parseLen, ppos.getErrorIndex(), "error case parse position"); + assertEquals(strict.parseVal, parsed, "unexpected parse result"); } else { - assertEquals(ppos.getIndex(), strict.parseLen, "parse position"); + assertEquals(strict.parseLen, ppos.getIndex(), "parse position"); assertParsed(parsed, YEAR, strict.parseVal != null ? (long) strict.parseVal : null); } } - @Test(dataProvider="ParseLenientSensitive") + @ParameterizedTest + @MethodSource("provider_parseLenientSensitive") public void test_parseStrict_baseDate(TemporalField field, int minWidth, int maxWidth, int baseValue, String input, int pos, Pair strict, Pair lenient) { ParsePosition ppos = new ParsePosition(pos); setStrict(true); TemporalAccessor parsed = getFormatterBaseDate(field, minWidth, maxWidth, baseValue).parseUnresolved(input, ppos); if (ppos.getErrorIndex() != -1) { - assertEquals(ppos.getErrorIndex(), strict.parseLen, "error case parse position"); - assertEquals(parsed, strict.parseVal, "unexpected parse result"); + assertEquals(strict.parseLen, ppos.getErrorIndex(), "error case parse position"); + assertEquals(strict.parseVal, parsed, "unexpected parse result"); } else { - assertEquals(ppos.getIndex(), strict.parseLen, "parse position"); + assertEquals(strict.parseLen, ppos.getIndex(), "parse position"); assertParsed(parsed, YEAR, strict.parseVal != null ? (long) strict.parseVal : null); } } @@ -301,42 +307,44 @@ public class TestReducedParser extends AbstractTestPrinterParser { //----------------------------------------------------------------------- // Parsing tests for lenient mode //----------------------------------------------------------------------- - @Test(dataProvider="ParseLenientSensitive") + @ParameterizedTest + @MethodSource("provider_parseLenientSensitive") public void test_parseLenient(TemporalField field, int minWidth, int maxWidth, int baseValue, String input, int pos, Pair strict, Pair lenient) { ParsePosition ppos = new ParsePosition(pos); setStrict(false); TemporalAccessor parsed = getFormatter0(field, minWidth, maxWidth, baseValue).parseUnresolved(input, ppos); if (ppos.getErrorIndex() != -1) { - assertEquals(ppos.getErrorIndex(), lenient.parseLen, "error case parse position"); - assertEquals(parsed, lenient.parseVal, "unexpected parse result"); + assertEquals(lenient.parseLen, ppos.getErrorIndex(), "error case parse position"); + assertEquals(lenient.parseVal, parsed, "unexpected parse result"); } else { - assertEquals(ppos.getIndex(), lenient.parseLen, "parse position"); + assertEquals(lenient.parseLen, ppos.getIndex(), "parse position"); assertParsed(parsed, YEAR, lenient.parseVal != null ? (long) lenient.parseVal : null); } } - @Test(dataProvider="ParseLenientSensitive") + @ParameterizedTest + @MethodSource("provider_parseLenientSensitive") public void test_parseLenient_baseDate(TemporalField field, int minWidth, int maxWidth, int baseValue, String input, int pos, Pair strict, Pair lenient) { ParsePosition ppos = new ParsePosition(pos); setStrict(false); TemporalAccessor parsed = getFormatterBaseDate(field, minWidth, maxWidth, baseValue).parseUnresolved(input, ppos); if (ppos.getErrorIndex() != -1) { - assertEquals(ppos.getErrorIndex(), lenient.parseLen, "error case parse position"); - assertEquals(parsed, lenient.parseVal, "unexpected parse result"); + assertEquals(lenient.parseLen, ppos.getErrorIndex(), "error case parse position"); + assertEquals(lenient.parseVal, parsed, "unexpected parse result"); } else { - assertEquals(ppos.getIndex(), lenient.parseLen, "parse position"); + assertEquals(lenient.parseLen, ppos.getIndex(), "parse position"); assertParsed(parsed, YEAR, lenient.parseVal != null ? (long) lenient.parseVal : null); } } private void assertParsed(TemporalAccessor parsed, TemporalField field, Long value) { if (value == null) { - assertEquals(parsed, null, "Parsed Value"); + assertEquals(null, parsed, "Parsed Value"); } else { - assertEquals(parsed.isSupported(field), true, "isSupported: " + field); - assertEquals(parsed.getLong(field), (long) value, "Temporal.getLong: " + field); + assertEquals(true, parsed.isSupported(field), "isSupported: " + field); + assertEquals((long) value, parsed.getLong(field), "Temporal.getLong: " + field); } } @@ -344,7 +352,6 @@ public class TestReducedParser extends AbstractTestPrinterParser { //----------------------------------------------------------------------- // Cases and values in adjacent parsing mode //----------------------------------------------------------------------- - @DataProvider(name="ParseAdjacent") Object[][] provider_parseAdjacent() { return new Object[][] { // general @@ -363,7 +370,8 @@ public class TestReducedParser extends AbstractTestPrinterParser { }; } - @Test(dataProvider="ParseAdjacent") + @ParameterizedTest + @MethodSource("provider_parseAdjacent") public void test_parseAdjacent(String pattern, String input, boolean strict, int pos, int parseLen, int year, int month, int day) { ParsePosition ppos = new ParsePosition(0); builder = new DateTimeFormatterBuilder(); @@ -374,9 +382,9 @@ public class TestReducedParser extends AbstractTestPrinterParser { TemporalAccessor parsed = dtf.parseUnresolved(input, ppos); assertNotNull(parsed, String.format("parse failed: ppos: %s, formatter: %s%n", ppos.toString(), dtf)); if (ppos.getErrorIndex() != -1) { - assertEquals(ppos.getErrorIndex(), parseLen, "error case parse position"); + assertEquals(parseLen, ppos.getErrorIndex(), "error case parse position"); } else { - assertEquals(ppos.getIndex(), parseLen, "parse position"); + assertEquals(parseLen, ppos.getIndex(), "parse position"); assertParsed(parsed, YEAR_OF_ERA, Long.valueOf(year)); assertParsed(parsed, MONTH_OF_YEAR, Long.valueOf(month)); assertParsed(parsed, DAY_OF_MONTH, Long.valueOf(day)); @@ -386,7 +394,6 @@ public class TestReducedParser extends AbstractTestPrinterParser { //----------------------------------------------------------------------- // Cases and values in reduced value parsing mode //----------------------------------------------------------------------- - @DataProvider(name="ReducedWithChrono") Object[][] provider_reducedWithChrono() { LocalDate baseYear = LocalDate.of(2000, 1, 1); return new Object[][] { @@ -408,7 +415,8 @@ public class TestReducedParser extends AbstractTestPrinterParser { }; } - @Test(dataProvider="ReducedWithChrono") + @ParameterizedTest + @MethodSource("provider_reducedWithChrono") public void test_reducedWithChronoYear(ChronoLocalDate date) { Chronology chrono = date.getChronology(); DateTimeFormatter df @@ -421,12 +429,13 @@ public class TestReducedParser extends AbstractTestPrinterParser { ParsePosition pos = new ParsePosition(0); TemporalAccessor parsed = df.parseUnresolved(input, pos); int actual = parsed.get(YEAR); - assertEquals(actual, expected, + assertEquals(expected, actual, String.format("Wrong date parsed, chrono: %s, input: %s", chrono, input)); } - @Test(dataProvider="ReducedWithChrono") + @ParameterizedTest + @MethodSource("provider_reducedWithChrono") public void test_reducedWithChronoYearOfEra(ChronoLocalDate date) { Chronology chrono = date.getChronology(); DateTimeFormatter df @@ -439,7 +448,7 @@ public class TestReducedParser extends AbstractTestPrinterParser { ParsePosition pos = new ParsePosition(0); TemporalAccessor parsed = df.parseUnresolved(input, pos); int actual = parsed.get(YEAR_OF_ERA); - assertEquals(actual, expected, + assertEquals(expected, actual, String.format("Wrong date parsed, chrono: %s, input: %s", chrono, input)); @@ -459,10 +468,10 @@ public class TestReducedParser extends AbstractTestPrinterParser { ParsePosition pos = new ParsePosition(0); TemporalAccessor parsed = df.parseUnresolved(input, pos); - assertEquals(pos.getIndex(), input.length(), "Input not parsed completely"); - assertEquals(pos.getErrorIndex(), -1, "Error index should be -1 (no-error)"); + assertEquals(input.length(), pos.getIndex(), "Input not parsed completely"); + assertEquals(-1, pos.getErrorIndex(), "Error index should be -1 (no-error)"); int actual = parsed.get(YEAR); - assertEquals(actual, expected, + assertEquals(expected, actual, String.format("Wrong date parsed, chrono: %s, input: %s", parsed.query(TemporalQueries.chronology()), input)); @@ -482,10 +491,10 @@ public class TestReducedParser extends AbstractTestPrinterParser { String input = "44 ThaiBuddhist ISO"; ParsePosition pos = new ParsePosition(0); TemporalAccessor parsed = df.parseUnresolved(input, pos); - assertEquals(pos.getIndex(), input.length(), "Input not parsed completely: " + pos); - assertEquals(pos.getErrorIndex(), -1, "Error index should be -1 (no-error)"); + assertEquals(input.length(), pos.getIndex(), "Input not parsed completely: " + pos); + assertEquals(-1, pos.getErrorIndex(), "Error index should be -1 (no-error)"); int actual = parsed.get(YEAR); - assertEquals(actual, expected, + assertEquals(expected, actual, String.format("Wrong date parsed, chrono: %s, input: %s", parsed.query(TemporalQueries.chronology()), input)); diff --git a/test/jdk/java/time/test/java/time/format/TestReducedPrinter.java b/test/jdk/java/time/test/java/time/format/TestReducedPrinter.java index c4b6cf4dc39..94c45662666 100644 --- a/test/jdk/java/time/test/java/time/format/TestReducedPrinter.java +++ b/test/jdk/java/time/test/java/time/format/TestReducedPrinter.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2012, 2013, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2012, 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 @@ -60,8 +60,9 @@ package test.java.time.format; import static java.time.temporal.ChronoField.YEAR; -import static org.testng.Assert.assertEquals; -import static org.testng.Assert.fail; + +import static org.junit.jupiter.api.Assertions.assertEquals; +import static org.junit.jupiter.api.Assertions.fail; import java.time.DateTimeException; import java.time.LocalDate; @@ -70,14 +71,18 @@ import java.time.format.DateTimeFormatter; import java.time.format.DateTimeFormatterBuilder; import java.time.temporal.TemporalField; -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.api.TestInstance; +import org.junit.jupiter.params.ParameterizedTest; +import org.junit.jupiter.params.provider.MethodSource; + import test.java.time.temporal.MockFieldValue; /** * Test ReducedPrinterParser. */ -@Test +@TestInstance(TestInstance.Lifecycle.PER_CLASS) public class TestReducedPrinter extends AbstractTestPrinterParser { private DateTimeFormatter getFormatter0(TemporalField field, int width, int baseValue) { @@ -93,20 +98,20 @@ public class TestReducedPrinter extends AbstractTestPrinterParser { } //----------------------------------------------------------------------- - @Test(expectedExceptions=DateTimeException.class) + @Test public void test_print_emptyCalendrical() throws Exception { - getFormatter0(YEAR, 2, 2010).formatTo(EMPTY_DTA, buf); + Assertions.assertThrows(DateTimeException.class, () -> getFormatter0(YEAR, 2, 2010).formatTo(EMPTY_DTA, buf)); } //----------------------------------------------------------------------- + @Test public void test_print_append() throws Exception { buf.append("EXISTING"); getFormatter0(YEAR, 2, 2010).formatTo(LocalDate.of(2012, 1, 1), buf); - assertEquals(buf.toString(), "EXISTING12"); + assertEquals("EXISTING12", buf.toString()); } //----------------------------------------------------------------------- - @DataProvider(name="Pivot") Object[][] provider_pivot() { return new Object[][] { {1, 1, 2010, 2010, "0"}, @@ -175,34 +180,36 @@ public class TestReducedPrinter extends AbstractTestPrinterParser { }; } - @Test(dataProvider="Pivot") + @ParameterizedTest + @MethodSource("provider_pivot") public void test_pivot(int minWidth, int maxWidth, int baseValue, int value, String result) throws Exception { try { getFormatter0(YEAR, minWidth, maxWidth, baseValue).formatTo(new MockFieldValue(YEAR, value), buf); if (result == null) { fail("Expected exception"); } - assertEquals(buf.toString(), result); + assertEquals(result, buf.toString()); } catch (DateTimeException ex) { if (result == null || value < 0) { - assertEquals(ex.getMessage().contains(YEAR.toString()), true); + assertEquals(true, ex.getMessage().contains(YEAR.toString())); } else { throw ex; } } } - @Test(dataProvider="Pivot") + @ParameterizedTest + @MethodSource("provider_pivot") public void test_pivot_baseDate(int minWidth, int maxWidth, int baseValue, int value, String result) throws Exception { try { getFormatterBaseDate(YEAR, minWidth, maxWidth, baseValue).formatTo(new MockFieldValue(YEAR, value), buf); if (result == null) { fail("Expected exception"); } - assertEquals(buf.toString(), result); + assertEquals(result, buf.toString()); } catch (DateTimeException ex) { if (result == null || value < 0) { - assertEquals(ex.getMessage().contains(YEAR.toString()), true); + assertEquals(true, ex.getMessage().contains(YEAR.toString())); } else { throw ex; } @@ -210,49 +217,51 @@ public class TestReducedPrinter extends AbstractTestPrinterParser { } //----------------------------------------------------------------------- + @Test public void test_minguoChrono_fixedWidth() throws Exception { // ISO 2021 is Minguo 110 DateTimeFormatter f = getFormatterBaseDate(YEAR, 2, 2, 2021); MinguoDate date = MinguoDate.of(109, 6, 30); - assertEquals(f.format(date), "09"); + assertEquals("09", f.format(date)); date = MinguoDate.of(110, 6, 30); - assertEquals(f.format(date), "10"); + assertEquals("10", f.format(date)); date = MinguoDate.of(199, 6, 30); - assertEquals(f.format(date), "99"); + assertEquals("99", f.format(date)); date = MinguoDate.of(200, 6, 30); - assertEquals(f.format(date), "00"); + assertEquals("00", f.format(date)); date = MinguoDate.of(209, 6, 30); - assertEquals(f.format(date), "09"); + assertEquals("09", f.format(date)); date = MinguoDate.of(210, 6, 30); - assertEquals(f.format(date), "10"); + assertEquals("10", f.format(date)); } + @Test public void test_minguoChrono_extendedWidth() throws Exception { // ISO 2021 is Minguo 110 DateTimeFormatter f = getFormatterBaseDate(YEAR, 2, 4, 2021); MinguoDate date = MinguoDate.of(109, 6, 30); - assertEquals(f.format(date), "109"); + assertEquals("109", f.format(date)); date = MinguoDate.of(110, 6, 30); - assertEquals(f.format(date), "10"); + assertEquals("10", f.format(date)); date = MinguoDate.of(199, 6, 30); - assertEquals(f.format(date), "99"); + assertEquals("99", f.format(date)); date = MinguoDate.of(200, 6, 30); - assertEquals(f.format(date), "00"); + assertEquals("00", f.format(date)); date = MinguoDate.of(209, 6, 30); - assertEquals(f.format(date), "09"); + assertEquals("09", f.format(date)); date = MinguoDate.of(210, 6, 30); - assertEquals(f.format(date), "210"); + assertEquals("210", f.format(date)); } //----------------------------------------------------------------------- + @Test public void test_toString() throws Exception { - assertEquals(getFormatter0(YEAR, 2, 2, 2005).toString(), "ReducedValue(Year,2,2,2005)"); + assertEquals("ReducedValue(Year,2,2,2005)", getFormatter0(YEAR, 2, 2, 2005).toString()); } //----------------------------------------------------------------------- // Cases and values in adjacent parsing mode //----------------------------------------------------------------------- - @DataProvider(name="PrintAdjacent") Object[][] provider_printAdjacent() { return new Object[][] { // general @@ -265,7 +274,8 @@ public class TestReducedPrinter extends AbstractTestPrinterParser { }; } - @Test(dataProvider="PrintAdjacent") + @ParameterizedTest + @MethodSource("provider_printAdjacent") public void test_printAdjacent(String pattern, String text, int year, int month, int day) { builder = new DateTimeFormatterBuilder(); builder.appendPattern(pattern); @@ -273,7 +283,7 @@ public class TestReducedPrinter extends AbstractTestPrinterParser { LocalDate ld = LocalDate.of(year, month, day); String actual = dtf.format(ld); - assertEquals(actual, text, "formatter output: " + dtf); + assertEquals(text, actual, "formatter output: " + dtf); } } diff --git a/test/jdk/java/time/test/java/time/format/TestSettingsParser.java b/test/jdk/java/time/test/java/time/format/TestSettingsParser.java index ce7b2d7f187..1f71a37a007 100644 --- a/test/jdk/java/time/test/java/time/format/TestSettingsParser.java +++ b/test/jdk/java/time/test/java/time/format/TestSettingsParser.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2012, 2013, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2012, 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 @@ -59,29 +59,30 @@ */ package test.java.time.format; -import static org.testng.Assert.assertEquals; +import static org.junit.jupiter.api.Assertions.assertEquals; import java.text.ParsePosition; -import org.testng.annotations.Test; +import org.junit.jupiter.api.Test; /** * Test SettingsParser. */ -@Test public class TestSettingsParser extends AbstractTestPrinterParser { //----------------------------------------------------------------------- + @Test public void test_print_sensitive() throws Exception { setCaseSensitive(true); getFormatter().formatTo(dta, buf); - assertEquals(buf.toString(), ""); + assertEquals("", buf.toString()); } + @Test public void test_print_strict() throws Exception { setStrict(true); getFormatter().formatTo(dta, buf); - assertEquals(buf.toString(), ""); + assertEquals("", buf.toString()); } /* @@ -92,53 +93,61 @@ public class TestSettingsParser extends AbstractTestPrinterParser { */ //----------------------------------------------------------------------- + @Test public void test_parse_changeStyle_sensitive() throws Exception { setCaseSensitive(true); ParsePosition pos = new ParsePosition(0); getFormatter().parseUnresolved("a", pos); - assertEquals(pos.getIndex(), 0); + assertEquals(0, pos.getIndex()); } + @Test public void test_parse_changeStyle_insensitive() throws Exception { setCaseSensitive(false); ParsePosition pos = new ParsePosition(0); getFormatter().parseUnresolved("a", pos); - assertEquals(pos.getIndex(), 0); + assertEquals(0, pos.getIndex()); } + @Test public void test_parse_changeStyle_strict() throws Exception { setStrict(true); ParsePosition pos = new ParsePosition(0); getFormatter().parseUnresolved("a", pos); - assertEquals(pos.getIndex(), 0); + assertEquals(0, pos.getIndex()); } + @Test public void test_parse_changeStyle_lenient() throws Exception { setStrict(false); ParsePosition pos = new ParsePosition(0); getFormatter().parseUnresolved("a", pos); - assertEquals(pos.getIndex(), 0); + assertEquals(0, pos.getIndex()); } //----------------------------------------------------------------------- + @Test public void test_toString_sensitive() throws Exception { setCaseSensitive(true); - assertEquals(getFormatter().toString(), "ParseCaseSensitive(true)"); + assertEquals("ParseCaseSensitive(true)", getFormatter().toString()); } + @Test public void test_toString_insensitive() throws Exception { setCaseSensitive(false); - assertEquals(getFormatter().toString(), "ParseCaseSensitive(false)"); + assertEquals("ParseCaseSensitive(false)", getFormatter().toString()); } + @Test public void test_toString_strict() throws Exception { setStrict(true); - assertEquals(getFormatter().toString(), "ParseStrict(true)"); + assertEquals("ParseStrict(true)", getFormatter().toString()); } + @Test public void test_toString_lenient() throws Exception { setStrict(false); - assertEquals(getFormatter().toString(), "ParseStrict(false)"); + assertEquals("ParseStrict(false)", getFormatter().toString()); } } diff --git a/test/jdk/java/time/test/java/time/format/TestStringLiteralParser.java b/test/jdk/java/time/test/java/time/format/TestStringLiteralParser.java index f8f5147f921..c442621ce34 100644 --- a/test/jdk/java/time/test/java/time/format/TestStringLiteralParser.java +++ b/test/jdk/java/time/test/java/time/format/TestStringLiteralParser.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2012, 2013, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2012, 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 @@ -60,24 +60,25 @@ package test.java.time.format; import static java.time.temporal.ChronoField.YEAR; -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 java.text.ParsePosition; import java.time.temporal.TemporalAccessor; import java.time.temporal.TemporalQueries; -import org.testng.annotations.DataProvider; -import org.testng.annotations.Test; +import org.junit.jupiter.api.TestInstance; +import org.junit.jupiter.params.ParameterizedTest; +import org.junit.jupiter.params.provider.MethodSource; /** * Test StringLiteralPrinterParser. */ -@Test +@TestInstance(TestInstance.Lifecycle.PER_CLASS) public class TestStringLiteralParser extends AbstractTestPrinterParser { - @DataProvider(name="success") Object[][] data_success() { return new Object[][] { // match @@ -104,23 +105,23 @@ public class TestStringLiteralParser extends AbstractTestPrinterParser { }; } - @Test(dataProvider="success") + @ParameterizedTest + @MethodSource("data_success") public void test_parse_success(String s, boolean caseSensitive, String text, int pos, int expectedPos) { setCaseSensitive(caseSensitive); ParsePosition ppos = new ParsePosition(pos); TemporalAccessor parsed = getFormatter(s).parseUnresolved(text, ppos); if (ppos.getErrorIndex() != -1) { - assertEquals(ppos.getIndex(), expectedPos); + assertEquals(expectedPos, ppos.getIndex()); } else { - assertEquals(ppos.getIndex(), expectedPos); - assertEquals(parsed.isSupported(YEAR), false); - assertEquals(parsed.query(TemporalQueries.chronology()), null); - assertEquals(parsed.query(TemporalQueries.zoneId()), null); + assertEquals(expectedPos, ppos.getIndex()); + assertEquals(false, parsed.isSupported(YEAR)); + assertEquals(null, parsed.query(TemporalQueries.chronology())); + assertEquals(null, parsed.query(TemporalQueries.zoneId())); } } //----------------------------------------------------------------------- - @DataProvider(name="error") Object[][] data_error() { return new Object[][] { {"hello", "hello", -1, IndexOutOfBoundsException.class}, @@ -128,7 +129,8 @@ public class TestStringLiteralParser extends AbstractTestPrinterParser { }; } - @Test(dataProvider="error") + @ParameterizedTest + @MethodSource("data_error") public void test_parse_error(String s, String text, int pos, Class expected) { try { ParsePosition ppos = new ParsePosition(pos); diff --git a/test/jdk/java/time/test/java/time/format/TestStringLiteralPrinter.java b/test/jdk/java/time/test/java/time/format/TestStringLiteralPrinter.java index 6733af164a4..ed8717d8bdb 100644 --- a/test/jdk/java/time/test/java/time/format/TestStringLiteralPrinter.java +++ b/test/jdk/java/time/test/java/time/format/TestStringLiteralPrinter.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2012, 2013, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2012, 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 @@ -59,44 +59,47 @@ */ package test.java.time.format; -import static org.testng.Assert.assertEquals; - -import org.testng.annotations.Test; +import static org.junit.jupiter.api.Assertions.assertEquals; +import org.junit.jupiter.api.Test; /** * Test StringLiteralPrinterParser. */ -@Test public class TestStringLiteralPrinter extends AbstractTestPrinterParser { //----------------------------------------------------------------------- + @Test public void test_print_emptyCalendrical() throws Exception { buf.append("EXISTING"); getFormatter("hello").formatTo(EMPTY_DTA, buf); - assertEquals(buf.toString(), "EXISTINGhello"); + assertEquals("EXISTINGhello", buf.toString()); } + @Test public void test_print_dateTime() throws Exception { buf.append("EXISTING"); getFormatter("hello").formatTo(dta, buf); - assertEquals(buf.toString(), "EXISTINGhello"); + assertEquals("EXISTINGhello", buf.toString()); } + @Test public void test_print_emptyAppendable() throws Exception { getFormatter("hello").formatTo(dta, buf); - assertEquals(buf.toString(), "hello"); + assertEquals("hello", buf.toString()); } //----------------------------------------------------------------------- + @Test public void test_toString() throws Exception { - assertEquals(getFormatter("hello").toString(), "'hello'"); + assertEquals("'hello'", getFormatter("hello").toString()); } + @Test public void test_toString_apos() throws Exception { - assertEquals(getFormatter("o'clock").toString(), "'o''clock'"); + assertEquals("'o''clock'", getFormatter("o'clock").toString()); } } diff --git a/test/jdk/java/time/test/java/time/format/TestTextParser.java b/test/jdk/java/time/test/java/time/format/TestTextParser.java index b6126a6b407..2482cbc5a6e 100644 --- a/test/jdk/java/time/test/java/time/format/TestTextParser.java +++ b/test/jdk/java/time/test/java/time/format/TestTextParser.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2012, 2016, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2012, 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 @@ -63,8 +63,9 @@ import static java.time.temporal.ChronoField.DAY_OF_MONTH; import static java.time.temporal.ChronoField.DAY_OF_WEEK; import static java.time.temporal.ChronoField.MONTH_OF_YEAR; import static java.time.temporal.IsoFields.QUARTER_OF_YEAR; -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 java.text.ParsePosition; import java.time.DayOfWeek; @@ -77,17 +78,18 @@ import java.time.temporal.TemporalQueries; import java.time.temporal.ChronoField; import java.util.Locale; -import org.testng.annotations.DataProvider; -import org.testng.annotations.Test; +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 TextPrinterParser. */ -@Test +@TestInstance(TestInstance.Lifecycle.PER_CLASS) public class TestTextParser extends AbstractTestPrinterParser { //----------------------------------------------------------------------- - @DataProvider(name="error") Object[][] data_error() { return new Object[][] { {DAY_OF_WEEK, TextStyle.FULL, "Monday", -1, IndexOutOfBoundsException.class}, @@ -95,7 +97,8 @@ public class TestTextParser extends AbstractTestPrinterParser { }; } - @Test(dataProvider="error") + @ParameterizedTest + @MethodSource("data_error") public void test_parse_error(TemporalField field, TextStyle style, String text, int pos, Class expected) { try { getFormatter(field, style).parseUnresolved(text, new ParsePosition(pos)); @@ -105,49 +108,53 @@ public class TestTextParser extends AbstractTestPrinterParser { } //----------------------------------------------------------------------- + @Test public void test_parse_midStr() throws Exception { ParsePosition pos = new ParsePosition(3); - assertEquals(getFormatter(DAY_OF_WEEK, TextStyle.FULL) - .parseUnresolved("XxxMondayXxx", pos) - .getLong(DAY_OF_WEEK), 1L); - assertEquals(pos.getIndex(), 9); + assertEquals(1L, getFormatter(DAY_OF_WEEK, TextStyle.FULL) + .parseUnresolved("XxxMondayXxx", pos) + .getLong(DAY_OF_WEEK)); + assertEquals(9, pos.getIndex()); } + @Test public void test_parse_remainderIgnored() throws Exception { ParsePosition pos = new ParsePosition(0); - assertEquals(getFormatter(DAY_OF_WEEK, TextStyle.SHORT) - .parseUnresolved("Wednesday", pos) - .getLong(DAY_OF_WEEK), 3L); - assertEquals(pos.getIndex(), 3); + assertEquals(3L, getFormatter(DAY_OF_WEEK, TextStyle.SHORT) + .parseUnresolved("Wednesday", pos) + .getLong(DAY_OF_WEEK)); + assertEquals(3, pos.getIndex()); } //----------------------------------------------------------------------- + @Test public void test_parse_noMatch1() throws Exception { ParsePosition pos = new ParsePosition(0); TemporalAccessor parsed = getFormatter(DAY_OF_WEEK, TextStyle.FULL).parseUnresolved("Munday", pos); - assertEquals(pos.getErrorIndex(), 0); - assertEquals(parsed, null); + assertEquals(0, pos.getErrorIndex()); + assertEquals(null, parsed); } + @Test public void test_parse_noMatch2() throws Exception { ParsePosition pos = new ParsePosition(3); TemporalAccessor parsed = getFormatter(DAY_OF_WEEK, TextStyle.FULL).parseUnresolved("Monday", pos); - assertEquals(pos.getErrorIndex(), 3); - assertEquals(parsed, null); + assertEquals(3, pos.getErrorIndex()); + assertEquals(null, parsed); } + @Test public void test_parse_noMatch_atEnd() throws Exception { ParsePosition pos = new ParsePosition(6); TemporalAccessor parsed = getFormatter(DAY_OF_WEEK, TextStyle.FULL).parseUnresolved("Monday", pos); - assertEquals(pos.getErrorIndex(), 6); - assertEquals(parsed, null); + assertEquals(6, pos.getErrorIndex()); + assertEquals(null, parsed); } //----------------------------------------------------------------------- - @DataProvider(name="parseText") Object[][] provider_text() { return new Object[][] { {DAY_OF_WEEK, TextStyle.FULL, 1, "Monday"}, @@ -189,7 +196,6 @@ public class TestTextParser extends AbstractTestPrinterParser { }; } - @DataProvider(name="parseNumber") Object[][] provider_number() { return new Object[][] { {DAY_OF_MONTH, TextStyle.FULL, 1, "1"}, @@ -204,7 +210,6 @@ public class TestTextParser extends AbstractTestPrinterParser { }; } - @DataProvider(name="parseDayOfWeekText") Object[][] providerDayOfWeekData() { return new Object[][] { // Locale, pattern, input text, expected DayOfWeek @@ -215,30 +220,34 @@ public class TestTextParser extends AbstractTestPrinterParser { } - @Test(dataProvider="parseText") + @ParameterizedTest + @MethodSource("provider_text") public void test_parseText(TemporalField field, TextStyle style, int value, String input) throws Exception { ParsePosition pos = new ParsePosition(0); - assertEquals(getFormatter(field, style).parseUnresolved(input, pos).getLong(field), (long) value); - assertEquals(pos.getIndex(), input.length()); + assertEquals((long) value, getFormatter(field, style).parseUnresolved(input, pos).getLong(field)); + assertEquals(input.length(), pos.getIndex()); } - @Test(dataProvider="parseNumber") + @ParameterizedTest + @MethodSource("provider_number") public void test_parseNumber(TemporalField field, TextStyle style, int value, String input) throws Exception { ParsePosition pos = new ParsePosition(0); - assertEquals(getFormatter(field, style).parseUnresolved(input, pos).getLong(field), (long) value); - assertEquals(pos.getIndex(), input.length()); + assertEquals((long) value, getFormatter(field, style).parseUnresolved(input, pos).getLong(field)); + assertEquals(input.length(), pos.getIndex()); } - @Test(dataProvider="parseDayOfWeekText") + @ParameterizedTest + @MethodSource("providerDayOfWeekData") public void test_parseDayOfWeekText(Locale locale, String pattern, String input, DayOfWeek expected) { DateTimeFormatter formatter = getPatternFormatter(pattern).withLocale(locale); ParsePosition pos = new ParsePosition(0); - assertEquals(DayOfWeek.from(formatter.parse(input, pos)), expected); - assertEquals(pos.getIndex(), input.length()); + assertEquals(expected, DayOfWeek.from(formatter.parse(input, pos))); + assertEquals(input.length(), pos.getIndex()); } //----------------------------------------------------------------------- - @Test(dataProvider="parseText") + @ParameterizedTest + @MethodSource("provider_text") public void test_parse_strict_caseSensitive_parseUpper(TemporalField field, TextStyle style, int value, String input) throws Exception { if (input.equals(input.toUpperCase(Locale.ROOT))) { // Skip if the given input is all upper case (e.g., "Q1") @@ -247,19 +256,21 @@ public class TestTextParser extends AbstractTestPrinterParser { setCaseSensitive(true); ParsePosition pos = new ParsePosition(0); getFormatter(field, style).parseUnresolved(input.toUpperCase(Locale.ROOT), pos); - assertEquals(pos.getErrorIndex(), 0); + assertEquals(0, pos.getErrorIndex()); } - @Test(dataProvider="parseText") + @ParameterizedTest + @MethodSource("provider_text") public void test_parse_strict_caseInsensitive_parseUpper(TemporalField field, TextStyle style, int value, String input) throws Exception { setCaseSensitive(false); ParsePosition pos = new ParsePosition(0); - assertEquals(getFormatter(field, style).parseUnresolved(input.toUpperCase(Locale.ROOT), pos).getLong(field), (long) value); - assertEquals(pos.getIndex(), input.length()); + assertEquals((long) value, getFormatter(field, style).parseUnresolved(input.toUpperCase(Locale.ROOT), pos).getLong(field)); + assertEquals(input.length(), pos.getIndex()); } //----------------------------------------------------------------------- - @Test(dataProvider="parseText") + @ParameterizedTest + @MethodSource("provider_text") public void test_parse_strict_caseSensitive_parseLower(TemporalField field, TextStyle style, int value, String input) throws Exception { if (input.equals(input.toLowerCase(Locale.ROOT))) { // Skip if the given input is all lower case (e.g., "1st quarter") @@ -268,105 +279,118 @@ public class TestTextParser extends AbstractTestPrinterParser { setCaseSensitive(true); ParsePosition pos = new ParsePosition(0); getFormatter(field, style).parseUnresolved(input.toLowerCase(Locale.ROOT), pos); - assertEquals(pos.getErrorIndex(), 0); + assertEquals(0, pos.getErrorIndex()); } - @Test(dataProvider="parseText") + @ParameterizedTest + @MethodSource("provider_text") public void test_parse_strict_caseInsensitive_parseLower(TemporalField field, TextStyle style, int value, String input) throws Exception { setCaseSensitive(false); ParsePosition pos = new ParsePosition(0); - assertEquals(getFormatter(field, style).parseUnresolved(input.toLowerCase(Locale.ROOT), pos).getLong(field), (long) value); - assertEquals(pos.getIndex(), input.length()); + assertEquals((long) value, getFormatter(field, style).parseUnresolved(input.toLowerCase(Locale.ROOT), pos).getLong(field)); + assertEquals(input.length(), pos.getIndex()); } //----------------------------------------------------------------------- //----------------------------------------------------------------------- //----------------------------------------------------------------------- + @Test public void test_parse_full_strict_full_match() throws Exception { setStrict(true); ParsePosition pos = new ParsePosition(0); - assertEquals(getFormatter(MONTH_OF_YEAR, TextStyle.FULL).parseUnresolved("January", pos).getLong(MONTH_OF_YEAR), 1L); - assertEquals(pos.getIndex(), 7); + assertEquals(1L, getFormatter(MONTH_OF_YEAR, TextStyle.FULL).parseUnresolved("January", pos).getLong(MONTH_OF_YEAR)); + assertEquals(7, pos.getIndex()); } + @Test public void test_parse_full_strict_short_noMatch() throws Exception { setStrict(true); ParsePosition pos = new ParsePosition(0); getFormatter(MONTH_OF_YEAR, TextStyle.FULL).parseUnresolved("Janua", pos); - assertEquals(pos.getErrorIndex(), 0); + assertEquals(0, pos.getErrorIndex()); } + @Test public void test_parse_full_strict_number_noMatch() throws Exception { setStrict(true); ParsePosition pos = new ParsePosition(0); getFormatter(MONTH_OF_YEAR, TextStyle.FULL).parseUnresolved("1", pos); - assertEquals(pos.getErrorIndex(), 0); + assertEquals(0, pos.getErrorIndex()); } //----------------------------------------------------------------------- + @Test public void test_parse_short_strict_full_match() throws Exception { setStrict(true); ParsePosition pos = new ParsePosition(0); - assertEquals(getFormatter(MONTH_OF_YEAR, TextStyle.SHORT).parseUnresolved("January", pos).getLong(MONTH_OF_YEAR), 1L); - assertEquals(pos.getIndex(), 3); + assertEquals(1L, getFormatter(MONTH_OF_YEAR, TextStyle.SHORT).parseUnresolved("January", pos).getLong(MONTH_OF_YEAR)); + assertEquals(3, pos.getIndex()); } + @Test public void test_parse_short_strict_short_match() throws Exception { setStrict(true); ParsePosition pos = new ParsePosition(0); - assertEquals(getFormatter(MONTH_OF_YEAR, TextStyle.SHORT).parseUnresolved("Janua", pos).getLong(MONTH_OF_YEAR), 1L); - assertEquals(pos.getIndex(), 3); + assertEquals(1L, getFormatter(MONTH_OF_YEAR, TextStyle.SHORT).parseUnresolved("Janua", pos).getLong(MONTH_OF_YEAR)); + assertEquals(3, pos.getIndex()); } + @Test public void test_parse_short_strict_number_noMatch() throws Exception { setStrict(true); ParsePosition pos = new ParsePosition(0); getFormatter(MONTH_OF_YEAR, TextStyle.SHORT).parseUnresolved("1", pos); - assertEquals(pos.getErrorIndex(), 0); + assertEquals(0, pos.getErrorIndex()); } //----------------------------------------------------------------------- + @Test public void test_parse_full_lenient_full_match() throws Exception { setStrict(false); ParsePosition pos = new ParsePosition(0); - assertEquals(getFormatter(MONTH_OF_YEAR, TextStyle.FULL).parseUnresolved("January.", pos).getLong(MONTH_OF_YEAR), 1L); - assertEquals(pos.getIndex(), 7); + assertEquals(1L, getFormatter(MONTH_OF_YEAR, TextStyle.FULL).parseUnresolved("January.", pos).getLong(MONTH_OF_YEAR)); + assertEquals(7, pos.getIndex()); } + @Test public void test_parse_full_lenient_short_match() throws Exception { setStrict(false); ParsePosition pos = new ParsePosition(0); - assertEquals(getFormatter(MONTH_OF_YEAR, TextStyle.FULL).parseUnresolved("Janua", pos).getLong(MONTH_OF_YEAR), 1L); - assertEquals(pos.getIndex(), 3); + assertEquals(1L, getFormatter(MONTH_OF_YEAR, TextStyle.FULL).parseUnresolved("Janua", pos).getLong(MONTH_OF_YEAR)); + assertEquals(3, pos.getIndex()); } + @Test public void test_parse_full_lenient_number_match() throws Exception { setStrict(false); ParsePosition pos = new ParsePosition(0); - assertEquals(getFormatter(MONTH_OF_YEAR, TextStyle.FULL).parseUnresolved("1", pos).getLong(MONTH_OF_YEAR), 1L); - assertEquals(pos.getIndex(), 1); + assertEquals(1L, getFormatter(MONTH_OF_YEAR, TextStyle.FULL).parseUnresolved("1", pos).getLong(MONTH_OF_YEAR)); + assertEquals(1, pos.getIndex()); } //----------------------------------------------------------------------- + @Test public void test_parse_short_lenient_full_match() throws Exception { setStrict(false); ParsePosition pos = new ParsePosition(0); - assertEquals(getFormatter(MONTH_OF_YEAR, TextStyle.SHORT).parseUnresolved("January", pos).getLong(MONTH_OF_YEAR), 1L); - assertEquals(pos.getIndex(), 7); + assertEquals(1L, getFormatter(MONTH_OF_YEAR, TextStyle.SHORT).parseUnresolved("January", pos).getLong(MONTH_OF_YEAR)); + assertEquals(7, pos.getIndex()); } + @Test public void test_parse_short_lenient_short_match() throws Exception { setStrict(false); ParsePosition pos = new ParsePosition(0); - assertEquals(getFormatter(MONTH_OF_YEAR, TextStyle.SHORT).parseUnresolved("Janua", pos).getLong(MONTH_OF_YEAR), 1L); - assertEquals(pos.getIndex(), 3); + assertEquals(1L, getFormatter(MONTH_OF_YEAR, TextStyle.SHORT).parseUnresolved("Janua", pos).getLong(MONTH_OF_YEAR)); + assertEquals(3, pos.getIndex()); } + @Test public void test_parse_short_lenient_number_match() throws Exception { setStrict(false); ParsePosition pos = new ParsePosition(0); - assertEquals(getFormatter(MONTH_OF_YEAR, TextStyle.SHORT).parseUnresolved("1", pos).getLong(MONTH_OF_YEAR), 1L); - assertEquals(pos.getIndex(), 1); + assertEquals(1L, getFormatter(MONTH_OF_YEAR, TextStyle.SHORT).parseUnresolved("1", pos).getLong(MONTH_OF_YEAR)); + assertEquals(1, pos.getIndex()); } } diff --git a/test/jdk/java/time/test/java/time/format/TestTextParserWithLocale.java b/test/jdk/java/time/test/java/time/format/TestTextParserWithLocale.java index 371c5180832..35d458d6b45 100644 --- a/test/jdk/java/time/test/java/time/format/TestTextParserWithLocale.java +++ b/test/jdk/java/time/test/java/time/format/TestTextParserWithLocale.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2012, 2022, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2012, 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 @@ -81,24 +81,26 @@ import java.time.temporal.ChronoField; import java.time.temporal.TemporalField; import java.util.Locale; -import org.testng.annotations.DataProvider; -import org.testng.annotations.Test; import static java.time.temporal.ChronoField.DAY_OF_MONTH; import static java.time.temporal.ChronoField.DAY_OF_WEEK; import static java.time.temporal.ChronoField.MONTH_OF_YEAR; -import static org.testng.Assert.assertEquals; + +import static org.junit.jupiter.api.Assertions.assertEquals; +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 TextPrinterParser. */ -@Test +@TestInstance(TestInstance.Lifecycle.PER_CLASS) public class TestTextParserWithLocale extends AbstractTestPrinterParser { static final Locale RUSSIAN = Locale.of("ru"); static final Locale FINNISH = Locale.of("fi"); - @DataProvider(name="parseDayOfWeekText") Object[][] providerDayOfWeekData() { return new Object[][] { // Locale, pattern, input text, expected DayOfWeek @@ -112,17 +114,17 @@ public class TestTextParserWithLocale extends AbstractTestPrinterParser { }; } - @Test(dataProvider="parseDayOfWeekText") + @ParameterizedTest + @MethodSource("providerDayOfWeekData") public void test_parseDayOfWeekText(Locale locale, String pattern, String input, DayOfWeek expected) { DateTimeFormatter formatter = getPatternFormatter(pattern).withLocale(locale); ParsePosition pos = new ParsePosition(0); - assertEquals(DayOfWeek.from(formatter.parse(input, pos)), expected); - assertEquals(pos.getIndex(), input.length()); + assertEquals(expected, DayOfWeek.from(formatter.parse(input, pos))); + assertEquals(input.length(), pos.getIndex()); } //-------------------------------------------------------------------- // Test data is dependent on localized resources. - @DataProvider(name="parseStandaloneText") Object[][] providerStandaloneText() { // Locale, TemporalField, TextStyle, expected value, input text return new Object[][] { @@ -136,7 +138,6 @@ public class TestTextParserWithLocale extends AbstractTestPrinterParser { } // Test data is dependent on localized resources. - @DataProvider(name="parseLenientText") Object[][] providerLenientText() { // Locale, TemporalField, expected value, input text return new Object[][] { @@ -147,47 +148,49 @@ public class TestTextParserWithLocale extends AbstractTestPrinterParser { }; } - @Test(dataProvider="parseStandaloneText") + @ParameterizedTest + @MethodSource("providerStandaloneText") public void test_parseStandaloneText(Locale locale, TemporalField field, TextStyle style, int expectedValue, String input) { DateTimeFormatter formatter = getFormatter(field, style).withLocale(locale); ParsePosition pos = new ParsePosition(0); - assertEquals(formatter.parseUnresolved(input, pos).getLong(field), (long) expectedValue); - assertEquals(pos.getIndex(), input.length()); + assertEquals((long) expectedValue, formatter.parseUnresolved(input, pos).getLong(field)); + assertEquals(input.length(), pos.getIndex()); } //----------------------------------------------------------------------- + @Test public void test_parse_french_short_strict_full_noMatch() throws Exception { setStrict(true); ParsePosition pos = new ParsePosition(0); getFormatter(MONTH_OF_YEAR, TextStyle.SHORT).withLocale(Locale.FRENCH) .parseUnresolved("janvier", pos); - assertEquals(pos.getErrorIndex(), 0); + assertEquals(0, pos.getErrorIndex()); } + @Test public void test_parse_french_short_strict_short_match() throws Exception { setStrict(true); ParsePosition pos = new ParsePosition(0); - assertEquals(getFormatter(MONTH_OF_YEAR, TextStyle.SHORT).withLocale(Locale.FRENCH) - .parseUnresolved("janv.", pos) - .getLong(MONTH_OF_YEAR), - 1L); - assertEquals(pos.getIndex(), 5); + assertEquals(1L, getFormatter(MONTH_OF_YEAR, TextStyle.SHORT).withLocale(Locale.FRENCH) + .parseUnresolved("janv.", pos) + .getLong(MONTH_OF_YEAR)); + assertEquals(5, pos.getIndex()); } //----------------------------------------------------------------------- - @Test(dataProvider="parseLenientText") + @ParameterizedTest + @MethodSource("providerLenientText") public void test_parseLenientText(Locale locale, TemporalField field, int expectedValue, String input) { setStrict(false); ParsePosition pos = new ParsePosition(0); DateTimeFormatter formatter = getFormatter(field).withLocale(locale); - assertEquals(formatter.parseUnresolved(input, pos).getLong(field), (long) expectedValue); - assertEquals(pos.getIndex(), input.length()); + assertEquals((long) expectedValue, formatter.parseUnresolved(input, pos).getLong(field)); + assertEquals(input.length(), pos.getIndex()); } //----------------------------------------------------------------------- - @DataProvider(name="parseChronoLocalDate") Object[][] provider_chronoLocalDate() { return new Object[][] { { HijrahDate.now() }, @@ -213,14 +216,15 @@ public class TestTextParserWithLocale extends AbstractTestPrinterParser { .appendValue(ChronoField.DAY_OF_MONTH, 1, 2, SignStyle.NEVER) .toFormatter(); - @Test(dataProvider="parseChronoLocalDate") + @ParameterizedTest + @MethodSource("provider_chronoLocalDate") public void test_chronoLocalDate(ChronoLocalDate date) throws Exception { System.out.printf(" %s, [fmt=%s]%n", date, fmt_chrono.format(date)); - assertEquals(date, fmt_chrono.parse(fmt_chrono.format(date), ChronoLocalDate::from)); + assertEquals(fmt_chrono.parse(fmt_chrono.format(date), ChronoLocalDate::from), date); DateTimeFormatter fmt = DateTimeFormatter.ofPattern("[GGG ]yyy-MM-dd") .withChronology(date.getChronology()); System.out.printf(" %s, [fmt=%s]%n", date.toString(), fmt.format(date)); - assertEquals(date, fmt.parse(fmt.format(date), ChronoLocalDate::from)); + assertEquals(fmt.parse(fmt.format(date), ChronoLocalDate::from), date); } } diff --git a/test/jdk/java/time/test/java/time/format/TestTextPrinter.java b/test/jdk/java/time/test/java/time/format/TestTextPrinter.java index 379d6a23bb0..f07c935b025 100644 --- a/test/jdk/java/time/test/java/time/format/TestTextPrinter.java +++ b/test/jdk/java/time/test/java/time/format/TestTextPrinter.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2012, 2016, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2012, 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 @@ -64,7 +64,8 @@ import static java.time.temporal.ChronoField.DAY_OF_WEEK; import static java.time.temporal.ChronoField.ERA; import static java.time.temporal.ChronoField.MONTH_OF_YEAR; import static java.time.temporal.IsoFields.QUARTER_OF_YEAR; -import static org.testng.Assert.assertEquals; + +import static org.junit.jupiter.api.Assertions.assertEquals; import java.time.DateTimeException; import java.time.DayOfWeek; @@ -75,30 +76,34 @@ import java.time.format.TextStyle; import java.time.temporal.TemporalField; import java.util.Locale; -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.api.TestInstance; +import org.junit.jupiter.params.ParameterizedTest; +import org.junit.jupiter.params.provider.MethodSource; + import test.java.time.temporal.MockFieldValue; /** * Test TextPrinterParser. */ -@Test +@TestInstance(TestInstance.Lifecycle.PER_CLASS) public class TestTextPrinter extends AbstractTestPrinterParser { //----------------------------------------------------------------------- - @Test(expectedExceptions=DateTimeException.class) + @Test public void test_print_emptyCalendrical() throws Exception { - getFormatter(DAY_OF_WEEK, TextStyle.FULL).formatTo(EMPTY_DTA, buf); + Assertions.assertThrows(DateTimeException.class, () -> getFormatter(DAY_OF_WEEK, TextStyle.FULL).formatTo(EMPTY_DTA, buf)); } + @Test public void test_print_append() throws Exception { buf.append("EXISTING"); getFormatter(DAY_OF_WEEK, TextStyle.FULL).formatTo(LocalDate.of(2012, 4, 18), buf); - assertEquals(buf.toString(), "EXISTINGWednesday"); + assertEquals("EXISTINGWednesday", buf.toString()); } //----------------------------------------------------------------------- - @DataProvider(name="print") Object[][] provider_dow() { return new Object[][] { {DAY_OF_WEEK, TextStyle.FULL, 1, "Monday"}, @@ -204,7 +209,6 @@ public class TestTextPrinter extends AbstractTestPrinterParser { }; } - @DataProvider(name="print_DayOfWeekData") Object[][] providerDayOfWeekData() { return new Object[][] { // Locale, pattern, expected text, input DayOfWeek @@ -214,26 +218,30 @@ public class TestTextPrinter extends AbstractTestPrinterParser { }; } - @Test(dataProvider="print") + @ParameterizedTest + @MethodSource("provider_dow") public void test_format(TemporalField field, TextStyle style, int value, String expected) throws Exception { getFormatter(field, style).formatTo(new MockFieldValue(field, value), buf); - assertEquals(buf.toString(), expected); + assertEquals(expected, buf.toString()); } - @Test(dataProvider="print_DayOfWeekData") + @ParameterizedTest + @MethodSource("providerDayOfWeekData") public void test_formatDayOfWeek(Locale locale, String pattern, String expected, DayOfWeek dayOfWeek) { DateTimeFormatter formatter = getPatternFormatter(pattern).withLocale(locale); String text = formatter.format(dayOfWeek); - assertEquals(text, expected); + assertEquals(expected, text); } //----------------------------------------------------------------------- + @Test public void test_toString1() throws Exception { - assertEquals(getFormatter(MONTH_OF_YEAR, TextStyle.FULL).toString(), "Text(MonthOfYear)"); + assertEquals("Text(MonthOfYear)", getFormatter(MONTH_OF_YEAR, TextStyle.FULL).toString()); } + @Test public void test_toString2() throws Exception { - assertEquals(getFormatter(MONTH_OF_YEAR, TextStyle.SHORT).toString(), "Text(MonthOfYear,SHORT)"); + assertEquals("Text(MonthOfYear,SHORT)", getFormatter(MONTH_OF_YEAR, TextStyle.SHORT).toString()); } } diff --git a/test/jdk/java/time/test/java/time/format/TestTextPrinterWithLocale.java b/test/jdk/java/time/test/java/time/format/TestTextPrinterWithLocale.java index abbe4302f99..9b85de777b1 100644 --- a/test/jdk/java/time/test/java/time/format/TestTextPrinterWithLocale.java +++ b/test/jdk/java/time/test/java/time/format/TestTextPrinterWithLocale.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2012, 2022, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2012, 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 @@ -70,7 +70,8 @@ import static java.time.temporal.ChronoField.DAY_OF_WEEK; import static java.time.temporal.ChronoField.ERA; import static java.time.temporal.ChronoField.MONTH_OF_YEAR; import static java.time.temporal.IsoFields.QUARTER_OF_YEAR; -import static org.testng.Assert.assertEquals; + +import static org.junit.jupiter.api.Assertions.assertEquals; import java.time.DateTimeException; import java.time.DayOfWeek; @@ -81,20 +82,22 @@ import java.time.format.TextStyle; import java.time.temporal.TemporalField; import java.util.Locale; -import org.testng.annotations.DataProvider; -import org.testng.annotations.Test; +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; + import test.java.time.temporal.MockFieldValue; /** * Test TextPrinterParserWithLocale. */ -@Test +@TestInstance(TestInstance.Lifecycle.PER_CLASS) public class TestTextPrinterWithLocale extends AbstractTestPrinterParser { static final Locale RUSSIAN = Locale.of("ru"); static final Locale FINNISH = Locale.of("fi"); //----------------------------------------------------------------------- - @DataProvider(name="print_DayOfWeekData") Object[][] providerDayOfWeekData() { return new Object[][] { // Locale, pattern, expected text, input DayOfWeek @@ -109,7 +112,6 @@ public class TestTextPrinterWithLocale extends AbstractTestPrinterParser { } // Test data is dependent on localized resources. - @DataProvider(name="print_standalone") Object[][] provider_StandaloneNames() { return new Object[][] { // standalone names for 2013-01-01 (Tue) @@ -121,31 +123,34 @@ public class TestTextPrinterWithLocale extends AbstractTestPrinterParser { }; } - @Test(dataProvider="print_DayOfWeekData") + @ParameterizedTest + @MethodSource("providerDayOfWeekData") public void test_formatDayOfWeek(Locale locale, String pattern, String expected, DayOfWeek dayOfWeek) { DateTimeFormatter formatter = getPatternFormatter(pattern).withLocale(locale); String text = formatter.format(dayOfWeek); - assertEquals(text, expected); + assertEquals(expected, text); } - @Test(dataProvider="print_standalone") + @ParameterizedTest + @MethodSource("provider_StandaloneNames") public void test_standaloneNames(Locale locale, TemporalField field, TextStyle style, String expected) { getFormatter(field, style).withLocale(locale).formatTo(LocalDate.of(2013, 1, 1), buf); - assertEquals(buf.toString(), expected); + assertEquals(expected, buf.toString()); } //----------------------------------------------------------------------- + @Test public void test_print_french_long() throws Exception { getFormatter(MONTH_OF_YEAR, TextStyle.FULL).withLocale(Locale.FRENCH).formatTo(LocalDate.of(2012, 1, 1), buf); - assertEquals(buf.toString(), "janvier"); + assertEquals("janvier", buf.toString()); } + @Test public void test_print_french_short() throws Exception { getFormatter(MONTH_OF_YEAR, TextStyle.SHORT).withLocale(Locale.FRENCH).formatTo(LocalDate.of(2012, 1, 1), buf); - assertEquals(buf.toString(), "janv."); + assertEquals("janv.", buf.toString()); } - @DataProvider(name="print_JapaneseChronology") Object[][] provider_japaneseEra() { return new Object[][] { {ERA, TextStyle.FULL, 2, "Heisei"}, // Note: CLDR doesn't define "wide" Japanese era names. @@ -154,10 +159,11 @@ public class TestTextPrinterWithLocale extends AbstractTestPrinterParser { }; }; - @Test(dataProvider="print_JapaneseChronology") + @ParameterizedTest + @MethodSource("provider_japaneseEra") public void test_formatJapaneseEra(TemporalField field, TextStyle style, int value, String expected) throws Exception { LocalDate ld = LocalDate.of(2013, 1, 31); getFormatter(field, style).withChronology(JapaneseChronology.INSTANCE).formatTo(ld, buf); - assertEquals(buf.toString(), expected); + assertEquals(expected, buf.toString()); } } diff --git a/test/jdk/java/time/test/java/time/format/TestUTCParse.java b/test/jdk/java/time/test/java/time/format/TestUTCParse.java index 2c41af68281..551f660e368 100644 --- a/test/jdk/java/time/test/java/time/format/TestUTCParse.java +++ b/test/jdk/java/time/test/java/time/format/TestUTCParse.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2023, 2024, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2023, 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 @@ -33,13 +33,14 @@ import java.time.format.DateTimeFormatterBuilder; import java.time.format.TextStyle; import java.time.temporal.TemporalQueries; -import org.testng.annotations.DataProvider; -import org.testng.annotations.Test; -import static org.testng.Assert.assertEquals; +import static org.junit.jupiter.api.Assertions.assertEquals; +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 TestUTCParse { - @DataProvider public Object[][] utcZoneIdStrings() { return new Object[][] { {"UTC"}, @@ -48,12 +49,13 @@ public class TestUTCParse { }; } - @Test(dataProvider = "utcZoneIdStrings") + @ParameterizedTest + @MethodSource("utcZoneIdStrings") public void testUTCOffsetRoundTrip(String zidString) { var fmt = new DateTimeFormatterBuilder() .appendZoneText(TextStyle.NARROW) .toFormatter(); var zid = ZoneId.of(zidString); - assertEquals(fmt.parse(zidString).query(TemporalQueries.zoneId()), zid); + assertEquals(zid, fmt.parse(zidString).query(TemporalQueries.zoneId())); } } diff --git a/test/jdk/java/time/test/java/time/format/TestUnicodeExtension.java b/test/jdk/java/time/test/java/time/format/TestUnicodeExtension.java index 6b99fea5c7c..80460fad007 100644 --- a/test/jdk/java/time/test/java/time/format/TestUnicodeExtension.java +++ b/test/jdk/java/time/test/java/time/format/TestUnicodeExtension.java @@ -31,7 +31,7 @@ */ package test.java.time.format; -import static org.testng.Assert.assertEquals; +import static org.junit.jupiter.api.Assertions.assertEquals; import java.time.DayOfWeek; import java.time.ZonedDateTime; @@ -50,15 +50,16 @@ import java.util.Locale; import java.util.TimeZone; import java.util.stream.Stream; -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.api.TestInstance; +import org.junit.jupiter.params.ParameterizedTest; +import org.junit.jupiter.params.provider.MethodSource; /** * Test JavaTime with BCP47 U extensions */ -@Test +@TestInstance(TestInstance.Lifecycle.PER_CLASS) public class TestUnicodeExtension { private static TimeZone defaultTZ; @@ -87,18 +88,17 @@ public class TestUnicodeExtension { private static final String PATTERN = "GGGG MMMM-dd-uu HH:mm:ss zzzz"; - @BeforeTest + @BeforeAll public void beforeTest() { defaultTZ = TimeZone.getDefault(); TimeZone.setDefault(TimeZone.getTimeZone(AMLA)); } - @AfterTest + @AfterAll public void afterTest() { TimeZone.setDefault(defaultTZ); } - @DataProvider(name="localizedBy") Object[][] localizedBy() { return new Object[][] { // Locale, Chrono override, Zone override, Expected Chrono, Expected Zone, @@ -188,7 +188,6 @@ public class TestUnicodeExtension { }; } - @DataProvider(name="withLocale") Object[][] withLocale() { return new Object[][] { // Locale, Chrono override, Zone override, Expected Chrono, Expected Zone, @@ -277,7 +276,6 @@ public class TestUnicodeExtension { }; } - @DataProvider(name="firstDayOfWeek") Object[][] firstDayOfWeek () { return new Object[][] { // Locale, Expected DayOfWeek, @@ -304,7 +302,6 @@ public class TestUnicodeExtension { }; } - @DataProvider(name="minDaysInFirstWeek") Object[][] minDaysInFrstWeek () { return new Object[][] { // Locale, Expected minDay, @@ -316,7 +313,6 @@ public class TestUnicodeExtension { }; } - @DataProvider(name="ofPattern") Object[][] ofPattern() { return new Object[][] { // Locale, Expected Chrono, Expected Zone, @@ -342,7 +338,6 @@ public class TestUnicodeExtension { }; } - @DataProvider(name="shortTZID") Object[][] shortTZID() { return new Object[][] { // LDML's short ID, Expected Zone, @@ -817,7 +812,6 @@ public class TestUnicodeExtension { }; } - @DataProvider(name="getLocalizedDateTimePattern") Object[][] getLocalizedDateTimePattern() { return new Object[][] { // Locale, Expected pattern, @@ -832,7 +826,6 @@ public class TestUnicodeExtension { }; } - @DataProvider(name="getDisplayName") Object[][] getDisplayName() { return new Object[][] { // Locale, field, Expected name, @@ -841,7 +834,8 @@ public class TestUnicodeExtension { }; } - @Test(dataProvider="localizedBy") + @ParameterizedTest + @MethodSource("localizedBy") public void test_localizedBy(Locale locale, Chronology chrono, ZoneId zone, Chronology chronoExpected, ZoneId zoneExpected, String formatExpected) { @@ -855,91 +849,94 @@ public class TestUnicodeExtension { DateTimeFormatter dtf = DateTimeFormatter.ofLocalizedDateTime(FormatStyle.FULL, FormatStyle.FULL) .withChronology(chrono).withZone(zone).localizedBy(locale); - assertEquals(dtf.getChronology(), chronoExpected); - assertEquals(dtf.getZone(), zoneExpected); + assertEquals(chronoExpected, dtf.getChronology()); + assertEquals(zoneExpected, dtf.getZone()); String formatted = dtf.format(ZDT); - assertEquals(formatted, formatExpected); - assertEquals(dtf.parse(formatted, ZonedDateTime::from), - zoneExpected != null ? ZDT.withZoneSameInstant(zoneExpected) : ZDT); + assertEquals(formatExpected, formatted); + assertEquals(zoneExpected != null ? ZDT.withZoneSameInstant(zoneExpected) : ZDT, dtf.parse(formatted, ZonedDateTime::from)); }); } finally { Locale.setDefault(def); } } - @Test(dataProvider="withLocale") + @ParameterizedTest + @MethodSource("withLocale") public void test_withLocale(Locale locale, Chronology chrono, ZoneId zone, Chronology chronoExpected, ZoneId zoneExpected, String formatExpected) { DateTimeFormatter dtf = DateTimeFormatter.ofLocalizedDateTime(FormatStyle.FULL, FormatStyle.FULL) .withChronology(chrono).withZone(zone).withLocale(locale); - assertEquals(dtf.getChronology(), chronoExpected); - assertEquals(dtf.getZone(), zoneExpected); + assertEquals(chronoExpected, dtf.getChronology()); + assertEquals(zoneExpected, dtf.getZone()); String formatted = dtf.format(ZDT); - assertEquals(formatted, formatExpected); - assertEquals(dtf.parse(formatted, ZonedDateTime::from), - zoneExpected != null ? ZDT.withZoneSameInstant(zoneExpected) : ZDT); + assertEquals(formatExpected, formatted); + assertEquals(zoneExpected != null ? ZDT.withZoneSameInstant(zoneExpected) : ZDT, dtf.parse(formatted, ZonedDateTime::from)); } - @Test(dataProvider="firstDayOfWeek") + @ParameterizedTest + @MethodSource("firstDayOfWeek") public void test_firstDayOfWeek(Locale locale, DayOfWeek dowExpected) { DayOfWeek dow = WeekFields.of(locale).getFirstDayOfWeek(); - assertEquals(dow, dowExpected); + assertEquals(dowExpected, dow); } - @Test(dataProvider="minDaysInFirstWeek") + @ParameterizedTest + @MethodSource("minDaysInFrstWeek") public void test_minDaysInFirstWeek(Locale locale, int minDaysExpected) { int minDays = WeekFields.of(locale).getMinimalDaysInFirstWeek(); - assertEquals(minDays, minDaysExpected); + assertEquals(minDaysExpected, minDays); } - @Test(dataProvider="ofPattern") + @ParameterizedTest + @MethodSource("ofPattern") public void test_ofPattern(Locale locale, Chronology chronoExpected, ZoneId zoneExpected, String formatExpected) { DateTimeFormatter dtf = DateTimeFormatter.ofPattern(PATTERN, locale); - assertEquals(dtf.getChronology(), chronoExpected); - assertEquals(dtf.getZone(), zoneExpected); + assertEquals(chronoExpected, dtf.getChronology()); + assertEquals(zoneExpected, dtf.getZone()); String formatted = dtf.format(ZDT); - assertEquals(formatted, formatExpected); - assertEquals(dtf.parse(formatted, ZonedDateTime::from), - zoneExpected != null ? ZDT.withZoneSameInstant(zoneExpected) : ZDT); + assertEquals(formatExpected, formatted); + assertEquals(zoneExpected != null ? ZDT.withZoneSameInstant(zoneExpected) : ZDT, dtf.parse(formatted, ZonedDateTime::from)); } - @Test(dataProvider="ofPattern") + @ParameterizedTest + @MethodSource("ofPattern") public void test_toFormatter(Locale locale, Chronology chronoExpected, ZoneId zoneExpected, String formatExpected) { DateTimeFormatter dtf = new DateTimeFormatterBuilder().appendPattern(PATTERN).toFormatter(locale); - assertEquals(dtf.getChronology(), chronoExpected); - assertEquals(dtf.getZone(), zoneExpected); + assertEquals(chronoExpected, dtf.getChronology()); + assertEquals(zoneExpected, dtf.getZone()); String formatted = dtf.format(ZDT); - assertEquals(formatted, formatExpected); - assertEquals(dtf.parse(formatted, ZonedDateTime::from), - zoneExpected != null ? ZDT.withZoneSameInstant(zoneExpected) : ZDT); + assertEquals(formatExpected, formatted); + assertEquals(zoneExpected != null ? ZDT.withZoneSameInstant(zoneExpected) : ZDT, dtf.parse(formatted, ZonedDateTime::from)); } - @Test(dataProvider="shortTZID") + @ParameterizedTest + @MethodSource("shortTZID") public void test_shortTZID(String shortID, String expectedZone) { Locale l = Locale.forLanguageTag("en-US-u-tz-" + shortID); DateTimeFormatter dtf = DateTimeFormatter.ofLocalizedDateTime(FormatStyle.FULL, FormatStyle.FULL) .localizedBy(l); - assertEquals(dtf.getZone(), ZoneId.of(expectedZone)); + assertEquals(ZoneId.of(expectedZone), dtf.getZone()); } - @Test(dataProvider="getLocalizedDateTimePattern") + @ParameterizedTest + @MethodSource("getLocalizedDateTimePattern") public void test_getLocalizedDateTimePattern(Locale l, FormatStyle s, String expectedPattern) { DateTimeFormatterBuilder dtfb = new DateTimeFormatterBuilder(); - assertEquals(dtfb.getLocalizedDateTimePattern(s, s, IsoChronology.INSTANCE, l), - expectedPattern); + assertEquals(expectedPattern, dtfb.getLocalizedDateTimePattern(s, s, IsoChronology.INSTANCE, l)); } - @Test(dataProvider="getDisplayName") + @ParameterizedTest + @MethodSource("getDisplayName") public void test_getDisplayName(Locale l, TemporalField f, String expectedName) { - assertEquals(f.getDisplayName(l), expectedName); + assertEquals(expectedName, f.getDisplayName(l)); } } diff --git a/test/jdk/java/time/test/java/time/format/TestZoneOffsetParser.java b/test/jdk/java/time/test/java/time/format/TestZoneOffsetParser.java index 32425549834..b5807e3cb2d 100644 --- a/test/jdk/java/time/test/java/time/format/TestZoneOffsetParser.java +++ b/test/jdk/java/time/test/java/time/format/TestZoneOffsetParser.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2012, 2016, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2012, 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 @@ -60,24 +60,26 @@ package test.java.time.format; import static java.time.temporal.ChronoField.OFFSET_SECONDS; -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 java.text.ParsePosition; import java.time.ZoneOffset; import java.time.temporal.TemporalAccessor; -import org.testng.annotations.DataProvider; -import org.testng.annotations.Test; +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 ZoneOffsetPrinterParser. */ -@Test +@TestInstance(TestInstance.Lifecycle.PER_CLASS) public class TestZoneOffsetParser extends AbstractTestPrinterParser { //----------------------------------------------------------------------- - @DataProvider(name="error") Object[][] data_error() { return new Object[][] { {"+HH:MM:ss", "Z", "hello", -1, IndexOutOfBoundsException.class}, @@ -85,7 +87,8 @@ public class TestZoneOffsetParser extends AbstractTestPrinterParser { }; } - @Test(dataProvider="error") + @ParameterizedTest + @MethodSource("data_error") public void test_parse_error(String pattern, String noOffsetText, String text, int pos, Class expected) { try { getFormatter(pattern, noOffsetText).parseUnresolved(text, new ParsePosition(pos)); @@ -95,65 +98,72 @@ public class TestZoneOffsetParser extends AbstractTestPrinterParser { } //----------------------------------------------------------------------- + @Test public void test_parse_exactMatch_UTC() throws Exception { ParsePosition pos = new ParsePosition(0); TemporalAccessor parsed = getFormatter("+HH:MM:ss", "Z").parseUnresolved("Z", pos); - assertEquals(pos.getIndex(), 1); + assertEquals(1, pos.getIndex()); assertParsed(parsed, ZoneOffset.UTC); } + @Test public void test_parse_startStringMatch_UTC() throws Exception { ParsePosition pos = new ParsePosition(0); TemporalAccessor parsed = getFormatter("+HH:MM:ss", "Z").parseUnresolved("ZOTHER", pos); - assertEquals(pos.getIndex(), 1); + assertEquals(1, pos.getIndex()); assertParsed(parsed, ZoneOffset.UTC); } + @Test public void test_parse_midStringMatch_UTC() throws Exception { ParsePosition pos = new ParsePosition(5); TemporalAccessor parsed = getFormatter("+HH:MM:ss", "Z").parseUnresolved("OTHERZOTHER", pos); - assertEquals(pos.getIndex(), 6); + assertEquals(6, pos.getIndex()); assertParsed(parsed, ZoneOffset.UTC); } + @Test public void test_parse_endStringMatch_UTC() throws Exception { ParsePosition pos = new ParsePosition(5); TemporalAccessor parsed = getFormatter("+HH:MM:ss", "Z").parseUnresolved("OTHERZ", pos); - assertEquals(pos.getIndex(), 6); + assertEquals(6, pos.getIndex()); assertParsed(parsed, ZoneOffset.UTC); } //----------------------------------------------------------------------- + @Test public void test_parse_exactMatch_UTC_EmptyUTC() throws Exception { ParsePosition pos = new ParsePosition(0); TemporalAccessor parsed = getFormatter("+HH:MM:ss", "").parseUnresolved("", pos); - assertEquals(pos.getIndex(), 0); + assertEquals(0, pos.getIndex()); assertParsed(parsed, ZoneOffset.UTC); } + @Test public void test_parse_startStringMatch_UTC_EmptyUTC() throws Exception { ParsePosition pos = new ParsePosition(0); TemporalAccessor parsed = getFormatter("+HH:MM:ss", "").parseUnresolved("OTHER", pos); - assertEquals(pos.getIndex(), 0); + assertEquals(0, pos.getIndex()); assertParsed(parsed, ZoneOffset.UTC); } + @Test public void test_parse_midStringMatch_UTC_EmptyUTC() throws Exception { ParsePosition pos = new ParsePosition(5); TemporalAccessor parsed = getFormatter("+HH:MM:ss", "").parseUnresolved("OTHEROTHER", pos); - assertEquals(pos.getIndex(), 5); + assertEquals(5, pos.getIndex()); assertParsed(parsed, ZoneOffset.UTC); } + @Test public void test_parse_endStringMatch_UTC_EmptyUTC() throws Exception { ParsePosition pos = new ParsePosition(5); TemporalAccessor parsed = getFormatter("+HH:MM:ss", "").parseUnresolved("OTHER", pos); - assertEquals(pos.getIndex(), 5); + assertEquals(5, pos.getIndex()); assertParsed(parsed, ZoneOffset.UTC); } //----------------------------------------------------------------------- - @DataProvider(name="offsets") Object[][] provider_offsets() { return new Object[][] { {"+HH", "+00", ZoneOffset.UTC}, @@ -228,72 +238,79 @@ public class TestZoneOffsetParser extends AbstractTestPrinterParser { }; } - @Test(dataProvider="offsets") + @ParameterizedTest + @MethodSource("provider_offsets") public void test_parse_exactMatch(String pattern, String parse, ZoneOffset expected) throws Exception { ParsePosition pos = new ParsePosition(0); TemporalAccessor parsed = getFormatter(pattern, "Z").parseUnresolved(parse, pos); - assertEquals(pos.getIndex(), parse.length()); + assertEquals(parse.length(), pos.getIndex()); assertParsed(parsed, expected); } - @Test(dataProvider="offsets") + @ParameterizedTest + @MethodSource("provider_offsets") public void test_parse_startStringMatch(String pattern, String parse, ZoneOffset expected) throws Exception { ParsePosition pos = new ParsePosition(0); TemporalAccessor parsed = getFormatter(pattern, "Z").parseUnresolved(parse + ":OTHER", pos); - assertEquals(pos.getIndex(), parse.length()); + assertEquals(parse.length(), pos.getIndex()); assertParsed(parsed, expected); } - @Test(dataProvider="offsets") + @ParameterizedTest + @MethodSource("provider_offsets") public void test_parse_midStringMatch(String pattern, String parse, ZoneOffset expected) throws Exception { ParsePosition pos = new ParsePosition(5); TemporalAccessor parsed = getFormatter(pattern, "Z").parseUnresolved("OTHER" + parse + ":OTHER", pos); - assertEquals(pos.getIndex(), parse.length() + 5); + assertEquals(parse.length() + 5, pos.getIndex()); assertParsed(parsed, expected); } - @Test(dataProvider="offsets") + @ParameterizedTest + @MethodSource("provider_offsets") public void test_parse_endStringMatch(String pattern, String parse, ZoneOffset expected) throws Exception { ParsePosition pos = new ParsePosition(5); TemporalAccessor parsed = getFormatter(pattern, "Z").parseUnresolved("OTHER" + parse, pos); - assertEquals(pos.getIndex(), parse.length() + 5); + assertEquals(parse.length() + 5, pos.getIndex()); assertParsed(parsed, expected); } - @Test(dataProvider="offsets") + @ParameterizedTest + @MethodSource("provider_offsets") public void test_parse_exactMatch_EmptyUTC(String pattern, String parse, ZoneOffset expected) throws Exception { ParsePosition pos = new ParsePosition(0); TemporalAccessor parsed = getFormatter(pattern, "").parseUnresolved(parse, pos); - assertEquals(pos.getIndex(), parse.length()); + assertEquals(parse.length(), pos.getIndex()); assertParsed(parsed, expected); } - @Test(dataProvider="offsets") + @ParameterizedTest + @MethodSource("provider_offsets") public void test_parse_startStringMatch_EmptyUTC(String pattern, String parse, ZoneOffset expected) throws Exception { ParsePosition pos = new ParsePosition(0); TemporalAccessor parsed = getFormatter(pattern, "").parseUnresolved(parse + ":OTHER", pos); - assertEquals(pos.getIndex(), parse.length()); + assertEquals(parse.length(), pos.getIndex()); assertParsed(parsed, expected); } - @Test(dataProvider="offsets") + @ParameterizedTest + @MethodSource("provider_offsets") public void test_parse_midStringMatch_EmptyUTC(String pattern, String parse, ZoneOffset expected) throws Exception { ParsePosition pos = new ParsePosition(5); TemporalAccessor parsed = getFormatter(pattern, "").parseUnresolved("OTHER" + parse + ":OTHER", pos); - assertEquals(pos.getIndex(), parse.length() + 5); + assertEquals(parse.length() + 5, pos.getIndex()); assertParsed(parsed, expected); } - @Test(dataProvider="offsets") + @ParameterizedTest + @MethodSource("provider_offsets") public void test_parse_endStringMatch_EmptyUTC(String pattern, String parse, ZoneOffset expected) throws Exception { ParsePosition pos = new ParsePosition(5); TemporalAccessor parsed = getFormatter(pattern, "").parseUnresolved("OTHER" + parse, pos); - assertEquals(pos.getIndex(), parse.length() + 5); + assertEquals(parse.length() + 5, pos.getIndex()); assertParsed(parsed, expected); } //----------------------------------------------------------------------- - @DataProvider(name="bigOffsets") Object[][] provider_bigOffsets() { return new Object[][] { {"+HH", "+19", 19 * 3600}, @@ -319,16 +336,16 @@ public class TestZoneOffsetParser extends AbstractTestPrinterParser { }; } - @Test(dataProvider="bigOffsets") + @ParameterizedTest + @MethodSource("provider_bigOffsets") public void test_parse_bigOffsets(String pattern, String parse, long offsetSecs) throws Exception { ParsePosition pos = new ParsePosition(0); TemporalAccessor parsed = getFormatter(pattern, "").parseUnresolved(parse, pos); - assertEquals(pos.getIndex(), parse.length()); - assertEquals(parsed.getLong(OFFSET_SECONDS), offsetSecs); + assertEquals(parse.length(), pos.getIndex()); + assertEquals(offsetSecs, parsed.getLong(OFFSET_SECONDS)); } //----------------------------------------------------------------------- - @DataProvider(name="badOffsets") Object[][] provider_badOffsets() { return new Object[][] { {"+HH", "+1", 0}, @@ -390,55 +407,60 @@ public class TestZoneOffsetParser extends AbstractTestPrinterParser { }; } - @Test(dataProvider="badOffsets") + @ParameterizedTest + @MethodSource("provider_badOffsets") public void test_parse_invalid(String pattern, String parse, int expectedPosition) throws Exception { ParsePosition pos = new ParsePosition(0); TemporalAccessor parsed = getFormatter(pattern, "Z").parseUnresolved(parse, pos); - assertEquals(pos.getErrorIndex(), expectedPosition); - assertEquals(parsed, null); + assertEquals(expectedPosition, pos.getErrorIndex()); + assertEquals(null, parsed); } //----------------------------------------------------------------------- //----------------------------------------------------------------------- //----------------------------------------------------------------------- + @Test public void test_parse_caseSensitiveUTC_matchedCase() throws Exception { setCaseSensitive(true); ParsePosition pos = new ParsePosition(0); TemporalAccessor parsed = getFormatter("+HH:MM:ss", "Z").parseUnresolved("Z", pos); - assertEquals(pos.getIndex(), 1); + assertEquals(1, pos.getIndex()); assertParsed(parsed, ZoneOffset.UTC); } + @Test public void test_parse_caseSensitiveUTC_unmatchedCase() throws Exception { setCaseSensitive(true); ParsePosition pos = new ParsePosition(0); TemporalAccessor parsed = getFormatter("+HH:MM:ss", "Z").parseUnresolved("z", pos); - assertEquals(pos.getErrorIndex(), 0); - assertEquals(parsed, null); + assertEquals(0, pos.getErrorIndex()); + assertEquals(null, parsed); } + @Test public void test_parse_caseInsensitiveUTC_matchedCase() throws Exception { setCaseSensitive(false); ParsePosition pos = new ParsePosition(0); TemporalAccessor parsed = getFormatter("+HH:MM:ss", "Z").parseUnresolved("Z", pos); - assertEquals(pos.getIndex(), 1); + assertEquals(1, pos.getIndex()); assertParsed(parsed, ZoneOffset.UTC); } + @Test public void test_parse_caseInsensitiveUTC_unmatchedCase() throws Exception { setCaseSensitive(false); ParsePosition pos = new ParsePosition(0); TemporalAccessor parsed = getFormatter("+HH:MM:ss", "Z").parseUnresolved("z", pos); - assertEquals(pos.getIndex(), 1); + assertEquals(1, pos.getIndex()); assertParsed(parsed, ZoneOffset.UTC); } private void assertParsed(TemporalAccessor parsed, ZoneOffset expectedOffset) { if (expectedOffset == null) { - assertEquals(parsed, null); + assertEquals(null, parsed); } else { - assertEquals(parsed.isSupported(OFFSET_SECONDS), true); - assertEquals(parsed.getLong(OFFSET_SECONDS), (long) expectedOffset.getTotalSeconds()); + assertEquals(true, parsed.isSupported(OFFSET_SECONDS)); + assertEquals((long) expectedOffset.getTotalSeconds(), parsed.getLong(OFFSET_SECONDS)); } } diff --git a/test/jdk/java/time/test/java/time/format/TestZoneOffsetPrinter.java b/test/jdk/java/time/test/java/time/format/TestZoneOffsetPrinter.java index 4e1b7a402c7..12d54d12200 100644 --- a/test/jdk/java/time/test/java/time/format/TestZoneOffsetPrinter.java +++ b/test/jdk/java/time/test/java/time/format/TestZoneOffsetPrinter.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2012, 2013, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2012, 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 @@ -59,24 +59,26 @@ */ package test.java.time.format; -import static org.testng.Assert.assertEquals; +import static org.junit.jupiter.api.Assertions.assertEquals; import java.time.DateTimeException; import java.time.ZoneOffset; -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.api.TestInstance; +import org.junit.jupiter.params.ParameterizedTest; +import org.junit.jupiter.params.provider.MethodSource; /** * Test ZoneOffsetPrinterParser. */ -@Test +@TestInstance(TestInstance.Lifecycle.PER_CLASS) public class TestZoneOffsetPrinter extends AbstractTestPrinterParser { private static final ZoneOffset OFFSET_0130 = ZoneOffset.of("+01:30"); //----------------------------------------------------------------------- - @DataProvider(name="offsets") Object[][] provider_offsets() { return new Object[][] { {"+HH", "NO-OFFSET", ZoneOffset.UTC}, @@ -147,27 +149,30 @@ public class TestZoneOffsetPrinter extends AbstractTestPrinterParser { }; } - @Test(dataProvider="offsets") + @ParameterizedTest + @MethodSource("provider_offsets") public void test_format(String pattern, String expected, ZoneOffset offset) throws Exception { buf.append("EXISTING"); getFormatter(pattern, "NO-OFFSET").formatTo(offset, buf); - assertEquals(buf.toString(), "EXISTING" + expected); + assertEquals("EXISTING" + expected, buf.toString()); } - @Test(dataProvider="offsets") + @ParameterizedTest + @MethodSource("provider_offsets") public void test_toString(String pattern, String expected, ZoneOffset offset) throws Exception { - assertEquals(getFormatter(pattern, "NO-OFFSET").toString(), "Offset(" + pattern + ",'NO-OFFSET')"); + assertEquals("Offset(" + pattern + ",'NO-OFFSET')", getFormatter(pattern, "NO-OFFSET").toString()); } //----------------------------------------------------------------------- - @Test(expectedExceptions=DateTimeException.class) + @Test public void test_print_emptyCalendrical() throws Exception { - getFormatter("+HH:MM:ss", "Z").formatTo(EMPTY_DTA, buf); + Assertions.assertThrows(DateTimeException.class, () -> getFormatter("+HH:MM:ss", "Z").formatTo(EMPTY_DTA, buf)); } + @Test public void test_print_emptyAppendable() throws Exception { getFormatter("+HH:MM:ss", "Z").formatTo(OFFSET_0130, buf); - assertEquals(buf.toString(), "+01:30"); + assertEquals("+01:30", buf.toString()); } } diff --git a/test/jdk/java/time/test/java/time/format/TestZoneTextPrinterParser.java b/test/jdk/java/time/test/java/time/format/TestZoneTextPrinterParser.java index 20861f151e0..abe3cd6b154 100644 --- a/test/jdk/java/time/test/java/time/format/TestZoneTextPrinterParser.java +++ b/test/jdk/java/time/test/java/time/format/TestZoneTextPrinterParser.java @@ -23,8 +23,8 @@ package test.java.time.format; -import static org.testng.Assert.assertEquals; -import static org.testng.Assert.fail; +import static org.junit.jupiter.api.Assertions.assertEquals; +import static org.junit.jupiter.api.Assertions.fail; import java.text.DateFormatSymbols; import java.time.ZoneId; @@ -46,8 +46,10 @@ import java.util.Set; import java.util.TimeZone; import jdk.test.lib.RandomFactory; -import org.testng.annotations.DataProvider; -import org.testng.annotations.Test; +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 @@ -59,7 +61,7 @@ import org.testng.annotations.Test; /** * Test ZoneTextPrinterParser */ -@Test +@TestInstance(TestInstance.Lifecycle.PER_CLASS) public class TestZoneTextPrinterParser extends AbstractTestPrinterParser { private static final Locale[] SAMPLE_LOCALES = { @@ -73,6 +75,7 @@ public class TestZoneTextPrinterParser extends AbstractTestPrinterParser { .withDecimalStyle(DecimalStyle.of(locale)); } + @Test public void test_printText() { Random r = RandomFactory.getRandom(); int N = 8; @@ -123,9 +126,10 @@ public class TestZoneTextPrinterParser extends AbstractTestPrinterParser { System.out.printf("[%-5s, %5s] :[%s]%n", locale.toString(), style.toString(),result); System.out.printf(" %5s, %5s :[%s] %s%n", "", "", expected, zone); } - assertEquals(result, expected); + assertEquals(expected, result); } + @Test public void test_ParseText() { Set zids = ZoneRulesProvider.getAvailableZoneIds(); for (Locale locale : SAMPLE_LOCALES) { @@ -153,7 +157,6 @@ public class TestZoneTextPrinterParser extends AbstractTestPrinterParser { private static Set none = new HashSet<>(); - @DataProvider(name="preferredZones") Object[][] data_preferredZones() { return new Object[][] { {"America/New_York", "Eastern Standard Time", none, Locale.ENGLISH, TextStyle.FULL}, @@ -178,7 +181,8 @@ public class TestZoneTextPrinterParser extends AbstractTestPrinterParser { }; } - @Test(dataProvider="preferredZones") + @ParameterizedTest + @MethodSource("data_preferredZones") public void test_ParseText(String expected, String text, Set preferred, Locale locale, TextStyle style) { DateTimeFormatter fmt = new DateTimeFormatterBuilder().appendZoneText(style, preferred) .toFormatter(locale) @@ -191,7 +195,7 @@ public class TestZoneTextPrinterParser extends AbstractTestPrinterParser { style == TextStyle.FULL ? " full" :"short", text, ret, expected); - assertEquals(ret, expected); + assertEquals(expected, ret); } @@ -246,7 +250,6 @@ public class TestZoneTextPrinterParser extends AbstractTestPrinterParser { .withDecimalStyle(DecimalStyle.of(locale)); } - @DataProvider(name="roundTripAtOverlap") Object[][] data_roundTripAtOverlap() { return new Object[][] { {"yyyy-MM-dd HH:mm:ss.SSS z", "2021-10-31 02:30:00.000 CET"}, @@ -265,10 +268,11 @@ public class TestZoneTextPrinterParser extends AbstractTestPrinterParser { }; } - @Test(dataProvider="roundTripAtOverlap") + @ParameterizedTest + @MethodSource("data_roundTripAtOverlap") public void test_roundTripAtOverlap(String pattern, String input) { var dtf = DateTimeFormatter.ofPattern(pattern, Locale.US); - assertEquals(dtf.format(ZonedDateTime.parse(input, dtf)), input); + assertEquals(input, dtf.format(ZonedDateTime.parse(input, dtf))); var lc = input.toLowerCase(Locale.ROOT); try { ZonedDateTime.parse(lc, dtf); @@ -276,7 +280,7 @@ public class TestZoneTextPrinterParser extends AbstractTestPrinterParser { } catch (DateTimeParseException ignore) {} dtf = new DateTimeFormatterBuilder().parseCaseInsensitive().appendPattern(pattern).toFormatter(Locale.US); - assertEquals(dtf.format(ZonedDateTime.parse(input, dtf)), input); - assertEquals(dtf.format(ZonedDateTime.parse(lc, dtf)), input); + assertEquals(input, dtf.format(ZonedDateTime.parse(input, dtf))); + assertEquals(input, dtf.format(ZonedDateTime.parse(lc, dtf))); } } diff --git a/test/jdk/java/time/test/java/time/temporal/TestChronoField.java b/test/jdk/java/time/test/java/time/temporal/TestChronoField.java index a353a6b247b..716f586ff79 100644 --- a/test/jdk/java/time/test/java/time/temporal/TestChronoField.java +++ b/test/jdk/java/time/test/java/time/temporal/TestChronoField.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2013, 2016, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2013, 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 @@ -54,8 +54,7 @@ */ package test.java.time.temporal; -import static org.testng.Assert.assertEquals; -import static org.testng.Assert.fail; +import static org.junit.jupiter.api.Assertions.assertEquals; import java.time.temporal.ChronoField; import java.time.temporal.IsoFields; @@ -64,18 +63,18 @@ import java.time.temporal.WeekFields; import java.util.HashMap; import java.util.Locale; import java.util.Map; -import java.util.ResourceBundle; -import org.testng.annotations.BeforeClass; -import org.testng.annotations.DataProvider; -import org.testng.annotations.Test; +import org.junit.jupiter.api.Assertions; +import org.junit.jupiter.api.BeforeAll; +import org.junit.jupiter.api.Test; +import org.junit.jupiter.api.TestInstance; -@Test +@TestInstance(TestInstance.Lifecycle.PER_CLASS) public class TestChronoField { Map fieldMap; - @BeforeClass + @BeforeAll public void initClass() { fieldMap = new HashMap<>(); fieldMap.put(ChronoField.ERA, "era"); @@ -91,7 +90,6 @@ public class TestChronoField { fieldMap.put(ChronoField.OFFSET_SECONDS, "zone"); } - @DataProvider(name = "localeList") Locale[] data_localeList() { return new Locale[] { Locale.US, @@ -101,7 +99,6 @@ public class TestChronoField { }; } //----------------------------------------------------------------------- - @DataProvider(name = "localeDisplayNames") Object[][] data_localeDisplayNames() { return new Object[][] { {ChronoField.ERA}, @@ -121,12 +118,14 @@ public class TestChronoField { public void test_IsoFields_week_based_year() { Locale locale = Locale.US; String name = IsoFields.WEEK_OF_WEEK_BASED_YEAR.getDisplayName(locale); - assertEquals(name, "week"); + assertEquals("week", name); } - @Test(expectedExceptions=NullPointerException.class) + @Test public void test_nullIsoFields_week_based_year() { - String name = IsoFields.WEEK_OF_WEEK_BASED_YEAR.getDisplayName((Locale)null); + Assertions.assertThrows(NullPointerException.class, () -> { + String name = IsoFields.WEEK_OF_WEEK_BASED_YEAR.getDisplayName((Locale)null); + }); } @Test @@ -134,24 +133,28 @@ public class TestChronoField { Locale locale = Locale.US; TemporalField weekOfYearField = WeekFields.SUNDAY_START.weekOfYear(); String name = weekOfYearField.getDisplayName(locale); - assertEquals(name, "week"); + assertEquals("week", name); } - @Test(expectedExceptions=NullPointerException.class) + @Test public void test_nullWeekFields_week_based_year() { - TemporalField weekOfYearField = WeekFields.SUNDAY_START.weekOfYear(); - String name = weekOfYearField.getDisplayName((Locale)null); + Assertions.assertThrows(NullPointerException.class, () -> { + TemporalField weekOfYearField = WeekFields.SUNDAY_START.weekOfYear(); + String name = weekOfYearField.getDisplayName((Locale)null); + }); } - @Test(expectedExceptions=NullPointerException.class) + @Test public void test_nullLocaleChronoFieldDisplayName() { - ChronoField.YEAR.getDisplayName((Locale)null); + Assertions.assertThrows(NullPointerException.class, () -> ChronoField.YEAR.getDisplayName((Locale)null)); } - @Test(expectedExceptions=NullPointerException.class) + @Test public void test_nullLocaleTemporalFieldDisplayName() { - // Test the default method in TemporalField using the - // IsoFields.DAY_OF_QUARTER which does not override getDisplayName - IsoFields.DAY_OF_QUARTER.getDisplayName((Locale)null); + Assertions.assertThrows(NullPointerException.class, () -> { + // Test the default method in TemporalField using the + // IsoFields.DAY_OF_QUARTER which does not override getDisplayName + IsoFields.DAY_OF_QUARTER.getDisplayName((Locale)null); + }); } } diff --git a/test/jdk/java/time/test/java/time/temporal/TestChronoUnit.java b/test/jdk/java/time/test/java/time/temporal/TestChronoUnit.java index 95e5f6503ed..11ebcfd13bd 100644 --- a/test/jdk/java/time/test/java/time/temporal/TestChronoUnit.java +++ b/test/jdk/java/time/test/java/time/temporal/TestChronoUnit.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2012, 2013, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2012, 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 @@ -65,23 +65,24 @@ import static java.time.temporal.ChronoUnit.DAYS; import static java.time.temporal.ChronoUnit.MONTHS; import static java.time.temporal.ChronoUnit.WEEKS; import static java.time.temporal.ChronoUnit.YEARS; -import static org.testng.Assert.assertEquals; + +import static org.junit.jupiter.api.Assertions.assertEquals; import java.time.LocalDate; import java.time.Month; import java.time.ZoneOffset; -import org.testng.annotations.DataProvider; -import org.testng.annotations.Test; +import org.junit.jupiter.api.TestInstance; +import org.junit.jupiter.params.ParameterizedTest; +import org.junit.jupiter.params.provider.MethodSource; /** * Test. */ -@Test +@TestInstance(TestInstance.Lifecycle.PER_CLASS) public class TestChronoUnit { //----------------------------------------------------------------------- - @DataProvider(name = "yearsBetween") Object[][] data_yearsBetween() { return new Object[][] { {date(1939, SEPTEMBER, 2), date(1939, SEPTEMBER, 1), 0}, @@ -102,47 +103,52 @@ public class TestChronoUnit { }; } - @Test(dataProvider = "yearsBetween") + @ParameterizedTest + @MethodSource("data_yearsBetween") public void test_yearsBetween(LocalDate start, LocalDate end, long expected) { - assertEquals(YEARS.between(start, end), expected); + assertEquals(expected, YEARS.between(start, end)); } - @Test(dataProvider = "yearsBetween") + @ParameterizedTest + @MethodSource("data_yearsBetween") public void test_yearsBetweenReversed(LocalDate start, LocalDate end, long expected) { - assertEquals(YEARS.between(end, start), -expected); + assertEquals(-expected, YEARS.between(end, start)); } - @Test(dataProvider = "yearsBetween") + @ParameterizedTest + @MethodSource("data_yearsBetween") public void test_yearsBetween_LocalDateTimeSameTime(LocalDate start, LocalDate end, long expected) { - assertEquals(YEARS.between(start.atTime(12, 30), end.atTime(12, 30)), expected); + assertEquals(expected, YEARS.between(start.atTime(12, 30), end.atTime(12, 30))); } - @Test(dataProvider = "yearsBetween") + @ParameterizedTest + @MethodSource("data_yearsBetween") public void test_yearsBetween_LocalDateTimeLaterTime(LocalDate start, LocalDate end, long expected) { if (expected >= 0) { - assertEquals(YEARS.between(start.atTime(12, 30), end.atTime(12, 31)), expected); + assertEquals(expected, YEARS.between(start.atTime(12, 30), end.atTime(12, 31))); } else { - assertEquals(YEARS.between(start.atTime(12, 30), end.atTime(12, 29)), expected); + assertEquals(expected, YEARS.between(start.atTime(12, 30), end.atTime(12, 29))); } } - @Test(dataProvider = "yearsBetween") + @ParameterizedTest + @MethodSource("data_yearsBetween") public void test_yearsBetween_ZonedDateSameOffset(LocalDate start, LocalDate end, long expected) { - assertEquals(YEARS.between(start.atStartOfDay(ZoneOffset.ofHours(2)), end.atStartOfDay(ZoneOffset.ofHours(2))), expected); + assertEquals(expected, YEARS.between(start.atStartOfDay(ZoneOffset.ofHours(2)), end.atStartOfDay(ZoneOffset.ofHours(2)))); } - @Test(dataProvider = "yearsBetween") + @ParameterizedTest + @MethodSource("data_yearsBetween") public void test_yearsBetween_ZonedDateLaterOffset(LocalDate start, LocalDate end, long expected) { // +01:00 is later than +02:00 if (expected >= 0) { - assertEquals(YEARS.between(start.atStartOfDay(ZoneOffset.ofHours(2)), end.atStartOfDay(ZoneOffset.ofHours(1))), expected); + assertEquals(expected, YEARS.between(start.atStartOfDay(ZoneOffset.ofHours(2)), end.atStartOfDay(ZoneOffset.ofHours(1)))); } else { - assertEquals(YEARS.between(start.atStartOfDay(ZoneOffset.ofHours(1)), end.atStartOfDay(ZoneOffset.ofHours(2))), expected); + assertEquals(expected, YEARS.between(start.atStartOfDay(ZoneOffset.ofHours(1)), end.atStartOfDay(ZoneOffset.ofHours(2)))); } } //----------------------------------------------------------------------- - @DataProvider(name = "monthsBetween") Object[][] data_monthsBetween() { return new Object[][] { {date(2012, JULY, 2), date(2012, JULY, 1), 0}, @@ -175,47 +181,52 @@ public class TestChronoUnit { }; } - @Test(dataProvider = "monthsBetween") + @ParameterizedTest + @MethodSource("data_monthsBetween") public void test_monthsBetween(LocalDate start, LocalDate end, long expected) { - assertEquals(MONTHS.between(start, end), expected); + assertEquals(expected, MONTHS.between(start, end)); } - @Test(dataProvider = "monthsBetween") + @ParameterizedTest + @MethodSource("data_monthsBetween") public void test_monthsBetweenReversed(LocalDate start, LocalDate end, long expected) { - assertEquals(MONTHS.between(end, start), -expected); + assertEquals(-expected, MONTHS.between(end, start)); } - @Test(dataProvider = "monthsBetween") + @ParameterizedTest + @MethodSource("data_monthsBetween") public void test_monthsBetween_LocalDateTimeSameTime(LocalDate start, LocalDate end, long expected) { - assertEquals(MONTHS.between(start.atTime(12, 30), end.atTime(12, 30)), expected); + assertEquals(expected, MONTHS.between(start.atTime(12, 30), end.atTime(12, 30))); } - @Test(dataProvider = "monthsBetween") + @ParameterizedTest + @MethodSource("data_monthsBetween") public void test_monthsBetween_LocalDateTimeLaterTime(LocalDate start, LocalDate end, long expected) { if (expected >= 0) { - assertEquals(MONTHS.between(start.atTime(12, 30), end.atTime(12, 31)), expected); + assertEquals(expected, MONTHS.between(start.atTime(12, 30), end.atTime(12, 31))); } else { - assertEquals(MONTHS.between(start.atTime(12, 30), end.atTime(12, 29)), expected); + assertEquals(expected, MONTHS.between(start.atTime(12, 30), end.atTime(12, 29))); } } - @Test(dataProvider = "monthsBetween") + @ParameterizedTest + @MethodSource("data_monthsBetween") public void test_monthsBetween_ZonedDateSameOffset(LocalDate start, LocalDate end, long expected) { - assertEquals(MONTHS.between(start.atStartOfDay(ZoneOffset.ofHours(2)), end.atStartOfDay(ZoneOffset.ofHours(2))), expected); + assertEquals(expected, MONTHS.between(start.atStartOfDay(ZoneOffset.ofHours(2)), end.atStartOfDay(ZoneOffset.ofHours(2)))); } - @Test(dataProvider = "monthsBetween") + @ParameterizedTest + @MethodSource("data_monthsBetween") public void test_monthsBetween_ZonedDateLaterOffset(LocalDate start, LocalDate end, long expected) { // +01:00 is later than +02:00 if (expected >= 0) { - assertEquals(MONTHS.between(start.atStartOfDay(ZoneOffset.ofHours(2)), end.atStartOfDay(ZoneOffset.ofHours(1))), expected); + assertEquals(expected, MONTHS.between(start.atStartOfDay(ZoneOffset.ofHours(2)), end.atStartOfDay(ZoneOffset.ofHours(1)))); } else { - assertEquals(MONTHS.between(start.atStartOfDay(ZoneOffset.ofHours(1)), end.atStartOfDay(ZoneOffset.ofHours(2))), expected); + assertEquals(expected, MONTHS.between(start.atStartOfDay(ZoneOffset.ofHours(1)), end.atStartOfDay(ZoneOffset.ofHours(2)))); } } //----------------------------------------------------------------------- - @DataProvider(name = "weeksBetween") Object[][] data_weeksBetween() { return new Object[][] { {date(2012, JULY, 2), date(2012, JUNE, 25), -1}, @@ -242,18 +253,19 @@ public class TestChronoUnit { }; } - @Test(dataProvider = "weeksBetween") + @ParameterizedTest + @MethodSource("data_weeksBetween") public void test_weeksBetween(LocalDate start, LocalDate end, long expected) { - assertEquals(WEEKS.between(start, end), expected); + assertEquals(expected, WEEKS.between(start, end)); } - @Test(dataProvider = "weeksBetween") + @ParameterizedTest + @MethodSource("data_weeksBetween") public void test_weeksBetweenReversed(LocalDate start, LocalDate end, long expected) { - assertEquals(WEEKS.between(end, start), -expected); + assertEquals(-expected, WEEKS.between(end, start)); } //----------------------------------------------------------------------- - @DataProvider(name = "daysBetween") Object[][] data_daysBetween() { return new Object[][] { {date(2012, JULY, 2), date(2012, JULY, 1), -1}, @@ -285,42 +297,48 @@ public class TestChronoUnit { }; } - @Test(dataProvider = "daysBetween") + @ParameterizedTest + @MethodSource("data_daysBetween") public void test_daysBetween(LocalDate start, LocalDate end, long expected) { - assertEquals(DAYS.between(start, end), expected); + assertEquals(expected, DAYS.between(start, end)); } - @Test(dataProvider = "daysBetween") + @ParameterizedTest + @MethodSource("data_daysBetween") public void test_daysBetweenReversed(LocalDate start, LocalDate end, long expected) { - assertEquals(DAYS.between(end, start), -expected); + assertEquals(-expected, DAYS.between(end, start)); } - @Test(dataProvider = "daysBetween") + @ParameterizedTest + @MethodSource("data_daysBetween") public void test_daysBetween_LocalDateTimeSameTime(LocalDate start, LocalDate end, long expected) { - assertEquals(DAYS.between(start.atTime(12, 30), end.atTime(12, 30)), expected); + assertEquals(expected, DAYS.between(start.atTime(12, 30), end.atTime(12, 30))); } - @Test(dataProvider = "daysBetween") + @ParameterizedTest + @MethodSource("data_daysBetween") public void test_daysBetween_LocalDateTimeLaterTime(LocalDate start, LocalDate end, long expected) { if (expected >= 0) { - assertEquals(DAYS.between(start.atTime(12, 30), end.atTime(12, 31)), expected); + assertEquals(expected, DAYS.between(start.atTime(12, 30), end.atTime(12, 31))); } else { - assertEquals(DAYS.between(start.atTime(12, 30), end.atTime(12, 29)), expected); + assertEquals(expected, DAYS.between(start.atTime(12, 30), end.atTime(12, 29))); } } - @Test(dataProvider = "daysBetween") + @ParameterizedTest + @MethodSource("data_daysBetween") public void test_daysBetween_ZonedDateSameOffset(LocalDate start, LocalDate end, long expected) { - assertEquals(DAYS.between(start.atStartOfDay(ZoneOffset.ofHours(2)), end.atStartOfDay(ZoneOffset.ofHours(2))), expected); + assertEquals(expected, DAYS.between(start.atStartOfDay(ZoneOffset.ofHours(2)), end.atStartOfDay(ZoneOffset.ofHours(2)))); } - @Test(dataProvider = "daysBetween") + @ParameterizedTest + @MethodSource("data_daysBetween") public void test_daysBetween_ZonedDateLaterOffset(LocalDate start, LocalDate end, long expected) { // +01:00 is later than +02:00 if (expected >= 0) { - assertEquals(DAYS.between(start.atStartOfDay(ZoneOffset.ofHours(2)), end.atStartOfDay(ZoneOffset.ofHours(1))), expected); + assertEquals(expected, DAYS.between(start.atStartOfDay(ZoneOffset.ofHours(2)), end.atStartOfDay(ZoneOffset.ofHours(1)))); } else { - assertEquals(DAYS.between(start.atStartOfDay(ZoneOffset.ofHours(1)), end.atStartOfDay(ZoneOffset.ofHours(2))), expected); + assertEquals(expected, DAYS.between(start.atStartOfDay(ZoneOffset.ofHours(1)), end.atStartOfDay(ZoneOffset.ofHours(2)))); } } diff --git a/test/jdk/java/time/test/java/time/temporal/TestDateTimeBuilderCombinations.java b/test/jdk/java/time/test/java/time/temporal/TestDateTimeBuilderCombinations.java index ffa9fc3c342..8a81da27458 100644 --- a/test/jdk/java/time/test/java/time/temporal/TestDateTimeBuilderCombinations.java +++ b/test/jdk/java/time/test/java/time/temporal/TestDateTimeBuilderCombinations.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2012, 2013, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2012, 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 @@ -70,8 +70,9 @@ import static java.time.temporal.ChronoField.EPOCH_DAY; import static java.time.temporal.ChronoField.MONTH_OF_YEAR; import static java.time.temporal.ChronoField.PROLEPTIC_MONTH; import static java.time.temporal.ChronoField.YEAR; -import static org.testng.Assert.assertEquals; -import static org.testng.Assert.fail; + +import static org.junit.jupiter.api.Assertions.assertEquals; +import static org.junit.jupiter.api.Assertions.fail; import java.time.DateTimeException; import java.time.LocalDate; @@ -80,15 +81,16 @@ import java.time.format.DateTimeFormatterBuilder; import java.time.temporal.TemporalAccessor; import java.time.temporal.TemporalField; -import org.testng.annotations.DataProvider; -import org.testng.annotations.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 TestDateTimeBuilderCombinations { - @DataProvider(name = "combine") Object[][] data_combine() { return new Object[][] { {YEAR, 2012, MONTH_OF_YEAR, 6, DAY_OF_MONTH, 3, null, null, LocalDate.class, LocalDate.of(2012, 6, 3)}, @@ -101,7 +103,8 @@ public class TestDateTimeBuilderCombinations { }; } - @Test(dataProvider = "combine") + @ParameterizedTest + @MethodSource("data_combine") public void test_derive(final TemporalField field1, final Number value1, final TemporalField field2, final Number value2, final TemporalField field3, final Number value3, @@ -149,7 +152,7 @@ public class TestDateTimeBuilderCombinations { TemporalAccessor parsed = dtfb.toFormatter().parse(str); if (query == LocalDate.class) { if (expectedVal != null) { - assertEquals(parsed.query(LocalDate::from), expectedVal); + assertEquals(expectedVal, parsed.query(LocalDate::from)); } else { try { parsed.query(LocalDate::from); @@ -164,7 +167,6 @@ public class TestDateTimeBuilderCombinations { } //----------------------------------------------------------------------- - @DataProvider(name = "normalized") Object[][] data_normalized() { return new Object[][] { {YEAR, 2127, YEAR, 2127}, @@ -182,7 +184,8 @@ public class TestDateTimeBuilderCombinations { }; } - @Test(dataProvider = "normalized") + @ParameterizedTest + @MethodSource("data_normalized") public void test_normalized(final TemporalField field1, final Number value1, TemporalField expectedField, Number expectedVal) { // mock for testing that does not fully comply with TemporalAccessor contract TemporalAccessor test = new TemporalAccessor() { @@ -202,9 +205,9 @@ public class TestDateTimeBuilderCombinations { String str = value1.toString(); TemporalAccessor temporal = f.parse(str); if (expectedVal != null) { - assertEquals(temporal.getLong(expectedField), expectedVal.longValue()); + assertEquals(expectedVal.longValue(), temporal.getLong(expectedField)); } else { - assertEquals(temporal.isSupported(expectedField), false); + assertEquals(false, temporal.isSupported(expectedField)); } } diff --git a/test/jdk/java/time/test/java/time/temporal/TestDateTimeValueRange.java b/test/jdk/java/time/test/java/time/temporal/TestDateTimeValueRange.java index 570e6634a8a..e3e2f1758b9 100644 --- a/test/jdk/java/time/test/java/time/temporal/TestDateTimeValueRange.java +++ b/test/jdk/java/time/test/java/time/temporal/TestDateTimeValueRange.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2012, 2020, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2012, 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 @@ -59,7 +59,7 @@ */ package test.java.time.temporal; -import static org.testng.Assert.assertEquals; +import static org.junit.jupiter.api.Assertions.assertEquals; import java.io.ByteArrayInputStream; import java.io.ByteArrayOutputStream; @@ -69,15 +69,19 @@ import java.time.DateTimeException; import java.time.temporal.ChronoField; import java.time.temporal.ValueRange; -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.api.TestInstance; +import org.junit.jupiter.params.ParameterizedTest; +import org.junit.jupiter.params.provider.MethodSource; + import test.java.time.AbstractTest; /** * Test. * @bug 8239520 */ -@Test +@TestInstance(TestInstance.Lifecycle.PER_CLASS) public class TestDateTimeValueRange extends AbstractTest { //----------------------------------------------------------------------- @@ -91,63 +95,65 @@ public class TestDateTimeValueRange extends AbstractTest { //----------------------------------------------------------------------- // of(long,long) //----------------------------------------------------------------------- + @Test public void test_of_longlong() { ValueRange test = ValueRange.of(1, 12); - assertEquals(test.getMinimum(), 1); - assertEquals(test.getLargestMinimum(), 1); - assertEquals(test.getSmallestMaximum(), 12); - assertEquals(test.getMaximum(), 12); - assertEquals(test.isFixed(), true); - assertEquals(test.isIntValue(), true); + assertEquals(1, test.getMinimum()); + assertEquals(1, test.getLargestMinimum()); + assertEquals(12, test.getSmallestMaximum()); + assertEquals(12, test.getMaximum()); + assertEquals(true, test.isFixed()); + assertEquals(true, test.isIntValue()); } + @Test public void test_of_longlong_big() { ValueRange test = ValueRange.of(1, 123456789012345L); - assertEquals(test.getMinimum(), 1); - assertEquals(test.getLargestMinimum(), 1); - assertEquals(test.getSmallestMaximum(), 123456789012345L); - assertEquals(test.getMaximum(), 123456789012345L); - assertEquals(test.isFixed(), true); - assertEquals(test.isIntValue(), false); + assertEquals(1, test.getMinimum()); + assertEquals(1, test.getLargestMinimum()); + assertEquals(123456789012345L, test.getSmallestMaximum()); + assertEquals(123456789012345L, test.getMaximum()); + assertEquals(true, test.isFixed()); + assertEquals(false, test.isIntValue()); } - @Test(expectedExceptions = IllegalArgumentException.class) + @Test public void test_of_longlong_minGtMax() { - ValueRange.of(12, 1); + Assertions.assertThrows(IllegalArgumentException.class, () -> ValueRange.of(12, 1)); } //----------------------------------------------------------------------- // of(long,long,long) //----------------------------------------------------------------------- + @Test public void test_of_longlonglong() { ValueRange test = ValueRange.of(1, 28, 31); - assertEquals(test.getMinimum(), 1); - assertEquals(test.getLargestMinimum(), 1); - assertEquals(test.getSmallestMaximum(), 28); - assertEquals(test.getMaximum(), 31); - assertEquals(test.isFixed(), false); - assertEquals(test.isIntValue(), true); + assertEquals(1, test.getMinimum()); + assertEquals(1, test.getLargestMinimum()); + assertEquals(28, test.getSmallestMaximum()); + assertEquals(31, test.getMaximum()); + assertEquals(false, test.isFixed()); + assertEquals(true, test.isIntValue()); } - @Test(expectedExceptions = IllegalArgumentException.class) + @Test public void test_of_longlonglong_minGtMax() { - ValueRange.of(12, 1, 2); + Assertions.assertThrows(IllegalArgumentException.class, () -> ValueRange.of(12, 1, 2)); } - @Test(expectedExceptions = IllegalArgumentException.class) + @Test public void test_of_longlonglong_smallestmaxminGtMax() { - ValueRange.of(1, 31, 28); + Assertions.assertThrows(IllegalArgumentException.class, () -> ValueRange.of(1, 31, 28)); } - @Test(expectedExceptions = IllegalArgumentException.class) + @Test public void test_of_longlonglong_minGtSmallestMax() { - ValueRange.of(5, 2, 10); + Assertions.assertThrows(IllegalArgumentException.class, () -> ValueRange.of(5, 2, 10)); } //----------------------------------------------------------------------- // of(long,long,long,long) //----------------------------------------------------------------------- - @DataProvider(name="valid") Object[][] data_valid() { return new Object[][] { {1, 1, 1, 1}, @@ -162,18 +168,18 @@ public class TestDateTimeValueRange extends AbstractTest { }; } - @Test(dataProvider="valid") + @ParameterizedTest + @MethodSource("data_valid") public void test_of_longlonglonglong(long sMin, long lMin, long sMax, long lMax) { ValueRange test = ValueRange.of(sMin, lMin, sMax, lMax); - assertEquals(test.getMinimum(), sMin); - assertEquals(test.getLargestMinimum(), lMin); - assertEquals(test.getSmallestMaximum(), sMax); - assertEquals(test.getMaximum(), lMax); - assertEquals(test.isFixed(), sMin == lMin && sMax == lMax); - assertEquals(test.isIntValue(), true); + assertEquals(sMin, test.getMinimum()); + assertEquals(lMin, test.getLargestMinimum()); + assertEquals(sMax, test.getSmallestMaximum()); + assertEquals(lMax, test.getMaximum()); + assertEquals(sMin == lMin && sMax == lMax, test.isFixed()); + assertEquals(true, test.isIntValue()); } - @DataProvider(name="invalid") Object[][] data_invalid() { return new Object[][] { {1, 2, 31, 28}, @@ -192,118 +198,138 @@ public class TestDateTimeValueRange extends AbstractTest { }; } - @Test(dataProvider="invalid", expectedExceptions=IllegalArgumentException.class) + @ParameterizedTest + @MethodSource("data_invalid") public void test_of_longlonglonglong_invalid(long sMin, long lMin, long sMax, long lMax) { - ValueRange.of(sMin, lMin, sMax, lMax); + Assertions.assertThrows(IllegalArgumentException.class, () -> ValueRange.of(sMin, lMin, sMax, lMax)); } //----------------------------------------------------------------------- // isValidValue(long) //----------------------------------------------------------------------- + @Test public void test_isValidValue_long() { ValueRange test = ValueRange.of(1, 28, 31); - assertEquals(test.isValidValue(0), false); - assertEquals(test.isValidValue(1), true); - assertEquals(test.isValidValue(2), true); - assertEquals(test.isValidValue(30), true); - assertEquals(test.isValidValue(31), true); - assertEquals(test.isValidValue(32), false); + assertEquals(false, test.isValidValue(0)); + assertEquals(true, test.isValidValue(1)); + assertEquals(true, test.isValidValue(2)); + assertEquals(true, test.isValidValue(30)); + assertEquals(true, test.isValidValue(31)); + assertEquals(false, test.isValidValue(32)); } //----------------------------------------------------------------------- // isValidIntValue(long) //----------------------------------------------------------------------- + @Test public void test_isValidValue_long_int() { ValueRange test = ValueRange.of(1, 28, 31); - assertEquals(test.isValidValue(0), false); - assertEquals(test.isValidValue(1), true); - assertEquals(test.isValidValue(31), true); - assertEquals(test.isValidValue(32), false); + assertEquals(false, test.isValidValue(0)); + assertEquals(true, test.isValidValue(1)); + assertEquals(true, test.isValidValue(31)); + assertEquals(false, test.isValidValue(32)); } + @Test public void test_isValidValue_long_long() { ValueRange test = ValueRange.of(1, 28, Integer.MAX_VALUE + 1L); - assertEquals(test.isValidIntValue(0), false); - assertEquals(test.isValidIntValue(1), false); - assertEquals(test.isValidIntValue(31), false); - assertEquals(test.isValidIntValue(32), false); + assertEquals(false, test.isValidIntValue(0)); + assertEquals(false, test.isValidIntValue(1)); + assertEquals(false, test.isValidIntValue(31)); + assertEquals(false, test.isValidIntValue(32)); } //----------------------------------------------------------------------- // checkValidValue //----------------------------------------------------------------------- - @Test(dataProvider="valid") + @ParameterizedTest + @MethodSource("data_valid") public void test_of_checkValidValue(long sMin, long lMin, long sMax, long lMax) { ValueRange test = ValueRange.of(sMin, lMin, sMax, lMax); - assertEquals(test.checkValidIntValue(sMin, null), sMin); - assertEquals(test.checkValidIntValue(lMin, null), lMin); - assertEquals(test.checkValidIntValue(sMax, null), sMax); - assertEquals(test.checkValidIntValue(lMax, null), lMax); + assertEquals(sMin, test.checkValidIntValue(sMin, null)); + assertEquals(lMin, test.checkValidIntValue(lMin, null)); + assertEquals(sMax, test.checkValidIntValue(sMax, null)); + assertEquals(lMax, test.checkValidIntValue(lMax, null)); } - @Test(dataProvider="valid", expectedExceptions = DateTimeException.class) + @ParameterizedTest + @MethodSource("data_valid") public void test_of_checkValidValueMinException(long sMin, long lMin, long sMax, long lMax) { - ValueRange test = ValueRange.of(sMin, lMin, sMax, lMax); - test.checkValidIntValue(sMin-1, null); + Assertions.assertThrows(DateTimeException.class, () -> { + ValueRange test = ValueRange.of(sMin, lMin, sMax, lMax); + test.checkValidIntValue(sMin-1, null); + }); } - @Test(dataProvider="valid", expectedExceptions = DateTimeException.class) + @ParameterizedTest + @MethodSource("data_valid") public void test_of_checkValidValueMaxException(long sMin, long lMin, long sMax, long lMax) { - ValueRange test = ValueRange.of(sMin, lMin, sMax, lMax); - test.checkValidIntValue(lMax+1, null); + Assertions.assertThrows(DateTimeException.class, () -> { + ValueRange test = ValueRange.of(sMin, lMin, sMax, lMax); + test.checkValidIntValue(lMax+1, null); + }); } - @Test(expectedExceptions = DateTimeException.class) + @Test public void test_checkValidValueUnsupported_long_long() { - ValueRange test = ValueRange.of(1, 28, Integer.MAX_VALUE + 1L); - test.checkValidIntValue(0, (ChronoField)null); + Assertions.assertThrows(DateTimeException.class, () -> { + ValueRange test = ValueRange.of(1, 28, Integer.MAX_VALUE + 1L); + test.checkValidIntValue(0, (ChronoField)null); + }); } - @Test(expectedExceptions = DateTimeException.class) + @Test public void test_checkValidValueInvalid_long_long() { - ValueRange test = ValueRange.of(1, 28, Integer.MAX_VALUE + 1L); - test.checkValidIntValue(Integer.MAX_VALUE + 2L, (ChronoField)null); + Assertions.assertThrows(DateTimeException.class, () -> { + ValueRange test = ValueRange.of(1, 28, Integer.MAX_VALUE + 1L); + test.checkValidIntValue(Integer.MAX_VALUE + 2L, (ChronoField)null); + }); } //----------------------------------------------------------------------- // equals() / hashCode() //----------------------------------------------------------------------- + @Test public void test_equals1() { ValueRange a = ValueRange.of(1, 2, 3, 4); ValueRange b = ValueRange.of(1, 2, 3, 4); - assertEquals(a.equals(a), true); - assertEquals(a.equals(b), true); - assertEquals(b.equals(a), true); - assertEquals(b.equals(b), true); - assertEquals(a.hashCode() == b.hashCode(), true); + assertEquals(true, a.equals(a)); + assertEquals(true, a.equals(b)); + assertEquals(true, b.equals(a)); + assertEquals(true, b.equals(b)); + assertEquals(true, a.hashCode() == b.hashCode()); } + @Test public void test_equals2() { ValueRange a = ValueRange.of(1, 2, 3, 4); - assertEquals(a.equals(ValueRange.of(0, 2, 3, 4)), false); - assertEquals(a.equals(ValueRange.of(1, 3, 3, 4)), false); - assertEquals(a.equals(ValueRange.of(1, 2, 4, 4)), false); - assertEquals(a.equals(ValueRange.of(1, 2, 3, 5)), false); + assertEquals(false, a.equals(ValueRange.of(0, 2, 3, 4))); + assertEquals(false, a.equals(ValueRange.of(1, 3, 3, 4))); + assertEquals(false, a.equals(ValueRange.of(1, 2, 4, 4))); + assertEquals(false, a.equals(ValueRange.of(1, 2, 3, 5))); } + @Test public void test_equals_otherType() { ValueRange a = ValueRange.of(1, 12); - assertEquals(a.equals("Rubbish"), false); + assertEquals(false, a.equals("Rubbish")); } + @Test public void test_equals_null() { ValueRange a = ValueRange.of(1, 12); - assertEquals(a.equals(null), false); + assertEquals(false, a.equals(null)); } //----------------------------------------------------------------------- // toString() //----------------------------------------------------------------------- + @Test public void test_toString() { - assertEquals(ValueRange.of(1, 1, 4, 4).toString(), "1 - 4"); - assertEquals(ValueRange.of(1, 1, 3, 4).toString(), "1 - 3/4"); - assertEquals(ValueRange.of(1, 2, 3, 4).toString(), "1/2 - 3/4"); - assertEquals(ValueRange.of(1, 2, 4, 4).toString(), "1/2 - 4"); + assertEquals("1 - 4", ValueRange.of(1, 1, 4, 4).toString()); + assertEquals("1 - 3/4", ValueRange.of(1, 1, 3, 4).toString()); + assertEquals("1/2 - 3/4", ValueRange.of(1, 2, 3, 4).toString()); + assertEquals("1/2 - 4", ValueRange.of(1, 2, 4, 4).toString()); } } diff --git a/test/jdk/java/time/test/java/time/temporal/TestIsoFields.java b/test/jdk/java/time/test/java/time/temporal/TestIsoFields.java index 53cd721c0e5..8a74582d976 100644 --- a/test/jdk/java/time/test/java/time/temporal/TestIsoFields.java +++ b/test/jdk/java/time/test/java/time/temporal/TestIsoFields.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2022, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2022, 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 @@ -26,8 +26,9 @@ import static java.time.temporal.IsoFields.DAY_OF_QUARTER; import static java.time.temporal.IsoFields.QUARTER_OF_YEAR; import static java.time.temporal.IsoFields.WEEK_BASED_YEAR; import static java.time.temporal.IsoFields.WEEK_OF_WEEK_BASED_YEAR; -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 java.time.LocalDate; import java.time.chrono.ChronoLocalDate; @@ -38,15 +39,16 @@ import java.time.temporal.TemporalField; import java.time.temporal.ValueRange; import java.util.List; -import org.testng.annotations.DataProvider; -import org.testng.annotations.Test; +import org.junit.jupiter.api.TestInstance; +import org.junit.jupiter.params.ParameterizedTest; +import org.junit.jupiter.params.provider.MethodSource; /** * Tests fields in IsoFields class are supported in Japanese/Minguo/ThaiBuddhist * date classes * @bug 8279185 */ -@Test +@TestInstance(TestInstance.Lifecycle.PER_CLASS) public class TestIsoFields { private static final LocalDate ld = LocalDate.of(2022, 2, 25); private static final ChronoLocalDate J_DATE = JapaneseDate.from(ld); @@ -54,7 +56,6 @@ public class TestIsoFields { private static final ChronoLocalDate TB_DATE = ThaiBuddhistDate.from(ld); private static final List CLDATES = List.of(J_DATE, M_DATE, TB_DATE); - @DataProvider(name = "isSupported") Object[][] data_isSupported() { return new Object[][]{ {DAY_OF_QUARTER}, @@ -64,7 +65,6 @@ public class TestIsoFields { }; } - @DataProvider(name = "range") Object[][] data_range() { return new Object[][]{ {J_DATE, DAY_OF_QUARTER, ValueRange.of(1, 90)}, @@ -82,7 +82,6 @@ public class TestIsoFields { }; } - @DataProvider(name = "with_getLong") Object[][] data_with_getLong() { return new Object[][]{ {DAY_OF_QUARTER, 45}, @@ -92,24 +91,27 @@ public class TestIsoFields { }; } - @Test(dataProvider = "isSupported") + @ParameterizedTest + @MethodSource("data_isSupported") public void test_isSupported(TemporalField f) { CLDATES.forEach(d -> assertTrue(d.isSupported(f))); } - @Test(dataProvider = "range") + @ParameterizedTest + @MethodSource("data_range") public void test_range(ChronoLocalDate cld, TemporalField f, ValueRange r) { - assertEquals(cld.range(f), r); + assertEquals(r, cld.range(f)); } - @Test(dataProvider = "with_getLong") + @ParameterizedTest + @MethodSource("data_with_getLong") public void test_with_getLong(TemporalField f, long val) { CLDATES.forEach(d -> { var min = d.range(f).getMinimum(); var max = d.range(f).getMaximum(); - assertEquals(d.with(f, min).getLong(f), min); - assertEquals(d.with(f, max).getLong(f), max); - assertEquals(d.with(f, val).getLong(f), val); + assertEquals(min, d.with(f, min).getLong(f)); + assertEquals(max, d.with(f, max).getLong(f)); + assertEquals(val, d.with(f, val).getLong(f)); }); } } diff --git a/test/jdk/java/time/test/java/time/temporal/TestIsoWeekFields.java b/test/jdk/java/time/test/java/time/temporal/TestIsoWeekFields.java index 4c40e7278ed..80caa3ffcc1 100644 --- a/test/jdk/java/time/test/java/time/temporal/TestIsoWeekFields.java +++ b/test/jdk/java/time/test/java/time/temporal/TestIsoWeekFields.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2014, 2022, Oracle and/or its affiliates. All rights reserved. + * 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 @@ -23,8 +23,9 @@ package test.java.time.temporal; import static java.time.temporal.ChronoField.DAY_OF_WEEK; -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 java.time.DayOfWeek; import java.time.LocalDate; @@ -40,16 +41,17 @@ import java.time.temporal.TemporalField; import java.time.temporal.ValueRange; import java.time.temporal.WeekFields; -import org.testng.annotations.DataProvider; -import org.testng.annotations.Test; +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. */ -@Test +@TestInstance(TestInstance.Lifecycle.PER_CLASS) public class TestIsoWeekFields { - @DataProvider(name = "fields") Object[][] data_Fields() { return new Object[][] { {IsoFields.WEEK_OF_WEEK_BASED_YEAR, IsoFields.WEEK_BASED_YEAR}, @@ -60,92 +62,101 @@ public class TestIsoWeekFields { //----------------------------------------------------------------------- // WEEK_OF_WEEK_BASED_YEAR //----------------------------------------------------------------------- - @Test(dataProvider = "fields") + @ParameterizedTest + @MethodSource("data_Fields") public void test_WOWBY_basics(TemporalField weekField, TemporalField yearField) { - assertEquals(weekField.isDateBased(), true); - assertEquals(weekField.isTimeBased(), false); - assertEquals(weekField.getBaseUnit(), ChronoUnit.WEEKS); - assertEquals(weekField.getRangeUnit(), IsoFields.WEEK_BASED_YEARS); + assertEquals(true, weekField.isDateBased()); + assertEquals(false, weekField.isTimeBased()); + assertEquals(ChronoUnit.WEEKS, weekField.getBaseUnit()); + assertEquals(IsoFields.WEEK_BASED_YEARS, weekField.getRangeUnit()); } - @Test(dataProvider = "fields") + @ParameterizedTest + @MethodSource("data_Fields") public void test_WOWBY_isSupportedBy(TemporalField weekField, TemporalField yearField) { - assertEquals(weekField.isSupportedBy(LocalTime.NOON), false); - assertEquals(weekField.isSupportedBy(MonthDay.of(2, 1)), false); - assertEquals(weekField.isSupportedBy(LocalDate.MIN), true); - assertEquals(weekField.isSupportedBy(OffsetDateTime.MAX), true); - assertEquals(weekField.isSupportedBy(ThaiBuddhistDate.now()), true); + assertEquals(false, weekField.isSupportedBy(LocalTime.NOON)); + assertEquals(false, weekField.isSupportedBy(MonthDay.of(2, 1))); + assertEquals(true, weekField.isSupportedBy(LocalDate.MIN)); + assertEquals(true, weekField.isSupportedBy(OffsetDateTime.MAX)); + assertEquals(true, weekField.isSupportedBy(ThaiBuddhistDate.now())); } @Test public void test_WOWBY_isSupportedBy_fieldsDiffer() { - assertEquals(IsoFields.WEEK_OF_WEEK_BASED_YEAR.isSupportedBy(HijrahDate.now()), false); - assertEquals(WeekFields.ISO.weekOfWeekBasedYear().isSupportedBy(HijrahDate.now()), true); + assertEquals(false, IsoFields.WEEK_OF_WEEK_BASED_YEAR.isSupportedBy(HijrahDate.now())); + assertEquals(true, WeekFields.ISO.weekOfWeekBasedYear().isSupportedBy(HijrahDate.now())); } - @Test(dataProvider = "fields") + @ParameterizedTest + @MethodSource("data_Fields") public void test_WOWBY_range(TemporalField weekField, TemporalField yearField) { - assertEquals(weekField.range(), ValueRange.of(1, 52, 53)); + assertEquals(ValueRange.of(1, 52, 53), weekField.range()); } - @Test(dataProvider = "fields") + @ParameterizedTest + @MethodSource("data_Fields") public void test_WOWBY_rangeRefinedBy(TemporalField weekField, TemporalField yearField) { - assertEquals(weekField.rangeRefinedBy(LocalDate.of(2012, 12, 31)), ValueRange.of(1, 52)); - assertEquals(weekField.rangeRefinedBy(LocalDate.of(2013, 12, 29)), ValueRange.of(1, 52)); - assertEquals(weekField.rangeRefinedBy(LocalDate.of(2013, 12, 30)), ValueRange.of(1, 52)); - assertEquals(weekField.rangeRefinedBy(LocalDate.of(2014, 12, 28)), ValueRange.of(1, 52)); - assertEquals(weekField.rangeRefinedBy(LocalDate.of(2014, 12, 29)), ValueRange.of(1, 53)); - assertEquals(weekField.rangeRefinedBy(LocalDate.of(2016, 1, 3)), ValueRange.of(1, 53)); - assertEquals(weekField.rangeRefinedBy(LocalDate.of(2016, 1, 4)), ValueRange.of(1, 52)); + assertEquals(ValueRange.of(1, 52), weekField.rangeRefinedBy(LocalDate.of(2012, 12, 31))); + assertEquals(ValueRange.of(1, 52), weekField.rangeRefinedBy(LocalDate.of(2013, 12, 29))); + assertEquals(ValueRange.of(1, 52), weekField.rangeRefinedBy(LocalDate.of(2013, 12, 30))); + assertEquals(ValueRange.of(1, 52), weekField.rangeRefinedBy(LocalDate.of(2014, 12, 28))); + assertEquals(ValueRange.of(1, 53), weekField.rangeRefinedBy(LocalDate.of(2014, 12, 29))); + assertEquals(ValueRange.of(1, 53), weekField.rangeRefinedBy(LocalDate.of(2016, 1, 3))); + assertEquals(ValueRange.of(1, 52), weekField.rangeRefinedBy(LocalDate.of(2016, 1, 4))); } //----------------------------------------------------------------------- // WEEK_BASED_YEAR //----------------------------------------------------------------------- - @Test(dataProvider = "fields") + @ParameterizedTest + @MethodSource("data_Fields") public void test_WBY_basics(TemporalField weekField, TemporalField yearField) { - assertEquals(yearField.isDateBased(), true); - assertEquals(yearField.isTimeBased(), false); - assertEquals(yearField.getBaseUnit(), IsoFields.WEEK_BASED_YEARS); - assertEquals(yearField.getRangeUnit(), ChronoUnit.FOREVER); + assertEquals(true, yearField.isDateBased()); + assertEquals(false, yearField.isTimeBased()); + assertEquals(IsoFields.WEEK_BASED_YEARS, yearField.getBaseUnit()); + assertEquals(ChronoUnit.FOREVER, yearField.getRangeUnit()); } - @Test(dataProvider = "fields") + @ParameterizedTest + @MethodSource("data_Fields") public void test_WBY_isSupportedBy(TemporalField weekField, TemporalField yearField) { - assertEquals(yearField.isSupportedBy(LocalTime.NOON), false); - assertEquals(yearField.isSupportedBy(MonthDay.of(2, 1)), false); - assertEquals(yearField.isSupportedBy(LocalDate.MIN), true); - assertEquals(yearField.isSupportedBy(OffsetDateTime.MAX), true); - assertEquals(yearField.isSupportedBy(ThaiBuddhistDate.now()), true); + assertEquals(false, yearField.isSupportedBy(LocalTime.NOON)); + assertEquals(false, yearField.isSupportedBy(MonthDay.of(2, 1))); + assertEquals(true, yearField.isSupportedBy(LocalDate.MIN)); + assertEquals(true, yearField.isSupportedBy(OffsetDateTime.MAX)); + assertEquals(true, yearField.isSupportedBy(ThaiBuddhistDate.now())); } @Test public void test_WBY_isSupportedBy_ISO() { - assertEquals(IsoFields.WEEK_BASED_YEAR.isSupportedBy(HijrahDate.now()), false); + assertEquals(false, IsoFields.WEEK_BASED_YEAR.isSupportedBy(HijrahDate.now())); } @Test public void test_Unit_isSupportedBy_ISO() { - assertEquals(IsoFields.WEEK_BASED_YEARS.isSupportedBy(LocalDate.now()), true); - assertEquals(IsoFields.WEEK_BASED_YEARS.isSupportedBy(ThaiBuddhistDate.now()), true); - assertEquals(IsoFields.WEEK_BASED_YEARS.isSupportedBy(HijrahDate.now()), false); - assertEquals(IsoFields.QUARTER_YEARS.isSupportedBy(LocalDate.now()), true); - assertEquals(IsoFields.QUARTER_YEARS.isSupportedBy(ThaiBuddhistDate.now()), true); - assertEquals(IsoFields.QUARTER_YEARS.isSupportedBy(HijrahDate.now()), false); + assertEquals(true, IsoFields.WEEK_BASED_YEARS.isSupportedBy(LocalDate.now())); + assertEquals(true, IsoFields.WEEK_BASED_YEARS.isSupportedBy(ThaiBuddhistDate.now())); + assertEquals(false, IsoFields.WEEK_BASED_YEARS.isSupportedBy(HijrahDate.now())); + assertEquals(true, IsoFields.QUARTER_YEARS.isSupportedBy(LocalDate.now())); + assertEquals(true, IsoFields.QUARTER_YEARS.isSupportedBy(ThaiBuddhistDate.now())); + assertEquals(false, IsoFields.QUARTER_YEARS.isSupportedBy(HijrahDate.now())); } - @Test(dataProvider = "fields") + @ParameterizedTest + @MethodSource("data_Fields") public void test_WBY_range(TemporalField weekField, TemporalField yearField) { - assertEquals(yearField.range(), ValueRange.of(Year.MIN_VALUE, Year.MAX_VALUE)); + assertEquals(ValueRange.of(Year.MIN_VALUE, Year.MAX_VALUE), yearField.range()); } - @Test(dataProvider = "fields") + @ParameterizedTest + @MethodSource("data_Fields") public void test_WBY_rangeRefinedBy(TemporalField weekField, TemporalField yearField) { - assertEquals(yearField.rangeRefinedBy(LocalDate.of(2012, 12, 31)), ValueRange.of(Year.MIN_VALUE, Year.MAX_VALUE)); + assertEquals(ValueRange.of(Year.MIN_VALUE, Year.MAX_VALUE), yearField.rangeRefinedBy(LocalDate.of(2012, 12, 31))); } //----------------------------------------------------------------------- - @Test(dataProvider = "fields") + @ParameterizedTest + @MethodSource("data_Fields") public void test_getFrom(TemporalField weekField, TemporalField yearField) { // tests every day from 2011 to 2016 inclusive LocalDate date = LocalDate.of(2011, 1, 3); @@ -153,9 +164,9 @@ public class TestIsoWeekFields { int week = 1; int dow = 1; for (int i = 1; i <= ((52 + 52 + 52 + 52 + 53 + 52) * 7); i++) { - assertEquals(yearField.getFrom(date), wby); - assertEquals(weekField.getFrom(date), week); - assertEquals(DAY_OF_WEEK.getFrom(date), dow); + assertEquals(wby, yearField.getFrom(date)); + assertEquals(week, weekField.getFrom(date)); + assertEquals(dow, DAY_OF_WEEK.getFrom(date)); if (dow == 7) { dow = 1; week++; @@ -168,12 +179,13 @@ public class TestIsoWeekFields { } date = date.plusDays(1); } - assertEquals(yearField.getFrom(date), 2017); - assertEquals(weekField.getFrom(date), 1); - assertEquals(DAY_OF_WEEK.getFrom(date), 1); + assertEquals(2017, yearField.getFrom(date)); + assertEquals(1, weekField.getFrom(date)); + assertEquals(1, DAY_OF_WEEK.getFrom(date)); } - @Test(dataProvider = "fields") + @ParameterizedTest + @MethodSource("data_Fields") public void test_adjustInto_dow(TemporalField weekField, TemporalField yearField) { // tests every day from 2012 to 2016 inclusive LocalDate date = LocalDate.of(2012, 1, 2); @@ -183,9 +195,9 @@ public class TestIsoWeekFields { for (int i = 1; i <= ((52 + 52 + 52 + 53 + 52) * 7); i++) { for (int j = 1; j <= 7; j++) { LocalDate adjusted = DAY_OF_WEEK.adjustInto(date, j); - assertEquals(adjusted.get(DAY_OF_WEEK), j); - assertEquals(adjusted.get(weekField), week); - assertEquals(adjusted.get(yearField), wby); + assertEquals(j, adjusted.get(DAY_OF_WEEK)); + assertEquals(week, adjusted.get(weekField)); + assertEquals(wby, adjusted.get(yearField)); } if (dow == 7) { dow = 1; @@ -201,7 +213,8 @@ public class TestIsoWeekFields { } } - @Test(dataProvider = "fields") + @ParameterizedTest + @MethodSource("data_Fields") public void test_adjustInto_week(TemporalField weekField, TemporalField yearField) { // tests every day from 2012 to 2016 inclusive LocalDate date = LocalDate.of(2012, 1, 2); @@ -212,9 +225,9 @@ public class TestIsoWeekFields { int weeksInYear = (wby == 2015 ? 53 : 52); for (int j = 1; j <= weeksInYear; j++) { LocalDate adjusted = weekField.adjustInto(date, j); - assertEquals(adjusted.get(weekField), j); - assertEquals(adjusted.get(DAY_OF_WEEK), dow); - assertEquals(adjusted.get(yearField), wby); + assertEquals(j, adjusted.get(weekField)); + assertEquals(dow, adjusted.get(DAY_OF_WEEK)); + assertEquals(wby, adjusted.get(yearField)); } if (dow == 7) { dow = 1; @@ -230,7 +243,8 @@ public class TestIsoWeekFields { } } - @Test(dataProvider = "fields") + @ParameterizedTest + @MethodSource("data_Fields") public void test_adjustInto_wby(TemporalField weekField, TemporalField yearField) { // tests every day from 2012 to 2016 inclusive LocalDate date = LocalDate.of(2012, 1, 2); @@ -240,9 +254,9 @@ public class TestIsoWeekFields { for (int i = 1; i <= ((52 + 52 + 52 + 53 + 52) * 7); i++) { for (int j = 2004; j <= 2015; j++) { LocalDate adjusted = yearField.adjustInto(date, j); - assertEquals(adjusted.get(yearField), j); - assertEquals(adjusted.get(DAY_OF_WEEK), dow); - assertEquals(adjusted.get(weekField), (week == 53 && wbyLen(j) == 52 ? 52 : week), "" + date + " " + adjusted); + assertEquals(j, adjusted.get(yearField)); + assertEquals(dow, adjusted.get(DAY_OF_WEEK)); + assertEquals((week == 53 && wbyLen(j) == 52 ? 52 : week), adjusted.get(weekField), "" + date + " " + adjusted); } if (dow == 7) { dow = 1; @@ -258,7 +272,8 @@ public class TestIsoWeekFields { } } - @Test(dataProvider = "fields") + @ParameterizedTest + @MethodSource("data_Fields") public void test_addTo_weekBasedYears(TemporalField weekField, TemporalField yearField) { // tests every day from 2012 to 2016 inclusive LocalDate date = LocalDate.of(2012, 1, 2); @@ -268,9 +283,9 @@ public class TestIsoWeekFields { for (int i = 1; i <= ((52 + 52 + 52 + 53 + 52) * 7); i++) { for (int j = -5; j <= 5; j++) { LocalDate adjusted = IsoFields.WEEK_BASED_YEARS.addTo(date, j); - assertEquals(adjusted.get(yearField), wby + j); - assertEquals(adjusted.get(DAY_OF_WEEK), dow); - assertEquals(adjusted.get(weekField), (week == 53 && wbyLen(wby + j) == 52 ? 52 : week), "" + date + " " + adjusted); + assertEquals(wby + j, adjusted.get(yearField)); + assertEquals(dow, adjusted.get(DAY_OF_WEEK)); + assertEquals((week == 53 && wbyLen(wby + j) == 52 ? 52 : week), adjusted.get(weekField), "" + date + " " + adjusted); } if (dow == 7) { dow = 1; diff --git a/test/jdk/java/time/test/java/time/temporal/TestJulianFields.java b/test/jdk/java/time/test/java/time/temporal/TestJulianFields.java index 0d9d79e3158..5ed393d1b87 100644 --- a/test/jdk/java/time/test/java/time/temporal/TestJulianFields.java +++ b/test/jdk/java/time/test/java/time/temporal/TestJulianFields.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2012, 2013, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2012, 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 @@ -59,16 +59,15 @@ */ package test.java.time.temporal; -import static org.testng.Assert.assertEquals; +import static org.junit.jupiter.api.Assertions.assertEquals; import java.time.temporal.JulianFields; -import org.testng.annotations.Test; +import org.junit.jupiter.api.Test; /** * Test. */ -@Test public class TestJulianFields { //----------------------------------------------------------------------- @@ -76,9 +75,9 @@ public class TestJulianFields { //----------------------------------------------------------------------- @Test public void test_toString() { - assertEquals(JulianFields.JULIAN_DAY.toString(), "JulianDay"); - assertEquals(JulianFields.MODIFIED_JULIAN_DAY.toString(), "ModifiedJulianDay"); - assertEquals(JulianFields.RATA_DIE.toString(), "RataDie"); + assertEquals("JulianDay", JulianFields.JULIAN_DAY.toString()); + assertEquals("ModifiedJulianDay", JulianFields.MODIFIED_JULIAN_DAY.toString()); + assertEquals("RataDie", JulianFields.RATA_DIE.toString()); } } diff --git a/test/jdk/java/time/test/java/time/zone/TestFixedZoneRules.java b/test/jdk/java/time/test/java/time/zone/TestFixedZoneRules.java index d479134c26e..8f52372ab01 100644 --- a/test/jdk/java/time/test/java/time/zone/TestFixedZoneRules.java +++ b/test/jdk/java/time/test/java/time/zone/TestFixedZoneRules.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2012, 2013, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2012, 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 @@ -61,19 +61,18 @@ package test.java.time.zone; import java.time.zone.ZoneRules; -import static org.testng.Assert.assertEquals; +import static org.junit.jupiter.api.Assertions.assertEquals; import java.time.Duration; import java.time.Instant; import java.time.LocalDateTime; import java.time.ZoneOffset; -import org.testng.annotations.Test; +import org.junit.jupiter.api.Test; /** * Test ZoneRules for fixed offset time-zones. */ -@Test public class TestFixedZoneRules { private static final ZoneOffset OFFSET_PONE = ZoneOffset.ofHours(1); @@ -86,16 +85,16 @@ public class TestFixedZoneRules { @Test public void test_data_nullInput() { ZoneRules test = make(OFFSET_PONE); - assertEquals(test.getOffset((Instant) null), OFFSET_PONE); - assertEquals(test.getOffset((LocalDateTime) null), OFFSET_PONE); - assertEquals(test.getValidOffsets(null).size(), 1); - assertEquals(test.getValidOffsets(null).get(0), OFFSET_PONE); - assertEquals(test.getTransition(null), null); - assertEquals(test.getStandardOffset(null), OFFSET_PONE); - assertEquals(test.getDaylightSavings(null), Duration.ZERO); - assertEquals(test.isDaylightSavings(null), false); - assertEquals(test.nextTransition(null), null); - assertEquals(test.previousTransition(null), null); + assertEquals(OFFSET_PONE, test.getOffset((Instant) null)); + assertEquals(OFFSET_PONE, test.getOffset((LocalDateTime) null)); + assertEquals(1, test.getValidOffsets(null).size()); + assertEquals(OFFSET_PONE, test.getValidOffsets(null).get(0)); + assertEquals(null, test.getTransition(null)); + assertEquals(OFFSET_PONE, test.getStandardOffset(null)); + assertEquals(Duration.ZERO, test.getDaylightSavings(null)); + assertEquals(false, test.isDaylightSavings(null)); + assertEquals(null, test.nextTransition(null)); + assertEquals(null, test.previousTransition(null)); } } diff --git a/test/jdk/java/time/test/java/time/zone/TestMutableZoneRules.java b/test/jdk/java/time/test/java/time/zone/TestMutableZoneRules.java index 4474f70db05..a8d7f4746c7 100644 --- a/test/jdk/java/time/test/java/time/zone/TestMutableZoneRules.java +++ b/test/jdk/java/time/test/java/time/zone/TestMutableZoneRules.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2021, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2021, 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 @@ -27,16 +27,15 @@ import java.time.*; import java.time.zone.*; import java.util.*; -import org.testng.annotations.Test; -import static org.testng.Assert.assertEquals; -import static org.testng.Assert.assertThrows; +import static org.junit.jupiter.api.Assertions.assertEquals; +import static org.junit.jupiter.api.Assertions.assertThrows; +import org.junit.jupiter.api.Test; /** * @summary ZoneRules invariants can be broken. * * @bug 8246788 */ -@Test public class TestMutableZoneRules { static final ZoneOffset offset = ZoneOffset.ofHoursMinutes(1, 30); @@ -48,16 +47,18 @@ public class TestMutableZoneRules { ZoneOffsetTransitionRule.of(Month.MARCH, 2, DayOfWeek.MONDAY, LocalTime.MIN, true, ZoneOffsetTransitionRule.TimeDefinition.UTC, offset, offset, offset); + @Test public void testMutation() { ZoneOffsetTransitionRule[] array = { rule1 }; ZoneRules zr1 = ZoneRules.of(offset, offset, List.of(), List.of(), List.of(rule1)); ZoneRules zr2 = ZoneRules.of(offset, offset, List.of(), List.of(), new TestList(array, array.length)); - assertEquals(zr2, zr1); + assertEquals(zr1, zr2); array[0] = rule2; - assertEquals(zr2, zr1); + assertEquals(zr1, zr2); } + @Test public void testLength() { ZoneOffsetTransitionRule[] array = new ZoneOffsetTransitionRule[17]; Arrays.setAll(array, i -> rule1); diff --git a/test/jdk/java/time/test/java/time/zone/TestZoneRules.java b/test/jdk/java/time/test/java/time/zone/TestZoneRules.java index 584ed2e56c7..7a1e656ee87 100644 --- a/test/jdk/java/time/test/java/time/zone/TestZoneRules.java +++ b/test/jdk/java/time/test/java/time/zone/TestZoneRules.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2019, 2020, Oracle and/or its affiliates. All rights reserved. + * 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 @@ -40,17 +40,19 @@ import java.time.zone.ZoneRules; import java.util.Collections; import java.util.List; -import org.testng.annotations.DataProvider; -import org.testng.annotations.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; +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; /** * @summary Tests for ZoneRules class. * * @bug 8212970 8236903 8239836 */ -@Test +@TestInstance(TestInstance.Lifecycle.PER_CLASS) public class TestZoneRules { private static final ZoneId DUBLIN = ZoneId.of("Europe/Dublin"); @@ -68,7 +70,6 @@ public class TestZoneRules { private static final ZoneOffsetTransition ZOT = ZoneId.of("America/Los_Angeles").getRules().getTransitions().get(0); private static final ZoneOffsetTransitionRule ZOTR = ZoneId.of("America/Los_Angeles").getRules().getTransitionRules().get(0); - @DataProvider private Object[][] negativeDST () { return new Object[][] { // ZoneId, localDate, offset, standard offset, isDaylightSavings @@ -102,7 +103,6 @@ public class TestZoneRules { }; } - @DataProvider private Object[][] transitionBeyondDay() { return new Object[][] { // ZoneId, LocalDateTime, beforeOffset, afterOffset @@ -117,7 +117,6 @@ public class TestZoneRules { }; } - @DataProvider private Object[][] emptyTransitionList() { return new Object[][] { // days, offset, std offset, savings, isDST @@ -126,7 +125,6 @@ public class TestZoneRules { }; } - @DataProvider private Object[][] isFixedOffset() { return new Object[][] { // ZoneRules, expected @@ -144,20 +142,22 @@ public class TestZoneRules { * negative savings in the source TZ files. * @bug 8212970 */ - @Test(dataProvider="negativeDST") + @ParameterizedTest + @MethodSource("negativeDST") public void test_NegativeDST(ZoneId zid, LocalDate ld, ZoneOffset offset, ZoneOffset stdOffset, boolean isDST) { Instant i = Instant.from(ZonedDateTime.of(ld, LocalTime.MIN, zid)); ZoneRules zr = zid.getRules(); - assertEquals(zr.getOffset(i), offset); - assertEquals(zr.getStandardOffset(i), stdOffset); - assertEquals(zr.isDaylightSavings(i), isDST); + assertEquals(offset, zr.getOffset(i)); + assertEquals(stdOffset, zr.getStandardOffset(i)); + assertEquals(isDST, zr.isDaylightSavings(i)); } /** * Check the transition cutover time beyond 24:00, which should translate into the next day. * @bug 8212970 */ - @Test(dataProvider="transitionBeyondDay") + @ParameterizedTest + @MethodSource("transitionBeyondDay") public void test_TransitionBeyondDay(ZoneId zid, LocalDateTime ldt, ZoneOffset before, ZoneOffset after) { ZoneOffsetTransition zot = ZoneOffsetTransition.of(ldt, before, after); ZoneRules zr = zid.getRules(); @@ -198,14 +198,15 @@ public class TestZoneRules { Collections.singletonList(transitionRule)); ZoneOffset offsetA = zoneRulesA.getOffset(maxLocalDateTime); ZoneOffset offsetB = zoneRulesB.getOffset(maxLocalDateTime); - assertEquals(offsetA, offsetB); + assertEquals(offsetB, offsetA); } /** * Tests whether empty "transitionList" is correctly interpreted. * @bug 8239836 */ - @Test(dataProvider="emptyTransitionList") + @ParameterizedTest + @MethodSource("emptyTransitionList") public void test_EmptyTransitionList(int days, int offset, int stdOffset, int savings, boolean isDST) { LocalDateTime transitionDay = LocalDateTime.of(2020, 1, 1, 2, 0); Instant testDay = transitionDay.plusDays(days).toInstant(ZoneOffset.UTC); @@ -217,18 +218,19 @@ public class TestZoneRules { Collections.singletonList(trans), Collections.emptyList(), Collections.emptyList()); - assertEquals(rules.getOffset(testDay), ZoneOffset.ofHours(offset)); - assertEquals(rules.getStandardOffset(testDay), ZoneOffset.ofHours(stdOffset)); - assertEquals(rules.getDaylightSavings(testDay), Duration.ofHours(savings)); - assertEquals(rules.isDaylightSavings(testDay), isDST); + assertEquals(ZoneOffset.ofHours(offset), rules.getOffset(testDay)); + assertEquals(ZoneOffset.ofHours(stdOffset), rules.getStandardOffset(testDay)); + assertEquals(Duration.ofHours(savings), rules.getDaylightSavings(testDay)); + assertEquals(isDST, rules.isDaylightSavings(testDay)); } /** * Tests whether isFixedOffset() is working correctly * @bug 8239836 */ - @Test(dataProvider="isFixedOffset") + @ParameterizedTest + @MethodSource("isFixedOffset") public void test_IsFixedOffset(ZoneRules zr, boolean expected) { - assertEquals(zr.isFixedOffset(), expected); + assertEquals(expected, zr.isFixedOffset()); } } diff --git a/test/jdk/java/time/test/java/time/zone/TestZoneRulesProvider.java b/test/jdk/java/time/test/java/time/zone/TestZoneRulesProvider.java index 3a20dc2b864..6b0463d1b26 100644 --- a/test/jdk/java/time/test/java/time/zone/TestZoneRulesProvider.java +++ b/test/jdk/java/time/test/java/time/zone/TestZoneRulesProvider.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2023, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2023, 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 @@ -32,17 +32,15 @@ import java.util.LinkedHashSet; import java.util.NavigableMap; import java.util.Set; -import org.testng.annotations.Test; -import static org.testng.Assert.assertFalse; -import static org.testng.Assert.assertNotNull; -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.assertTrue; +import static org.junit.jupiter.api.Assertions.fail; +import org.junit.jupiter.api.Test; /** * @summary Tests for ZoneRulesProvider class. * @bug 8299571 8302983 */ -@Test public class TestZoneRulesProvider { /** diff --git a/test/jdk/java/time/test/java/util/TestFormatter.java b/test/jdk/java/time/test/java/util/TestFormatter.java index 903e48ba96d..72b859e533e 100644 --- a/test/jdk/java/time/test/java/util/TestFormatter.java +++ b/test/jdk/java/time/test/java/util/TestFormatter.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2012, 2016, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2012, 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 @@ -22,7 +22,7 @@ */ package test.java.util; -import static org.testng.Assert.assertEquals; +import static org.junit.jupiter.api.Assertions.assertEquals; import java.time.Instant; import java.time.LocalTime; @@ -42,14 +42,15 @@ import java.time.temporal.UnsupportedTemporalTypeException; import java.util.*; -import org.testng.annotations.DataProvider; -import org.testng.annotations.Test; +import org.junit.jupiter.api.TestInstance; +import org.junit.jupiter.params.ParameterizedTest; +import org.junit.jupiter.params.provider.MethodSource; /* @test * @summary Unit test for j.u.Formatter threeten date/time support * @bug 8003680 8043387 8012638 */ -@Test +@TestInstance(TestInstance.Lifecycle.PER_CLASS) public class TestFormatter { // time @@ -71,7 +72,6 @@ public class TestFormatter { private int failure = 0; private boolean verbose = false; - @DataProvider(name = "calendarsByLocale") Object[][] data_calendars() { return new Object[][] { {"en_US"}, @@ -80,7 +80,8 @@ public class TestFormatter { }; } - @Test(dataProvider="calendarsByLocale") + @ParameterizedTest + @MethodSource("data_calendars") public void test (String calendarLocale) { failure = 0; int N = 12; @@ -128,7 +129,7 @@ public class TestFormatter { System.out.println("All tests (" + total + ") PASSED"); } } - assertEquals(failure, 0); + assertEquals(0, failure); } private String getClassName(Object o) { From 7c979c148724ab7de650593caa22df8405d740e5 Mon Sep 17 00:00:00 2001 From: David Beaumont Date: Tue, 6 Jan 2026 19:54:49 +0000 Subject: [PATCH 066/712] 8374308: ImageBufferCache has no effect and can be removed Reviewed-by: alanb, rriggs --- .../jdk/internal/jimage/BasicImageReader.java | 42 ++--- .../jdk/internal/jimage/ImageBufferCache.java | 158 ------------------ .../jdk/internal/jimage/ImageReader.java | 17 +- .../internal/module/SystemModuleFinders.java | 8 +- 4 files changed, 16 insertions(+), 209 deletions(-) delete mode 100644 src/java.base/share/classes/jdk/internal/jimage/ImageBufferCache.java 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 6807928b2c2..10aa0397f0c 100644 --- a/src/java.base/share/classes/jdk/internal/jimage/BasicImageReader.java +++ b/src/java.base/share/classes/jdk/internal/jimage/BasicImageReader.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 @@ -220,14 +220,6 @@ public class BasicImageReader implements AutoCloseable { return slice(buffer, offset, size).order(byteOrder).asIntBuffer(); } - public static void releaseByteBuffer(ByteBuffer buffer) { - Objects.requireNonNull(buffer); - - if (!MAP_ALL) { - ImageBufferCache.releaseBuffer(buffer); - } - } - public String getName() { return name; } @@ -362,13 +354,15 @@ public class BasicImageReader implements AutoCloseable { if (offset < 0 || Integer.MAX_VALUE <= offset) { throw new IndexOutOfBoundsException("Bad offset: " + offset); } + int checkedOffset = (int) offset; if (size < 0 || Integer.MAX_VALUE <= size) { - throw new IndexOutOfBoundsException("Bad size: " + size); + throw new IllegalArgumentException("Bad size: " + size); } + int checkedSize = (int) size; if (MAP_ALL) { - ByteBuffer buffer = slice(memoryMap, (int)offset, (int)size); + ByteBuffer buffer = slice(memoryMap, checkedOffset, checkedSize); buffer.order(ByteOrder.BIG_ENDIAN); return buffer; @@ -376,21 +370,18 @@ public class BasicImageReader implements AutoCloseable { if (channel == null) { throw new InternalError("Image file channel not open"); } - - ByteBuffer buffer = ImageBufferCache.getBuffer(size); + ByteBuffer buffer = ByteBuffer.allocate(checkedSize); int read; try { - read = channel.read(buffer, offset); + read = channel.read(buffer, checkedOffset); buffer.rewind(); } catch (IOException ex) { - ImageBufferCache.releaseBuffer(buffer); throw new RuntimeException(ex); } - if (read != size) { - ImageBufferCache.releaseBuffer(buffer); + if (read != checkedSize) { throw new RuntimeException("Short read: " + read + - " instead of " + size + " bytes"); + " instead of " + checkedSize + " bytes"); } return buffer; @@ -406,17 +397,12 @@ public class BasicImageReader implements AutoCloseable { public byte[] getResource(ImageLocation loc) { ByteBuffer buffer = getResourceBuffer(loc); - - if (buffer != null) { - byte[] bytes = getBufferBytes(buffer); - ImageBufferCache.releaseBuffer(buffer); - - return bytes; - } - - return null; + return buffer != null ? getBufferBytes(buffer) : null; } + /** + * Returns the content of jimage location in a newly allocated byte buffer. + */ public ByteBuffer getResourceBuffer(ImageLocation loc) { Objects.requireNonNull(loc); long offset = loc.getContentOffset() + indexSize; @@ -437,10 +423,8 @@ public class BasicImageReader implements AutoCloseable { return readBuffer(offset, uncompressedSize); } else { ByteBuffer buffer = readBuffer(offset, compressedSize); - if (buffer != null) { byte[] bytesIn = getBufferBytes(buffer); - ImageBufferCache.releaseBuffer(buffer); byte[] bytesOut; try { diff --git a/src/java.base/share/classes/jdk/internal/jimage/ImageBufferCache.java b/src/java.base/share/classes/jdk/internal/jimage/ImageBufferCache.java deleted file mode 100644 index c2cc4a028be..00000000000 --- a/src/java.base/share/classes/jdk/internal/jimage/ImageBufferCache.java +++ /dev/null @@ -1,158 +0,0 @@ -/* - * Copyright (c) 2014, 2016, Oracle and/or its affiliates. All rights reserved. - * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. - * - * This code is free software; you can redistribute it and/or modify it - * under the terms of the GNU General Public License version 2 only, as - * published by the Free Software Foundation. Oracle designates this - * particular file as subject to the "Classpath" exception as provided - * by Oracle in the LICENSE file that accompanied this code. - * - * This code is distributed in the hope that it will be useful, but WITHOUT - * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or - * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License - * version 2 for more details (a copy is included in the LICENSE file that - * accompanied this code). - * - * You should have received a copy of the GNU General Public License version - * 2 along with this work; if not, write to the Free Software Foundation, - * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. - * - * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA - * or visit www.oracle.com if you need additional information or have any - * questions. - */ -package jdk.internal.jimage; - -import java.lang.ref.WeakReference; -import java.nio.ByteBuffer; -import java.util.AbstractMap; -import java.util.Arrays; -import java.util.Comparator; -import java.util.Map; - -/** - * @implNote This class needs to maintain JDK 8 source compatibility. - * - * It is used internally in the JDK to implement jimage/jrtfs access, - * but also compiled and delivered as part of the jrt-fs.jar to support access - * to the jimage file provided by the shipped JDK by tools running on JDK 8. - */ -class ImageBufferCache { - private static final int MAX_CACHED_BUFFERS = 3; - private static final int LARGE_BUFFER = 0x10000; - - /* - * We used to have a class BufferReference extending from WeakReference. - * BufferReference class had an instance field called "capacity". This field was - * used to make DECREASING_CAPACITY_NULLS_LAST comparator stable in the presence - * of GC clearing the WeakReference concurrently. - * - * But this scheme results in metaspace leak. The thread local is alive till the - * the thread is alive. And so ImageBufferCache$BufferReference class was kept alive. - * Because this class and ImageBufferCache$BufferReference are all loaded by a URL - * class loader from jrt-fs.jar, the class loader and so all the classes loaded by it - * were alive! - * - * Solution is to avoid using a URL loader loaded class type with thread local. All we - * need is a pair of WeakReference, Integer (saved capacity for stability - * of comparator). We use Map.Entry as pair implementation. With this, all types used - * with thread local are bootstrap types and so no metaspace leak. - */ - @SuppressWarnings("unchecked") - private static final ThreadLocal, Integer>[]> CACHE = - new ThreadLocal, Integer>[]>() { - @Override - protected Map.Entry, Integer>[] initialValue() { - // 1 extra slot to simplify logic of releaseBuffer() - return (Map.Entry, Integer>[])new Map.Entry[MAX_CACHED_BUFFERS + 1]; - } - }; - - private static ByteBuffer allocateBuffer(long size) { - return ByteBuffer.allocateDirect((int)((size + 0xFFF) & ~0xFFF)); - } - - static ByteBuffer getBuffer(long size) { - if (size < 0 || Integer.MAX_VALUE < size) { - throw new IndexOutOfBoundsException("size"); - } - - ByteBuffer result = null; - - if (size > LARGE_BUFFER) { - result = allocateBuffer(size); - } else { - Map.Entry, Integer>[] cache = CACHE.get(); - - // buffers are ordered by decreasing capacity - // cache[MAX_CACHED_BUFFERS] is always null - for (int i = MAX_CACHED_BUFFERS - 1; i >= 0; i--) { - Map.Entry, Integer> reference = cache[i]; - - if (reference != null) { - ByteBuffer buffer = getByteBuffer(reference); - - if (buffer != null && size <= buffer.capacity()) { - cache[i] = null; - result = buffer; - result.rewind(); - break; - } - } - } - - if (result == null) { - result = allocateBuffer(size); - } - } - - result.limit((int)size); - - return result; - } - - static void releaseBuffer(ByteBuffer buffer) { - if (buffer.capacity() > LARGE_BUFFER) { - return; - } - - Map.Entry, Integer>[] cache = CACHE.get(); - - // expunge cleared BufferRef(s) - for (int i = 0; i < MAX_CACHED_BUFFERS; i++) { - Map.Entry, Integer> reference = cache[i]; - if (reference != null && getByteBuffer(reference) == null) { - cache[i] = null; - } - } - - // insert buffer back with new BufferRef wrapping it - cache[MAX_CACHED_BUFFERS] = newCacheEntry(buffer); - Arrays.sort(cache, DECREASING_CAPACITY_NULLS_LAST); - // squeeze the smallest one out - cache[MAX_CACHED_BUFFERS] = null; - } - - private static Map.Entry, Integer> newCacheEntry(ByteBuffer bb) { - return new AbstractMap.SimpleEntry, Integer>( - new WeakReference(bb), bb.capacity()); - } - - private static int getCapacity(Map.Entry, Integer> e) { - return e == null? 0 : e.getValue(); - } - - private static ByteBuffer getByteBuffer(Map.Entry, Integer> e) { - return e == null? null : e.getKey().get(); - } - - private static Comparator, Integer>> DECREASING_CAPACITY_NULLS_LAST = - new Comparator, Integer>>() { - @Override - public int compare(Map.Entry, Integer> br1, - Map.Entry, Integer> br2) { - return Integer.compare(getCapacity(br1), getCapacity(br2)); - } - }; -} 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 e062e1629ff..c36e265ee2f 100644 --- a/src/java.base/share/classes/jdk/internal/jimage/ImageReader.java +++ b/src/java.base/share/classes/jdk/internal/jimage/ImageReader.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 @@ -190,20 +190,7 @@ public final class ImageReader implements AutoCloseable { } /** - * Releases a (possibly cached) {@link ByteBuffer} obtained via - * {@link #getResourceBuffer(Node)}. - * - *

Note that no testing is performed to check whether the buffer about - * to be released actually came from a call to {@code getResourceBuffer()}. - */ - public static void releaseByteBuffer(ByteBuffer buffer) { - BasicImageReader.releaseByteBuffer(buffer); - } - - /** - * Returns the content of a resource node in a possibly cached byte buffer. - * Callers of this method must call {@link #releaseByteBuffer(ByteBuffer)} - * when they are finished with it. + * Returns the content of a resource node in a newly allocated byte buffer. */ public ByteBuffer getResourceBuffer(Node node) { requireOpen(); diff --git a/src/java.base/share/classes/jdk/internal/module/SystemModuleFinders.java b/src/java.base/share/classes/jdk/internal/module/SystemModuleFinders.java index 370c151af84..afebb89168c 100644 --- a/src/java.base/share/classes/jdk/internal/module/SystemModuleFinders.java +++ b/src/java.base/share/classes/jdk/internal/module/SystemModuleFinders.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 @@ -467,12 +467,6 @@ public final class SystemModuleFinders { .map(reader::getResourceBuffer); } - @Override - public void release(ByteBuffer bb) { - Objects.requireNonNull(bb); - ImageReader.releaseByteBuffer(bb); - } - @Override public Stream list() throws IOException { if (closed) From 6b3c1e0f786a889d2ac25c8bd05f4d83e666425f Mon Sep 17 00:00:00 2001 From: Alexey Semenyuk Date: Tue, 6 Jan 2026 23:56:59 +0000 Subject: [PATCH 067/712] 8373833: "error.cert.not.found" and "error.explicit-sign-no-cert" errors duplicate each other Reviewed-by: almatvee --- .../jdk/jpackage/internal/SigningIdentityBuilder.java | 11 +++++------ .../internal/resources/MacResources.properties | 4 +--- test/jdk/tools/jpackage/share/ErrorTest.java | 8 +------- 3 files changed, 7 insertions(+), 16 deletions(-) diff --git a/src/jdk.jpackage/macosx/classes/jdk/jpackage/internal/SigningIdentityBuilder.java b/src/jdk.jpackage/macosx/classes/jdk/jpackage/internal/SigningIdentityBuilder.java index 87193783041..0f753c07569 100644 --- a/src/jdk.jpackage/macosx/classes/jdk/jpackage/internal/SigningIdentityBuilder.java +++ b/src/jdk.jpackage/macosx/classes/jdk/jpackage/internal/SigningIdentityBuilder.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 @@ -40,6 +40,7 @@ import javax.naming.ldap.Rdn; import javax.security.auth.x500.X500Principal; import jdk.jpackage.internal.MacCertificateUtils.CertificateHash; import jdk.jpackage.internal.model.ConfigException; +import jdk.jpackage.internal.model.JPackageException; import jdk.jpackage.internal.model.SigningIdentity; final class SigningIdentityBuilder { @@ -147,11 +148,9 @@ final class SigningIdentityBuilder { Objects.requireNonNull(keychain); switch (certs.size()) { case 0 -> { - var errMsg = I18N.format("error.cert.not.found", certificateSelector.signingIdentities().getFirst(), - keychain.map(Keychain::name).orElse("")); - Log.error(I18N.format("message.error-header", errMsg)); - throw I18N.buildConfigException("error.explicit-sign-no-cert") - .advice("error.explicit-sign-no-cert.advice").create(); + throw new JPackageException(I18N.format("error.cert.not.found", + certificateSelector.signingIdentities().getFirst(), + keychain.map(Keychain::name).orElse(""))); } case 1 -> { return certs.getFirst(); 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 d01297aa814..240e82dcc9b 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 @@ -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 @@ -24,8 +24,6 @@ # # error.invalid-cfbundle-version.advice=Set a compatible 'app-version' value. Valid versions are one to three integers separated by dots. -error.explicit-sign-no-cert=Signature explicitly requested but no signing certificate found -error.explicit-sign-no-cert.advice=Specify a valid mac-signing-key-user-name and mac-signing-keychain error.certificate.expired=Certificate expired {0} 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}] diff --git a/test/jdk/tools/jpackage/share/ErrorTest.java b/test/jdk/tools/jpackage/share/ErrorTest.java index 955c17e6043..bc12577fa20 100644 --- a/test/jdk/tools/jpackage/share/ErrorTest.java +++ b/test/jdk/tools/jpackage/share/ErrorTest.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 @@ -707,12 +707,6 @@ public final class ErrorTest { final List errorMessages = new ArrayList<>(); errorMessages.add(makeError(JPackageStringBundle.MAIN.cannedFormattedString( "error.cert.not.found", "Developer ID Application: " + signingId, ""))); - errorMessages.addAll(Stream.of( - Map.>entry("error.explicit-sign-no-cert", JPackageCommand::makeError), - Map.>entry("error.explicit-sign-no-cert.advice", JPackageCommand::makeAdvice) - ).map(e -> { - return e.getValue().apply(JPackageStringBundle.MAIN.cannedFormattedString(e.getKey())); - }).toList()); final var cmd = JPackageCommand.helloAppImage() .ignoreDefaultVerbose(true) From 5c6947f736568413d53d5a00de2e865f86e637c4 Mon Sep 17 00:00:00 2001 From: Thomas Schatzl Date: Wed, 7 Jan 2026 06:30:14 +0000 Subject: [PATCH 068/712] 8373429: gc/g1/TestCodeCacheUnloadDuringConcCycle fails on various platforms Reviewed-by: mbaesken, mdoerr --- .../jtreg/gc/g1/TestCodeCacheUnloadDuringConcCycle.java | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) diff --git a/test/hotspot/jtreg/gc/g1/TestCodeCacheUnloadDuringConcCycle.java b/test/hotspot/jtreg/gc/g1/TestCodeCacheUnloadDuringConcCycle.java index af746ad206d..e36ccace9dc 100644 --- a/test/hotspot/jtreg/gc/g1/TestCodeCacheUnloadDuringConcCycle.java +++ b/test/hotspot/jtreg/gc/g1/TestCodeCacheUnloadDuringConcCycle.java @@ -53,9 +53,9 @@ import java.util.regex.Matcher; import java.util.regex.Pattern; import jdk.test.lib.Asserts; +import jdk.test.lib.Platform; import jdk.test.lib.process.OutputAnalyzer; import jdk.test.lib.process.ProcessTools; -import static jdk.test.lib.Asserts.*; import jdk.test.whitebox.WhiteBox; public class TestCodeCacheUnloadDuringConcCycle { @@ -70,9 +70,10 @@ public class TestCodeCacheUnloadDuringConcCycle { "-Xbootclasspath/a:.", "-Xlog:gc=trace,codecache", "-XX:+WhiteBoxAPI", - "-XX:ReservedCodeCacheSize=8M", + "-XX:ReservedCodeCacheSize=" + (Platform.is32bit() ? "4M" : "8M"), "-XX:StartAggressiveSweepingAt=50", "-XX:CompileCommand=compileonly,gc.g1.SomeClass::*", + "-XX:CompileCommand=compileonly,gc.g1.Foo*::*", TestCodeCacheUnloadDuringConcCycleRunner.class.getName(), concPhase); return output; @@ -140,7 +141,7 @@ class TestCodeCacheUnloadDuringConcCycleRunner { System.out.println("Compiled " + i + " classes"); } i++; - } while (i < 1000); + } while (i < 200); System.out.println("Compilation done, compiled " + i + " classes"); } catch (Throwable t) { } From c1c0ac877033c3edb0c2681c2c5f825be8adcfb3 Mon Sep 17 00:00:00 2001 From: Damon Fenacci Date: Wed, 7 Jan 2026 07:29:00 +0000 Subject: [PATCH 069/712] 8342772: Assert in LateInlineMHCallGenerator::do_late_inline_check Reviewed-by: vlivanov, chagedorn, thartmann --- src/hotspot/share/opto/callGenerator.cpp | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/src/hotspot/share/opto/callGenerator.cpp b/src/hotspot/share/opto/callGenerator.cpp index db03dd9d80c..1465da02ac8 100644 --- a/src/hotspot/share/opto/callGenerator.cpp +++ b/src/hotspot/share/opto/callGenerator.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 @@ -418,7 +418,8 @@ bool LateInlineMHCallGenerator::do_late_inline_check(Compile* C, JVMState* jvms) C->inline_printer()->record(cg->method(), call_node()->jvms(), InliningResult::FAILURE, "late method handle call resolution"); } - assert(!cg->is_late_inline() || cg->is_mh_late_inline() || AlwaysIncrementalInline || StressIncrementalInlining, "we're doing late inlining"); + assert(!cg->is_late_inline() || cg->is_mh_late_inline() || cg->is_virtual_late_inline() || + AlwaysIncrementalInline || StressIncrementalInlining, "we're doing late inlining"); _inline_cg = cg; return true; } else { From a01283a5a57723673b1fd3c93434678fdae4102c Mon Sep 17 00:00:00 2001 From: Ana-Maria Mihalceanu Date: Wed, 7 Jan 2026 08:24:31 +0000 Subject: [PATCH 070/712] 8374632: Broken list layout in the man page of jlink Reviewed-by: jpai --- src/jdk.jlink/share/man/jlink.md | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/src/jdk.jlink/share/man/jlink.md b/src/jdk.jlink/share/man/jlink.md index 0d16e69c9ef..5c77202434c 100644 --- a/src/jdk.jlink/share/man/jlink.md +++ b/src/jdk.jlink/share/man/jlink.md @@ -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 @@ -70,6 +70,7 @@ Developers are responsible for updating their custom runtime images. and zip-9 provides the best compression. Default is zip-6. : Deprecated values to be removed in a future release: + - `0`: No compression. Use zip-0 instead. - `1`: Constant string sharing - `2`: ZIP. Use zip-6 instead. @@ -182,6 +183,7 @@ Description and zip-9 provides the best compression. Default is zip-6. : Deprecated values to be removed in a future release: + - Level 0: No compression. Use zip-0 instead. - Level 1: Constant string sharing - Level 2: ZIP. Use zip-6 instead. From 7e18de137c3b5f08a479af2b64eb22923261900b Mon Sep 17 00:00:00 2001 From: Volkan Yazici Date: Wed, 7 Jan 2026 09:22:38 +0000 Subject: [PATCH 071/712] 8374210: [BACKOUT] Move input validation checks to Java for java.lang.StringCoding intrinsics Reviewed-by: shade, thartmann --- .../cpu/aarch64/macroAssembler_aarch64.cpp | 12 +- .../cpu/riscv/c2_MacroAssembler_riscv.cpp | 12 +- src/hotspot/cpu/x86/macroAssembler_x86.cpp | 66 +++++------ src/hotspot/share/classfile/vmIntrinsics.hpp | 6 +- src/hotspot/share/opto/c2_globals.hpp | 3 - src/hotspot/share/opto/library_call.cpp | 57 +++------- src/hotspot/share/opto/library_call.hpp | 3 +- .../share/classes/java/lang/String.java | 2 +- .../share/classes/java/lang/StringCoding.java | 93 ++-------------- .../share/classes/java/lang/System.java | 5 +- .../jdk/internal/access/JavaLangAccess.java | 18 ++- .../share/classes/sun/nio/cs/CESU_8.java | 2 +- .../share/classes/sun/nio/cs/DoubleByte.java | 2 +- .../share/classes/sun/nio/cs/ISO_8859_1.java | 40 ++++--- .../share/classes/sun/nio/cs/SingleByte.java | 2 +- .../share/classes/sun/nio/cs/US_ASCII.java | 2 +- .../share/classes/sun/nio/cs/UTF_8.java | 2 +- .../sun/nio/cs/ext/EUC_JP.java.template | 2 +- .../intrinsics/TestVerifyIntrinsicChecks.java | 105 ------------------ .../intrinsics/string/TestCountPositives.java | 30 +---- .../string/TestEncodeIntrinsics.java | 22 +--- .../intrinsics/string/TestHasNegatives.java | 25 +---- .../patches/java.base/java/lang/Helper.java | 5 - 23 files changed, 105 insertions(+), 411 deletions(-) delete mode 100644 test/hotspot/jtreg/compiler/intrinsics/TestVerifyIntrinsicChecks.java diff --git a/src/hotspot/cpu/aarch64/macroAssembler_aarch64.cpp b/src/hotspot/cpu/aarch64/macroAssembler_aarch64.cpp index 2ccc755be3c..b8a9afc123f 100644 --- a/src/hotspot/cpu/aarch64/macroAssembler_aarch64.cpp +++ b/src/hotspot/cpu/aarch64/macroAssembler_aarch64.cpp @@ -6259,14 +6259,10 @@ void MacroAssembler::fill_words(Register base, Register cnt, Register value) // Intrinsic for // -// - sun.nio.cs.ISO_8859_1.Encoder#encodeISOArray0(byte[] sa, int sp, byte[] da, int dp, int len) -// Encodes char[] to byte[] in ISO-8859-1 -// -// - java.lang.StringCoding#encodeISOArray0(byte[] sa, int sp, byte[] da, int dp, int len) -// Encodes byte[] (containing UTF-16) to byte[] in ISO-8859-1 -// -// - java.lang.StringCoding#encodeAsciiArray0(char[] sa, int sp, byte[] da, int dp, int len) -// Encodes char[] to byte[] in ASCII +// - sun/nio/cs/ISO_8859_1$Encoder.implEncodeISOArray +// return the number of characters copied. +// - java/lang/StringUTF16.compress +// return index of non-latin1 character if copy fails, otherwise 'len'. // // This version always returns the number of characters copied, and does not // clobber the 'len' register. A successful copy will complete with the post- diff --git a/src/hotspot/cpu/riscv/c2_MacroAssembler_riscv.cpp b/src/hotspot/cpu/riscv/c2_MacroAssembler_riscv.cpp index dcf20752a21..824ea872935 100644 --- a/src/hotspot/cpu/riscv/c2_MacroAssembler_riscv.cpp +++ b/src/hotspot/cpu/riscv/c2_MacroAssembler_riscv.cpp @@ -2813,14 +2813,10 @@ void C2_MacroAssembler::char_array_compress_v(Register src, Register dst, Regist // Intrinsic for // -// - sun.nio.cs.ISO_8859_1.Encoder#encodeISOArray0(byte[] sa, int sp, byte[] da, int dp, int len) -// Encodes char[] to byte[] in ISO-8859-1 -// -// - java.lang.StringCoding#encodeISOArray0(byte[] sa, int sp, byte[] da, int dp, int len) -// Encodes byte[] (containing UTF-16) to byte[] in ISO-8859-1 -// -// - java.lang.StringCoding#encodeAsciiArray0(char[] sa, int sp, byte[] da, int dp, int len) -// Encodes char[] to byte[] in ASCII +// - sun/nio/cs/ISO_8859_1$Encoder.implEncodeISOArray +// return the number of characters copied. +// - java/lang/StringUTF16.compress +// return index of non-latin1 character if copy fails, otherwise 'len'. // // This version always returns the number of characters copied. A successful // copy will complete with the post-condition: 'res' == 'len', while an diff --git a/src/hotspot/cpu/x86/macroAssembler_x86.cpp b/src/hotspot/cpu/x86/macroAssembler_x86.cpp index 3f18d8c6262..be7deb884ce 100644 --- a/src/hotspot/cpu/x86/macroAssembler_x86.cpp +++ b/src/hotspot/cpu/x86/macroAssembler_x86.cpp @@ -6251,46 +6251,32 @@ void MacroAssembler::evpbroadcast(BasicType type, XMMRegister dst, Register src, } } -// Encode given char[]/byte[] to byte[] in ISO_8859_1 or ASCII -// -// @IntrinsicCandidate -// int sun.nio.cs.ISO_8859_1.Encoder#encodeISOArray0( -// char[] sa, int sp, byte[] da, int dp, int len) { -// int i = 0; -// for (; i < len; i++) { -// char c = sa[sp++]; -// if (c > '\u00FF') -// break; -// da[dp++] = (byte) c; -// } -// return i; -// } -// -// @IntrinsicCandidate -// int java.lang.StringCoding.encodeISOArray0( -// byte[] sa, int sp, byte[] da, int dp, int len) { -// int i = 0; -// for (; i < len; i++) { -// char c = StringUTF16.getChar(sa, sp++); -// if (c > '\u00FF') -// break; -// da[dp++] = (byte) c; -// } -// return i; -// } -// -// @IntrinsicCandidate -// int java.lang.StringCoding.encodeAsciiArray0( -// char[] sa, int sp, byte[] da, int dp, int len) { -// int i = 0; -// for (; i < len; i++) { -// char c = sa[sp++]; -// if (c >= '\u0080') -// break; -// da[dp++] = (byte) c; -// } -// return i; -// } +// encode char[] to byte[] in ISO_8859_1 or ASCII + //@IntrinsicCandidate + //private static int implEncodeISOArray(byte[] sa, int sp, + //byte[] da, int dp, int len) { + // int i = 0; + // for (; i < len; i++) { + // char c = StringUTF16.getChar(sa, sp++); + // if (c > '\u00FF') + // break; + // da[dp++] = (byte)c; + // } + // return i; + //} + // + //@IntrinsicCandidate + //private static int implEncodeAsciiArray(char[] sa, int sp, + // byte[] da, int dp, int len) { + // int i = 0; + // for (; i < len; i++) { + // char c = sa[sp++]; + // if (c >= '\u0080') + // break; + // da[dp++] = (byte)c; + // } + // return i; + //} void MacroAssembler::encode_iso_array(Register src, Register dst, Register len, XMMRegister tmp1Reg, XMMRegister tmp2Reg, XMMRegister tmp3Reg, XMMRegister tmp4Reg, diff --git a/src/hotspot/share/classfile/vmIntrinsics.hpp b/src/hotspot/share/classfile/vmIntrinsics.hpp index 6f9c2326a45..07fa294e8e1 100644 --- a/src/hotspot/share/classfile/vmIntrinsics.hpp +++ b/src/hotspot/share/classfile/vmIntrinsics.hpp @@ -415,18 +415,18 @@ class methodHandle; \ do_class(java_lang_StringCoding, "java/lang/StringCoding") \ do_intrinsic(_countPositives, java_lang_StringCoding, countPositives_name, countPositives_signature, F_S) \ - do_name( countPositives_name, "countPositives0") \ + do_name( countPositives_name, "countPositives") \ do_signature(countPositives_signature, "([BII)I") \ \ do_class(sun_nio_cs_iso8859_1_Encoder, "sun/nio/cs/ISO_8859_1$Encoder") \ do_intrinsic(_encodeISOArray, sun_nio_cs_iso8859_1_Encoder, encodeISOArray_name, encodeISOArray_signature, F_S) \ - do_name( encodeISOArray_name, "encodeISOArray0") \ + do_name( encodeISOArray_name, "implEncodeISOArray") \ do_signature(encodeISOArray_signature, "([CI[BII)I") \ \ do_intrinsic(_encodeByteISOArray, java_lang_StringCoding, encodeISOArray_name, indexOfI_signature, F_S) \ \ do_intrinsic(_encodeAsciiArray, java_lang_StringCoding, encodeAsciiArray_name, encodeISOArray_signature, F_S) \ - do_name( encodeAsciiArray_name, "encodeAsciiArray0") \ + do_name( encodeAsciiArray_name, "implEncodeAsciiArray") \ \ do_class(java_math_BigInteger, "java/math/BigInteger") \ do_intrinsic(_multiplyToLen, java_math_BigInteger, multiplyToLen_name, multiplyToLen_signature, F_S) \ diff --git a/src/hotspot/share/opto/c2_globals.hpp b/src/hotspot/share/opto/c2_globals.hpp index 7fa3ca638c2..f470049bf7e 100644 --- a/src/hotspot/share/opto/c2_globals.hpp +++ b/src/hotspot/share/opto/c2_globals.hpp @@ -675,9 +675,6 @@ product(bool, PrintIntrinsics, false, DIAGNOSTIC, \ "prints attempted and successful inlining of intrinsics") \ \ - develop(bool, VerifyIntrinsicChecks, false, \ - "Verify in intrinsic that Java level checks work as expected") \ - \ develop(bool, StressReflectiveCode, false, \ "Use inexact types at allocations, etc., to test reflection") \ \ diff --git a/src/hotspot/share/opto/library_call.cpp b/src/hotspot/share/opto/library_call.cpp index a057f66a989..2c2a7c020b8 100644 --- a/src/hotspot/share/opto/library_call.cpp +++ b/src/hotspot/share/opto/library_call.cpp @@ -940,11 +940,7 @@ inline Node* LibraryCallKit::generate_limit_guard(Node* offset, } // Emit range checks for the given String.value byte array -void LibraryCallKit::generate_string_range_check(Node* array, - Node* offset, - Node* count, - bool char_count, - bool halt_on_oob) { +void LibraryCallKit::generate_string_range_check(Node* array, Node* offset, Node* count, bool char_count) { if (stopped()) { return; // already stopped } @@ -962,17 +958,10 @@ void LibraryCallKit::generate_string_range_check(Node* array, generate_limit_guard(offset, count, load_array_length(array), bailout); 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); - } + PreserveJVMState pjvms(this); + set_control(_gvn.transform(bailout)); + uncommon_trap(Deoptimization::Reason_intrinsic, + Deoptimization::Action_maybe_recompile); } } @@ -1130,7 +1119,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; @@ -1142,14 +1130,13 @@ bool LibraryCallKit::inline_countPositives() { Node* offset = argument(1); Node* len = argument(2); - if (VerifyIntrinsicChecks) { - ba = must_be_not_null(ba, true); - generate_string_range_check(ba, offset, len, false, true); - if (stopped()) { - return true; - } - } + ba = must_be_not_null(ba, true); + // Range checks + generate_string_range_check(ba, offset, len, false); + if (stopped()) { + return true; + } Node* ba_start = array_element_address(ba, offset, T_BYTE); Node* result = new CountPositivesNode(control(), memory(TypeAryPtr::BYTES), ba_start, len); set_result(_gvn.transform(result)); @@ -6184,9 +6171,6 @@ CallStaticJavaNode* LibraryCallKit::get_uncommon_trap_from_success_proj(Node* no } //-------------inline_encodeISOArray----------------------------------- -// int sun.nio.cs.ISO_8859_1.Encoder#encodeISOArray0(byte[] sa, int sp, byte[] da, int dp, int len) -// int java.lang.StringCoding#encodeISOArray0(byte[] sa, int sp, byte[] da, int dp, int len) -// int java.lang.StringCoding#encodeAsciiArray0(char[] sa, int sp, byte[] da, int dp, int len) // encode char[] to byte[] in ISO_8859_1 or ASCII bool LibraryCallKit::inline_encodeISOArray(bool ascii) { assert(callee()->signature()->size() == 5, "encodeISOArray has 5 parameters"); @@ -6197,14 +6181,8 @@ bool LibraryCallKit::inline_encodeISOArray(bool ascii) { Node *dst_offset = argument(3); Node *length = argument(4); - // Cast source & target arrays to not-null - if (VerifyIntrinsicChecks) { - src = must_be_not_null(src, true); - dst = must_be_not_null(dst, true); - if (stopped()) { - return true; - } - } + src = must_be_not_null(src, true); + dst = must_be_not_null(dst, true); const TypeAryPtr* src_type = src->Value(&_gvn)->isa_aryptr(); const TypeAryPtr* dst_type = dst->Value(&_gvn)->isa_aryptr(); @@ -6221,15 +6199,6 @@ bool LibraryCallKit::inline_encodeISOArray(bool ascii) { return false; } - // Check source & target bounds - if (VerifyIntrinsicChecks) { - 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()) { - return true; - } - } - Node* src_start = array_element_address(src, src_offset, T_CHAR); Node* dst_start = array_element_address(dst, dst_offset, dst_elem); // 'src_start' points to src array + scaled offset diff --git a/src/hotspot/share/opto/library_call.hpp b/src/hotspot/share/opto/library_call.hpp index bfe29814dec..00ba4c795f1 100644 --- a/src/hotspot/share/opto/library_call.hpp +++ b/src/hotspot/share/opto/library_call.hpp @@ -163,8 +163,7 @@ class LibraryCallKit : public GraphKit { Node* array_length, RegionNode* region); void generate_string_range_check(Node* array, Node* offset, - Node* length, bool char_count, - bool halt_on_oob = false); + Node* length, bool char_count); Node* current_thread_helper(Node* &tls_output, ByteSize handle_offset, bool is_immutable); Node* generate_current_thread(Node* &tls_output); diff --git a/src/java.base/share/classes/java/lang/String.java b/src/java.base/share/classes/java/lang/String.java index d7aef113e15..d3eda052740 100644 --- a/src/java.base/share/classes/java/lang/String.java +++ b/src/java.base/share/classes/java/lang/String.java @@ -1111,7 +1111,7 @@ public final class String int sp = 0; int sl = len; while (sp < sl) { - int ret = StringCoding.encodeISOArray(val, sp, dst, dp, len); + int ret = StringCoding.implEncodeISOArray(val, sp, dst, dp, len); sp = sp + ret; dp = dp + ret; if (ret != len) { diff --git a/src/java.base/share/classes/java/lang/StringCoding.java b/src/java.base/share/classes/java/lang/StringCoding.java index 545f216b755..c02af28c37d 100644 --- a/src/java.base/share/classes/java/lang/StringCoding.java +++ b/src/java.base/share/classes/java/lang/StringCoding.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2000, 2025, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2000, 2024, 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,11 +26,8 @@ package java.lang; -import jdk.internal.util.Preconditions; import jdk.internal.vm.annotation.IntrinsicCandidate; -import java.util.function.BiFunction; - /** * Utility class for string encoding and decoding. */ @@ -41,7 +38,7 @@ class StringCoding { /** * Count the number of leading non-zero ascii chars in the range. */ - static int countNonZeroAscii(String s) { + public static int countNonZeroAscii(String s) { byte[] value = s.value(); if (s.isLatin1()) { return countNonZeroAsciiLatin1(value, 0, value.length); @@ -53,7 +50,7 @@ class StringCoding { /** * Count the number of non-zero ascii chars in the range. */ - private static int countNonZeroAsciiLatin1(byte[] ba, int off, int len) { + public static int countNonZeroAsciiLatin1(byte[] ba, int off, int len) { int limit = off + len; for (int i = off; i < limit; i++) { if (ba[i] <= 0) { @@ -66,7 +63,7 @@ class StringCoding { /** * Count the number of leading non-zero ascii chars in the range. */ - private static int countNonZeroAsciiUTF16(byte[] ba, int off, int strlen) { + public static int countNonZeroAsciiUTF16(byte[] ba, int off, int strlen) { int limit = off + strlen; for (int i = off; i < limit; i++) { char c = StringUTF16.charAt(ba, i); @@ -77,7 +74,7 @@ class StringCoding { return strlen; } - static boolean hasNegatives(byte[] ba, int off, int len) { + public static boolean hasNegatives(byte[] ba, int off, int len) { return countPositives(ba, off, len) != len; } @@ -88,24 +85,9 @@ class StringCoding { * bytes in the range. If there are negative bytes, the implementation must return * a value that is less than or equal to the index of the first negative byte * in the range. - * - * @param ba a byte array - * @param off the index of the first byte to start reading from - * @param len the total number of bytes to read - * @throws NullPointerException if {@code ba} is null - * @throws ArrayIndexOutOfBoundsException if the provided sub-range is - * {@linkplain Preconditions#checkFromIndexSize(int, int, int, BiFunction) out of bounds} */ - static int countPositives(byte[] ba, int off, int len) { - Preconditions.checkFromIndexSize( - off, len, - ba.length, // Implicit null check on `ba` - Preconditions.AIOOBE_FORMATTER); - return countPositives0(ba, off, len); - } - @IntrinsicCandidate - private static int countPositives0(byte[] ba, int off, int len) { + public static int countPositives(byte[] ba, int off, int len) { int limit = off + len; for (int i = off; i < limit; i++) { if (ba[i] < 0) { @@ -115,37 +97,9 @@ class StringCoding { return len; } - /** - * Encodes as many ISO-8859-1 codepoints as possible from the source byte - * array containing characters encoded in UTF-16, into the destination byte - * array, assuming that the encoding is ISO-8859-1 compatible. - * - * @param sa the source byte array containing characters encoded in UTF-16 - * @param sp the index of the character (not byte!) from the source array to start reading from - * @param da the target byte array - * @param dp the index of the target array to start writing to - * @param len the maximum number of characters (not bytes!) to be encoded - * @return the total number of characters (not bytes!) successfully encoded - * @throws NullPointerException if any of the provided arrays is null - */ - static int encodeISOArray(byte[] sa, int sp, - byte[] da, int dp, int len) { - // This method should tolerate invalid arguments, matching the lenient behavior of the VM intrinsic. - // Hence, using operator expressions instead of `Preconditions`, which throw on failure. - int sl; - if ((sp | dp | len) < 0 || - // Halving the length of `sa` to obtain the number of characters: - sp >= (sl = sa.length >>> 1) || // Implicit null check on `sa` - dp >= da.length) { // Implicit null check on `da` - return 0; - } - int minLen = Math.min(len, Math.min(sl - sp, da.length - dp)); - return encodeISOArray0(sa, sp, da, dp, minLen); - } - @IntrinsicCandidate - private static int encodeISOArray0(byte[] sa, int sp, - byte[] da, int dp, int len) { + public static int implEncodeISOArray(byte[] sa, int sp, + byte[] da, int dp, int len) { int i = 0; for (; i < len; i++) { char c = StringUTF16.getChar(sa, sp++); @@ -156,35 +110,10 @@ class StringCoding { return i; } - /** - * Encodes as many ASCII codepoints as possible from the source - * character array into the destination byte array, assuming that - * the encoding is ASCII compatible. - * - * @param sa the source character array - * @param sp the index of the source array to start reading from - * @param da the target byte array - * @param dp the index of the target array to start writing to - * @param len the maximum number of characters to be encoded - * @return the total number of characters successfully encoded - * @throws NullPointerException if any of the provided arrays is null - */ - static int encodeAsciiArray(char[] sa, int sp, - byte[] da, int dp, int len) { - // This method should tolerate invalid arguments, matching the lenient behavior of the VM intrinsic. - // Hence, using operator expressions instead of `Preconditions`, which throw on failure. - if ((sp | dp | len) < 0 || - sp >= sa.length || // Implicit null check on `sa` - dp >= da.length) { // Implicit null check on `da` - return 0; - } - int minLen = Math.min(len, Math.min(sa.length - sp, da.length - dp)); - return encodeAsciiArray0(sa, sp, da, dp, minLen); - } - @IntrinsicCandidate - static int encodeAsciiArray0(char[] sa, int sp, - byte[] da, int dp, int len) { + public static int implEncodeAsciiArray(char[] sa, int sp, + byte[] da, int dp, int len) + { int i = 0; for (; i < len; i++) { char c = sa[sp++]; diff --git a/src/java.base/share/classes/java/lang/System.java b/src/java.base/share/classes/java/lang/System.java index 5c2b47afe3d..f3a57c34165 100644 --- a/src/java.base/share/classes/java/lang/System.java +++ b/src/java.base/share/classes/java/lang/System.java @@ -55,6 +55,7 @@ import java.util.Properties; import java.util.ResourceBundle; import java.util.Set; import java.util.concurrent.Executor; +import java.util.concurrent.ScheduledExecutorService; import java.util.function.Supplier; import java.util.concurrent.ConcurrentHashMap; import java.util.stream.Stream; @@ -2176,8 +2177,8 @@ public final class System { return String.decodeASCII(src, srcOff, dst, dstOff, len); } - public int encodeASCII(char[] sa, int sp, byte[] da, int dp, int len) { - return StringCoding.encodeAsciiArray(sa, sp, da, dp, len); + public int uncheckedEncodeASCII(char[] src, int srcOff, byte[] dst, int dstOff, int len) { + return StringCoding.implEncodeAsciiArray(src, srcOff, dst, dstOff, len); } public InputStream initialSystemIn() { diff --git a/src/java.base/share/classes/jdk/internal/access/JavaLangAccess.java b/src/java.base/share/classes/jdk/internal/access/JavaLangAccess.java index 86e5f317dc7..c5c45ca3553 100644 --- a/src/java.base/share/classes/jdk/internal/access/JavaLangAccess.java +++ b/src/java.base/share/classes/jdk/internal/access/JavaLangAccess.java @@ -448,19 +448,15 @@ public interface JavaLangAccess { PrintStream initialSystemErr(); /** - * Encodes as many ASCII codepoints as possible from the source - * character array into the destination byte array, assuming that - * the encoding is ASCII compatible. + * Encodes as many ASCII codepoints as possible from the source array into + * the destination byte array, assuming that the encoding is ASCII + * compatible. + *

+ * WARNING: This method does not perform any bound checks. * - * @param sa the source character array - * @param sp the index of the source array to start reading from - * @param da the target byte array - * @param dp the index of the target array to start writing to - * @param len the total number of characters to be encoded - * @return the total number of characters successfully encoded - * @throws NullPointerException if any of the provided arrays is null + * @return the number of bytes successfully encoded, or 0 if none */ - int encodeASCII(char[] sa, int sp, byte[] da, int dp, int len); + int uncheckedEncodeASCII(char[] src, int srcOff, byte[] dst, int dstOff, int len); /** * Set the cause of Throwable diff --git a/src/java.base/share/classes/sun/nio/cs/CESU_8.java b/src/java.base/share/classes/sun/nio/cs/CESU_8.java index 409b375ec88..11f21f56139 100644 --- a/src/java.base/share/classes/sun/nio/cs/CESU_8.java +++ b/src/java.base/share/classes/sun/nio/cs/CESU_8.java @@ -445,7 +445,7 @@ class CESU_8 extends Unicode int dl = dst.arrayOffset() + dst.limit(); // Handle ASCII-only prefix - int n = JLA.encodeASCII(sa, sp, da, dp, Math.min(sl - sp, dl - dp)); + int n = JLA.uncheckedEncodeASCII(sa, sp, da, dp, Math.min(sl - sp, dl - dp)); sp += n; dp += n; diff --git a/src/java.base/share/classes/sun/nio/cs/DoubleByte.java b/src/java.base/share/classes/sun/nio/cs/DoubleByte.java index 0969669a35b..2a4dbdc95ed 100644 --- a/src/java.base/share/classes/sun/nio/cs/DoubleByte.java +++ b/src/java.base/share/classes/sun/nio/cs/DoubleByte.java @@ -600,7 +600,7 @@ public class DoubleByte { try { if (isASCIICompatible) { - int n = JLA.encodeASCII(sa, sp, da, dp, Math.min(dl - dp, sl - sp)); + int n = JLA.uncheckedEncodeASCII(sa, sp, da, dp, Math.min(dl - dp, sl - sp)); sp += n; dp += n; } diff --git a/src/java.base/share/classes/sun/nio/cs/ISO_8859_1.java b/src/java.base/share/classes/sun/nio/cs/ISO_8859_1.java index ff5970e92a8..39215bfa93d 100644 --- a/src/java.base/share/classes/sun/nio/cs/ISO_8859_1.java +++ b/src/java.base/share/classes/sun/nio/cs/ISO_8859_1.java @@ -35,6 +35,7 @@ import java.util.Objects; import jdk.internal.access.JavaLangAccess; import jdk.internal.access.SharedSecrets; +import jdk.internal.util.Preconditions; import jdk.internal.vm.annotation.IntrinsicCandidate; public class ISO_8859_1 @@ -141,34 +142,20 @@ public class ISO_8859_1 private final Surrogate.Parser sgp = new Surrogate.Parser(); - /** - * Encodes as many ISO-8859-1 codepoints as possible from the source - * character array into the destination byte array, assuming that - * the encoding is ISO-8859-1 compatible. - * - * @param sa the source character array - * @param sp the index of the source array to start reading from - * @param da the target byte array - * @param dp the index of the target array to start writing to - * @param len the maximum number of characters to be encoded - * @return the total number of characters successfully encoded - * @throws NullPointerException if any of the provided arrays is null - */ + // Method possible replaced with a compiler intrinsic. private static int encodeISOArray(char[] sa, int sp, byte[] da, int dp, int len) { - // This method should tolerate invalid arguments, matching the lenient behavior of the VM intrinsic. - // Hence, using operator expressions instead of `Preconditions`, which throw on failure. - if ((sp | dp | len) < 0 || - sp >= sa.length || // Implicit null check on `sa` - dp >= da.length) { // Implicit null check on `da` + if (len <= 0) { return 0; } - int minLen = Math.min(len, Math.min(sa.length - sp, da.length - dp)); - return encodeISOArray0(sa, sp, da, dp, minLen); + encodeISOArrayCheck(sa, sp, da, dp, len); + return implEncodeISOArray(sa, sp, da, dp, len); } @IntrinsicCandidate - private static int encodeISOArray0(char[] sa, int sp, byte[] da, int dp, int len) { + private static int implEncodeISOArray(char[] sa, int sp, + byte[] da, int dp, int len) + { int i = 0; for (; i < len; i++) { char c = sa[sp++]; @@ -179,6 +166,17 @@ public class ISO_8859_1 return i; } + private static void encodeISOArrayCheck(char[] sa, int sp, + byte[] da, int dp, int len) { + Objects.requireNonNull(sa); + Objects.requireNonNull(da); + Preconditions.checkIndex(sp, sa.length, Preconditions.AIOOBE_FORMATTER); + Preconditions.checkIndex(dp, da.length, Preconditions.AIOOBE_FORMATTER); + + Preconditions.checkIndex(sp + len - 1, sa.length, Preconditions.AIOOBE_FORMATTER); + Preconditions.checkIndex(dp + len - 1, da.length, Preconditions.AIOOBE_FORMATTER); + } + private CoderResult encodeArrayLoop(CharBuffer src, ByteBuffer dst) { diff --git a/src/java.base/share/classes/sun/nio/cs/SingleByte.java b/src/java.base/share/classes/sun/nio/cs/SingleByte.java index a5bf06cb251..59887b944d3 100644 --- a/src/java.base/share/classes/sun/nio/cs/SingleByte.java +++ b/src/java.base/share/classes/sun/nio/cs/SingleByte.java @@ -217,7 +217,7 @@ public class SingleByte int len = Math.min(dl - dp, sl - sp); if (isASCIICompatible) { - int n = JLA.encodeASCII(sa, sp, da, dp, len); + int n = JLA.uncheckedEncodeASCII(sa, sp, da, dp, len); sp += n; dp += n; len -= n; diff --git a/src/java.base/share/classes/sun/nio/cs/US_ASCII.java b/src/java.base/share/classes/sun/nio/cs/US_ASCII.java index 3886978d209..bb84ab1bd4b 100644 --- a/src/java.base/share/classes/sun/nio/cs/US_ASCII.java +++ b/src/java.base/share/classes/sun/nio/cs/US_ASCII.java @@ -159,7 +159,7 @@ public class US_ASCII assert (dp <= dl); dp = (dp <= dl ? dp : dl); - int n = JLA.encodeASCII(sa, sp, da, dp, Math.min(sl - sp, dl - dp)); + int n = JLA.uncheckedEncodeASCII(sa, sp, da, dp, Math.min(sl - sp, dl - dp)); sp += n; dp += n; diff --git a/src/java.base/share/classes/sun/nio/cs/UTF_8.java b/src/java.base/share/classes/sun/nio/cs/UTF_8.java index d2d6d7e485d..54e479f838a 100644 --- a/src/java.base/share/classes/sun/nio/cs/UTF_8.java +++ b/src/java.base/share/classes/sun/nio/cs/UTF_8.java @@ -452,7 +452,7 @@ public final class UTF_8 extends Unicode { int dl = dst.arrayOffset() + dst.limit(); // Handle ASCII-only prefix - int n = JLA.encodeASCII(sa, sp, da, dp, Math.min(sl - sp, dl - dp)); + int n = JLA.uncheckedEncodeASCII(sa, sp, da, dp, Math.min(sl - sp, dl - dp)); sp += n; dp += n; diff --git a/src/jdk.charsets/share/classes/sun/nio/cs/ext/EUC_JP.java.template b/src/jdk.charsets/share/classes/sun/nio/cs/ext/EUC_JP.java.template index f3d03a9e9c7..4fc0b2796ee 100644 --- a/src/jdk.charsets/share/classes/sun/nio/cs/ext/EUC_JP.java.template +++ b/src/jdk.charsets/share/classes/sun/nio/cs/ext/EUC_JP.java.template @@ -309,7 +309,7 @@ public class EUC_JP try { if (enc0201.isASCIICompatible()) { - int n = JLA.encodeASCII(sa, sp, da, dp, Math.min(dl - dp, sl - sp)); + int n = JLA.uncheckedEncodeASCII(sa, sp, da, dp, Math.min(dl - dp, sl - sp)); sp += n; dp += n; } diff --git a/test/hotspot/jtreg/compiler/intrinsics/TestVerifyIntrinsicChecks.java b/test/hotspot/jtreg/compiler/intrinsics/TestVerifyIntrinsicChecks.java deleted file mode 100644 index c482a73affd..00000000000 --- a/test/hotspot/jtreg/compiler/intrinsics/TestVerifyIntrinsicChecks.java +++ /dev/null @@ -1,105 +0,0 @@ -/* - * Copyright (c) 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 8361842 - * @summary Verify the effectiveness of the `VerifyIntrinsicChecks` VM flag - * through (bypassing `StringCoding::encodeAsciiArray`, and) feeding - * invalid input to an intrinsified `StringCoding::encodeAsciiArray0` - * (note the `0` suffix!). - * @library /compiler/patches - * @library /test/lib - * @build java.base/java.lang.Helper - * @comment `vm.debug == true` is required since `VerifyIntrinsicChecks` is a - * development flag - * @requires vm.debug == true & vm.flavor == "server" & !vm.graal.enabled - * @requires (os.arch != "riscv64" | (os.arch == "riscv64" & vm.cpu.features ~= ".*rvv.*")) - * @run main/othervm compiler.intrinsics.TestVerifyIntrinsicChecks verify - */ - -package compiler.intrinsics; - -import java.lang.Helper; -import java.time.Instant; -import jdk.test.lib.process.ProcessTools; -import jdk.test.lib.process.OutputAnalyzer; - -public final class TestVerifyIntrinsicChecks { - - public static void main(String[] args) throws Exception { - switch (args[0]) { - case "verify" -> { - log("Starting JVM in a separate process to verify the crash"); - OutputAnalyzer outputAnalyzer = ProcessTools.executeTestJava( - "-Xcomp", - "-XX:-TieredCompilation", - "-XX:CompileCommand=inline,java.lang.StringCoding::encodeAsciiArray0", - "-XX:+VerifyIntrinsicChecks", - "--patch-module", "java.base=%s/java.base".formatted(System.getProperty("test.patch.path")), - "compiler.intrinsics.TestVerifyIntrinsicChecks", - "crash"); - outputAnalyzer.shouldContain("unexpected null in intrinsic"); - outputAnalyzer.shouldNotHaveExitValue(0); - } - case "crash" -> { - log("Triggering the crash"); - warmUpIntrinsicMethod(); - violateIntrinsicMethodContract(); - } - default -> throw new IllegalArgumentException(); - } - } - - private static void warmUpIntrinsicMethod() { - log("Warming up the intrinsic method"); - char[] sa = createAsciiChars(8192); - byte[] sp = new byte[4096]; - for (int i = 0; i < 1_000; i++) { - Helper.StringCodingEncodeAsciiArray0(sa, i, sp, 0, sp.length - i); - } - } - - private static char[] createAsciiChars(int length) { - char[] buffer = new char[length]; - for (int i = 0; i < length; i++) { - buffer[i] = (char) (i % '\u0080'); - } - return buffer; - } - - private static void violateIntrinsicMethodContract() { - log("Violating the intrinsic method contract (sa=null)"); - Helper.StringCodingEncodeAsciiArray0(null, 1, null, 1, 1); - } - - private synchronized static void log(String format, Object... args) { - Object[] extendedArgs = new Object[2 + args.length]; - extendedArgs[0] = Instant.now(); - extendedArgs[1] = Thread.currentThread().getName(); - System.arraycopy(args, 0, extendedArgs, extendedArgs.length - args.length, args.length); - String extendedFormat = "%%s [%%s] %s%%n".formatted(format); - System.out.printf(extendedFormat, extendedArgs); - } - -} diff --git a/test/hotspot/jtreg/compiler/intrinsics/string/TestCountPositives.java b/test/hotspot/jtreg/compiler/intrinsics/string/TestCountPositives.java index 1c20a49d281..76ef4766159 100644 --- a/test/hotspot/jtreg/compiler/intrinsics/string/TestCountPositives.java +++ b/test/hotspot/jtreg/compiler/intrinsics/string/TestCountPositives.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2022, 2025, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2022, 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 @@ -32,7 +32,6 @@ * @build java.base/java.lang.Helper * @run main compiler.intrinsics.string.TestCountPositives */ - /* * @test * @bug 8281146 8318509 @@ -47,38 +46,17 @@ * @run main/othervm/timeout=1200 -XX:UseAVX=3 compiler.intrinsics.string.TestCountPositives * @run main/othervm/timeout=1200 -XX:UseAVX=3 -XX:+UnlockDiagnosticVMOptions -XX:AVX3Threshold=0 compiler.intrinsics.string.TestCountPositives */ - -/* - * @test - * @bug 8281146 - * @summary Verify `StringCoding::countPositives` intrinsic Java wrapper checks - * by enabling the ones in the VM intrinsic using - * `-XX:+VerifyIntrinsicChecks` - * @comment This does not check out-of-range conditions. The - * `-XX:+VerifyIntrinsicChecks` version of this test simply ensures - * that the VM intrinsic will produce no spurious errors. - * @key randomness - * @library /compiler/patches - * @library /test/lib - * @comment `vm.debug == true` is required since `VerifyIntrinsicChecks` is a - * development flag - * @requires vm.debug == true - * @build java.base/java.lang.Helper - * @run main/othervm - * -XX:+VerifyIntrinsicChecks - * compiler.intrinsics.string.TestCountPositives +/** + * This test was derived from compiler.intrinsics.string.TestHasNegatives */ - package compiler.intrinsics.string; import java.lang.Helper; import java.util.Random; +import java.util.stream.IntStream; import jdk.test.lib.Utils; -/** - * This test was derived from {@link TestHasNegatives}. - */ public class TestCountPositives { private static byte[] bytes = new byte[4096 + 32]; diff --git a/test/hotspot/jtreg/compiler/intrinsics/string/TestEncodeIntrinsics.java b/test/hotspot/jtreg/compiler/intrinsics/string/TestEncodeIntrinsics.java index bb343b246ff..38a516e7521 100644 --- a/test/hotspot/jtreg/compiler/intrinsics/string/TestEncodeIntrinsics.java +++ b/test/hotspot/jtreg/compiler/intrinsics/string/TestEncodeIntrinsics.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2013, 2025, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2013, 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 @@ -31,26 +31,6 @@ * @run main/othervm/timeout=1200 --add-opens=java.base/sun.nio.cs=ALL-UNNAMED -Xbatch -Xmx256m compiler.intrinsics.string.TestEncodeIntrinsics */ -/* - * @test - * @bug 6896617 8274242 - * @summary Verify `sun.nio.cs.ISO_8859_1.Encoder::encodeISOArray` intrinsic - * Java wrapper checks by enabling the ones in the VM intrinsic using - * `-XX:+VerifyIntrinsicChecks` - * @comment This does not check out-of-range conditions. The - * `-XX:+VerifyIntrinsicChecks` version of this test simply ensures - * that the VM intrinsic will produce no spurious errors. - * @key randomness - * @library /test/lib - * @comment `vm.debug == true` is required since `VerifyIntrinsicChecks` is a - * development flag - * @requires vm.debug == true - * @run main/othervm/timeout=1200 - * -XX:+VerifyIntrinsicChecks - * --add-opens=java.base/sun.nio.cs=ALL-UNNAMED -Xbatch -Xmx256m - * compiler.intrinsics.string.TestEncodeIntrinsics - */ - package compiler.intrinsics.string; import jdk.test.lib.Utils; diff --git a/test/hotspot/jtreg/compiler/intrinsics/string/TestHasNegatives.java b/test/hotspot/jtreg/compiler/intrinsics/string/TestHasNegatives.java index a15f6aade2e..6edf2dc2e56 100644 --- a/test/hotspot/jtreg/compiler/intrinsics/string/TestHasNegatives.java +++ b/test/hotspot/jtreg/compiler/intrinsics/string/TestHasNegatives.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2016, 2025, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2016, 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 @@ -31,7 +31,6 @@ * @build java.base/java.lang.Helper * @run main compiler.intrinsics.string.TestHasNegatives */ - /* * @test * @bug 8054307 8318509 @@ -47,31 +46,11 @@ * @run main/othervm/timeout=1200 -XX:UseAVX=3 -XX:+UnlockDiagnosticVMOptions -XX:AVX3Threshold=0 compiler.intrinsics.string.TestHasNegatives */ -/* - * @test - * @bug 8054307 - * @summary Verify `StringCoding::hasNegatives` intrinsic Java wrapper checks - * by enabling the ones in the VM intrinsic using - * `-XX:+VerifyIntrinsicChecks` - * @comment This does not check out-of-range conditions. The - * `-XX:+VerifyIntrinsicChecks` version of this test simply ensures - * that the VM intrinsic will produce no spurious errors. - * @key randomness - * @library /compiler/patches - * @library /test/lib - * @comment `vm.debug == true` is required since `VerifyIntrinsicChecks` is a - * development flag - * @requires vm.debug == true - * @build java.base/java.lang.Helper - * @run main/othervm - * -XX:+VerifyIntrinsicChecks - * compiler.intrinsics.string.TestHasNegatives - */ - package compiler.intrinsics.string; import java.lang.Helper; import java.util.Random; +import java.util.stream.IntStream; import jdk.test.lib.Utils; 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 3985ad8ea90..e6c8b68fc6f 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 @@ -39,11 +39,6 @@ public class Helper { return StringCoding.countPositives(ba, off, len); } - @jdk.internal.vm.annotation.ForceInline - public static int StringCodingEncodeAsciiArray0(char[] sa, int sp, byte[] da, int dp, int len) { - return StringCoding.encodeAsciiArray0(sa, sp, da, dp, len); - } - @jdk.internal.vm.annotation.ForceInline public static byte[] compressByte(byte[] src, int srcOff, int dstSize, int dstOff, int len) { byte[] dst = new byte[dstSize]; From 2074b975c3d08fec2ecd47dab48132be2ec7c3cf Mon Sep 17 00:00:00 2001 From: Kim Barrett Date: Wed, 7 Jan 2026 10:06:29 +0000 Subject: [PATCH 072/712] 8374623: Move DependentAlwaysFalse variable template to its own file Reviewed-by: jsjolen --- .../metaprogramming/dependentAlwaysFalse.hpp | 36 +++++++++++++++++++ src/hotspot/share/runtime/atomic.hpp | 3 +- .../share/utilities/globalDefinitions.hpp | 10 +----- src/hotspot/share/utilities/lockFreeStack.hpp | 3 +- 4 files changed, 41 insertions(+), 11 deletions(-) create mode 100644 src/hotspot/share/metaprogramming/dependentAlwaysFalse.hpp diff --git a/src/hotspot/share/metaprogramming/dependentAlwaysFalse.hpp b/src/hotspot/share/metaprogramming/dependentAlwaysFalse.hpp new file mode 100644 index 00000000000..b1f9d89df11 --- /dev/null +++ b/src/hotspot/share/metaprogramming/dependentAlwaysFalse.hpp @@ -0,0 +1,36 @@ +/* + * 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. + * + */ + +#ifndef SHARE_METAPROGRAMMING_DEPENDENTALWAYSFALSE_HPP +#define SHARE_METAPROGRAMMING_DEPENDENTALWAYSFALSE_HPP + +// This provides a workaround for static_assert(false) in discarded or +// otherwise uninstantiated places. Instead use +// static_assert(DependentAlwaysFalse, "...") +// See http://wg21.link/p2593r1. Some, but not all, compiler versions we're +// using have implemented that change as a DR: +// https://cplusplus.github.io/CWG/issues/2518.html +template inline constexpr bool DependentAlwaysFalse = false; + +#endif // SHARE_METAPROGRAMMING_DEPENDENTALWAYSFALSE_HPP diff --git a/src/hotspot/share/runtime/atomic.hpp b/src/hotspot/share/runtime/atomic.hpp index 0c335913b5c..02e9f82cfb6 100644 --- a/src/hotspot/share/runtime/atomic.hpp +++ b/src/hotspot/share/runtime/atomic.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,6 +26,7 @@ #define SHARE_RUNTIME_ATOMIC_HPP #include "cppstdlib/type_traits.hpp" +#include "metaprogramming/dependentAlwaysFalse.hpp" #include "metaprogramming/primitiveConversions.hpp" #include "runtime/atomicAccess.hpp" #include "utilities/globalDefinitions.hpp" diff --git a/src/hotspot/share/utilities/globalDefinitions.hpp b/src/hotspot/share/utilities/globalDefinitions.hpp index 3284fd3bd15..54602297759 100644 --- a/src/hotspot/share/utilities/globalDefinitions.hpp +++ b/src/hotspot/share/utilities/globalDefinitions.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 @@ -1374,14 +1374,6 @@ template int primitive_compare(const K& k0, const K& k1) { template std::add_rvalue_reference_t declval() noexcept; -// This provides a workaround for static_assert(false) in discarded or -// otherwise uninstantiated places. Instead use -// static_assert(DependentAlwaysFalse, "...") -// See http://wg21.link/p2593r1. Some, but not all, compiler versions we're -// using have implemented that change as a DR: -// https://cplusplus.github.io/CWG/issues/2518.html -template inline constexpr bool DependentAlwaysFalse = false; - // Quickly test to make sure IEEE-754 subnormal numbers are correctly // handled. bool IEEE_subnormal_handling_OK(); diff --git a/src/hotspot/share/utilities/lockFreeStack.hpp b/src/hotspot/share/utilities/lockFreeStack.hpp index 3f63482a268..871e697f404 100644 --- a/src/hotspot/share/utilities/lockFreeStack.hpp +++ b/src/hotspot/share/utilities/lockFreeStack.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,6 +25,7 @@ #ifndef SHARE_UTILITIES_LOCKFREESTACK_HPP #define SHARE_UTILITIES_LOCKFREESTACK_HPP +#include "metaprogramming/dependentAlwaysFalse.hpp" #include "runtime/atomic.hpp" #include "runtime/atomicAccess.hpp" #include "utilities/debug.hpp" From f83918c692143802f2e94bed72dfe7121d1742f9 Mon Sep 17 00:00:00 2001 From: Alan Bateman Date: Wed, 7 Jan 2026 10:43:11 +0000 Subject: [PATCH 073/712] 8369227: Virtual thread stuck in PARKED state Reviewed-by: pchilanomate --- .../classes/java/lang/VirtualThread.java | 35 +++-- .../virtual/stress/ParkAfterTimedPark.java | 120 ++++++++++++++++++ .../Thread/virtual/stress/TimedWaitALot.java | 21 +-- 3 files changed, 154 insertions(+), 22 deletions(-) create mode 100644 test/jdk/java/lang/Thread/virtual/stress/ParkAfterTimedPark.java diff --git a/src/java.base/share/classes/java/lang/VirtualThread.java b/src/java.base/share/classes/java/lang/VirtualThread.java index 514bf07e665..93862db9105 100644 --- a/src/java.base/share/classes/java/lang/VirtualThread.java +++ b/src/java.base/share/classes/java/lang/VirtualThread.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 @@ -89,15 +89,19 @@ final class VirtualThread extends BaseVirtualThread { * * RUNNING -> PARKING // Thread parking with LockSupport.park * PARKING -> PARKED // cont.yield successful, parked indefinitely - * PARKING -> PINNED // cont.yield failed, parked indefinitely on carrier * PARKED -> UNPARKED // unparked, may be scheduled to continue - * PINNED -> RUNNING // unparked, continue execution on same carrier * UNPARKED -> RUNNING // continue execution after park * + * PARKING -> RUNNING // cont.yield failed, need to park on carrier + * RUNNING -> PINNED // park on carrier + * PINNED -> RUNNING // unparked, continue execution on same carrier + * * RUNNING -> TIMED_PARKING // Thread parking with LockSupport.parkNanos * TIMED_PARKING -> TIMED_PARKED // cont.yield successful, timed-parked - * TIMED_PARKING -> TIMED_PINNED // cont.yield failed, timed-parked on carrier * TIMED_PARKED -> UNPARKED // unparked, may be scheduled to continue + * + * TIMED_PARKING -> RUNNING // cont.yield failed, need to park on carrier + * RUNNING -> TIMED_PINNED // park on carrier * TIMED_PINNED -> RUNNING // unparked, continue execution on same carrier * * RUNNING -> BLOCKING // blocking on monitor enter @@ -108,7 +112,7 @@ final class VirtualThread extends BaseVirtualThread { * RUNNING -> WAITING // transitional state during wait on monitor * WAITING -> WAIT // waiting on monitor * WAIT -> BLOCKED // notified, waiting to be unblocked by monitor owner - * WAIT -> UNBLOCKED // timed-out/interrupted + * WAIT -> UNBLOCKED // interrupted * * RUNNING -> TIMED_WAITING // transition state during timed-waiting on monitor * TIMED_WAITING -> TIMED_WAIT // timed-waiting on monitor @@ -856,16 +860,20 @@ final class VirtualThread extends BaseVirtualThread { * Re-enables this virtual thread for scheduling. If this virtual thread is parked * then its task is scheduled to continue, otherwise its next call to {@code park} or * {@linkplain #parkNanos(long) parkNanos} is guaranteed not to block. + * @param lazySubmit to use lazySubmit if possible * @throws RejectedExecutionException if the scheduler cannot accept a task */ - @Override - void unpark() { + private void unpark(boolean lazySubmit) { if (!getAndSetParkPermit(true) && currentThread() != this) { int s = state(); // unparked while parked if ((s == PARKED || s == TIMED_PARKED) && compareAndSetState(s, UNPARKED)) { - submitRunContinuation(); + if (lazySubmit) { + lazySubmitRunContinuation(); + } else { + submitRunContinuation(); + } return; } @@ -888,6 +896,11 @@ final class VirtualThread extends BaseVirtualThread { } } + @Override + void unpark() { + unpark(false); + } + /** * Invoked by unblocker thread to unblock this virtual thread. */ @@ -904,11 +917,7 @@ final class VirtualThread extends BaseVirtualThread { */ private void parkTimeoutExpired() { assert !VirtualThread.currentThread().isVirtual(); - if (!getAndSetParkPermit(true) - && (state() == TIMED_PARKED) - && compareAndSetState(TIMED_PARKED, UNPARKED)) { - lazySubmitRunContinuation(); - } + unpark(true); } /** diff --git a/test/jdk/java/lang/Thread/virtual/stress/ParkAfterTimedPark.java b/test/jdk/java/lang/Thread/virtual/stress/ParkAfterTimedPark.java new file mode 100644 index 00000000000..1b173271a79 --- /dev/null +++ b/test/jdk/java/lang/Thread/virtual/stress/ParkAfterTimedPark.java @@ -0,0 +1,120 @@ +/* + * 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 id=parked + * @bug 8369227 + * @summary Stress test untimed park after a timed park when a thread is unparked around the + * same time that the timeout expires. + * @library /test/lib + * @run main/othervm --enable-native-access=ALL-UNNAMED ParkAfterTimedPark 200 false + */ + +/* + * @test id=pinned + * @summary Stress test untimed park, while pinned, and after a timed park when a thread is + * unparked around the same time that the timeout expires. + * @library /test/lib + * @run main/othervm --enable-native-access=ALL-UNNAMED ParkAfterTimedPark 200 true + */ + +import java.time.Instant; +import java.util.concurrent.CountDownLatch; +import java.util.concurrent.ThreadLocalRandom; +import java.util.concurrent.TimeUnit; +import java.util.concurrent.locks.LockSupport; +import jdk.test.lib.thread.VThreadPinner; + +public class ParkAfterTimedPark { + public static void main(String[] args) throws Exception { + int iterations = (args.length > 0) ? Integer.parseInt(args[0]) : 100; + boolean pinned = (args.length > 1) ? Boolean.parseBoolean(args[1]) : false; + + for (int i = 1; i <= iterations; i++) { + System.out.println(Instant.now() + " => " + i + " of " + iterations); + for (int timeout = 1; timeout <= 10; timeout++) { + test(timeout, true); + } + } + } + + /** + * Creates two virtual threads. The first does a timed-park for the given time, + * then parks in CountDownLatch.await. A second virtual thread unparks the first + * around the same time that the timeout for the first expires. + */ + private static void test(int millis, boolean pinned) throws Exception { + long nanos = TimeUnit.MILLISECONDS.toNanos(millis); + + var finish = new CountDownLatch(1); + + Thread thread1 = Thread.startVirtualThread(() -> { + LockSupport.parkNanos(nanos); + boolean done = false; + while (!done) { + try { + if (pinned) { + VThreadPinner.runPinned(() -> { + finish.await(); + }); + } else { + finish.await(); + } + done = true; + } catch (InterruptedException e) { } + } + }); + + Thread thread2 = Thread.startVirtualThread(() -> { + int delta = ThreadLocalRandom.current().nextInt(millis); + boolean done = false; + while (!done) { + try { + Thread.sleep(millis - delta); + done = true; + } catch (InterruptedException e) { } + } + LockSupport.unpark(thread1); + }); + + // wait for first thread to park before count down + await(thread1, Thread.State.WAITING); + finish.countDown(); + + thread1.join(); + thread2.join(); + } + + /** + * Waits for the given thread to reach a given state. + */ + private static void await(Thread thread, Thread.State expectedState) throws Exception { + Thread.State state = thread.getState(); + while (state != expectedState) { + if (state == Thread.State.TERMINATED) + throw new RuntimeException("Thread has terminated"); + Thread.sleep(10); + state = thread.getState(); + } + } +} diff --git a/test/jdk/java/lang/Thread/virtual/stress/TimedWaitALot.java b/test/jdk/java/lang/Thread/virtual/stress/TimedWaitALot.java index 6a81a7c5fee..704e299ad8b 100644 --- a/test/jdk/java/lang/Thread/virtual/stress/TimedWaitALot.java +++ b/test/jdk/java/lang/Thread/virtual/stress/TimedWaitALot.java @@ -94,17 +94,20 @@ public class TimedWaitALot { // start thread to Object.notifyAll at around time that the timeout expires if (notify) { - if (ThreadLocalRandom.current().nextBoolean()) { - synchronized (lock) { + executor.submit(() -> { + if (ThreadLocalRandom.current().nextBoolean()) { + synchronized (lock) { + sleepLessThan(timeout); + lock.notifyAll(); + } + } else { sleepLessThan(timeout); - lock.notifyAll(); + synchronized (lock) { + lock.notifyAll(); + } } - } else { - sleepLessThan(timeout); - synchronized (lock) { - lock.notifyAll(); - } - } + return null; + }); } // start thread to interrupt first thread at around time that the timeout expires From 6af27420e3b1980bc093776e3db76072123f7487 Mon Sep 17 00:00:00 2001 From: Alan Bateman Date: Wed, 7 Jan 2026 10:43:24 +0000 Subject: [PATCH 074/712] 8373427: StructuredTaskScope::join not clear if called with interrupted status set Reviewed-by: jpai --- .../java/util/concurrent/StructuredTaskScope.java | 14 ++++++++------ 1 file changed, 8 insertions(+), 6 deletions(-) diff --git a/src/java.base/share/classes/java/util/concurrent/StructuredTaskScope.java b/src/java.base/share/classes/java/util/concurrent/StructuredTaskScope.java index 01bf1158bf6..66ba2c29bb3 100644 --- a/src/java.base/share/classes/java/util/concurrent/StructuredTaskScope.java +++ b/src/java.base/share/classes/java/util/concurrent/StructuredTaskScope.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 @@ -1081,10 +1081,9 @@ public sealed interface StructuredTaskScope * does not throw then the {@code Joiner}'s {@code result()} method is invoked to * get the result or throw. * - *

This method may only be invoked by the scope owner. Once the result or - * exception outcome is obtained, this method may not be invoked again. The only - * case where the method may be called again is where {@code InterruptedException} - * is thrown while waiting. + *

This method may only be invoked by the scope owner. It may only be invoked once + * to get the result, exception or timeout outcome, unless the previous invocation + * resulted in an {@code InterruptedException} being thrown. * * @return the result * @throws WrongThreadException if the current thread is not the scope owner @@ -1093,8 +1092,11 @@ public sealed interface StructuredTaskScope * exception from {@link Joiner#result() Joiner.result()} as the cause * @throws TimeoutException if a timeout is set, the timeout expires before or while * waiting, and {@link Joiner#onTimeout() Joiner.onTimeout()} throws this exception - * @throws InterruptedException if interrupted while waiting + * @throws InterruptedException if the current thread is interrupted before or + * while waiting. The current thread's interrupted status is cleared when this + * exception is thrown. * @since 25 + * @see Thread##thread-interruption Thread Interruption */ R join() throws InterruptedException; From d7a3df639977ac8442eec1efb41de6dc50384150 Mon Sep 17 00:00:00 2001 From: Tobias Hotz Date: Wed, 7 Jan 2026 11:48:47 +0000 Subject: [PATCH 075/712] 8374436: compiler/igvn/IntegerDivValueTests.java failed with division by zero Reviewed-by: chagedorn, thartmann --- .../jtreg/compiler/igvn/IntegerDivValueTests.java | 12 ++++++++++-- 1 file changed, 10 insertions(+), 2 deletions(-) diff --git a/test/hotspot/jtreg/compiler/igvn/IntegerDivValueTests.java b/test/hotspot/jtreg/compiler/igvn/IntegerDivValueTests.java index 3585d1347ac..2abeffb0c41 100644 --- a/test/hotspot/jtreg/compiler/igvn/IntegerDivValueTests.java +++ b/test/hotspot/jtreg/compiler/igvn/IntegerDivValueTests.java @@ -204,7 +204,11 @@ public class IntegerDivValueTests { @Run(test = {"testIntConstantFolding", "testIntConstantFoldingSpecialCase"}) public void checkIntConstants(RunInfo info) { - Asserts.assertEquals(INT_CONST_1 / INT_CONST_2, testIntConstantFolding()); + if (INT_CONST_2 == 0) { + Asserts.assertThrows(ArithmeticException.class, () -> testIntConstantFolding()); + } else { + Asserts.assertEquals(INT_CONST_1 / INT_CONST_2, testIntConstantFolding()); + } Asserts.assertEquals(Integer.MIN_VALUE, testIntConstantFoldingSpecialCase()); } @@ -441,7 +445,11 @@ public class IntegerDivValueTests { @Run(test = {"testLongConstantFolding", "testLongConstantFoldingSpecialCase"}) public void checkLongConstants(RunInfo infoLong) { - Asserts.assertEquals(LONG_CONST_1 / LONG_CONST_2, testLongConstantFolding()); + if (LONG_CONST_2 == 0L) { + Asserts.assertThrows(ArithmeticException.class, () -> testLongConstantFolding()); + } else { + Asserts.assertEquals(LONG_CONST_1 / LONG_CONST_2, testLongConstantFolding()); + } Asserts.assertEquals(Long.MIN_VALUE, testLongConstantFoldingSpecialCase()); } From 929864b1a40eb222d3b7b3451fc6d4e5316a7cc8 Mon Sep 17 00:00:00 2001 From: SendaoYan Date: Wed, 7 Jan 2026 11:51:28 +0000 Subject: [PATCH 076/712] 8362087: Test containers/docker/ShareTmpDir.java intermittent fails Reviewed-by: sgehwolf, cnorrbin --- .../jtreg/containers/docker/ShareTmpDir.java | 17 +++++++++++++---- .../containers/docker/WaitForFlagFile.java | 4 ++-- 2 files changed, 15 insertions(+), 6 deletions(-) diff --git a/test/hotspot/jtreg/containers/docker/ShareTmpDir.java b/test/hotspot/jtreg/containers/docker/ShareTmpDir.java index b7f807d76a3..bbf08c0dae7 100644 --- a/test/hotspot/jtreg/containers/docker/ShareTmpDir.java +++ b/test/hotspot/jtreg/containers/docker/ShareTmpDir.java @@ -66,17 +66,23 @@ public class ShareTmpDir { private static void test() throws Exception { File sharedtmpdir = new File("sharedtmpdir"); File flag = new File(sharedtmpdir, "flag"); - File started = new File(sharedtmpdir, "started"); + File started1 = new File(sharedtmpdir, "started-1"); + File started2 = new File(sharedtmpdir, "started-2"); sharedtmpdir.mkdir(); flag.delete(); - started.delete(); + started1.delete(); + started2.delete(); DockerRunOptions opts = new DockerRunOptions(imageName, "/jdk/bin/java", "WaitForFlagFile"); + Object lock = new Object(); opts.addDockerOpts("--volume", Utils.TEST_CLASSES + ":/test-classes/"); opts.addDockerOpts("--volume", sharedtmpdir.getAbsolutePath() + ":/tmp/"); opts.addJavaOpts("-Xlog:os+container=trace", "-Xlog:perf+memops=debug", "-cp", "/test-classes/"); Thread t1 = new Thread() { public void run() { + synchronized(lock) { + opts.addClassOptions("1"); + } try { out1 = Common.run(opts); } catch (Exception e) { e.printStackTrace(); } } }; @@ -84,13 +90,16 @@ public class ShareTmpDir { Thread t2 = new Thread() { public void run() { + synchronized(lock) { + opts.addClassOptions("2"); + } try { out2 = Common.run(opts); } catch (Exception e) { e.printStackTrace(); } } }; t2.start(); - while (!started.exists()) { - System.out.println("Wait for at least one JVM to start"); + while (!started1.exists() || !started2.exists()) { + System.out.println("Waiting for all two JVMs to start"); Thread.sleep(1000); } diff --git a/test/hotspot/jtreg/containers/docker/WaitForFlagFile.java b/test/hotspot/jtreg/containers/docker/WaitForFlagFile.java index 64596830a3f..ed549e33cf1 100644 --- a/test/hotspot/jtreg/containers/docker/WaitForFlagFile.java +++ b/test/hotspot/jtreg/containers/docker/WaitForFlagFile.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2022, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2022, 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 @@ -28,7 +28,7 @@ public class WaitForFlagFile { public static void main(String[] args) throws Exception { System.out.println("WaitForFlagFile: Entering"); - File started = new File("/tmp/started"); + File started = new File("/tmp/started-" + args.length); FileOutputStream fout = new FileOutputStream(started); fout.close(); From da14813a5bdadaf0a1f81fa57ff6e1b103eaf113 Mon Sep 17 00:00:00 2001 From: Emanuel Peter Date: Wed, 7 Jan 2026 12:37:52 +0000 Subject: [PATCH 077/712] 8373453: C2 SuperWord: must handle load slices that have loads with different memory inputs Reviewed-by: kvn, thartmann, qamai --- src/hotspot/share/opto/vectorization.cpp | 23 ++++- src/hotspot/share/opto/vectorization.hpp | 6 +- ...oadSliceWithMultipleMemoryInputStates.java | 94 +++++++++++++++++++ 3 files changed, 116 insertions(+), 7 deletions(-) create mode 100644 test/hotspot/jtreg/compiler/loopopts/superword/TestLoadSliceWithMultipleMemoryInputStates.java diff --git a/src/hotspot/share/opto/vectorization.cpp b/src/hotspot/share/opto/vectorization.cpp index f81ee1b7ddb..1755b0453eb 100644 --- a/src/hotspot/share/opto/vectorization.cpp +++ b/src/hotspot/share/opto/vectorization.cpp @@ -187,7 +187,10 @@ VStatus VLoopAnalyzer::setup_submodules_helper() { return body_status; } - _memory_slices.find_memory_slices(); + VStatus slices_status = _memory_slices.find_memory_slices(); + if (!slices_status.is_success()) { + return slices_status; + } // If there is no memory slice detected, it means there is no store. // If there is no reduction and no store, then we give up, because @@ -207,9 +210,11 @@ VStatus VLoopAnalyzer::setup_submodules_helper() { } // There are 2 kinds of slices: -// - No memory phi: only loads. All have the same input memory state from before the loop. +// - No memory phi: only loads. +// - Usually, all loads have the same input memory state from before the loop. +// - Only rarely this is not the case, and we just bail out for now. // - With memory phi. Chain of memory operations inside the loop. -void VLoopMemorySlices::find_memory_slices() { +VStatus VLoopMemorySlices::find_memory_slices() { Compile* C = _vloop.phase()->C; // We iterate over the body, which is topologically sorted. Hence, if there is a phi // in a slice, we will find it first, and the loads and stores afterwards. @@ -228,8 +233,15 @@ void VLoopMemorySlices::find_memory_slices() { PhiNode* head = _heads.at(alias_idx); if (head == nullptr) { // We did not find a phi on this slice yet -> must be a slice with only loads. - assert(_inputs.at(alias_idx) == nullptr || _inputs.at(alias_idx) == load->in(1), - "not yet touched or the same input"); + // For now, we can only handle slices with a single memory input before the loop, + // so if we find multiple, we bail out of auto vectorization. If this becomes + // too restrictive in the fututure, we could consider tracking multiple inputs. + // Different memory inputs can for example happen if one load has its memory state + // optimized, and the other load fails to have it optimized, for example because + // it does not end up on the IGVN worklist any more. + if (_inputs.at(alias_idx) != nullptr && _inputs.at(alias_idx) != load->in(1)) { + return VStatus::make_failure(FAILURE_DIFFERENT_MEMORY_INPUT); + } _inputs.at_put(alias_idx, load->in(1)); } // else: the load belongs to a slice with a phi that already set heads and inputs. #ifdef ASSERT @@ -243,6 +255,7 @@ void VLoopMemorySlices::find_memory_slices() { } } NOT_PRODUCT( if (_vloop.is_trace_memory_slices()) { print(); } ) + return VStatus::make_success(); } #ifndef PRODUCT diff --git a/src/hotspot/share/opto/vectorization.hpp b/src/hotspot/share/opto/vectorization.hpp index 9308712f78a..b187435c04d 100644 --- a/src/hotspot/share/opto/vectorization.hpp +++ b/src/hotspot/share/opto/vectorization.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. * Copyright (c) 2023, Arm Limited. All rights reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * @@ -504,6 +504,8 @@ private: // class VLoopMemorySlices : public StackObj { private: + static constexpr char const* FAILURE_DIFFERENT_MEMORY_INPUT = "Load only slice has multiple memory inputs"; + const VLoop& _vloop; const VLoopBody& _body; @@ -521,7 +523,7 @@ public: const GrowableArray& inputs() const { return _inputs; } const GrowableArray& heads() const { return _heads; } - void find_memory_slices(); + VStatus find_memory_slices(); void get_slice_in_reverse_order(PhiNode* head, MemNode* tail, GrowableArray& slice) const; bool same_memory_slice(MemNode* m1, MemNode* m2) const; diff --git a/test/hotspot/jtreg/compiler/loopopts/superword/TestLoadSliceWithMultipleMemoryInputStates.java b/test/hotspot/jtreg/compiler/loopopts/superword/TestLoadSliceWithMultipleMemoryInputStates.java new file mode 100644 index 00000000000..7bd85d343cd --- /dev/null +++ b/test/hotspot/jtreg/compiler/loopopts/superword/TestLoadSliceWithMultipleMemoryInputStates.java @@ -0,0 +1,94 @@ +/* + * 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=all-flags + * @summary Test a case where we can have one memory slice that has only loads, + * but the loads from the slice do not have all the same input memory + * state from before the loop. This is rather rare but it can happen. + * @bug 8373453 + * @run main/othervm + * -XX:CompileCommand=compileonly,${test.main.class}::test + * -Xbatch -XX:-TieredCompilation + * ${test.main.class} + */ + +/* + * @test id=fewer-flags + * @bug 8373453 + * @run main/othervm + * -XX:CompileCommand=compileonly,${test.main.class}::test + * ${test.main.class} + */ + +/* + * @test id=vanilla + * @bug 8373453 + * @run main ${test.main.class} + */ + +package compiler.loopopts.superword; + +public class TestLoadSliceWithMultipleMemoryInputStates { + static void test() { + // The relevant slice is the value field of the Byte Objects. + Byte x = 1; + + for (int i = 0; i < 2; i++) { + if ((i & 1) == 0) { + // Not sure what this loop is needed for, but it is very sensitive, + // I cannot even replace N with 32. + int N = 32; + for (int j = 0; j < N; j++) { + if (j == 1) { + x = (byte) x; + } + } + + for (int j = 0; j < 32; j++) { + // The call below has an effect on the memory state + // If we optimize the Load for Byte::value, we can bypass + // this call, since we know that Byte::value cannot be + // modified during the call. + Object o = 1; + o.toString(); + + for (int k = 0; k < 32; k++) { // OSR around here + // Loads of x byte field have different memory input states + // This is because some loads can split their memory state + // through a phi further up, and others are not put back on + // the IGVN worklist and are thus not optimized and keep + // the old memory state. Both are correct though. + x = (byte) (x + 1); + } + } + } + } + } + + public static void main(String[] args) { + for (int i = 0; i < 10_000; i++) { + test(); + } + } +} From 3541bc8635ad8f5f4151758de3a134c9c105cebd Mon Sep 17 00:00:00 2001 From: Volkan Yazici Date: Wed, 7 Jan 2026 15:38:20 +0000 Subject: [PATCH 078/712] 8373538: Migrate all tests to null-safe "SimpleSSLContext" methods Reviewed-by: djelinski, jpai --- .../net/httpserver/ClearTextServerSSL.java | 4 +- .../SetAuthenticator/HTTPTest.java | 18 ++++---- .../SetAuthenticator/HTTPTestClient.java | 4 +- test/jdk/java/net/URLPermission/URLTest.java | 6 +-- .../DummyCacheResponse.java | 5 +-- .../net/ssl/HttpsURLConnection/Equals.java | 5 +-- .../ssl/HttpsURLConnection/HttpsSession.java | 6 +-- .../HttpsURLConnection/SubjectAltNameIP.java | 6 +-- .../net/www/protocol/http/RedirectOnPost.java | 4 +- test/jdk/sun/security/krb5/auto/HttpsCB.java | 4 +- .../testLinkOption/TestRedirectLinks.java | 7 +--- .../jdk/test/lib/net/SimpleSSLContext.java | 42 +++++-------------- 12 files changed, 38 insertions(+), 73 deletions(-) diff --git a/test/jdk/com/sun/net/httpserver/ClearTextServerSSL.java b/test/jdk/com/sun/net/httpserver/ClearTextServerSSL.java index 75e4f3fcf45..896f02b178d 100644 --- a/test/jdk/com/sun/net/httpserver/ClearTextServerSSL.java +++ b/test/jdk/com/sun/net/httpserver/ClearTextServerSSL.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 @@ -79,7 +79,7 @@ public class ClearTextServerSSL { @Test public void test() throws Exception { - var sslContext = new SimpleSSLContext().get(); + var sslContext = SimpleSSLContext.findSSLContext(); var handler = new TestHandler(); var server = HttpServer.create(new InetSocketAddress(LOOPBACK_ADDR, 0), 0); server.createContext(path(""), handler); diff --git a/test/jdk/java/net/HttpURLConnection/SetAuthenticator/HTTPTest.java b/test/jdk/java/net/HttpURLConnection/SetAuthenticator/HTTPTest.java index 2dc6963a63e..8965a942153 100644 --- a/test/jdk/java/net/HttpURLConnection/SetAuthenticator/HTTPTest.java +++ b/test/jdk/java/net/HttpURLConnection/SetAuthenticator/HTTPTest.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2016, 2019, 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 @@ -142,16 +142,12 @@ public class HTTPTest { } static { - try { - HttpsURLConnection.setDefaultHostnameVerifier(new HostnameVerifier() { - public boolean verify(String hostname, SSLSession session) { - return true; - } - }); - SSLContext.setDefault(new SimpleSSLContext().get()); - } catch (IOException ex) { - throw new ExceptionInInitializerError(ex); - } + HttpsURLConnection.setDefaultHostnameVerifier(new HostnameVerifier() { + public boolean verify(String hostname, SSLSession session) { + return true; + } + }); + SSLContext.setDefault(SimpleSSLContext.findSSLContext()); } static final Logger logger = Logger.getLogger ("com.sun.net.httpserver"); diff --git a/test/jdk/java/net/HttpURLConnection/SetAuthenticator/HTTPTestClient.java b/test/jdk/java/net/HttpURLConnection/SetAuthenticator/HTTPTestClient.java index 3f436ef6d02..57790da171f 100644 --- a/test/jdk/java/net/HttpURLConnection/SetAuthenticator/HTTPTestClient.java +++ b/test/jdk/java/net/HttpURLConnection/SetAuthenticator/HTTPTestClient.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 @@ -112,7 +112,7 @@ public class HTTPTestClient extends HTTPTest { // anything here. Otherwise it could look like: // HttpsURLConnection httpsConn = (HttpsURLConnection)conn; // httpsConn.setSSLSocketFactory( - // new SimpleSSLContext().get().getSocketFactory()); + // SimpleSSLContext.findSSLContext().getSocketFactory()); } } diff --git a/test/jdk/java/net/URLPermission/URLTest.java b/test/jdk/java/net/URLPermission/URLTest.java index 907ba6072ec..9d1b4e840e6 100644 --- a/test/jdk/java/net/URLPermission/URLTest.java +++ b/test/jdk/java/net/URLPermission/URLTest.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 @@ -223,7 +223,7 @@ public class URLTest { static HttpsServer httpsServer; static HttpContext c, cs; static ExecutorService e, es; - static SSLContext ctx; + private static final SSLContext ctx = SimpleSSLContext.findSSLContext(); static int httpPort; static int httpsPort; static String httpAuth; @@ -243,8 +243,6 @@ public class URLTest { es = Executors.newCachedThreadPool(); httpServer.setExecutor(e); httpsServer.setExecutor(es); - - ctx = new SimpleSSLContext().get(); httpsServer.setHttpsConfigurator(new HttpsConfigurator (ctx)); httpServer.start(); diff --git a/test/jdk/javax/net/ssl/HttpsURLConnection/DummyCacheResponse.java b/test/jdk/javax/net/ssl/HttpsURLConnection/DummyCacheResponse.java index f18dca8b0f7..e0d9a3cdc01 100644 --- a/test/jdk/javax/net/ssl/HttpsURLConnection/DummyCacheResponse.java +++ b/test/jdk/javax/net/ssl/HttpsURLConnection/DummyCacheResponse.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 @@ -43,7 +43,7 @@ import jdk.test.lib.net.SimpleSSLContext; import com.sun.net.httpserver.*; public class DummyCacheResponse extends SecureCacheResponse { - static SSLContext sslContext; + private static final SSLContext sslContext = SimpleSSLContext.findSSLContext(); private final SSLSession cachedSession; private final Map> rqstHeaders; @@ -61,7 +61,6 @@ public class DummyCacheResponse extends SecureCacheResponse { executor = Executors.newCachedThreadPool(); httpsServer.setExecutor(executor); - sslContext = new SimpleSSLContext().get(); httpsServer.setHttpsConfigurator(new HttpsConfigurator(sslContext)); httpsServer.start(); diff --git a/test/jdk/javax/net/ssl/HttpsURLConnection/Equals.java b/test/jdk/javax/net/ssl/HttpsURLConnection/Equals.java index 35913edd2bf..1e43547c59d 100644 --- a/test/jdk/javax/net/ssl/HttpsURLConnection/Equals.java +++ b/test/jdk/javax/net/ssl/HttpsURLConnection/Equals.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 @@ -49,7 +49,7 @@ public class Equals { */ private static final boolean debug = false; - static SSLContext ctx; + private static final SSLContext ctx = SimpleSSLContext.findSSLContext(); public static void main(String[] args) throws Exception { if (debug) { @@ -65,7 +65,6 @@ public class Equals { HttpContext c2 = s2.createContext("/test1", h); executor = Executors.newCachedThreadPool(); s2.setExecutor(executor); - ctx = new SimpleSSLContext().get(); s2.setHttpsConfigurator(new HttpsConfigurator(ctx)); s2.start(); int httpsport = s2.getAddress().getPort(); diff --git a/test/jdk/javax/net/ssl/HttpsURLConnection/HttpsSession.java b/test/jdk/javax/net/ssl/HttpsURLConnection/HttpsSession.java index e17ff6c95b2..7b6ac18c4c9 100644 --- a/test/jdk/javax/net/ssl/HttpsURLConnection/HttpsSession.java +++ b/test/jdk/javax/net/ssl/HttpsURLConnection/HttpsSession.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 @@ -41,7 +41,7 @@ import jdk.test.lib.net.SimpleSSLContext; public class HttpsSession { - static SSLContext sslContext; + private static final SSLContext sslContext = SimpleSSLContext.findSSLContext(); public static void main(String[] args) throws Exception { HttpsServer httpsServer = null; @@ -53,8 +53,6 @@ public class HttpsSession { executor = Executors.newCachedThreadPool(); httpsServer.setExecutor(executor); - - sslContext = new SimpleSSLContext().get(); httpsServer.setHttpsConfigurator(new HttpsConfigurator(sslContext)); httpsServer.start(); diff --git a/test/jdk/javax/net/ssl/HttpsURLConnection/SubjectAltNameIP.java b/test/jdk/javax/net/ssl/HttpsURLConnection/SubjectAltNameIP.java index cbd2089e7bd..de747922d7b 100644 --- a/test/jdk/javax/net/ssl/HttpsURLConnection/SubjectAltNameIP.java +++ b/test/jdk/javax/net/ssl/HttpsURLConnection/SubjectAltNameIP.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,7 @@ public class SubjectAltNameIP { */ void doServerSide() throws Exception { SSLServerSocketFactory sslssf = - new SimpleSSLContext().get().getServerSocketFactory(); + SimpleSSLContext.findSSLContext().getServerSocketFactory(); SSLServerSocket sslServerSocket = (SSLServerSocket) sslssf.createServerSocket( serverPort, 0, @@ -139,7 +139,7 @@ public class SubjectAltNameIP { throw new RuntimeException("Server failed to start.", serverException); } - SSLSocketFactory sf = new SimpleSSLContext().get().getSocketFactory(); + SSLSocketFactory sf = SimpleSSLContext.findSSLContext().getSocketFactory(); URI uri = new URI("https://" + hostName + ":" + serverPort + "/index.html"); HttpsURLConnection conn = (HttpsURLConnection)uri.toURL().openConnection(); diff --git a/test/jdk/sun/net/www/protocol/http/RedirectOnPost.java b/test/jdk/sun/net/www/protocol/http/RedirectOnPost.java index 1f88c851f63..69da47651b7 100644 --- a/test/jdk/sun/net/www/protocol/http/RedirectOnPost.java +++ b/test/jdk/sun/net/www/protocol/http/RedirectOnPost.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 @@ -46,7 +46,7 @@ public class RedirectOnPost { public static void main(String[] args) throws Exception { ExecutorService e= Executors.newFixedThreadPool(5); - SSLContext ctx = new SimpleSSLContext().get(); + SSLContext ctx = SimpleSSLContext.findSSLContext(); HttpServer httpServer = getHttpServer(e); HttpsServer httpsServer = getHttpsServer(e, ctx); diff --git a/test/jdk/sun/security/krb5/auto/HttpsCB.java b/test/jdk/sun/security/krb5/auto/HttpsCB.java index 1f9f0de33ac..278e72592be 100644 --- a/test/jdk/sun/security/krb5/auto/HttpsCB.java +++ b/test/jdk/sun/security/krb5/auto/HttpsCB.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 @@ -214,7 +214,7 @@ public class HttpsCB { MyHttpHandler h = new MyHttpHandler(); HttpsServer server = HttpsServer.create(new InetSocketAddress(0), 0); server.setHttpsConfigurator( - new HttpsConfigurator(new SimpleSSLContext().get())); + new HttpsConfigurator(SimpleSSLContext.findSSLContext())); server.createContext("/", h).setAuthenticator( new MyServerAuthenticator(scheme, principal, ktab)); server.start(); diff --git a/test/langtools/jdk/javadoc/doclet/testLinkOption/TestRedirectLinks.java b/test/langtools/jdk/javadoc/doclet/testLinkOption/TestRedirectLinks.java index 2a415141229..a4fd5e3f68e 100644 --- a/test/langtools/jdk/javadoc/doclet/testLinkOption/TestRedirectLinks.java +++ b/test/langtools/jdk/javadoc/doclet/testLinkOption/TestRedirectLinks.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 @@ -221,10 +221,7 @@ public class TestRedirectLinks extends JavadocTester { out.println("Starting old server (" + oldServer.getClass().getSimpleName() + ") on " + oldURL); oldServer.start(); - SSLContext sslContext = new SimpleSSLContext().get(); - if (sslContext == null) { - throw new AssertionError("Could not create a SSLContext"); - } + SSLContext sslContext = SimpleSSLContext.findSSLContext(); newServer = HttpsServer.create(new InetSocketAddress(loopback, 0), 0); String newURL = URIBuilder.newBuilder() .scheme("https") diff --git a/test/lib/jdk/test/lib/net/SimpleSSLContext.java b/test/lib/jdk/test/lib/net/SimpleSSLContext.java index 3e0d362cc23..ae2b479c271 100644 --- a/test/lib/jdk/test/lib/net/SimpleSSLContext.java +++ b/test/lib/jdk/test/lib/net/SimpleSSLContext.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,12 +23,16 @@ package jdk.test.lib.net; +import java.io.File; import java.nio.file.Files; import java.nio.file.Path; -import java.util.*; -import java.io.*; -import java.security.*; -import javax.net.ssl.*; +import java.security.KeyStore; +import java.util.Collections; +import java.util.Objects; +import java.util.StringTokenizer; +import javax.net.ssl.KeyManagerFactory; +import javax.net.ssl.SSLContext; +import javax.net.ssl.TrustManagerFactory; /** * Utility for creating a simple usable {@link SSLContext} for testing purposes. @@ -39,17 +43,7 @@ public final class SimpleSSLContext { private static final String DEFAULT_KEY_STORE_FILE_REL_PATH = "jdk/test/lib/net/testkeys"; - private final SSLContext ssl; - - // Made `public` for backward compatibility - public SimpleSSLContext() throws IOException { - this.ssl = findSSLContext(DEFAULT_KEY_STORE_FILE_REL_PATH, DEFAULT_PROTOCOL); - } - - // Kept for backward compatibility - public SimpleSSLContext(String keyStoreFileRelPath) throws IOException { - this.ssl = findSSLContext(Objects.requireNonNull(keyStoreFileRelPath), DEFAULT_PROTOCOL); - } + private SimpleSSLContext() {} /** * {@return a new {@link SSLContext} instance by searching for a key store @@ -136,20 +130,4 @@ public final class SimpleSSLContext { } } - // Kept for backward compatibility - public static SSLContext getContext(String protocol) throws IOException { - try { - return protocol == null || protocol.isEmpty() - ? findSSLContext() - : findSSLContext(protocol); - } catch (RuntimeException re) { - throw new IOException(re); - } - } - - // Kept for backward compatibility - public SSLContext get() { - return ssl; - } - } From 640343f7d94894b0378ea5b1768eeac203a9aaf8 Mon Sep 17 00:00:00 2001 From: Jatin Bhateja Date: Wed, 7 Jan 2026 17:00:57 +0000 Subject: [PATCH 079/712] 8373724: Assertion failure in TestSignumVector.java with UseAPX Reviewed-by: sviswanathan --- src/hotspot/cpu/x86/x86.ad | 159 +++++++++++++++++++------------------ 1 file changed, 80 insertions(+), 79 deletions(-) diff --git a/src/hotspot/cpu/x86/x86.ad b/src/hotspot/cpu/x86/x86.ad index 5958db5d1eb..93b306c37d6 100644 --- a/src/hotspot/cpu/x86/x86.ad +++ b/src/hotspot/cpu/x86/x86.ad @@ -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 @@ -2633,17 +2633,19 @@ bool Matcher::supports_vector_calling_convention(void) { return EnableVectorSupport; } +static bool is_ndd_demotable_opr1(const MachNode* mdef) { + return ((mdef->flags() & Node::PD::Flag_ndd_demotable_opr1) != 0); +} + +static bool is_ndd_demotable_opr2(const MachNode* mdef) { + return ((mdef->flags() & Node::PD::Flag_ndd_demotable_opr2) != 0); +} + +#ifdef ASSERT static bool is_ndd_demotable(const MachNode* mdef) { - return ((mdef->flags() & Node::PD::Flag_ndd_demotable) != 0); -} - -static bool is_ndd_demotable_commutative(const MachNode* mdef) { - return ((mdef->flags() & Node::PD::Flag_ndd_demotable_commutative) != 0); -} - -static bool is_demotion_candidate(const MachNode* mdef) { - return (is_ndd_demotable(mdef) || is_ndd_demotable_commutative(mdef)); + return (is_ndd_demotable_opr1(mdef) || is_ndd_demotable_opr2(mdef)); } +#endif bool Matcher::is_register_biasing_candidate(const MachNode* mdef, int oper_index) { @@ -2653,8 +2655,8 @@ bool Matcher::is_register_biasing_candidate(const MachNode* mdef, if (mdef->num_opnds() <= oper_index || mdef->operand_index(oper_index) < 0 || mdef->in(mdef->operand_index(oper_index)) == nullptr) { - assert(oper_index != 1 || !is_demotion_candidate(mdef), "%s", mdef->Name()); - assert(oper_index != 2 || !is_ndd_demotable_commutative(mdef), "%s", mdef->Name()); + assert(oper_index != 1 || !is_ndd_demotable_opr1(mdef), "%s", mdef->Name()); + assert(oper_index != 2 || !is_ndd_demotable_opr2(mdef), "%s", mdef->Name()); return false; } @@ -2662,14 +2664,13 @@ bool Matcher::is_register_biasing_candidate(const MachNode* mdef, // address computation. Biasing def towards any address component will not // result in NDD demotion by assembler. if (mdef->operand_num_edges(oper_index) != 1) { - assert(!is_ndd_demotable(mdef), "%s", mdef->Name()); return false; } // Demotion candidate must be register mask compatible with definition. const RegMask& oper_mask = mdef->in_RegMask(mdef->operand_index(oper_index)); if (!oper_mask.overlap(mdef->out_RegMask())) { - assert(!is_demotion_candidate(mdef), "%s", mdef->Name()); + assert(!is_ndd_demotable(mdef), "%s", mdef->Name()); return false; } @@ -2681,12 +2682,12 @@ bool Matcher::is_register_biasing_candidate(const MachNode* mdef, // EVEX prefix with shorter REX/REX2 encoding. Demotion candidates // are decorated with a special flag by instruction selector. case 1: - return is_demotion_candidate(mdef); + return is_ndd_demotable_opr1(mdef); // Definition operand of commutative operation can be biased towards second // operand. case 2: - return is_ndd_demotable_commutative(mdef); + return is_ndd_demotable_opr2(mdef); // Current scheme only selects up to two biasing candidates default: @@ -2888,9 +2889,9 @@ public: Flag_clears_zero_flag = Node::_last_flag << 9, Flag_clears_overflow_flag = Node::_last_flag << 10, Flag_clears_sign_flag = Node::_last_flag << 11, - Flag_ndd_demotable = Node::_last_flag << 12, - Flag_ndd_demotable_commutative = Node::_last_flag << 13, - _last_flag = Flag_ndd_demotable_commutative + Flag_ndd_demotable_opr1 = Node::_last_flag << 12, + Flag_ndd_demotable_opr2 = Node::_last_flag << 13, + _last_flag = Flag_ndd_demotable_opr2 }; }; @@ -9872,7 +9873,7 @@ instruct addI_rReg_ndd(rRegI dst, rRegI src1, rRegI src2, rFlagsReg cr) predicate(UseAPX); match(Set dst (AddI src1 src2)); effect(KILL cr); - flag(PD::Flag_sets_overflow_flag, PD::Flag_sets_sign_flag, PD::Flag_sets_zero_flag, PD::Flag_sets_carry_flag, PD::Flag_sets_parity_flag, PD::Flag_ndd_demotable_commutative); + flag(PD::Flag_sets_overflow_flag, PD::Flag_sets_sign_flag, PD::Flag_sets_zero_flag, PD::Flag_sets_carry_flag, PD::Flag_sets_parity_flag, PD::Flag_ndd_demotable_opr1, PD::Flag_ndd_demotable_opr2); format %{ "eaddl $dst, $src1, $src2\t# int ndd" %} ins_encode %{ @@ -9900,7 +9901,7 @@ instruct addI_rReg_rReg_imm_ndd(rRegI dst, rRegI src1, immI src2, rFlagsReg cr) predicate(UseAPX); match(Set dst (AddI src1 src2)); effect(KILL cr); - flag(PD::Flag_sets_overflow_flag, PD::Flag_sets_sign_flag, PD::Flag_sets_zero_flag, PD::Flag_sets_carry_flag, PD::Flag_sets_parity_flag, PD::Flag_ndd_demotable); + flag(PD::Flag_sets_overflow_flag, PD::Flag_sets_sign_flag, PD::Flag_sets_zero_flag, PD::Flag_sets_carry_flag, PD::Flag_sets_parity_flag, PD::Flag_ndd_demotable_opr1); format %{ "eaddl $dst, $src1, $src2\t# int ndd" %} ins_encode %{ @@ -9943,7 +9944,7 @@ instruct addI_rReg_rReg_mem_ndd(rRegI dst, rRegI src1, memory src2, rFlagsReg cr predicate(UseAPX); match(Set dst (AddI src1 (LoadI src2))); effect(KILL cr); - flag(PD::Flag_sets_overflow_flag, PD::Flag_sets_sign_flag, PD::Flag_sets_zero_flag, PD::Flag_sets_carry_flag, PD::Flag_sets_parity_flag, PD::Flag_ndd_demotable_commutative); + flag(PD::Flag_sets_overflow_flag, PD::Flag_sets_sign_flag, PD::Flag_sets_zero_flag, PD::Flag_sets_carry_flag, PD::Flag_sets_parity_flag, PD::Flag_ndd_demotable_opr1, PD::Flag_ndd_demotable_opr2); ins_cost(150); format %{ "eaddl $dst, $src1, $src2\t# int ndd" %} @@ -10000,7 +10001,7 @@ instruct incI_rReg_ndd(rRegI dst, rRegI src, immI_1 val, rFlagsReg cr) predicate(UseAPX && UseIncDec); match(Set dst (AddI src val)); effect(KILL cr); - flag(PD::Flag_ndd_demotable); + flag(PD::Flag_ndd_demotable_opr1); format %{ "eincl $dst, $src\t# int ndd" %} ins_encode %{ @@ -10055,7 +10056,7 @@ instruct decI_rReg_ndd(rRegI dst, rRegI src, immI_M1 val, rFlagsReg cr) predicate(UseAPX && UseIncDec); match(Set dst (AddI src val)); effect(KILL cr); - flag(PD::Flag_ndd_demotable); + flag(PD::Flag_ndd_demotable_opr1); format %{ "edecl $dst, $src\t# int ndd" %} ins_encode %{ @@ -10162,7 +10163,7 @@ instruct addL_rReg_ndd(rRegL dst, rRegL src1, rRegL src2, rFlagsReg cr) predicate(UseAPX); match(Set dst (AddL src1 src2)); effect(KILL cr); - flag(PD::Flag_sets_overflow_flag, PD::Flag_sets_sign_flag, PD::Flag_sets_zero_flag, PD::Flag_sets_carry_flag, PD::Flag_sets_parity_flag, PD::Flag_ndd_demotable_commutative); + flag(PD::Flag_sets_overflow_flag, PD::Flag_sets_sign_flag, PD::Flag_sets_zero_flag, PD::Flag_sets_carry_flag, PD::Flag_sets_parity_flag, PD::Flag_ndd_demotable_opr1, PD::Flag_ndd_demotable_opr2); format %{ "eaddq $dst, $src1, $src2\t# long ndd" %} ins_encode %{ @@ -10190,7 +10191,7 @@ instruct addL_rReg_rReg_imm_ndd(rRegL dst, rRegL src1, immL32 src2, rFlagsReg cr predicate(UseAPX); match(Set dst (AddL src1 src2)); effect(KILL cr); - flag(PD::Flag_sets_overflow_flag, PD::Flag_sets_sign_flag, PD::Flag_sets_zero_flag, PD::Flag_sets_carry_flag, PD::Flag_sets_parity_flag, PD::Flag_ndd_demotable); + flag(PD::Flag_sets_overflow_flag, PD::Flag_sets_sign_flag, PD::Flag_sets_zero_flag, PD::Flag_sets_carry_flag, PD::Flag_sets_parity_flag, PD::Flag_ndd_demotable_opr1); format %{ "eaddq $dst, $src1, $src2\t# long ndd" %} ins_encode %{ @@ -10233,7 +10234,7 @@ instruct addL_rReg_rReg_mem_ndd(rRegL dst, rRegL src1, memory src2, rFlagsReg cr predicate(UseAPX); match(Set dst (AddL src1 (LoadL src2))); effect(KILL cr); - flag(PD::Flag_sets_overflow_flag, PD::Flag_sets_sign_flag, PD::Flag_sets_zero_flag, PD::Flag_sets_carry_flag, PD::Flag_sets_parity_flag, PD::Flag_ndd_demotable_commutative); + flag(PD::Flag_sets_overflow_flag, PD::Flag_sets_sign_flag, PD::Flag_sets_zero_flag, PD::Flag_sets_carry_flag, PD::Flag_sets_parity_flag, PD::Flag_ndd_demotable_opr1, PD::Flag_ndd_demotable_opr2); ins_cost(150); format %{ "eaddq $dst, $src1, $src2\t# long ndd" %} @@ -10289,7 +10290,7 @@ instruct incL_rReg_ndd(rRegL dst, rRegI src, immL1 val, rFlagsReg cr) predicate(UseAPX && UseIncDec); match(Set dst (AddL src val)); effect(KILL cr); - flag(PD::Flag_ndd_demotable); + flag(PD::Flag_ndd_demotable_opr1); format %{ "eincq $dst, $src\t# long ndd" %} ins_encode %{ @@ -10344,7 +10345,7 @@ instruct decL_rReg_ndd(rRegL dst, rRegL src, immL_M1 val, rFlagsReg cr) predicate(UseAPX && UseIncDec); match(Set dst (AddL src val)); effect(KILL cr); - flag(PD::Flag_ndd_demotable); + flag(PD::Flag_ndd_demotable_opr1); format %{ "edecq $dst, $src\t# long ndd" %} ins_encode %{ @@ -11059,7 +11060,7 @@ instruct subI_rReg_ndd(rRegI dst, rRegI src1, rRegI src2, rFlagsReg cr) predicate(UseAPX); match(Set dst (SubI src1 src2)); effect(KILL cr); - flag(PD::Flag_sets_overflow_flag, PD::Flag_sets_sign_flag, PD::Flag_sets_zero_flag, PD::Flag_sets_carry_flag, PD::Flag_sets_parity_flag, PD::Flag_ndd_demotable); + flag(PD::Flag_sets_overflow_flag, PD::Flag_sets_sign_flag, PD::Flag_sets_zero_flag, PD::Flag_sets_carry_flag, PD::Flag_sets_parity_flag, PD::Flag_ndd_demotable_opr1); format %{ "esubl $dst, $src1, $src2\t# int ndd" %} ins_encode %{ @@ -11073,7 +11074,7 @@ instruct subI_rReg_rReg_imm_ndd(rRegI dst, rRegI src1, immI src2, rFlagsReg cr) predicate(UseAPX); match(Set dst (SubI src1 src2)); effect(KILL cr); - flag(PD::Flag_sets_overflow_flag, PD::Flag_sets_sign_flag, PD::Flag_sets_zero_flag, PD::Flag_sets_carry_flag, PD::Flag_sets_parity_flag, PD::Flag_ndd_demotable); + flag(PD::Flag_sets_overflow_flag, PD::Flag_sets_sign_flag, PD::Flag_sets_zero_flag, PD::Flag_sets_carry_flag, PD::Flag_sets_parity_flag, PD::Flag_ndd_demotable_opr1); format %{ "esubl $dst, $src1, $src2\t# int ndd" %} ins_encode %{ @@ -11116,7 +11117,7 @@ instruct subI_rReg_rReg_mem_ndd(rRegI dst, rRegI src1, memory src2, rFlagsReg cr predicate(UseAPX); match(Set dst (SubI src1 (LoadI src2))); effect(KILL cr); - flag(PD::Flag_sets_overflow_flag, PD::Flag_sets_sign_flag, PD::Flag_sets_zero_flag, PD::Flag_sets_carry_flag, PD::Flag_sets_parity_flag, PD::Flag_ndd_demotable); + flag(PD::Flag_sets_overflow_flag, PD::Flag_sets_sign_flag, PD::Flag_sets_zero_flag, PD::Flag_sets_carry_flag, PD::Flag_sets_parity_flag, PD::Flag_ndd_demotable_opr1); ins_cost(150); format %{ "esubl $dst, $src1, $src2\t# int ndd" %} @@ -11174,7 +11175,7 @@ instruct subL_rReg_ndd(rRegL dst, rRegL src1, rRegL src2, rFlagsReg cr) predicate(UseAPX); match(Set dst (SubL src1 src2)); effect(KILL cr); - flag(PD::Flag_sets_overflow_flag, PD::Flag_sets_sign_flag, PD::Flag_sets_zero_flag, PD::Flag_sets_carry_flag, PD::Flag_sets_parity_flag, PD::Flag_ndd_demotable); + flag(PD::Flag_sets_overflow_flag, PD::Flag_sets_sign_flag, PD::Flag_sets_zero_flag, PD::Flag_sets_carry_flag, PD::Flag_sets_parity_flag, PD::Flag_ndd_demotable_opr1); format %{ "esubq $dst, $src1, $src2\t# long ndd" %} ins_encode %{ @@ -11188,7 +11189,7 @@ instruct subL_rReg_rReg_imm_ndd(rRegL dst, rRegL src1, immL32 src2, rFlagsReg cr predicate(UseAPX); match(Set dst (SubL src1 src2)); effect(KILL cr); - flag(PD::Flag_sets_overflow_flag, PD::Flag_sets_sign_flag, PD::Flag_sets_zero_flag, PD::Flag_sets_carry_flag, PD::Flag_sets_parity_flag, PD::Flag_ndd_demotable); + flag(PD::Flag_sets_overflow_flag, PD::Flag_sets_sign_flag, PD::Flag_sets_zero_flag, PD::Flag_sets_carry_flag, PD::Flag_sets_parity_flag, PD::Flag_ndd_demotable_opr1); format %{ "esubq $dst, $src1, $src2\t# long ndd" %} ins_encode %{ @@ -11231,7 +11232,7 @@ instruct subL_rReg_rReg_mem_ndd(rRegL dst, rRegL src1, memory src2, rFlagsReg cr predicate(UseAPX); match(Set dst (SubL src1 (LoadL src2))); effect(KILL cr); - flag(PD::Flag_sets_overflow_flag, PD::Flag_sets_sign_flag, PD::Flag_sets_zero_flag, PD::Flag_sets_carry_flag, PD::Flag_sets_parity_flag, PD::Flag_ndd_demotable); + flag(PD::Flag_sets_overflow_flag, PD::Flag_sets_sign_flag, PD::Flag_sets_zero_flag, PD::Flag_sets_carry_flag, PD::Flag_sets_parity_flag, PD::Flag_ndd_demotable_opr1); ins_cost(150); format %{ "esubq $dst, $src1, $src2\t# long ndd" %} @@ -11303,7 +11304,7 @@ instruct negI_rReg_ndd(rRegI dst, rRegI src, immI_0 zero, rFlagsReg cr) predicate(UseAPX); match(Set dst (SubI zero src)); effect(KILL cr); - flag(PD::Flag_sets_overflow_flag, PD::Flag_sets_sign_flag, PD::Flag_sets_zero_flag, PD::Flag_sets_parity_flag, PD::Flag_ndd_demotable); + flag(PD::Flag_sets_overflow_flag, PD::Flag_sets_sign_flag, PD::Flag_sets_zero_flag, PD::Flag_sets_parity_flag, PD::Flag_ndd_demotable_opr2); format %{ "enegl $dst, $src\t# int ndd" %} ins_encode %{ @@ -11331,7 +11332,7 @@ instruct negI_rReg_2_ndd(rRegI dst, rRegI src, rFlagsReg cr) predicate(UseAPX); match(Set dst (NegI src)); effect(KILL cr); - flag(PD::Flag_sets_overflow_flag, PD::Flag_sets_sign_flag, PD::Flag_sets_zero_flag, PD::Flag_sets_parity_flag, PD::Flag_ndd_demotable); + flag(PD::Flag_sets_overflow_flag, PD::Flag_sets_sign_flag, PD::Flag_sets_zero_flag, PD::Flag_sets_parity_flag, PD::Flag_ndd_demotable_opr1); format %{ "enegl $dst, $src\t# int ndd" %} ins_encode %{ @@ -11372,7 +11373,7 @@ instruct negL_rReg_ndd(rRegL dst, rRegL src, immL0 zero, rFlagsReg cr) predicate(UseAPX); match(Set dst (SubL zero src)); effect(KILL cr); - flag(PD::Flag_sets_overflow_flag, PD::Flag_sets_sign_flag, PD::Flag_sets_zero_flag, PD::Flag_sets_parity_flag, PD::Flag_ndd_demotable); + flag(PD::Flag_sets_overflow_flag, PD::Flag_sets_sign_flag, PD::Flag_sets_zero_flag, PD::Flag_sets_parity_flag, PD::Flag_ndd_demotable_opr2); format %{ "enegq $dst, $src\t# long ndd" %} ins_encode %{ @@ -11400,7 +11401,7 @@ instruct negL_rReg_2_ndd(rRegL dst, rRegL src, rFlagsReg cr) predicate(UseAPX); match(Set dst (NegL src)); effect(KILL cr); - flag(PD::Flag_sets_overflow_flag, PD::Flag_sets_sign_flag, PD::Flag_sets_zero_flag, PD::Flag_sets_parity_flag, PD::Flag_ndd_demotable); + flag(PD::Flag_sets_overflow_flag, PD::Flag_sets_sign_flag, PD::Flag_sets_zero_flag, PD::Flag_sets_parity_flag, PD::Flag_ndd_demotable_opr1); format %{ "enegq $dst, $src\t# long ndd" %} ins_encode %{ @@ -11445,7 +11446,7 @@ instruct mulI_rReg_ndd(rRegI dst, rRegI src1, rRegI src2, rFlagsReg cr) predicate(UseAPX); match(Set dst (MulI src1 src2)); effect(KILL cr); - flag(PD::Flag_ndd_demotable_commutative); + flag(PD::Flag_ndd_demotable_opr1, PD::Flag_ndd_demotable_opr2); ins_cost(300); format %{ "eimull $dst, $src1, $src2\t# int ndd" %} @@ -11487,7 +11488,7 @@ instruct mulI_rReg_rReg_mem_ndd(rRegI dst, rRegI src1, memory src2, rFlagsReg cr predicate(UseAPX); match(Set dst (MulI src1 (LoadI src2))); effect(KILL cr); - flag(PD::Flag_ndd_demotable); + flag(PD::Flag_ndd_demotable_opr1, PD::Flag_ndd_demotable_opr2); ins_cost(350); format %{ "eimull $dst, $src1, $src2\t# int ndd" %} @@ -11539,7 +11540,7 @@ instruct mulL_rReg_ndd(rRegL dst, rRegL src1, rRegL src2, rFlagsReg cr) predicate(UseAPX); match(Set dst (MulL src1 src2)); effect(KILL cr); - flag(PD::Flag_ndd_demotable_commutative); + flag(PD::Flag_ndd_demotable_opr1, PD::Flag_ndd_demotable_opr2); ins_cost(300); format %{ "eimulq $dst, $src1, $src2\t# long ndd" %} @@ -11581,7 +11582,7 @@ instruct mulL_rReg_rReg_mem_ndd(rRegL dst, rRegL src1, memory src2, rFlagsReg cr predicate(UseAPX); match(Set dst (MulL src1 (LoadL src2))); effect(KILL cr); - flag(PD::Flag_ndd_demotable_commutative); + flag(PD::Flag_ndd_demotable_opr1, PD::Flag_ndd_demotable_opr2); ins_cost(350); format %{ "eimulq $dst, $src1, $src2 \t# long" %} @@ -11856,7 +11857,7 @@ instruct salI_rReg_immI2_ndd(rRegI dst, rRegI src, immI2 shift, rFlagsReg cr) predicate(UseAPX); match(Set dst (LShiftI src shift)); effect(KILL cr); - flag(PD::Flag_ndd_demotable); + flag(PD::Flag_ndd_demotable_opr1); format %{ "esall $dst, $src, $shift\t# int(ndd)" %} ins_encode %{ @@ -11885,7 +11886,7 @@ instruct salI_rReg_imm_ndd(rRegI dst, rRegI src, immI8 shift, rFlagsReg cr) predicate(UseAPX); match(Set dst (LShiftI src shift)); effect(KILL cr); - flag(PD::Flag_ndd_demotable); + flag(PD::Flag_ndd_demotable_opr1); format %{ "esall $dst, $src, $shift\t# int (ndd)" %} ins_encode %{ @@ -11992,7 +11993,7 @@ instruct sarI_rReg_imm_ndd(rRegI dst, rRegI src, immI8 shift, rFlagsReg cr) predicate(UseAPX); match(Set dst (RShiftI src shift)); effect(KILL cr); - flag(PD::Flag_ndd_demotable); + flag(PD::Flag_ndd_demotable_opr1); format %{ "esarl $dst, $src, $shift\t# int (ndd)" %} ins_encode %{ @@ -12099,7 +12100,7 @@ instruct shrI_rReg_imm_ndd(rRegI dst, rRegI src, immI8 shift, rFlagsReg cr) predicate(UseAPX); match(Set dst (URShiftI src shift)); effect(KILL cr); - flag(PD::Flag_ndd_demotable); + flag(PD::Flag_ndd_demotable_opr1); format %{ "eshrl $dst, $src, $shift\t # int (ndd)" %} ins_encode %{ @@ -12207,7 +12208,7 @@ instruct salL_rReg_immI2_ndd(rRegL dst, rRegL src, immI2 shift, rFlagsReg cr) predicate(UseAPX); match(Set dst (LShiftL src shift)); effect(KILL cr); - flag(PD::Flag_ndd_demotable); + flag(PD::Flag_ndd_demotable_opr1); format %{ "esalq $dst, $src, $shift\t# long (ndd)" %} ins_encode %{ @@ -12236,7 +12237,7 @@ instruct salL_rReg_imm_ndd(rRegL dst, rRegL src, immI8 shift, rFlagsReg cr) predicate(UseAPX); match(Set dst (LShiftL src shift)); effect(KILL cr); - flag(PD::Flag_ndd_demotable); + flag(PD::Flag_ndd_demotable_opr1); format %{ "esalq $dst, $src, $shift\t# long (ndd)" %} ins_encode %{ @@ -12343,7 +12344,7 @@ instruct sarL_rReg_imm_ndd(rRegL dst, rRegL src, immI shift, rFlagsReg cr) predicate(UseAPX); match(Set dst (RShiftL src shift)); effect(KILL cr); - flag(PD::Flag_ndd_demotable); + flag(PD::Flag_ndd_demotable_opr1); format %{ "esarq $dst, $src, $shift\t# long (ndd)" %} ins_encode %{ @@ -12450,7 +12451,7 @@ instruct shrL_rReg_imm_ndd(rRegL dst, rRegL src, immI8 shift, rFlagsReg cr) predicate(UseAPX); match(Set dst (URShiftL src shift)); effect(KILL cr); - flag(PD::Flag_ndd_demotable); + flag(PD::Flag_ndd_demotable_opr1); format %{ "eshrq $dst, $src, $shift\t# long (ndd)" %} ins_encode %{ @@ -12622,7 +12623,7 @@ instruct rolI_rReg_Var_ndd(rRegI dst, rRegI src, rcx_RegI shift, rFlagsReg cr) predicate(UseAPX && n->bottom_type()->basic_type() == T_INT); match(Set dst (RotateLeft src shift)); effect(KILL cr); - flag(PD::Flag_ndd_demotable); + flag(PD::Flag_ndd_demotable_opr1); format %{ "eroll $dst, $src, $shift\t# rotate left (int ndd)" %} ins_encode %{ @@ -12687,7 +12688,7 @@ instruct rorI_rReg_Var_ndd(rRegI dst, rRegI src, rcx_RegI shift, rFlagsReg cr) predicate(UseAPX && n->bottom_type()->basic_type() == T_INT); match(Set dst (RotateRight src shift)); effect(KILL cr); - flag(PD::Flag_ndd_demotable); + flag(PD::Flag_ndd_demotable_opr1); format %{ "erorl $dst, $src, $shift\t# rotate right(int ndd)" %} ins_encode %{ @@ -12754,7 +12755,7 @@ instruct rolL_rReg_Var_ndd(rRegL dst, rRegL src, rcx_RegI shift, rFlagsReg cr) predicate(UseAPX && n->bottom_type()->basic_type() == T_LONG); match(Set dst (RotateLeft src shift)); effect(KILL cr); - flag(PD::Flag_ndd_demotable); + flag(PD::Flag_ndd_demotable_opr1); format %{ "erolq $dst, $src, $shift\t# rotate left(long ndd)" %} ins_encode %{ @@ -12819,7 +12820,7 @@ instruct rorL_rReg_Var_ndd(rRegL dst, rRegL src, rcx_RegI shift, rFlagsReg cr) predicate(UseAPX && n->bottom_type()->basic_type() == T_LONG); match(Set dst (RotateRight src shift)); effect(KILL cr); - flag(PD::Flag_ndd_demotable); + flag(PD::Flag_ndd_demotable_opr1); format %{ "erorq $dst, $src, $shift\t# rotate right(long ndd)" %} ins_encode %{ @@ -12897,7 +12898,7 @@ instruct andI_rReg_ndd(rRegI dst, rRegI src1, rRegI src2, rFlagsReg cr) predicate(UseAPX); match(Set dst (AndI src1 src2)); effect(KILL cr); - flag(PD::Flag_sets_sign_flag, PD::Flag_sets_zero_flag, PD::Flag_sets_parity_flag, PD::Flag_clears_overflow_flag, PD::Flag_clears_carry_flag, PD::Flag_ndd_demotable_commutative); + flag(PD::Flag_sets_sign_flag, PD::Flag_sets_zero_flag, PD::Flag_sets_parity_flag, PD::Flag_clears_overflow_flag, PD::Flag_clears_carry_flag, PD::Flag_ndd_demotable_opr1, PD::Flag_ndd_demotable_opr2); format %{ "eandl $dst, $src1, $src2\t# int ndd" %} ins_encode %{ @@ -12990,7 +12991,7 @@ instruct andI_rReg_rReg_imm_ndd(rRegI dst, rRegI src1, immI src2, rFlagsReg cr) predicate(UseAPX); match(Set dst (AndI src1 src2)); effect(KILL cr); - flag(PD::Flag_sets_sign_flag, PD::Flag_sets_zero_flag, PD::Flag_sets_parity_flag, PD::Flag_clears_overflow_flag, PD::Flag_clears_carry_flag, PD::Flag_ndd_demotable); + flag(PD::Flag_sets_sign_flag, PD::Flag_sets_zero_flag, PD::Flag_sets_parity_flag, PD::Flag_clears_overflow_flag, PD::Flag_clears_carry_flag, PD::Flag_ndd_demotable_opr1); format %{ "eandl $dst, $src1, $src2\t# int ndd" %} ins_encode %{ @@ -13034,7 +13035,7 @@ instruct andI_rReg_rReg_mem_ndd(rRegI dst, rRegI src1, memory src2, rFlagsReg cr predicate(UseAPX); match(Set dst (AndI src1 (LoadI src2))); effect(KILL cr); - flag(PD::Flag_sets_sign_flag, PD::Flag_sets_zero_flag, PD::Flag_sets_parity_flag, PD::Flag_clears_overflow_flag, PD::Flag_clears_carry_flag, PD::Flag_ndd_demotable_commutative); + flag(PD::Flag_sets_sign_flag, PD::Flag_sets_zero_flag, PD::Flag_sets_parity_flag, PD::Flag_clears_overflow_flag, PD::Flag_clears_carry_flag, PD::Flag_ndd_demotable_opr1, PD::Flag_ndd_demotable_opr2); ins_cost(150); format %{ "eandl $dst, $src1, $src2\t# int ndd" %} @@ -13234,7 +13235,7 @@ instruct orI_rReg_ndd(rRegI dst, rRegI src1, rRegI src2, rFlagsReg cr) predicate(UseAPX); match(Set dst (OrI src1 src2)); effect(KILL cr); - flag(PD::Flag_sets_sign_flag, PD::Flag_sets_zero_flag, PD::Flag_sets_parity_flag, PD::Flag_clears_overflow_flag, PD::Flag_clears_carry_flag, PD::Flag_ndd_demotable_commutative); + flag(PD::Flag_sets_sign_flag, PD::Flag_sets_zero_flag, PD::Flag_sets_parity_flag, PD::Flag_clears_overflow_flag, PD::Flag_clears_carry_flag, PD::Flag_ndd_demotable_opr1, PD::Flag_ndd_demotable_opr2); format %{ "eorl $dst, $src1, $src2\t# int ndd" %} ins_encode %{ @@ -13263,7 +13264,7 @@ instruct orI_rReg_rReg_imm_ndd(rRegI dst, rRegI src1, immI src2, rFlagsReg cr) predicate(UseAPX); match(Set dst (OrI src1 src2)); effect(KILL cr); - flag(PD::Flag_sets_sign_flag, PD::Flag_sets_zero_flag, PD::Flag_sets_parity_flag, PD::Flag_clears_overflow_flag, PD::Flag_clears_carry_flag, PD::Flag_ndd_demotable); + flag(PD::Flag_sets_sign_flag, PD::Flag_sets_zero_flag, PD::Flag_sets_parity_flag, PD::Flag_clears_overflow_flag, PD::Flag_clears_carry_flag, PD::Flag_ndd_demotable_opr1); format %{ "eorl $dst, $src1, $src2\t# int ndd" %} ins_encode %{ @@ -13277,7 +13278,7 @@ instruct orI_rReg_imm_rReg_ndd(rRegI dst, immI src1, rRegI src2, rFlagsReg cr) predicate(UseAPX); match(Set dst (OrI src1 src2)); effect(KILL cr); - flag(PD::Flag_sets_sign_flag, PD::Flag_sets_zero_flag, PD::Flag_sets_parity_flag, PD::Flag_clears_overflow_flag, PD::Flag_clears_carry_flag, PD::Flag_ndd_demotable); + flag(PD::Flag_sets_sign_flag, PD::Flag_sets_zero_flag, PD::Flag_sets_parity_flag, PD::Flag_clears_overflow_flag, PD::Flag_clears_carry_flag, PD::Flag_ndd_demotable_opr1); format %{ "eorl $dst, $src2, $src1\t# int ndd" %} ins_encode %{ @@ -13321,7 +13322,7 @@ instruct orI_rReg_rReg_mem_ndd(rRegI dst, rRegI src1, memory src2, rFlagsReg cr) predicate(UseAPX); match(Set dst (OrI src1 (LoadI src2))); effect(KILL cr); - flag(PD::Flag_sets_sign_flag, PD::Flag_sets_zero_flag, PD::Flag_sets_parity_flag, PD::Flag_clears_overflow_flag, PD::Flag_clears_carry_flag, PD::Flag_ndd_demotable); + flag(PD::Flag_sets_sign_flag, PD::Flag_sets_zero_flag, PD::Flag_sets_parity_flag, PD::Flag_clears_overflow_flag, PD::Flag_clears_carry_flag, PD::Flag_ndd_demotable_opr1, PD::Flag_ndd_demotable_opr2); ins_cost(150); format %{ "eorl $dst, $src1, $src2\t# int ndd" %} @@ -13397,7 +13398,7 @@ instruct xorI_rReg_ndd(rRegI dst, rRegI src1, rRegI src2, rFlagsReg cr) predicate(UseAPX); match(Set dst (XorI src1 src2)); effect(KILL cr); - flag(PD::Flag_sets_sign_flag, PD::Flag_sets_zero_flag, PD::Flag_sets_parity_flag, PD::Flag_clears_overflow_flag, PD::Flag_clears_carry_flag, PD::Flag_ndd_demotable_commutative); + flag(PD::Flag_sets_sign_flag, PD::Flag_sets_zero_flag, PD::Flag_sets_parity_flag, PD::Flag_clears_overflow_flag, PD::Flag_clears_carry_flag, PD::Flag_ndd_demotable_opr1, PD::Flag_ndd_demotable_opr2); format %{ "exorl $dst, $src1, $src2\t# int ndd" %} ins_encode %{ @@ -13423,7 +13424,7 @@ instruct xorI_rReg_im1_ndd(rRegI dst, rRegI src, immI_M1 imm) %{ match(Set dst (XorI src imm)); predicate(UseAPX); - flag(PD::Flag_ndd_demotable); + flag(PD::Flag_ndd_demotable_opr1); format %{ "enotl $dst, $src" %} ins_encode %{ @@ -13454,7 +13455,7 @@ instruct xorI_rReg_rReg_imm_ndd(rRegI dst, rRegI src1, immI src2, rFlagsReg cr) predicate(UseAPX && n->in(2)->bottom_type()->is_int()->get_con() != -1); match(Set dst (XorI src1 src2)); effect(KILL cr); - flag(PD::Flag_sets_sign_flag, PD::Flag_sets_zero_flag, PD::Flag_sets_parity_flag, PD::Flag_clears_overflow_flag, PD::Flag_clears_carry_flag, PD::Flag_ndd_demotable); + flag(PD::Flag_sets_sign_flag, PD::Flag_sets_zero_flag, PD::Flag_sets_parity_flag, PD::Flag_clears_overflow_flag, PD::Flag_clears_carry_flag, PD::Flag_ndd_demotable_opr1); format %{ "exorl $dst, $src1, $src2\t# int ndd" %} ins_encode %{ @@ -13500,7 +13501,7 @@ instruct xorI_rReg_rReg_mem_ndd(rRegI dst, rRegI src1, memory src2, rFlagsReg cr predicate(UseAPX); match(Set dst (XorI src1 (LoadI src2))); effect(KILL cr); - flag(PD::Flag_sets_sign_flag, PD::Flag_sets_zero_flag, PD::Flag_sets_parity_flag, PD::Flag_clears_overflow_flag, PD::Flag_clears_carry_flag, PD::Flag_ndd_demotable); + flag(PD::Flag_sets_sign_flag, PD::Flag_sets_zero_flag, PD::Flag_sets_parity_flag, PD::Flag_clears_overflow_flag, PD::Flag_clears_carry_flag, PD::Flag_ndd_demotable_opr1, PD::Flag_ndd_demotable_opr2); ins_cost(150); format %{ "exorl $dst, $src1, $src2\t# int ndd" %} @@ -13579,7 +13580,7 @@ instruct andL_rReg_ndd(rRegL dst, rRegL src1, rRegL src2, rFlagsReg cr) predicate(UseAPX); match(Set dst (AndL src1 src2)); effect(KILL cr); - flag(PD::Flag_sets_sign_flag, PD::Flag_sets_zero_flag, PD::Flag_sets_parity_flag, PD::Flag_clears_overflow_flag, PD::Flag_clears_carry_flag, PD::Flag_ndd_demotable_commutative); + flag(PD::Flag_sets_sign_flag, PD::Flag_sets_zero_flag, PD::Flag_sets_parity_flag, PD::Flag_clears_overflow_flag, PD::Flag_clears_carry_flag, PD::Flag_ndd_demotable_opr1, PD::Flag_ndd_demotable_opr2); format %{ "eandq $dst, $src1, $src2\t# long ndd" %} ins_encode %{ @@ -13635,7 +13636,7 @@ instruct andL_rReg_rReg_imm_ndd(rRegL dst, rRegL src1, immL32 src2, rFlagsReg cr predicate(UseAPX); match(Set dst (AndL src1 src2)); effect(KILL cr); - flag(PD::Flag_sets_sign_flag, PD::Flag_sets_zero_flag, PD::Flag_sets_parity_flag, PD::Flag_clears_overflow_flag, PD::Flag_clears_carry_flag, PD::Flag_ndd_demotable); + flag(PD::Flag_sets_sign_flag, PD::Flag_sets_zero_flag, PD::Flag_sets_parity_flag, PD::Flag_clears_overflow_flag, PD::Flag_clears_carry_flag, PD::Flag_ndd_demotable_opr1); format %{ "eandq $dst, $src1, $src2\t# long ndd" %} ins_encode %{ @@ -13679,7 +13680,7 @@ instruct andL_rReg_rReg_mem_ndd(rRegL dst, rRegL src1, memory src2, rFlagsReg cr predicate(UseAPX); match(Set dst (AndL src1 (LoadL src2))); effect(KILL cr); - flag(PD::Flag_sets_sign_flag, PD::Flag_sets_zero_flag, PD::Flag_sets_parity_flag, PD::Flag_clears_overflow_flag, PD::Flag_clears_carry_flag, PD::Flag_ndd_demotable_commutative); + flag(PD::Flag_sets_sign_flag, PD::Flag_sets_zero_flag, PD::Flag_sets_parity_flag, PD::Flag_clears_overflow_flag, PD::Flag_clears_carry_flag, PD::Flag_ndd_demotable_opr1, PD::Flag_ndd_demotable_opr2); ins_cost(150); format %{ "eandq $dst, $src1, $src2\t# long ndd" %} @@ -13882,7 +13883,7 @@ instruct orL_rReg_ndd(rRegL dst, rRegL src1, rRegL src2, rFlagsReg cr) predicate(UseAPX); match(Set dst (OrL src1 src2)); effect(KILL cr); - flag(PD::Flag_sets_sign_flag, PD::Flag_sets_zero_flag, PD::Flag_sets_parity_flag, PD::Flag_clears_overflow_flag, PD::Flag_clears_carry_flag, PD::Flag_ndd_demotable_commutative); + flag(PD::Flag_sets_sign_flag, PD::Flag_sets_zero_flag, PD::Flag_sets_parity_flag, PD::Flag_clears_overflow_flag, PD::Flag_clears_carry_flag, PD::Flag_ndd_demotable_opr1, PD::Flag_ndd_demotable_opr2); format %{ "eorq $dst, $src1, $src2\t# long ndd" %} ins_encode %{ @@ -13937,7 +13938,7 @@ instruct orL_rReg_rReg_imm_ndd(rRegL dst, rRegL src1, immL32 src2, rFlagsReg cr) predicate(UseAPX); match(Set dst (OrL src1 src2)); effect(KILL cr); - flag(PD::Flag_sets_sign_flag, PD::Flag_sets_zero_flag, PD::Flag_sets_parity_flag, PD::Flag_clears_overflow_flag, PD::Flag_clears_carry_flag, PD::Flag_ndd_demotable); + flag(PD::Flag_sets_sign_flag, PD::Flag_sets_zero_flag, PD::Flag_sets_parity_flag, PD::Flag_clears_overflow_flag, PD::Flag_clears_carry_flag, PD::Flag_ndd_demotable_opr1); format %{ "eorq $dst, $src1, $src2\t# long ndd" %} ins_encode %{ @@ -13951,7 +13952,7 @@ instruct orL_rReg_imm_rReg_ndd(rRegL dst, immL32 src1, rRegL src2, rFlagsReg cr) predicate(UseAPX); match(Set dst (OrL src1 src2)); effect(KILL cr); - flag(PD::Flag_sets_sign_flag, PD::Flag_sets_zero_flag, PD::Flag_sets_parity_flag, PD::Flag_clears_overflow_flag, PD::Flag_clears_carry_flag, PD::Flag_ndd_demotable); + flag(PD::Flag_sets_sign_flag, PD::Flag_sets_zero_flag, PD::Flag_sets_parity_flag, PD::Flag_clears_overflow_flag, PD::Flag_clears_carry_flag, PD::Flag_ndd_demotable_opr1); format %{ "eorq $dst, $src2, $src1\t# long ndd" %} ins_encode %{ @@ -13996,7 +13997,7 @@ instruct orL_rReg_rReg_mem_ndd(rRegL dst, rRegL src1, memory src2, rFlagsReg cr) predicate(UseAPX); match(Set dst (OrL src1 (LoadL src2))); effect(KILL cr); - flag(PD::Flag_sets_sign_flag, PD::Flag_sets_zero_flag, PD::Flag_sets_parity_flag, PD::Flag_clears_overflow_flag, PD::Flag_clears_carry_flag, PD::Flag_ndd_demotable_commutative); + flag(PD::Flag_sets_sign_flag, PD::Flag_sets_zero_flag, PD::Flag_sets_parity_flag, PD::Flag_clears_overflow_flag, PD::Flag_clears_carry_flag, PD::Flag_ndd_demotable_opr1, PD::Flag_ndd_demotable_opr2); ins_cost(150); format %{ "eorq $dst, $src1, $src2\t# long ndd" %} @@ -14075,7 +14076,7 @@ instruct xorL_rReg_ndd(rRegL dst, rRegL src1, rRegL src2, rFlagsReg cr) predicate(UseAPX); match(Set dst (XorL src1 src2)); effect(KILL cr); - flag(PD::Flag_sets_sign_flag, PD::Flag_sets_zero_flag, PD::Flag_sets_parity_flag, PD::Flag_clears_overflow_flag, PD::Flag_clears_carry_flag, PD::Flag_ndd_demotable_commutative); + flag(PD::Flag_sets_sign_flag, PD::Flag_sets_zero_flag, PD::Flag_sets_parity_flag, PD::Flag_clears_overflow_flag, PD::Flag_clears_carry_flag, PD::Flag_ndd_demotable_opr1, PD::Flag_ndd_demotable_opr2); format %{ "exorq $dst, $src1, $src2\t# long ndd" %} ins_encode %{ @@ -14101,7 +14102,7 @@ instruct xorL_rReg_im1_ndd(rRegL dst,rRegL src, immL_M1 imm) %{ predicate(UseAPX); match(Set dst (XorL src imm)); - flag(PD::Flag_ndd_demotable); + flag(PD::Flag_ndd_demotable_opr1); format %{ "enotq $dst, $src" %} ins_encode %{ @@ -14132,7 +14133,7 @@ instruct xorL_rReg_rReg_imm(rRegL dst, rRegL src1, immL32 src2, rFlagsReg cr) predicate(UseAPX && n->in(2)->bottom_type()->is_long()->get_con() != -1L); match(Set dst (XorL src1 src2)); effect(KILL cr); - flag(PD::Flag_sets_sign_flag, PD::Flag_sets_zero_flag, PD::Flag_sets_parity_flag, PD::Flag_clears_overflow_flag, PD::Flag_clears_carry_flag, PD::Flag_ndd_demotable); + flag(PD::Flag_sets_sign_flag, PD::Flag_sets_zero_flag, PD::Flag_sets_parity_flag, PD::Flag_clears_overflow_flag, PD::Flag_clears_carry_flag, PD::Flag_ndd_demotable_opr1); format %{ "exorq $dst, $src1, $src2\t# long ndd" %} ins_encode %{ @@ -14178,7 +14179,7 @@ instruct xorL_rReg_rReg_mem_ndd(rRegL dst, rRegL src1, memory src2, rFlagsReg cr predicate(UseAPX); match(Set dst (XorL src1 (LoadL src2))); effect(KILL cr); - flag(PD::Flag_sets_sign_flag, PD::Flag_sets_zero_flag, PD::Flag_sets_parity_flag, PD::Flag_clears_overflow_flag, PD::Flag_clears_carry_flag, PD::Flag_ndd_demotable_commutative); + flag(PD::Flag_sets_sign_flag, PD::Flag_sets_zero_flag, PD::Flag_sets_parity_flag, PD::Flag_clears_overflow_flag, PD::Flag_clears_carry_flag, PD::Flag_ndd_demotable_opr1, PD::Flag_ndd_demotable_opr2); ins_cost(150); format %{ "exorq $dst, $src1, $src2\t# long ndd" %} @@ -16633,7 +16634,7 @@ instruct minI_rReg_ndd(rRegI dst, rRegI src1, rRegI src2) predicate(UseAPX); match(Set dst (MinI src1 src2)); effect(DEF dst, USE src1, USE src2); - flag(PD::Flag_ndd_demotable); + flag(PD::Flag_ndd_demotable_opr1); ins_cost(200); expand %{ @@ -16685,7 +16686,7 @@ instruct maxI_rReg_ndd(rRegI dst, rRegI src1, rRegI src2) predicate(UseAPX); match(Set dst (MaxI src1 src2)); effect(DEF dst, USE src1, USE src2); - flag(PD::Flag_ndd_demotable); + flag(PD::Flag_ndd_demotable_opr1); ins_cost(200); expand %{ From dd20e9150666f247af61dfa524a170ef7dd96c03 Mon Sep 17 00:00:00 2001 From: Aleksey Shipilev Date: Wed, 7 Jan 2026 18:10:06 +0000 Subject: [PATCH 080/712] 8374521: Support fine-grained native debug levels Reviewed-by: erikj, krk, clanger --- .github/workflows/build-alpine-linux.yml | 1 + .github/workflows/build-cross-compile.yml | 1 + .github/workflows/build-linux.yml | 1 + .github/workflows/build-macos.yml | 1 + make/autoconf/flags-cflags.m4 | 27 +++++++++++++++++++---- 5 files changed, 27 insertions(+), 4 deletions(-) diff --git a/.github/workflows/build-alpine-linux.yml b/.github/workflows/build-alpine-linux.yml index c356a8a0f2a..569893d5ccc 100644 --- a/.github/workflows/build-alpine-linux.yml +++ b/.github/workflows/build-alpine-linux.yml @@ -97,6 +97,7 @@ jobs: --with-zlib=system --with-jmod-compress=zip-1 --with-external-symbols-in-bundles=none + --with-debug-info-level=1 ${{ inputs.extra-conf-options }} ${{ inputs.configure-arguments }} || ( echo "Dumping config.log:" && cat config.log && diff --git a/.github/workflows/build-cross-compile.yml b/.github/workflows/build-cross-compile.yml index c2ed63aa439..4860228c7de 100644 --- a/.github/workflows/build-cross-compile.yml +++ b/.github/workflows/build-cross-compile.yml @@ -180,6 +180,7 @@ jobs: --with-sysroot=sysroot --with-jmod-compress=zip-1 --with-external-symbols-in-bundles=none + --with-debug-info-level=1 CC=${{ matrix.gnu-arch }}-linux-gnu${{ matrix.gnu-abi}}-gcc-${{ inputs.gcc-major-version }} CXX=${{ matrix.gnu-arch }}-linux-gnu${{ matrix.gnu-abi}}-g++-${{ inputs.gcc-major-version }} ${{ inputs.extra-conf-options }} ${{ inputs.configure-arguments }} || ( diff --git a/.github/workflows/build-linux.yml b/.github/workflows/build-linux.yml index a668cb5a0f9..121416106f2 100644 --- a/.github/workflows/build-linux.yml +++ b/.github/workflows/build-linux.yml @@ -144,6 +144,7 @@ jobs: --with-zlib=system --with-jmod-compress=zip-1 --with-external-symbols-in-bundles=none + --with-debug-info-level=1 ${{ inputs.extra-conf-options }} ${{ inputs.configure-arguments }} || ( echo "Dumping config.log:" && cat config.log && diff --git a/.github/workflows/build-macos.yml b/.github/workflows/build-macos.yml index 4535d0dd760..32c5d43acbc 100644 --- a/.github/workflows/build-macos.yml +++ b/.github/workflows/build-macos.yml @@ -111,6 +111,7 @@ jobs: --with-zlib=system --with-jmod-compress=zip-1 --with-external-symbols-in-bundles=none + --with-debug-info-level=1 ${{ inputs.extra-conf-options }} ${{ inputs.configure-arguments }} || ( echo "Dumping config.log:" && cat config.log && diff --git a/make/autoconf/flags-cflags.m4 b/make/autoconf/flags-cflags.m4 index 6298bcae416..b7b2a6b5e17 100644 --- a/make/autoconf/flags-cflags.m4 +++ b/make/autoconf/flags-cflags.m4 @@ -69,6 +69,23 @@ AC_DEFUN([FLAGS_SETUP_DEBUG_SYMBOLS], # Debug prefix mapping if supported by compiler DEBUG_PREFIX_CFLAGS= + UTIL_ARG_WITH(NAME: debug-info-level, TYPE: string, + DEFAULT: "", + RESULT: DEBUG_INFO_LEVEL, + DESC: [Sets the debug info level, when debug info generation is enabled (GCC and Clang only)], + DEFAULT_DESC: [default]) + AC_SUBST(DEBUG_INFO_LEVEL) + + if test "x${TOOLCHAIN_TYPE}" = xgcc || \ + test "x${TOOLCHAIN_TYPE}" = xclang; then + DEBUG_INFO_LEVEL_FLAGS="-g" + if test "x${DEBUG_INFO_LEVEL}" != "x"; then + DEBUG_INFO_LEVEL_FLAGS="-g${DEBUG_INFO_LEVEL}" + FLAGS_COMPILER_CHECK_ARGUMENTS(ARGUMENT: [${DEBUG_INFO_LEVEL_FLAGS}], + IF_FALSE: AC_MSG_ERROR("Debug info level ${DEBUG_INFO_LEVEL} is not supported")) + fi + fi + # Debug symbols if test "x$TOOLCHAIN_TYPE" = xgcc; then if test "x$ALLOW_ABSOLUTE_PATHS_IN_OUTPUT" = "xfalse"; then @@ -93,8 +110,9 @@ AC_DEFUN([FLAGS_SETUP_DEBUG_SYMBOLS], ) fi - CFLAGS_DEBUG_SYMBOLS="-g -gdwarf-4" - ASFLAGS_DEBUG_SYMBOLS="-g" + # Debug info level should follow the debug format to be effective. + CFLAGS_DEBUG_SYMBOLS="-gdwarf-4 ${DEBUG_INFO_LEVEL_FLAGS}" + ASFLAGS_DEBUG_SYMBOLS="${DEBUG_INFO_LEVEL_FLAGS}" elif test "x$TOOLCHAIN_TYPE" = xclang; then if test "x$ALLOW_ABSOLUTE_PATHS_IN_OUTPUT" = "xfalse"; then # Check if compiler supports -fdebug-prefix-map. If so, use that to make @@ -113,8 +131,9 @@ AC_DEFUN([FLAGS_SETUP_DEBUG_SYMBOLS], FLAGS_COMPILER_CHECK_ARGUMENTS(ARGUMENT: [${GDWARF_FLAGS}], IF_FALSE: [GDWARF_FLAGS=""]) - CFLAGS_DEBUG_SYMBOLS="-g ${GDWARF_FLAGS}" - ASFLAGS_DEBUG_SYMBOLS="-g" + # Debug info level should follow the debug format to be effective. + CFLAGS_DEBUG_SYMBOLS="${GDWARF_FLAGS} ${DEBUG_INFO_LEVEL_FLAGS}" + ASFLAGS_DEBUG_SYMBOLS="${DEBUG_INFO_LEVEL_FLAGS}" elif test "x$TOOLCHAIN_TYPE" = xmicrosoft; then CFLAGS_DEBUG_SYMBOLS="-Z7" fi From 383fe1efc3a23385b8576e20f458f91085c6325e Mon Sep 17 00:00:00 2001 From: Erik Joelsson Date: Wed, 7 Jan 2026 21:52:12 +0000 Subject: [PATCH 081/712] 8374642: EscapeHash macro fails with GNU make 4.3 and 4.4 Reviewed-by: tbell, shade --- make/common/Utils.gmk | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/make/common/Utils.gmk b/make/common/Utils.gmk index c0ebabca3f7..b4bb949d3ee 100644 --- a/make/common/Utils.gmk +++ b/make/common/Utils.gmk @@ -114,7 +114,7 @@ EscapeDollar = $(subst $$,\$$,$(subst \$$,$$,$(strip $1))) ################################################################################ # This macro works just like EscapeDollar above, but for #. -EscapeHash = $(subst \#,\\\#,$(subst \\\#,\#,$(strip $1))) +EscapeHash = $(subst $(HASH),\$(HASH),$(subst \$(HASH),$(HASH),$(strip $1))) ################################################################################ # This macro translates $ into $$ to protect the string from make itself. From 9a944e558733950d135b5a91d093b7a28e934f59 Mon Sep 17 00:00:00 2001 From: Kim Barrett Date: Wed, 7 Jan 2026 22:23:39 +0000 Subject: [PATCH 082/712] 8372754: Add wrapper for 8369205: AIX build break in forbiddenFunctions.hpp Reviewed-by: mdoerr, tschatzl --- src/hotspot/cpu/aarch64/immediate_aarch64.cpp | 8 +- src/hotspot/cpu/aarch64/immediate_aarch64.hpp | 9 +- src/hotspot/os/aix/libodm_aix.cpp | 8 +- src/hotspot/os/aix/libperfstat_aix.hpp | 5 +- src/hotspot/os/aix/os_perf_aix.cpp | 4 +- src/hotspot/os/bsd/memMapPrinter_macosx.cpp | 4 +- src/hotspot/os/linux/os_linux.cpp | 4 +- src/hotspot/os/linux/os_perf_linux.cpp | 4 +- .../os/posix/forbiddenFunctions_posix.hpp | 11 +- src/hotspot/os/posix/os_posix.cpp | 3 +- .../posix/permitForbiddenFunctions_posix.hpp | 7 +- src/hotspot/os/windows/os_windows.cpp | 3 +- .../permitForbiddenFunctions_windows.hpp | 5 +- src/hotspot/os/windows/vmError_windows.cpp | 3 +- .../os_cpu/bsd_aarch64/os_bsd_aarch64.cpp | 4 +- src/hotspot/os_cpu/bsd_x86/os_bsd_x86.cpp | 4 +- .../os_cpu/linux_aarch64/os_linux_aarch64.cpp | 4 +- src/hotspot/os_cpu/linux_arm/os_linux_arm.cpp | 4 +- src/hotspot/os_cpu/linux_ppc/os_linux_ppc.cpp | 4 +- .../os_cpu/linux_riscv/os_linux_riscv.cpp | 4 +- .../os_cpu/linux_s390/os_linux_s390.cpp | 4 +- src/hotspot/os_cpu/linux_x86/os_linux_x86.cpp | 4 +- .../windows_aarch64/os_windows_aarch64.cpp | 4 +- src/hotspot/share/classfile/classLoader.cpp | 4 +- src/hotspot/share/cppstdlib/cstdlib.hpp | 105 ++++++++++++++++++ src/hotspot/share/utilities/byteswap.hpp | 3 +- .../share/utilities/forbiddenFunctions.hpp | 23 +--- .../share/utilities/globalDefinitions_gcc.hpp | 13 +-- .../utilities/globalDefinitions_visCPP.hpp | 5 +- src/hotspot/share/utilities/parseInteger.hpp | 4 +- .../utilities/permitForbiddenFunctions.hpp | 7 +- test/hotspot/gtest/gtestMain.cpp | 4 +- test/hotspot/gtest/unittest.hpp | 4 +- .../gtest/utilities/test_bitMap_setops.cpp | 5 +- 34 files changed, 193 insertions(+), 98 deletions(-) create mode 100644 src/hotspot/share/cppstdlib/cstdlib.hpp diff --git a/src/hotspot/cpu/aarch64/immediate_aarch64.cpp b/src/hotspot/cpu/aarch64/immediate_aarch64.cpp index 710a1f0677d..eb4cb23100c 100644 --- a/src/hotspot/cpu/aarch64/immediate_aarch64.cpp +++ b/src/hotspot/cpu/aarch64/immediate_aarch64.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) 2014, 2020, Red Hat Inc. All rights reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * @@ -23,13 +23,13 @@ * */ -#include // do not reorder -#include // do not reorder - +#include "cppstdlib/cstdlib.hpp" #include "immediate_aarch64.hpp" #include "metaprogramming/primitiveConversions.hpp" #include "utilities/globalDefinitions.hpp" +#include + // there are at most 2^13 possible logical immediate encodings // however, some combinations of immr and imms are invalid static const unsigned LI_TABLE_SIZE = (1 << 13); diff --git a/src/hotspot/cpu/aarch64/immediate_aarch64.hpp b/src/hotspot/cpu/aarch64/immediate_aarch64.hpp index 0cbdb562088..fb38995417b 100644 --- a/src/hotspot/cpu/aarch64/immediate_aarch64.hpp +++ b/src/hotspot/cpu/aarch64/immediate_aarch64.hpp @@ -1,4 +1,5 @@ /* + * Copyright (c) 2025, 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. * @@ -22,10 +23,10 @@ * */ -#ifndef _IMMEDIATE_H -#define _IMMEDIATE_H +#ifndef CPU_AARCH64_IMMEDIATE_AARCH64_HPP +#define CPU_AARCH64_IMMEDIATE_AARCH64_HPP -#include +#include /* * functions to map backwards and forwards between logical or floating @@ -51,4 +52,4 @@ uint32_t encoding_for_logical_immediate(uint64_t immediate); uint64_t fp_immediate_for_encoding(uint32_t imm8, int is_dp); uint32_t encoding_for_fp_immediate(float immediate); -#endif // _IMMEDIATE_H +#endif // CPU_AARCH64_IMMEDIATE_AARCH64_HPP diff --git a/src/hotspot/os/aix/libodm_aix.cpp b/src/hotspot/os/aix/libodm_aix.cpp index 035703a1771..38e8067181a 100644 --- a/src/hotspot/os/aix/libodm_aix.cpp +++ b/src/hotspot/os/aix/libodm_aix.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. * Copyright (c) 2015, 2019 SAP SE. All rights reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * @@ -23,15 +23,15 @@ * */ +#include "cppstdlib/cstdlib.hpp" #include "libodm_aix.hpp" #include "misc_aix.hpp" -#include -#include -#include #include "runtime/arguments.hpp" #include "runtime/os.hpp" #include "utilities/permitForbiddenFunctions.hpp" +#include +#include dynamicOdm::dynamicOdm() { const char* libodmname = "/usr/lib/libodm.a(shr_64.o)"; diff --git a/src/hotspot/os/aix/libperfstat_aix.hpp b/src/hotspot/os/aix/libperfstat_aix.hpp index 5a6ddfd8f4d..aff11cfb41f 100644 --- a/src/hotspot/os/aix/libperfstat_aix.hpp +++ b/src/hotspot/os/aix/libperfstat_aix.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) 2012, 2024 SAP SE. All rights reserved. * Copyright (c) 2022, IBM Corp. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. @@ -32,8 +32,9 @@ #ifndef OS_AIX_LIBPERFSTAT_AIX_HPP #define OS_AIX_LIBPERFSTAT_AIX_HPP +#include "cppstdlib/cstdlib.hpp" + #include -#include /////////////////////////////////////////////////////////////////////////////////////////////// // These are excerpts from the AIX 7.1 libperfstat.h - diff --git a/src/hotspot/os/aix/os_perf_aix.cpp b/src/hotspot/os/aix/os_perf_aix.cpp index 8444002b871..aa8819d035f 100644 --- a/src/hotspot/os/aix/os_perf_aix.cpp +++ b/src/hotspot/os/aix/os_perf_aix.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. * Copyright (c) 2022, 2024, IBM Corp. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * @@ -23,6 +23,7 @@ * */ +#include "cppstdlib/cstdlib.hpp" #include "jvm.h" #include "libperfstat_aix.hpp" #include "memory/allocation.inline.hpp" @@ -46,7 +47,6 @@ #include #include #include -#include #include typedef struct { diff --git a/src/hotspot/os/bsd/memMapPrinter_macosx.cpp b/src/hotspot/os/bsd/memMapPrinter_macosx.cpp index a7ddab04d85..6fd08d63e85 100644 --- a/src/hotspot/os/bsd/memMapPrinter_macosx.cpp +++ b/src/hotspot/os/bsd/memMapPrinter_macosx.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. * @@ -25,6 +25,7 @@ #if defined(__APPLE__) +#include "cppstdlib/cstdlib.hpp" #include "nmt/memMapPrinter.hpp" #include "runtime/os.hpp" #include "utilities/align.hpp" @@ -34,7 +35,6 @@ #include #include -#include #include #include diff --git a/src/hotspot/os/linux/os_linux.cpp b/src/hotspot/os/linux/os_linux.cpp index a28f9850495..88e5e9b582a 100644 --- a/src/hotspot/os/linux/os_linux.cpp +++ b/src/hotspot/os/linux/os_linux.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) 2015, 2024 SAP SE. All rights reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * @@ -27,6 +27,7 @@ #include "code/vtableStubs.hpp" #include "compiler/compileBroker.hpp" #include "compiler/disassembler.hpp" +#include "cppstdlib/cstdlib.hpp" #include "hugepages.hpp" #include "interpreter/interpreter.hpp" #include "jvm.h" @@ -96,7 +97,6 @@ # include # include # include -# include # include # include # include diff --git a/src/hotspot/os/linux/os_perf_linux.cpp b/src/hotspot/os/linux/os_perf_linux.cpp index 5708194521f..9f91f3b4c0d 100644 --- a/src/hotspot/os/linux/os_perf_linux.cpp +++ b/src/hotspot/os/linux/os_perf_linux.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 @@ -22,6 +22,7 @@ * */ +#include "cppstdlib/cstdlib.hpp" #include "jvm.h" #include "memory/allocation.inline.hpp" #include "os_linux.inline.hpp" @@ -40,7 +41,6 @@ #include #include #include -#include #include #include #include diff --git a/src/hotspot/os/posix/forbiddenFunctions_posix.hpp b/src/hotspot/os/posix/forbiddenFunctions_posix.hpp index 529cf22078e..1c91e9d2599 100644 --- a/src/hotspot/os/posix/forbiddenFunctions_posix.hpp +++ b/src/hotspot/os/posix/forbiddenFunctions_posix.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 @@ -36,15 +36,12 @@ #include #endif +// POSIX puts _exit in . +FORBID_IMPORTED_NORETURN_C_FUNCTION(void _exit(int), /* not noexcept */, "use os::exit") + // If needed, add os::strndup and use that instead. FORBID_C_FUNCTION(char* strndup(const char*, size_t), noexcept, "don't use"); -// These are unimplementable for Windows, and they aren't useful for a -// POSIX implementation of NMT either. -// https://stackoverflow.com/questions/62962839/stdaligned-alloc-missing-from-visual-studio-2019 -FORBID_C_FUNCTION(int posix_memalign(void**, size_t, size_t), noexcept, "don't use"); -FORBID_C_FUNCTION(void* aligned_alloc(size_t, size_t), noexcept, "don't use"); - // realpath with a null second argument mallocs a string for the result. // With a non-null second argument, there is a risk of buffer overrun. PRAGMA_DIAG_PUSH diff --git a/src/hotspot/os/posix/os_posix.cpp b/src/hotspot/os/posix/os_posix.cpp index 07e1920c62d..4cae7d359e4 100644 --- a/src/hotspot/os/posix/os_posix.cpp +++ b/src/hotspot/os/posix/os_posix.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 @@ -23,6 +23,7 @@ */ #include "classfile/classLoader.hpp" +#include "cppstdlib/cstdlib.hpp" #include "interpreter/interpreter.hpp" #include "jvm.h" #include "jvmtifiles/jvmti.h" diff --git a/src/hotspot/os/posix/permitForbiddenFunctions_posix.hpp b/src/hotspot/os/posix/permitForbiddenFunctions_posix.hpp index 3ff8c383a31..b45cede2e5f 100644 --- a/src/hotspot/os/posix/permitForbiddenFunctions_posix.hpp +++ b/src/hotspot/os/posix/permitForbiddenFunctions_posix.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 @@ -25,15 +25,20 @@ #ifndef OS_POSIX_PERMITFORBIDDENFUNCTIONS_POSIX_HPP #define OS_POSIX_PERMITFORBIDDENFUNCTIONS_POSIX_HPP +#include "cppstdlib/cstdlib.hpp" #include "utilities/compilerWarnings.hpp" #include "utilities/globalDefinitions.hpp" +#include + // Provide wrappers for some functions otherwise forbidden from use in HotSpot. // See forbiddenFunctions.hpp for details. namespace permit_forbidden_function { BEGIN_ALLOW_FORBIDDEN_FUNCTIONS +[[noreturn]] inline void _exit(int status) { ::_exit(status); } + // Used by the POSIX implementation of os::realpath. inline char* realpath(const char* path, char* resolved_path) { return ::realpath(path, resolved_path); diff --git a/src/hotspot/os/windows/os_windows.cpp b/src/hotspot/os/windows/os_windows.cpp index 0ac05e8a435..efbd1fe7c68 100644 --- a/src/hotspot/os/windows/os_windows.cpp +++ b/src/hotspot/os/windows/os_windows.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 @@ -30,6 +30,7 @@ #include "code/vtableStubs.hpp" #include "compiler/compileBroker.hpp" #include "compiler/disassembler.hpp" +#include "cppstdlib/cstdlib.hpp" #include "interpreter/interpreter.hpp" #include "jvm.h" #include "jvmtifiles/jvmti.h" diff --git a/src/hotspot/os/windows/permitForbiddenFunctions_windows.hpp b/src/hotspot/os/windows/permitForbiddenFunctions_windows.hpp index 99e77464fbd..fbd476ceb60 100644 --- a/src/hotspot/os/windows/permitForbiddenFunctions_windows.hpp +++ b/src/hotspot/os/windows/permitForbiddenFunctions_windows.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 @@ -25,6 +25,7 @@ #ifndef OS_WINDOWS_PERMITFORBIDDENFUNCTIONS_WINDOWS_HPP #define OS_WINDOWS_PERMITFORBIDDENFUNCTIONS_WINDOWS_HPP +#include "cppstdlib/cstdlib.hpp" #include "utilities/compilerWarnings.hpp" #include "utilities/globalDefinitions.hpp" @@ -34,6 +35,8 @@ namespace permit_forbidden_function { BEGIN_ALLOW_FORBIDDEN_FUNCTIONS +[[noreturn]] inline void _exit(int status) { ::_exit(status); } + // Used by the Windows implementation of os::realpath. inline char* _fullpath(char* absPath, const char* relPath, size_t maxLength) { return ::_fullpath(absPath, relPath, maxLength); diff --git a/src/hotspot/os/windows/vmError_windows.cpp b/src/hotspot/os/windows/vmError_windows.cpp index 22df4d82cbf..66df38d2734 100644 --- a/src/hotspot/os/windows/vmError_windows.cpp +++ b/src/hotspot/os/windows/vmError_windows.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 @@ -24,6 +24,7 @@ #include "cds/aotMetaspace.hpp" #include "cds/cdsConfig.hpp" +#include "cppstdlib/cstdlib.hpp" #include "runtime/arguments.hpp" #include "runtime/javaThread.hpp" #include "runtime/os.hpp" diff --git a/src/hotspot/os_cpu/bsd_aarch64/os_bsd_aarch64.cpp b/src/hotspot/os_cpu/bsd_aarch64/os_bsd_aarch64.cpp index f6e2d39e315..62dba218b2f 100644 --- a/src/hotspot/os_cpu/bsd_aarch64/os_bsd_aarch64.cpp +++ b/src/hotspot/os_cpu/bsd_aarch64/os_bsd_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, Red Hat Inc. All rights reserved. * Copyright (c) 2021, Azul Systems, Inc. All rights reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. @@ -29,6 +29,7 @@ #include "classfile/vmSymbols.hpp" #include "code/codeCache.hpp" #include "code/vtableStubs.hpp" +#include "cppstdlib/cstdlib.hpp" #include "interpreter/interpreter.hpp" #include "jvm.h" #include "logging/log.hpp" @@ -63,7 +64,6 @@ # include # include # include -# include # include # include # include diff --git a/src/hotspot/os_cpu/bsd_x86/os_bsd_x86.cpp b/src/hotspot/os_cpu/bsd_x86/os_bsd_x86.cpp index 420e7b4cd8d..f1c80594eaf 100644 --- a/src/hotspot/os_cpu/bsd_x86/os_bsd_x86.cpp +++ b/src/hotspot/os_cpu/bsd_x86/os_bsd_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 @@ -26,6 +26,7 @@ #include "classfile/vmSymbols.hpp" #include "code/codeCache.hpp" #include "code/vtableStubs.hpp" +#include "cppstdlib/cstdlib.hpp" #include "interpreter/interpreter.hpp" #include "jvm.h" #include "logging/log.hpp" @@ -58,7 +59,6 @@ # include # include # include -# include # include # include # include diff --git a/src/hotspot/os_cpu/linux_aarch64/os_linux_aarch64.cpp b/src/hotspot/os_cpu/linux_aarch64/os_linux_aarch64.cpp index e565f353382..da9e7e159f1 100644 --- a/src/hotspot/os_cpu/linux_aarch64/os_linux_aarch64.cpp +++ b/src/hotspot/os_cpu/linux_aarch64/os_linux_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, Red Hat Inc. All rights reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * @@ -28,6 +28,7 @@ #include "code/codeCache.hpp" #include "code/vtableStubs.hpp" #include "code/nativeInst.hpp" +#include "cppstdlib/cstdlib.hpp" #include "interpreter/interpreter.hpp" #include "jvm.h" #include "memory/allocation.inline.hpp" @@ -59,7 +60,6 @@ # include # include # include -# include # include # include # include diff --git a/src/hotspot/os_cpu/linux_arm/os_linux_arm.cpp b/src/hotspot/os_cpu/linux_arm/os_linux_arm.cpp index f4196d89fe3..41a4dbea384 100644 --- a/src/hotspot/os_cpu/linux_arm/os_linux_arm.cpp +++ b/src/hotspot/os_cpu/linux_arm/os_linux_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 @@ -25,6 +25,7 @@ #include "asm/assembler.inline.hpp" #include "classfile/vmSymbols.hpp" #include "code/vtableStubs.hpp" +#include "cppstdlib/cstdlib.hpp" #include "interpreter/interpreter.hpp" #include "jvm.h" #include "memory/allocation.inline.hpp" @@ -57,7 +58,6 @@ # include # include # include -# include # include # include # include diff --git a/src/hotspot/os_cpu/linux_ppc/os_linux_ppc.cpp b/src/hotspot/os_cpu/linux_ppc/os_linux_ppc.cpp index 5909b5799b9..6854fb805a9 100644 --- a/src/hotspot/os_cpu/linux_ppc/os_linux_ppc.cpp +++ b/src/hotspot/os_cpu/linux_ppc/os_linux_ppc.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, 2025 SAP SE. All rights reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * @@ -28,6 +28,7 @@ #include "classfile/vmSymbols.hpp" #include "code/codeCache.hpp" #include "code/vtableStubs.hpp" +#include "cppstdlib/cstdlib.hpp" #include "interpreter/interpreter.hpp" #include "jvm.h" #include "memory/allocation.inline.hpp" @@ -62,7 +63,6 @@ # include # include # include -# include # include # include # include diff --git a/src/hotspot/os_cpu/linux_riscv/os_linux_riscv.cpp b/src/hotspot/os_cpu/linux_riscv/os_linux_riscv.cpp index 7a5929b0f41..d4a306d35b1 100644 --- a/src/hotspot/os_cpu/linux_riscv/os_linux_riscv.cpp +++ b/src/hotspot/os_cpu/linux_riscv/os_linux_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) 2020, 2022, Huawei Technologies Co., Ltd. All rights reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * @@ -28,6 +28,7 @@ #include "code/codeCache.hpp" #include "code/nativeInst.hpp" #include "code/vtableStubs.hpp" +#include "cppstdlib/cstdlib.hpp" #include "interpreter/interpreter.hpp" #include "jvm.h" #include "memory/allocation.inline.hpp" @@ -61,7 +62,6 @@ # include # include # include -# include # include # include # include diff --git a/src/hotspot/os_cpu/linux_s390/os_linux_s390.cpp b/src/hotspot/os_cpu/linux_s390/os_linux_s390.cpp index 4e074512e34..9982b5860a8 100644 --- a/src/hotspot/os_cpu/linux_s390/os_linux_s390.cpp +++ b/src/hotspot/os_cpu/linux_s390/os_linux_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. * @@ -30,6 +30,7 @@ #include "code/nativeInst.hpp" #include "code/vtableStubs.hpp" #include "compiler/disassembler.hpp" +#include "cppstdlib/cstdlib.h" #include "interpreter/interpreter.hpp" #include "jvm.h" #include "memory/allocation.inline.hpp" @@ -62,7 +63,6 @@ # include # include # include -# include # include # include # include diff --git a/src/hotspot/os_cpu/linux_x86/os_linux_x86.cpp b/src/hotspot/os_cpu/linux_x86/os_linux_x86.cpp index a7f4e5ef688..07f53582a76 100644 --- a/src/hotspot/os_cpu/linux_x86/os_linux_x86.cpp +++ b/src/hotspot/os_cpu/linux_x86/os_linux_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 @@ -26,6 +26,7 @@ #include "classfile/vmSymbols.hpp" #include "code/codeCache.hpp" #include "code/vtableStubs.hpp" +#include "cppstdlib/cstdlib.hpp" #include "interpreter/interpreter.hpp" #include "jvm.h" #include "logging/log.hpp" @@ -59,7 +60,6 @@ # include # include # include -# include # include # include # include diff --git a/src/hotspot/os_cpu/windows_aarch64/os_windows_aarch64.cpp b/src/hotspot/os_cpu/windows_aarch64/os_windows_aarch64.cpp index d99e0167cbd..2c2afb168fd 100644 --- a/src/hotspot/os_cpu/windows_aarch64/os_windows_aarch64.cpp +++ b/src/hotspot/os_cpu/windows_aarch64/os_windows_aarch64.cpp @@ -1,6 +1,6 @@ /* * Copyright (c) 2020, Microsoft Corporation. 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 @@ -28,6 +28,7 @@ #include "code/codeCache.hpp" #include "code/vtableStubs.hpp" #include "code/nativeInst.hpp" +#include "cppstdlib/cstdlib.hpp" #include "interpreter/interpreter.hpp" #include "jvm.h" #include "memory/allocation.inline.hpp" @@ -54,7 +55,6 @@ # include # include # include -# include # include # include diff --git a/src/hotspot/share/classfile/classLoader.cpp b/src/hotspot/share/classfile/classLoader.cpp index 12fbda899b9..d9a63cd154b 100644 --- a/src/hotspot/share/classfile/classLoader.cpp +++ b/src/hotspot/share/classfile/classLoader.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 @@ -42,6 +42,7 @@ #include "classfile/vmClasses.hpp" #include "classfile/vmSymbols.hpp" #include "compiler/compileBroker.hpp" +#include "cppstdlib/cstdlib.hpp" #include "interpreter/bytecodeStream.hpp" #include "interpreter/oopMapCache.hpp" #include "jimage.hpp" @@ -81,7 +82,6 @@ #include "utilities/utf8.hpp" #include -#include // Entry point in java.dll for path canonicalization diff --git a/src/hotspot/share/cppstdlib/cstdlib.hpp b/src/hotspot/share/cppstdlib/cstdlib.hpp new file mode 100644 index 00000000000..2b58e737882 --- /dev/null +++ b/src/hotspot/share/cppstdlib/cstdlib.hpp @@ -0,0 +1,105 @@ +/* + * 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. + * + */ + +#ifndef SHARE_CPPSTDLIB_CSTDLIB_HPP +#define SHARE_CPPSTDLIB_CSTDLIB_HPP + +#include "utilities/compilerWarnings.hpp" + +// HotSpot usage for : +// +// Some functions are explicitly forbidden below. That may not be a complete +// list of all the functions we should forbid. +// +// We assume provides definitions in the global namespace, in +// addition to providing them in the std namespace. We prefer to use the names +// in the global namespace. + +BEGIN_ALLOW_FORBIDDEN_FUNCTIONS +#include "utilities/vmassert_uninstall.hpp" + +#include + +#include "utilities/vmassert_reinstall.hpp" // don't reorder +END_ALLOW_FORBIDDEN_FUNCTIONS + +// AIX may define malloc and calloc as macros when certain other features are +// present, causing us all sorts of grief. +// https://www.ibm.com/docs/en/openxl-c-and-cpp-aix/17.1.4?topic=compilers-memory-allocation +// Replace the macro definitions with something we can work with. +// AIX 7.3 no longer uses macro renaming when building with clang, instead +// using the same asm replacement approach as used below. This workaround can +// be removed once earlier versions are no longer supported as build platforms. +#if defined(AIX) && (defined(__VEC__) || defined(__AIXVEC)) +#if defined(malloc) || defined(calloc) +#if !defined(malloc) || !defined(calloc) +#error "Inconsistent alloc macro mappings, expected both to be mapped." +#endif +// Remove the macros. +#undef malloc +#undef calloc +// Implement the mapping using gcc/clang asm name mapping. +extern "C" { +extern void* malloc(size_t) noexcept asm("vec_malloc"); +extern void* calloc(size_t, size_t) noexcept asm("vec_calloc"); +} // extern "C" +// Because the macros are in place when brings names into the std +// namespace, macro replacement causes the expanded names to be added instead +// of the intended names. We can't remove std::vec_malloc and std::vec_calloc, +// but we do add the standard names in case someone uses them. +namespace std { +using ::malloc; +using ::calloc; +} // namespace std +#endif // Macro definition for malloc or calloc +#endif // AIX altivec allocator support + +// Prefer os:: variants of these. +FORBID_IMPORTED_NORETURN_C_FUNCTION(void exit(int), noexcept, "use os::exit") +FORBID_IMPORTED_NORETURN_C_FUNCTION(void _Exit(int), noexcept, "use os::exit") + +// Windows puts _exit in . POSIX puts it in . +// We can't forbid it here when using clang if it's not in - see +// the clang definition for FORBIDDEN_FUNCTION_NORETURN_ATTRIBUTE. +#ifdef _WINDOWS +FORBID_IMPORTED_NORETURN_C_FUNCTION(void _exit(int), /* not noexcept */, "use os::exit") +#endif // _WINDOWS + +// These functions return raw C-heap pointers or, in case of free(), take raw +// C-heap pointers. We generally want allocation to be done through NMT, using +// os::malloc and friends. +FORBID_IMPORTED_C_FUNCTION(void* malloc(size_t), noexcept, "use os::malloc"); +FORBID_IMPORTED_C_FUNCTION(void free(void*), noexcept, "use os::free"); +FORBID_IMPORTED_C_FUNCTION(void* calloc(size_t, size_t), noexcept, "use os::malloc and zero out manually"); +FORBID_IMPORTED_C_FUNCTION(void* realloc(void*, size_t), noexcept, "use os::realloc"); + +// These are not provided (and are unimplementable?) by Windows. +// https://stackoverflow.com/questions/62962839/stdaligned-alloc-missing-from-visual-studio-2019 +// They also aren't useful for a POSIX implementation of NMT. +#ifndef _WINDOWS +FORBID_C_FUNCTION(void* aligned_alloc(size_t, size_t), noexcept, "don't use"); +FORBID_C_FUNCTION(int posix_memalign(void**, size_t, size_t), noexcept, "don't use"); +#endif // !_WINDOWS + +#endif // SHARE_CPPSTDLIB_CSTDLIB_HPP diff --git a/src/hotspot/share/utilities/byteswap.hpp b/src/hotspot/share/utilities/byteswap.hpp index 371095bce49..9fc367c784e 100644 --- a/src/hotspot/share/utilities/byteswap.hpp +++ b/src/hotspot/share/utilities/byteswap.hpp @@ -1,4 +1,5 @@ /* + * Copyright (c) 2025, 2026, Oracle and/or its affiliates. All rights reserved. * Copyright (c) 2023, 2024, Google and/or its affiliates. All rights reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * @@ -141,7 +142,7 @@ struct ByteswapImpl : public ByteswapFallbackImpl {}; *****************************************************************************/ #elif defined(TARGET_COMPILER_visCPP) -#include +#include "cppstdlib/cstdlib.hpp" #pragma intrinsic(_byteswap_ushort) #pragma intrinsic(_byteswap_ulong) diff --git a/src/hotspot/share/utilities/forbiddenFunctions.hpp b/src/hotspot/share/utilities/forbiddenFunctions.hpp index 47becd7b4c7..9d1b88e6233 100644 --- a/src/hotspot/share/utilities/forbiddenFunctions.hpp +++ b/src/hotspot/share/utilities/forbiddenFunctions.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 @@ -32,12 +32,6 @@ #include #include -// Workaround for noreturn functions: exit, _exit, _Exit - see the clang -// definition of FORBIDDEN_FUNCTION_NORETURN_ATTRIBUTE. -#ifdef __clang__ -#include -#endif - #ifdef _WINDOWS #include "forbiddenFunctions_windows.hpp" #else @@ -49,12 +43,6 @@ // or have security concerns, either with preferred alternatives, or to be // avoided entirely. -FORBID_IMPORTED_NORETURN_C_FUNCTION(void exit(int), noexcept, "use os::exit") -FORBID_IMPORTED_NORETURN_C_FUNCTION(void _Exit(int), noexcept, "use os::exit") - -// Windows puts _exit in , POSIX in . -FORBID_IMPORTED_NORETURN_C_FUNCTION(void _exit(int), /* not noexcept */, "use os::exit") - FORBID_IMPORTED_C_FUNCTION(char* strerror(int), noexcept, "use os::strerror"); FORBID_IMPORTED_C_FUNCTION(char* strtok(char*, const char*), noexcept, "use strtok_r"); @@ -70,13 +58,8 @@ FORBID_C_FUNCTION(int vsprintf(char*, const char*, va_list), noexcept, "use os:: FORBID_C_FUNCTION(int vsnprintf(char*, size_t, const char*, va_list), noexcept, "use os::vsnprintf"); PRAGMA_DIAG_POP -// All of the following functions return raw C-heap pointers (sometimes as an -// option, e.g. realpath or getwd) or, in case of free(), take raw C-heap -// pointers. We generally want allocation to be done through NMT. -FORBID_IMPORTED_C_FUNCTION(void* malloc(size_t size), noexcept, "use os::malloc"); -FORBID_IMPORTED_C_FUNCTION(void free(void *ptr), noexcept, "use os::free"); -FORBID_IMPORTED_C_FUNCTION(void* calloc(size_t nmemb, size_t size), noexcept, "use os::malloc and zero out manually"); -FORBID_IMPORTED_C_FUNCTION(void* realloc(void *ptr, size_t size), noexcept, "use os::realloc"); +// All of the following functions return raw C-heap pointers. We generally +// want allocation to be done through NMT. FORBID_IMPORTED_C_FUNCTION(char* strdup(const char *s), noexcept, "use os::strdup"); FORBID_IMPORTED_C_FUNCTION(wchar_t* wcsdup(const wchar_t *s), noexcept, "don't use"); diff --git a/src/hotspot/share/utilities/globalDefinitions_gcc.hpp b/src/hotspot/share/utilities/globalDefinitions_gcc.hpp index f82f9b1386a..302a62de6c1 100644 --- a/src/hotspot/share/utilities/globalDefinitions_gcc.hpp +++ b/src/hotspot/share/utilities/globalDefinitions_gcc.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 @@ -31,6 +31,8 @@ // globally used constants & types, class (forward) // declarations and a few frequently used utility functions. +#include "cppstdlib/cstdlib.hpp" + #include #include #include @@ -44,15 +46,6 @@ #include #include #include -#include -// In stdlib.h on AIX malloc is defined as a macro causing -// compiler errors when resolving them in different depths as it -// happens in the log tags. This avoids the macro. -#if (defined(__VEC__) || defined(__AIXVEC)) && defined(AIX) \ - && defined(__open_xl_version__) && __open_xl_version__ >= 17 - #undef malloc - extern void *malloc(size_t) asm("vec_malloc"); -#endif #include #include #include diff --git a/src/hotspot/share/utilities/globalDefinitions_visCPP.hpp b/src/hotspot/share/utilities/globalDefinitions_visCPP.hpp index b9d25096cd5..dfd6f2f1880 100644 --- a/src/hotspot/share/utilities/globalDefinitions_visCPP.hpp +++ b/src/hotspot/share/utilities/globalDefinitions_visCPP.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 @@ -34,6 +34,8 @@ // Need this on windows to get the math constants (e.g., M_PI). #define _USE_MATH_DEFINES +#include "cppstdlib/cstdlib.hpp" + # include # include # include // for _isnan @@ -45,7 +47,6 @@ # include // for offsetof # include # include -# include # include # include # include diff --git a/src/hotspot/share/utilities/parseInteger.hpp b/src/hotspot/share/utilities/parseInteger.hpp index 3e3eafada87..8840275a8cb 100644 --- a/src/hotspot/share/utilities/parseInteger.hpp +++ b/src/hotspot/share/utilities/parseInteger.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) 2022 SAP SE. All rights reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * @@ -26,6 +26,7 @@ #ifndef SHARE_UTILITIES_PARSE_INTEGER_HPP #define SHARE_UTILITIES_PARSE_INTEGER_HPP +#include "cppstdlib/cstdlib.hpp" #include "cppstdlib/limits.hpp" #include "metaprogramming/enableIf.hpp" #include "utilities/debug.hpp" @@ -33,7 +34,6 @@ #include "utilities/macros.hpp" #include -#include // ************************************************************************* // ** Attention compatibility! ** diff --git a/src/hotspot/share/utilities/permitForbiddenFunctions.hpp b/src/hotspot/share/utilities/permitForbiddenFunctions.hpp index 1ba42f8e386..71719ac8a76 100644 --- a/src/hotspot/share/utilities/permitForbiddenFunctions.hpp +++ b/src/hotspot/share/utilities/permitForbiddenFunctions.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 @@ -25,6 +25,7 @@ #ifndef SHARE_UTILITIES_PERMITFORBIDDENFUNCTIONS_HPP #define SHARE_UTILITIES_PERMITFORBIDDENFUNCTIONS_HPP +#include "cppstdlib/cstdlib.hpp" #include "utilities/compilerWarnings.hpp" #include "utilities/globalDefinitions.hpp" @@ -34,6 +35,9 @@ #include "permitForbiddenFunctions_posix.hpp" #endif +#include +#include + // Provide wrappers for some functions otherwise forbidden from use in HotSpot. // // There may be special circumstances where an otherwise forbidden function @@ -53,7 +57,6 @@ namespace permit_forbidden_function { BEGIN_ALLOW_FORBIDDEN_FUNCTIONS [[noreturn]] inline void exit(int status) { ::exit(status); } -[[noreturn]] inline void _exit(int status) { ::_exit(status); } ATTRIBUTE_PRINTF(3, 0) inline int vsnprintf(char* str, size_t size, const char* format, va_list ap) { diff --git a/test/hotspot/gtest/gtestMain.cpp b/test/hotspot/gtest/gtestMain.cpp index 842b6547b48..a1869ab5499 100644 --- a/test/hotspot/gtest/gtestMain.cpp +++ b/test/hotspot/gtest/gtestMain.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,6 +22,7 @@ * */ +#include "cppstdlib/cstdlib.hpp" #include "jni.h" #include "runtime/os.hpp" #include "runtime/thread.inline.hpp" @@ -31,7 +32,6 @@ #include #include -#include #ifdef __APPLE__ #include #endif diff --git a/test/hotspot/gtest/unittest.hpp b/test/hotspot/gtest/unittest.hpp index 336a2f0766e..6a2cd400cb6 100644 --- a/test/hotspot/gtest/unittest.hpp +++ b/test/hotspot/gtest/unittest.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. * 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,9 @@ #ifndef UNITTEST_HPP #define UNITTEST_HPP +#include "cppstdlib/cstdlib.hpp" #include "utilities/globalDefinitions.hpp" -#include #include #define GTEST_DONT_DEFINE_TEST 1 diff --git a/test/hotspot/gtest/utilities/test_bitMap_setops.cpp b/test/hotspot/gtest/utilities/test_bitMap_setops.cpp index 2b1e67533df..1def9c89cfc 100644 --- a/test/hotspot/gtest/utilities/test_bitMap_setops.cpp +++ b/test/hotspot/gtest/utilities/test_bitMap_setops.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 @@ -21,6 +21,7 @@ * questions. */ +#include "cppstdlib/cstdlib.hpp" #include "runtime/os.hpp" #include "utilities/align.hpp" #include "utilities/bitMap.inline.hpp" @@ -29,8 +30,6 @@ #include "utilities/globalDefinitions.hpp" #include "unittest.hpp" -#include - typedef BitMap::idx_t idx_t; typedef BitMap::bm_word_t bm_word_t; From 0a1fa219214b985e4c7d9e612bd5cda1b0f25577 Mon Sep 17 00:00:00 2001 From: Chad Rakoczy Date: Thu, 8 Jan 2026 01:14:01 +0000 Subject: [PATCH 083/712] 8369150: NMethodRelocationTest fails when JVMTI events not published before JVM exit Reviewed-by: lmesnik, sspitsyn --- test/hotspot/jtreg/ProblemList.txt | 2 - .../NMethodRelocationTest.java | 119 ++++-------------- .../libNMethodRelocationTest.cpp | 115 +++++++++++------ test/lib/jdk/test/lib/jvmti/jvmti_common.hpp | 17 +++ 4 files changed, 121 insertions(+), 132 deletions(-) diff --git a/test/hotspot/jtreg/ProblemList.txt b/test/hotspot/jtreg/ProblemList.txt index 4e16e328ab4..13e1ea30a34 100644 --- a/test/hotspot/jtreg/ProblemList.txt +++ b/test/hotspot/jtreg/ProblemList.txt @@ -77,8 +77,6 @@ compiler/interpreter/Test6833129.java 8335266 generic-i586 compiler/c2/aarch64/TestStaticCallStub.java 8359963 linux-aarch64,macosx-aarch64 -serviceability/jvmti/NMethodRelocation/NMethodRelocationTest.java 8369150 generic-all - ############################################################################# # :hotspot_gc diff --git a/test/hotspot/jtreg/serviceability/jvmti/NMethodRelocation/NMethodRelocationTest.java b/test/hotspot/jtreg/serviceability/jvmti/NMethodRelocation/NMethodRelocationTest.java index 6c465b357d7..10888dce1b4 100644 --- a/test/hotspot/jtreg/serviceability/jvmti/NMethodRelocation/NMethodRelocationTest.java +++ b/test/hotspot/jtreg/serviceability/jvmti/NMethodRelocation/NMethodRelocationTest.java @@ -23,23 +23,30 @@ /* * @test - * * @bug 8316694 * @summary Verify that nmethod relocation posts the correct JVMTI events - * @requires vm.jvmti - * @requires vm.gc == "null" | vm.gc == "Serial" + * @requires vm.jvmti & + * vm.gc != "Epsilon" & + * vm.flavor == "server" & + * !vm.emulatedClient & + * (vm.opt.TieredStopAtLevel == null | vm.opt.TieredStopAtLevel == 4) * @library /test/lib /test/hotspot/jtreg * @build jdk.test.whitebox.WhiteBox * @run driver jdk.test.lib.helpers.ClassFileInstaller jdk.test.whitebox.WhiteBox - * @run main/othervm/native NMethodRelocationTest + * @run main/othervm/native -agentlib:NMethodRelocationTest + * --enable-native-access=ALL-UNNAMED + * -Xbootclasspath/a:. + * -Xbatch + * -XX:+UnlockDiagnosticVMOptions + * -XX:+WhiteBoxAPI + * -XX:+SegmentedCodeCache + * -XX:-TieredCompilation + * -XX:+UnlockExperimentalVMOptions + * -XX:+NMethodRelocation + * NMethodRelocationTest */ -import static compiler.whitebox.CompilerWhiteBoxTest.COMP_LEVEL_FULL_OPTIMIZATION; - import java.lang.reflect.Executable; -import java.util.Objects; -import java.util.regex.Matcher; -import java.util.regex.Pattern; import jdk.test.lib.Asserts; import jdk.test.lib.process.OutputAnalyzer; @@ -48,52 +55,9 @@ import jdk.test.whitebox.WhiteBox; import jdk.test.whitebox.code.BlobType; import jdk.test.whitebox.code.NMethod; +import static compiler.whitebox.CompilerWhiteBoxTest.COMP_LEVEL_FULL_OPTIMIZATION; public class NMethodRelocationTest { - public static void main(String[] args) throws Exception { - ProcessBuilder pb = ProcessTools.createTestJavaProcessBuilder( - "-agentlib:NMethodRelocationTest", - "--enable-native-access=ALL-UNNAMED", - "-Xbootclasspath/a:.", - "-XX:+UseSerialGC", - "-XX:+UnlockDiagnosticVMOptions", - "-XX:+WhiteBoxAPI", - "-XX:+SegmentedCodeCache", - "-XX:-TieredCompilation", - "-XX:+UnlockExperimentalVMOptions", - "-XX:+NMethodRelocation", - "DoWork"); - - OutputAnalyzer oa = new OutputAnalyzer(pb.start()); - String output = oa.getOutput(); - if (oa.getExitValue() != 0) { - System.err.println(oa.getOutput()); - throw new RuntimeException("Non-zero exit code returned from the test"); - } - Asserts.assertTrue(oa.getExitValue() == 0); - - Pattern pattern = Pattern.compile("(?m)^Relocated nmethod from (0x[0-9a-f]{16}) to (0x[0-9a-f]{16})$"); - Matcher matcher = pattern.matcher(output); - - if (matcher.find()) { - String fromAddr = matcher.group(1); - String toAddr = matcher.group(2); - - // Confirm events sent for both original and relocated nmethod - oa.shouldContain(": name: compiledMethod, code: " + fromAddr); - oa.shouldContain(": name: compiledMethod, code: " + toAddr); - oa.shouldContain(": name: compiledMethod, code: " + fromAddr); - oa.shouldContain(": name: compiledMethod, code: " + toAddr); - } else { - System.err.println(oa.getOutput()); - throw new RuntimeException("Unable to find relocation information"); - } - } -} - -class DoWork { - - protected static final WhiteBox WHITE_BOX = WhiteBox.getWhiteBox(); /** Load native library if required. */ static { @@ -107,43 +71,18 @@ class DoWork { } } - /** - * Returns value of VM option. - * - * @param name option's name - * @return value of option or {@code null}, if option doesn't exist - * @throws NullPointerException if name is null - */ - protected static String getVMOption(String name) { - Objects.requireNonNull(name); - return Objects.toString(WHITE_BOX.getVMFlag(name), null); - } + protected static final WhiteBox WHITE_BOX = WhiteBox.getWhiteBox(); - /** - * Returns value of VM option or default value. - * - * @param name option's name - * @param defaultValue default value - * @return value of option or {@code defaultValue}, if option doesn't exist - * @throws NullPointerException if name is null - * @see #getVMOption(String) - */ - protected static String getVMOption(String name, String defaultValue) { - String result = getVMOption(name); - return result == null ? defaultValue : result; - } + native static boolean shouldExit(); - public static void main(String argv[]) throws Exception { - run(); - } - - public static void run() throws Exception { - Executable method = DoWork.class.getDeclaredMethod("compiledMethod"); + public static void main(String[] argv) throws Exception { + Executable method = NMethodRelocationTest.class.getDeclaredMethod("compiledMethod"); WHITE_BOX.testSetDontInlineMethod(method, true); WHITE_BOX.enqueueMethodForCompilation(method, COMP_LEVEL_FULL_OPTIMIZATION); - while (WHITE_BOX.isMethodQueuedForCompilation(method)) { - Thread.onSpinWait(); + + if (!WHITE_BOX.isMethodCompiled(method)) { + throw new AssertionError("Method not compiled"); } NMethod originalNMethod = NMethod.get(method, false); @@ -164,13 +103,9 @@ class DoWork { WHITE_BOX.deoptimizeAll(); - WHITE_BOX.fullGC(); - WHITE_BOX.fullGC(); - - WHITE_BOX.lockCompilation(); - - System.out.printf("Relocated nmethod from 0x%016x to 0x%016x%n", originalNMethod.code_begin, relocatedNMethod.code_begin); - System.out.flush(); + while (!shouldExit()) { + WHITE_BOX.fullGC(); + } } public static long compiledMethod() { diff --git a/test/hotspot/jtreg/serviceability/jvmti/NMethodRelocation/libNMethodRelocationTest.cpp b/test/hotspot/jtreg/serviceability/jvmti/NMethodRelocation/libNMethodRelocationTest.cpp index 41ba6b10608..7f8ab7b78bc 100644 --- a/test/hotspot/jtreg/serviceability/jvmti/NMethodRelocation/libNMethodRelocationTest.cpp +++ b/test/hotspot/jtreg/serviceability/jvmti/NMethodRelocation/libNMethodRelocationTest.cpp @@ -21,10 +21,20 @@ * questions. */ +#include #include -#include -#include -#include +#include "jvmti_common.hpp" + +extern "C" { + +// Track nmethod addresses for LOAD and UNLOAD events +static const void* first_load_addr = nullptr; +static const void* second_load_addr = nullptr; +static const void* first_unload_addr = nullptr; +static const void* second_unload_addr = nullptr; + +// Keep track of test completion +static std::atomic should_exit{false}; /** * Callback for COMPILED_METHOD_LOAD event. @@ -34,18 +44,27 @@ callbackCompiledMethodLoad(jvmtiEnv* jvmti, jmethodID method, jint code_size, const void* code_addr, jint map_length, const jvmtiAddrLocationMap* map, const void* compile_info) { - char* name = nullptr; - char* sig = nullptr; - if (jvmti->GetMethodName(method, &name, &sig, nullptr) != JVMTI_ERROR_NONE) { - printf(" [Could not retrieve method name]\n"); - fflush(stdout); + // Only track events for "compiledMethod" + char* name = get_method_name(jvmti, method); + if (strcmp(name, "compiledMethod") != 0) { return; } - printf(": name: %s, code: 0x%016" PRIxPTR "\n", - name, (uintptr_t)code_addr); - fflush(stdout); + LOG(": name: %s, code: 0x%016" PRIxPTR "\n", name, (uintptr_t)code_addr); + + if (first_load_addr == nullptr) { + first_load_addr = code_addr; + } else if (second_load_addr == nullptr) { + second_load_addr = code_addr; + + // Verify that the addresses are different + if (first_load_addr == second_load_addr) { + fatal("Load events for 'compiledMethod' are expected to use different addresses"); + } + } else { + fatal("Received too many load events for 'compiledMethod'"); + } } /** @@ -54,25 +73,50 @@ callbackCompiledMethodLoad(jvmtiEnv* jvmti, jmethodID method, JNIEXPORT void JNICALL callbackCompiledMethodUnload(jvmtiEnv* jvmti, jmethodID method, const void* code_addr) { - char* name = nullptr; - char* sig = nullptr; - if (jvmti->GetMethodName(method, &name, &sig, nullptr) != JVMTI_ERROR_NONE) { - printf(" [Could not retrieve method name]\n"); - fflush(stdout); + // Only track events for "compiledMethod" + char* name = get_method_name(jvmti, method); + if (strcmp(name, "compiledMethod") != 0) { return; } - printf(": name: %s, code: 0x%016" PRIxPTR "\n", - name, (uintptr_t)code_addr); - fflush(stdout); + + LOG(": name: %s, code: 0x%016" PRIxPTR "\n", name, (uintptr_t)code_addr); + + // Validate both loads have occurred + if (first_load_addr == nullptr || second_load_addr == nullptr) { + fatal("UNLOAD event for 'compiledMethod' occurred before both LOAD events"); + } + + if (first_unload_addr == nullptr) { + first_unload_addr = code_addr; + } else if (second_unload_addr == nullptr) { + second_unload_addr = code_addr; + + // Verify that the addresses are different + if (first_unload_addr == second_unload_addr) { + fatal("Unload events for 'compiledMethod' are expected to use different addresses"); + } + + // LOAD and UNLOAD events should report the same two addresses, but the order of + // the UNLOADs is not guaranteed, since the GC may unload either nmethod first. + if ((first_load_addr == first_unload_addr && second_load_addr == second_unload_addr) || + (first_load_addr == second_unload_addr && second_load_addr == first_unload_addr)) { + + // Update should_exit to signal test completion + should_exit.store(true); + } else { + fatal("Address mismatch for 'compiledMethod' events"); + } + } else { + fatal("Received too many unload events for 'compiledMethod'"); + } } JNIEXPORT jint JNICALL Agent_OnLoad(JavaVM *jvm, char *options, void *reserved) { jvmtiEnv* jvmti = nullptr; - jvmtiError error; if (jvm->GetEnv((void **)&jvmti, JVMTI_VERSION_1_0) != JNI_OK) { - printf("Unable to access JVMTI!\n"); + LOG("Unable to access JVMTI!\n"); return JNI_ERR; } @@ -80,11 +124,8 @@ JNIEXPORT jint JNICALL Agent_OnLoad(JavaVM *jvm, char *options, void *reserved) jvmtiCapabilities caps; memset(&caps, 0, sizeof(caps)); caps.can_generate_compiled_method_load_events = 1; - error = jvmti->AddCapabilities(&caps); - if (error != JVMTI_ERROR_NONE) { - printf("ERROR: Unable to add capabilities, error=%d\n", error); - return JNI_ERR; - } + jvmtiError error = jvmti->AddCapabilities(&caps); + check_jvmti_error(error, "Unable to add capabilities"); // Set event callbacks jvmtiEventCallbacks eventCallbacks; @@ -92,23 +133,21 @@ JNIEXPORT jint JNICALL Agent_OnLoad(JavaVM *jvm, char *options, void *reserved) eventCallbacks.CompiledMethodLoad = callbackCompiledMethodLoad; eventCallbacks.CompiledMethodUnload = callbackCompiledMethodUnload; error = jvmti->SetEventCallbacks(&eventCallbacks, sizeof(eventCallbacks)); - if (error != JVMTI_ERROR_NONE) { - printf("ERROR: Unable to set event callbacks, error=%d\n", error); - return JNI_ERR; - } + check_jvmti_error(error, "Unable to set event callbacks"); // Enable events error = jvmti->SetEventNotificationMode(JVMTI_ENABLE, JVMTI_EVENT_COMPILED_METHOD_LOAD, nullptr); - if (error != JVMTI_ERROR_NONE) { - printf("ERROR: Unable to enable COMPILED_METHOD_LOAD event, error=%d\n", error); - return JNI_ERR; - } + check_jvmti_error(error, "Unable to enable COMPILED_METHOD_LOAD event"); error = jvmti->SetEventNotificationMode(JVMTI_ENABLE, JVMTI_EVENT_COMPILED_METHOD_UNLOAD, nullptr); - if (error != JVMTI_ERROR_NONE) { - printf("ERROR: Unable to enable COMPILED_METHOD_UNLOAD event, error=%d\n", error); - return JNI_ERR; - } + check_jvmti_error(error, "Unable to enable COMPILED_METHOD_UNLOAD event"); return JNI_OK; } + +JNIEXPORT jboolean JNICALL +Java_NMethodRelocationTest_shouldExit(JNIEnv *env, jclass cls) { + return should_exit.load(); +} + +} diff --git a/test/lib/jdk/test/lib/jvmti/jvmti_common.hpp b/test/lib/jdk/test/lib/jvmti/jvmti_common.hpp index 11600bd524b..3832d934b1e 100644 --- a/test/lib/jdk/test/lib/jvmti/jvmti_common.hpp +++ b/test/lib/jdk/test/lib/jvmti/jvmti_common.hpp @@ -123,6 +123,12 @@ char* julong_to_string(julong value, char *string) { return string; } +static void +fatal(const char* msg) { + LOG("FATAL ERROR: %s\n", msg); + abort(); +} + static void fatal(JNIEnv* jni, const char* msg) { jni->FatalError(msg); @@ -313,6 +319,17 @@ get_thread_name(jvmtiEnv *jvmti, JNIEnv* jni, jthread thread) { return tname; } +static char* +get_method_name(jvmtiEnv *jvmti, jmethodID method) { + char* mname = nullptr; + jvmtiError err; + + err = jvmti->GetMethodName(method, &mname, nullptr, nullptr); + check_jvmti_error(err, "get_method_name: error in JVMTI GetMethodName call"); + + return mname; +} + static char* get_method_name(jvmtiEnv *jvmti, JNIEnv* jni, jmethodID method) { char* mname = nullptr; From 70669d0585c708e04befe0f9ba945f6154f9afec Mon Sep 17 00:00:00 2001 From: Kim Barrett Date: Thu, 8 Jan 2026 04:43:06 +0000 Subject: [PATCH 084/712] 8374712: AOTMappedHeapWriter::relocate_field_in_buffer should use CompressedOops::narrow_oop_cast Reviewed-by: kvn --- src/hotspot/share/cds/aotMappedHeapWriter.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/hotspot/share/cds/aotMappedHeapWriter.cpp b/src/hotspot/share/cds/aotMappedHeapWriter.cpp index 9c67b2e0e8d..e73b980614a 100644 --- a/src/hotspot/share/cds/aotMappedHeapWriter.cpp +++ b/src/hotspot/share/cds/aotMappedHeapWriter.cpp @@ -696,7 +696,7 @@ template void AOTMappedHeapWriter::relocate_field_in_buffer(T* fiel // We use zero-based, 0-shift encoding, so the narrowOop is just the lower // 32 bits of request_referent intptr_t addr = cast_from_oop(request_referent); - *((narrowOop*)field_addr_in_buffer) = checked_cast(addr); + *((narrowOop*)field_addr_in_buffer) = CompressedOops::narrow_oop_cast(addr); } else { store_requested_oop_in_buffer(field_addr_in_buffer, request_referent); } From 95137580b81fb48474b0d8fb748d9d4af7a27850 Mon Sep 17 00:00:00 2001 From: Ioi Lam Date: Thu, 8 Jan 2026 05:31:06 +0000 Subject: [PATCH 085/712] 8374662: Remove unused type check functions from javaClasses.hpp Reviewed-by: jsjolen --- src/hotspot/share/classfile/javaClasses.cpp | 10 +--------- src/hotspot/share/classfile/javaClasses.hpp | 16 +--------------- 2 files changed, 2 insertions(+), 24 deletions(-) diff --git a/src/hotspot/share/classfile/javaClasses.cpp b/src/hotspot/share/classfile/javaClasses.cpp index 77a94c8afa5..dd70d7b49ab 100644 --- a/src/hotspot/share/classfile/javaClasses.cpp +++ b/src/hotspot/share/classfile/javaClasses.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 @@ -4297,10 +4297,6 @@ int jdk_internal_foreign_abi_NativeEntryPoint::_downcall_stub_address_offset; macro(_method_type_offset, k, "methodType", java_lang_invoke_MethodType_signature, false); \ macro(_downcall_stub_address_offset, k, "downcallStubAddress", long_signature, false); -bool jdk_internal_foreign_abi_NativeEntryPoint::is_instance(oop obj) { - return obj != nullptr && is_subclass(obj->klass()); -} - void jdk_internal_foreign_abi_NativeEntryPoint::compute_offsets() { InstanceKlass* k = vmClasses::NativeEntryPoint_klass(); NEP_FIELDS_DO(FIELD_COMPUTE_OFFSET); @@ -4337,10 +4333,6 @@ int jdk_internal_foreign_abi_ABIDescriptor::_scratch2_offset; macro(_scratch1_offset, k, "scratch1", jdk_internal_foreign_abi_VMStorage_signature, false); \ macro(_scratch2_offset, k, "scratch2", jdk_internal_foreign_abi_VMStorage_signature, false); -bool jdk_internal_foreign_abi_ABIDescriptor::is_instance(oop obj) { - return obj != nullptr && is_subclass(obj->klass()); -} - void jdk_internal_foreign_abi_ABIDescriptor::compute_offsets() { InstanceKlass* k = vmClasses::ABIDescriptor_klass(); ABIDescriptor_FIELDS_DO(FIELD_COMPUTE_OFFSET); diff --git a/src/hotspot/share/classfile/javaClasses.hpp b/src/hotspot/share/classfile/javaClasses.hpp index 33dc912404c..a8562a345c8 100644 --- a/src/hotspot/share/classfile/javaClasses.hpp +++ b/src/hotspot/share/classfile/javaClasses.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 @@ -1179,13 +1179,6 @@ class jdk_internal_foreign_abi_NativeEntryPoint: AllStatic { static oop method_type(oop entry); static jlong downcall_stub_address(oop entry); - // Testers - static bool is_subclass(Klass* klass) { - return vmClasses::NativeEntryPoint_klass() != nullptr && - klass->is_subclass_of(vmClasses::NativeEntryPoint_klass()); - } - static bool is_instance(oop obj); - // Accessors for code generation: static int method_type_offset_in_bytes() { return _method_type_offset; } static int downcall_stub_address_offset_in_bytes() { return _downcall_stub_address_offset; } @@ -1216,13 +1209,6 @@ class jdk_internal_foreign_abi_ABIDescriptor: AllStatic { static jint shadowSpace(oop entry); static oop scratch1(oop entry); static oop scratch2(oop entry); - - // Testers - static bool is_subclass(Klass* klass) { - return vmClasses::ABIDescriptor_klass() != nullptr && - klass->is_subclass_of(vmClasses::ABIDescriptor_klass()); - } - static bool is_instance(oop obj); }; class jdk_internal_foreign_abi_VMStorage: AllStatic { From e6abf98e35079ed1b5547f2cc0ac6f518b78d67b Mon Sep 17 00:00:00 2001 From: Jan Lahoda Date: Thu, 8 Jan 2026 07:01:03 +0000 Subject: [PATCH 086/712] 8374434: Several JShell tests report JUnit discovery warnings Reviewed-by: jpai --- test/langtools/jdk/jshell/ErrorTranslationTest.java | 3 +-- test/langtools/jdk/jshell/IdGeneratorTest.java | 3 +-- test/langtools/jdk/jshell/KullaCompletenessStressTest.java | 4 +--- 3 files changed, 3 insertions(+), 7 deletions(-) diff --git a/test/langtools/jdk/jshell/ErrorTranslationTest.java b/test/langtools/jdk/jshell/ErrorTranslationTest.java index 1aa1b2c41dd..235f4443004 100644 --- a/test/langtools/jdk/jshell/ErrorTranslationTest.java +++ b/test/langtools/jdk/jshell/ErrorTranslationTest.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 @@ -149,7 +149,6 @@ public class ErrorTranslationTest extends ReplToolTesting { return sb.toString(); } - @Test public String getKind(Diagnostic.Kind kind) { switch (kind) { case WARNING: diff --git a/test/langtools/jdk/jshell/IdGeneratorTest.java b/test/langtools/jdk/jshell/IdGeneratorTest.java index 6c7f6177e03..521c87b0265 100644 --- a/test/langtools/jdk/jshell/IdGeneratorTest.java +++ b/test/langtools/jdk/jshell/IdGeneratorTest.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 @@ -44,7 +44,6 @@ import org.junit.jupiter.api.Test; public class IdGeneratorTest { - @Test public JShell.Builder getBuilder() { TestingInputStream inStream = new TestingInputStream(); ByteArrayOutputStream outStream = new ByteArrayOutputStream(); diff --git a/test/langtools/jdk/jshell/KullaCompletenessStressTest.java b/test/langtools/jdk/jshell/KullaCompletenessStressTest.java index 69830880dcb..16274fa924e 100644 --- a/test/langtools/jdk/jshell/KullaCompletenessStressTest.java +++ b/test/langtools/jdk/jshell/KullaCompletenessStressTest.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 @@ -32,13 +32,11 @@ import java.io.File; import org.junit.jupiter.api.Assumptions; -import org.junit.jupiter.api.Test; import org.junit.jupiter.api.TestInstance; @TestInstance(TestInstance.Lifecycle.PER_CLASS) public class KullaCompletenessStressTest extends CompletenessStressTest { @Override - @Test public File[] getDirectoriesToTest() { String src = System.getProperty("test.src"); File file; From 1a6da4499cf8805ff3e1e517fbca81c2eeb987a9 Mon Sep 17 00:00:00 2001 From: Per Minborg Date: Thu, 8 Jan 2026 08:14:57 +0000 Subject: [PATCH 087/712] 8374467: Incorrect ranges in jdk.internal.util.ByteArray JavaDoc Reviewed-by: rriggs --- .../share/classes/jdk/internal/util/ByteArray.java | 14 +++++++------- .../jdk/internal/util/ByteArrayLittleEndian.java | 14 +++++++------- 2 files changed, 14 insertions(+), 14 deletions(-) diff --git a/src/java.base/share/classes/jdk/internal/util/ByteArray.java b/src/java.base/share/classes/jdk/internal/util/ByteArray.java index 94395df2c34..92b9dbbef19 100644 --- a/src/java.base/share/classes/jdk/internal/util/ByteArray.java +++ b/src/java.base/share/classes/jdk/internal/util/ByteArray.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 @@ -241,7 +241,7 @@ public final class ByteArray { * @param offset where setting (writing) in the array should begin * @param value value to set in the array * @throws IndexOutOfBoundsException if the provided {@code offset} is outside - * the range [0, array.length] + * the range [0, array.length - 1] * @see #getBoolean(byte[], int) */ public static void setBoolean(byte[] array, int offset, boolean value) { @@ -328,7 +328,7 @@ public final class ByteArray { * @param offset where setting (writing) in the array should begin * @param value value to set in the array * @throws IndexOutOfBoundsException if the provided {@code offset} is outside - * the range [0, array.length - 2] + * the range [0, array.length - 4] * @see #getFloat(byte[], int) */ public static void setFloat(byte[] array, int offset, float value) { @@ -350,7 +350,7 @@ public final class ByteArray { * @param offset where setting (writing) in the array should begin * @param value value to set in the array * @throws IndexOutOfBoundsException if the provided {@code offset} is outside - * the range [0, array.length - 2] + * the range [0, array.length - 4] * @see #getFloatRaw(byte[], int) */ public static void setFloatRaw(byte[] array, int offset, float value) { @@ -368,7 +368,7 @@ public final class ByteArray { * @param offset where setting (writing) in the array should begin * @param value value to set in the array * @throws IndexOutOfBoundsException if the provided {@code offset} is outside - * the range [0, array.length - 4] + * the range [0, array.length - 8] * @see #getLong(byte[], int) */ public static void setLong(byte[] array, int offset, long value) { @@ -387,7 +387,7 @@ public final class ByteArray { * @param offset where setting (writing) in the array should begin * @param value value to set in the array * @throws IndexOutOfBoundsException if the provided {@code offset} is outside - * the range [0, array.length - 2] + * the range [0, array.length - 8] * @see #getDouble(byte[], int) */ public static void setDouble(byte[] array, int offset, double value) { @@ -409,7 +409,7 @@ public final class ByteArray { * @param offset where setting (writing) in the array should begin * @param value value to set in the array * @throws IndexOutOfBoundsException if the provided {@code offset} is outside - * the range [0, array.length - 2] + * the range [0, array.length - 8] * @see #getDoubleRaw(byte[], int) */ public static void setDoubleRaw(byte[] array, int offset, double value) { diff --git a/src/java.base/share/classes/jdk/internal/util/ByteArrayLittleEndian.java b/src/java.base/share/classes/jdk/internal/util/ByteArrayLittleEndian.java index fcd7ca2b9bf..cc50686429b 100644 --- a/src/java.base/share/classes/jdk/internal/util/ByteArrayLittleEndian.java +++ b/src/java.base/share/classes/jdk/internal/util/ByteArrayLittleEndian.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 @@ -241,7 +241,7 @@ public final class ByteArrayLittleEndian { * @param offset where setting (writing) in the array should begin * @param value value to set in the array * @throws IndexOutOfBoundsException if the provided {@code offset} is outside - * the range [0, array.length] + * the range [0, array.length - 1] * @see #getBoolean(byte[], int) */ public static void setBoolean(byte[] array, int offset, boolean value) { @@ -328,7 +328,7 @@ public final class ByteArrayLittleEndian { * @param offset where setting (writing) in the array should begin * @param value value to set in the array * @throws IndexOutOfBoundsException if the provided {@code offset} is outside - * the range [0, array.length - 2] + * the range [0, array.length - 4] * @see #getFloat(byte[], int) */ public static void setFloat(byte[] array, int offset, float value) { @@ -350,7 +350,7 @@ public final class ByteArrayLittleEndian { * @param offset where setting (writing) in the array should begin * @param value value to set in the array * @throws IndexOutOfBoundsException if the provided {@code offset} is outside - * the range [0, array.length - 2] + * the range [0, array.length - 4] * @see #getFloatRaw(byte[], int) */ public static void setFloatRaw(byte[] array, int offset, float value) { @@ -368,7 +368,7 @@ public final class ByteArrayLittleEndian { * @param offset where setting (writing) in the array should begin * @param value value to set in the array * @throws IndexOutOfBoundsException if the provided {@code offset} is outside - * the range [0, array.length - 4] + * the range [0, array.length - 8] * @see #getLong(byte[], int) */ public static void setLong(byte[] array, int offset, long value) { @@ -387,7 +387,7 @@ public final class ByteArrayLittleEndian { * @param offset where setting (writing) in the array should begin * @param value value to set in the array * @throws IndexOutOfBoundsException if the provided {@code offset} is outside - * the range [0, array.length - 2] + * the range [0, array.length - 8] * @see #getDouble(byte[], int) */ public static void setDouble(byte[] array, int offset, double value) { @@ -409,7 +409,7 @@ public final class ByteArrayLittleEndian { * @param offset where setting (writing) in the array should begin * @param value value to set in the array * @throws IndexOutOfBoundsException if the provided {@code offset} is outside - * the range [0, array.length - 2] + * the range [0, array.length - 8] * @see #getDoubleRaw(byte[], int) */ public static void setDoubleRaw(byte[] array, int offset, double value) { From a71326a0e2660158fdb85282da4b59ce61c66ee3 Mon Sep 17 00:00:00 2001 From: Emanuel Peter Date: Thu, 8 Jan 2026 08:32:02 +0000 Subject: [PATCH 088/712] 8374528: C2 SuperWord: TestAliasingFuzzer.java strengthen no-multiversioning IR rule Reviewed-by: chagedorn, mhaessig --- .../superword/TestAliasingFuzzer.java | 45 +++++++------------ 1 file changed, 15 insertions(+), 30 deletions(-) diff --git a/test/hotspot/jtreg/compiler/loopopts/superword/TestAliasingFuzzer.java b/test/hotspot/jtreg/compiler/loopopts/superword/TestAliasingFuzzer.java index 5d20ce659b9..825d5ca60bc 100644 --- a/test/hotspot/jtreg/compiler/loopopts/superword/TestAliasingFuzzer.java +++ b/test/hotspot/jtreg/compiler/loopopts/superword/TestAliasingFuzzer.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 @@ -1052,35 +1052,20 @@ public class TestAliasingFuzzer { case Aliasing.CONTAINER_DIFFERENT, Aliasing.CONTAINER_SAME_ALIASING_NEVER, Aliasing.CONTAINER_UNKNOWN_ALIASING_NEVER -> - // We would have liked to check that there is no multiversioning. - // - // But sadly there are some cases that have issues with RCE and/or - // predicates, and so we end up using multiversioning anyway. We - // should fix those cases eventually, to strengthen the checks here. - // - // The array cases are a little more tame, and do not have the same - // issues as the MemorySegment cases. - (containerKind == ContainerKind.ARRAY) - ? """ - // Aliasing check should never fail at runtime, so the predicate - // should never fail, and we do not have to use multiversioning. - // Failure could have a few causes: - // - issues with doing RCE / missing predicates - // -> other loop-opts need to be fixed - // - predicate fails: recompile with multiversioning - // -> logic in runtime check may be wrong - @IR(counts = {".*multiversion.*", "= 0"}, - phase = CompilePhase.PRINT_IDEAL, - applyIf = {"UseAutoVectorizationPredicate", "true"}, - applyIfPlatform = {"64-bit", "true"}, - applyIfCPUFeatureOr = {"sse4.1", "true", "asimd", "true"}) - """ - : """ - // Due to cases like JDK-8360204 and JDK-8365982, there can be issues - // with RCE leading cases where we remove predicates and then unroll again - // and then end up multiversioning. These cases seem relatively rare but - // prevent us from asserting that there is never multiversioning in these cases. - """; + """ + // Aliasing check should never fail at runtime, so the predicate + // should never fail, and we do not have to use multiversioning. + // Failure could have a few causes: + // - issues with doing RCE / missing predicates + // -> other loop-opts need to be fixed + // - predicate fails: recompile with multiversioning + // -> logic in runtime check may be wrong + @IR(counts = {".*multiversion.*", "= 0"}, + phase = CompilePhase.PRINT_IDEAL, + applyIf = {"UseAutoVectorizationPredicate", "true"}, + applyIfPlatform = {"64-bit", "true"}, + applyIfCPUFeatureOr = {"sse4.1", "true", "asimd", "true"}) + """; case Aliasing.CONTAINER_SAME_ALIASING_UNKNOWN, Aliasing.CONTAINER_UNKNOWN_ALIASING_UNKNOWN -> """ From 08ff16f0aa8eaa9596da52d568720c69c897f3c5 Mon Sep 17 00:00:00 2001 From: Ramkumar Sunderbabu Date: Thu, 8 Jan 2026 09:25:11 +0000 Subject: [PATCH 089/712] 8374576: Disable MemoryEaterMT for VirtualThread Reviewed-by: lmesnik, dholmes --- .../vmTestbase/gc/gctests/MemoryEaterMT/MemoryEaterMT.java | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/test/hotspot/jtreg/vmTestbase/gc/gctests/MemoryEaterMT/MemoryEaterMT.java b/test/hotspot/jtreg/vmTestbase/gc/gctests/MemoryEaterMT/MemoryEaterMT.java index c97353006d4..d88e34ae5e0 100644 --- a/test/hotspot/jtreg/vmTestbase/gc/gctests/MemoryEaterMT/MemoryEaterMT.java +++ b/test/hotspot/jtreg/vmTestbase/gc/gctests/MemoryEaterMT/MemoryEaterMT.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2007, 2020, 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 @@ -28,6 +28,7 @@ * @summary converted from VM Testbase gc/gctests/MemoryEaterMT. * VM Testbase keywords: [gc, stress, stressopt, nonconcurrent] * + * @requires test.thread.factory != "Virtual" * @library /vmTestbase * /test/lib * @run main/othervm -XX:-UseGCOverheadLimit gc.gctests.MemoryEaterMT.MemoryEaterMT From 067fd3cb2fa6a4a0484a922df8efbde03325ad3d Mon Sep 17 00:00:00 2001 From: Aleksey Shipilev Date: Thu, 8 Jan 2026 09:32:51 +0000 Subject: [PATCH 090/712] 8374768: S390X builds are failing after JDK-8372754 Reviewed-by: stefank, mdoerr --- src/hotspot/os_cpu/linux_s390/os_linux_s390.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/hotspot/os_cpu/linux_s390/os_linux_s390.cpp b/src/hotspot/os_cpu/linux_s390/os_linux_s390.cpp index 9982b5860a8..749f6bec032 100644 --- a/src/hotspot/os_cpu/linux_s390/os_linux_s390.cpp +++ b/src/hotspot/os_cpu/linux_s390/os_linux_s390.cpp @@ -30,7 +30,7 @@ #include "code/nativeInst.hpp" #include "code/vtableStubs.hpp" #include "compiler/disassembler.hpp" -#include "cppstdlib/cstdlib.h" +#include "cppstdlib/cstdlib.hpp" #include "interpreter/interpreter.hpp" #include "jvm.h" #include "memory/allocation.inline.hpp" From 904ba5f5ed7d3ac1a3606ff7532ba3c206a2d9b9 Mon Sep 17 00:00:00 2001 From: Maurizio Cimadamore Date: Thu, 8 Jan 2026 10:24:03 +0000 Subject: [PATCH 091/712] 8374718: Generation of CompilerProperties can fail in subtle ways Reviewed-by: jlahoda --- .../tools/propertiesparser/gen/ClassGenerator.java | 9 +++++++-- .../resources/templates.properties | 2 +- .../classes/com/sun/tools/javac/code/Lint.java | 14 +++++++++----- 3 files changed, 17 insertions(+), 8 deletions(-) diff --git a/make/langtools/tools/propertiesparser/gen/ClassGenerator.java b/make/langtools/tools/propertiesparser/gen/ClassGenerator.java index 247537b4676..14e8c4fb00a 100644 --- a/make/langtools/tools/propertiesparser/gen/ClassGenerator.java +++ b/make/langtools/tools/propertiesparser/gen/ClassGenerator.java @@ -286,7 +286,7 @@ public class ClassGenerator { diagnosticFlags.isEmpty() ? StubKind.DIAGNOSTIC_FLAGS_EMPTY.format() : StubKind.DIAGNOSTIC_FLAGS_NON_EMPTY.format(diagnosticFlags), - StubKind.LINT_CATEGORY.format("\"" + lintCategory + "\""), + StubKind.LINT_CATEGORY.format(toLintFieldName(lintCategory)), "\"" + keyParts[0] + "\"", "\"" + Stream.of(keyParts).skip(2).collect(Collectors.joining(".")) + "\"", javadoc); @@ -314,7 +314,7 @@ public class ClassGenerator { diagnosticFlags.isEmpty() ? StubKind.DIAGNOSTIC_FLAGS_EMPTY.format() : StubKind.DIAGNOSTIC_FLAGS_NON_EMPTY.format(diagnosticFlags), - StubKind.LINT_CATEGORY.format("\"" + lintCategory + "\""), + StubKind.LINT_CATEGORY.format(toLintFieldName(lintCategory)), "\"" + keyParts[0] + "\"", "\"" + Stream.of(keyParts).skip(2).collect(Collectors.joining(".")) + "\"", argNames.stream().collect(Collectors.joining(", "))); @@ -329,6 +329,11 @@ public class ClassGenerator { } } + String toLintFieldName(String lintCategory) { + return lintCategory.toUpperCase() + .replaceAll("-", "_"); + } + /** * Form the name of a factory method/field given a resource key. */ diff --git a/make/langtools/tools/propertiesparser/resources/templates.properties b/make/langtools/tools/propertiesparser/resources/templates.properties index 81a9be2552c..f8ff07a878f 100644 --- a/make/langtools/tools/propertiesparser/resources/templates.properties +++ b/make/langtools/tools/propertiesparser/resources/templates.properties @@ -87,7 +87,7 @@ suppress.warnings=\ @SuppressWarnings("rawtypes")\n lint.category=\ - LintCategory.get({0}).get() + LintCategory.{0} diagnostic.flags.empty=\ EnumSet.noneOf(DiagnosticFlag.class) diff --git a/src/jdk.compiler/share/classes/com/sun/tools/javac/code/Lint.java b/src/jdk.compiler/share/classes/com/sun/tools/javac/code/Lint.java index 3a8b4e5dbea..773c573c201 100644 --- a/src/jdk.compiler/share/classes/com/sun/tools/javac/code/Lint.java +++ b/src/jdk.compiler/share/classes/com/sun/tools/javac/code/Lint.java @@ -37,11 +37,7 @@ import java.util.Set; import java.util.stream.Stream; import com.sun.tools.javac.main.Option; -import com.sun.tools.javac.tree.JCTree.*; -import com.sun.tools.javac.util.Assert; import com.sun.tools.javac.util.Context; -import com.sun.tools.javac.util.JCDiagnostic.DiagnosticPosition; -import com.sun.tools.javac.util.JCDiagnostic.LintWarning; import com.sun.tools.javac.util.Log; import com.sun.tools.javac.util.Names; import com.sun.tools.javac.util.Options; @@ -178,6 +174,14 @@ public class Lint { /** * Categories of warnings that can be generated by the compiler. + * Each lint category has a logical name (a string), which is the string used e.g. in a {@code SuppressWarning} annotation. + * To ensure automation, the enum field name for a lint category string {@code C} should be obtained by: + *

    + *
  1. capitalize all the letters in {@code C}, and
  2. + *
  3. replacing any occurrence of {@code -} with {@code _}
  4. + *
+ * For instance, the lint category string {@code dangling-doc-comments} corresponds to the enum field + * {@code DANGLING_DOC_COMMENTS}. */ public enum LintCategory { /** @@ -320,7 +324,7 @@ public class Lint { /** * Warn about unchecked operations on raw types. */ - RAW("rawtypes"), + RAWTYPES("rawtypes"), /** * Warn about use of deprecated-for-removal items. From c5159fc9fa0fd81dec629cd821b3411b4a6df967 Mon Sep 17 00:00:00 2001 From: Kim Barrett Date: Thu, 8 Jan 2026 11:07:08 +0000 Subject: [PATCH 092/712] 8374328: Convert simple AtomicAccess uses in gc/shared to use Atomic Reviewed-by: dholmes, tschatzl --- .../share/gc/shared/barrierSetNMethod.cpp | 7 +++--- .../share/gc/shared/concurrentGCThread.cpp | 14 +++++------ .../share/gc/shared/concurrentGCThread.hpp | 7 +++--- src/hotspot/share/gc/shared/gcLocker.cpp | 23 ++++++++----------- src/hotspot/share/gc/shared/gcLocker.hpp | 7 +++--- .../share/gc/shared/gcLocker.inline.hpp | 8 +++---- src/hotspot/share/gc/shared/pretouchTask.cpp | 8 +++---- src/hotspot/share/gc/shared/pretouchTask.hpp | 6 +++-- .../share/gc/shared/suspendibleThreadSet.cpp | 8 +++---- .../share/gc/shared/suspendibleThreadSet.hpp | 8 +++---- src/hotspot/share/gc/shared/workerThread.cpp | 15 +++++++----- src/hotspot/share/gc/shared/workerThread.hpp | 7 +++--- 12 files changed, 62 insertions(+), 56 deletions(-) diff --git a/src/hotspot/share/gc/shared/barrierSetNMethod.cpp b/src/hotspot/share/gc/shared/barrierSetNMethod.cpp index cb5d6b5a886..ab94bae079a 100644 --- a/src/hotspot/share/gc/shared/barrierSetNMethod.cpp +++ b/src/hotspot/share/gc/shared/barrierSetNMethod.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 @@ -33,6 +33,7 @@ #include "memory/universe.hpp" #include "oops/access.inline.hpp" #include "oops/method.inline.hpp" +#include "runtime/atomic.hpp" #include "runtime/frame.inline.hpp" #include "runtime/javaThread.hpp" #include "runtime/threads.hpp" @@ -196,8 +197,8 @@ int BarrierSetNMethod::nmethod_stub_entry_barrier(address* return_address_ptr) { // Diagnostic option to force deoptimization 1 in 10 times. It is otherwise // a very rare event. if (DeoptimizeNMethodBarriersALot && !nm->is_osr_method()) { - static volatile uint32_t counter=0; - if (AtomicAccess::add(&counter, 1u) % 10 == 0) { + static Atomic counter{0}; + if (counter.add_then_fetch(1u) % 10 == 0) { may_enter = false; } } diff --git a/src/hotspot/share/gc/shared/concurrentGCThread.cpp b/src/hotspot/share/gc/shared/concurrentGCThread.cpp index ac281f82f8a..ed6c1b4d283 100644 --- a/src/hotspot/share/gc/shared/concurrentGCThread.cpp +++ b/src/hotspot/share/gc/shared/concurrentGCThread.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 @@ -23,7 +23,7 @@ */ #include "gc/shared/concurrentGCThread.hpp" -#include "runtime/atomicAccess.hpp" +#include "runtime/atomic.hpp" #include "runtime/init.hpp" #include "runtime/jniHandles.hpp" #include "runtime/mutexLocker.hpp" @@ -48,7 +48,7 @@ void ConcurrentGCThread::run() { // Signal thread has terminated MonitorLocker ml(Terminator_lock); - AtomicAccess::release_store(&_has_terminated, true); + _has_terminated.release_store(true); ml.notify_all(); } @@ -57,21 +57,21 @@ void ConcurrentGCThread::stop() { assert(!has_terminated(), "Invalid state"); // Signal thread to terminate - AtomicAccess::release_store_fence(&_should_terminate, true); + _should_terminate.release_store_fence(true); stop_service(); // Wait for thread to terminate MonitorLocker ml(Terminator_lock); - while (!_has_terminated) { + while (!_has_terminated.load_relaxed()) { ml.wait(); } } bool ConcurrentGCThread::should_terminate() const { - return AtomicAccess::load_acquire(&_should_terminate); + return _should_terminate.load_acquire(); } bool ConcurrentGCThread::has_terminated() const { - return AtomicAccess::load_acquire(&_has_terminated); + return _has_terminated.load_acquire(); } diff --git a/src/hotspot/share/gc/shared/concurrentGCThread.hpp b/src/hotspot/share/gc/shared/concurrentGCThread.hpp index 630abeaeb9f..0c764546045 100644 --- a/src/hotspot/share/gc/shared/concurrentGCThread.hpp +++ b/src/hotspot/share/gc/shared/concurrentGCThread.hpp @@ -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 @@ -25,14 +25,15 @@ #ifndef SHARE_GC_SHARED_CONCURRENTGCTHREAD_HPP #define SHARE_GC_SHARED_CONCURRENTGCTHREAD_HPP +#include "runtime/atomic.hpp" #include "runtime/javaThread.hpp" #include "runtime/nonJavaThread.hpp" #include "utilities/debug.hpp" class ConcurrentGCThread: public NamedThread { private: - volatile bool _should_terminate; - volatile bool _has_terminated; + Atomic _should_terminate; + Atomic _has_terminated; protected: void create_and_start(ThreadPriority prio = NearMaxPriority); diff --git a/src/hotspot/share/gc/shared/gcLocker.cpp b/src/hotspot/share/gc/shared/gcLocker.cpp index 01d17b1117d..898588e6b06 100644 --- a/src/hotspot/share/gc/shared/gcLocker.cpp +++ b/src/hotspot/share/gc/shared/gcLocker.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 @@ -28,7 +28,7 @@ #include "logging/log.hpp" #include "memory/resourceArea.hpp" #include "memory/universe.hpp" -#include "runtime/atomicAccess.hpp" +#include "runtime/atomic.hpp" #include "runtime/interfaceSupport.inline.hpp" #include "runtime/javaThread.inline.hpp" #include "runtime/safepoint.hpp" @@ -60,16 +60,13 @@ public: }; Monitor* GCLocker::_lock; -volatile bool GCLocker::_is_gc_request_pending; +Atomic GCLocker::_is_gc_request_pending{false}; -DEBUG_ONLY(uint64_t GCLocker::_verify_in_cr_count;) +DEBUG_ONLY(Atomic GCLocker::_verify_in_cr_count{0};) void GCLocker::initialize() { assert(JNICritical_lock != nullptr, "inv"); _lock = JNICritical_lock; - _is_gc_request_pending = false; - - DEBUG_ONLY(_verify_in_cr_count = 0;) } bool GCLocker::is_active() { @@ -84,11 +81,11 @@ bool GCLocker::is_active() { void GCLocker::block() { // _lock is held from the beginning of block() to the end of of unblock(). _lock->lock(); - assert(AtomicAccess::load(&_is_gc_request_pending) == false, "precondition"); + assert(_is_gc_request_pending.load_relaxed() == false, "precondition"); GCLockerTimingDebugLogger logger("Thread blocked to start GC."); - AtomicAccess::store(&_is_gc_request_pending, true); + _is_gc_request_pending.store_relaxed(true); // The _is_gc_request_pending and _jni_active_critical (inside // in_critical_atomic()) variables form a Dekker duality. On the GC side, the @@ -112,14 +109,14 @@ void GCLocker::block() { #ifdef ASSERT // Matching the storestore in GCLocker::exit. OrderAccess::loadload(); - assert(AtomicAccess::load(&_verify_in_cr_count) == 0, "inv"); + assert(_verify_in_cr_count.load_relaxed() == 0, "inv"); #endif } void GCLocker::unblock() { - assert(AtomicAccess::load(&_is_gc_request_pending) == true, "precondition"); + assert(_is_gc_request_pending.load_relaxed() == true, "precondition"); - AtomicAccess::store(&_is_gc_request_pending, false); + _is_gc_request_pending.store_relaxed(false); _lock->unlock(); } @@ -139,7 +136,7 @@ void GCLocker::enter_slow(JavaThread* current_thread) { // Same as fast path. OrderAccess::fence(); - if (!AtomicAccess::load(&_is_gc_request_pending)) { + if (!_is_gc_request_pending.load_relaxed()) { return; } diff --git a/src/hotspot/share/gc/shared/gcLocker.hpp b/src/hotspot/share/gc/shared/gcLocker.hpp index c0e28b66539..be3c0c3593e 100644 --- a/src/hotspot/share/gc/shared/gcLocker.hpp +++ b/src/hotspot/share/gc/shared/gcLocker.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 @@ -27,6 +27,7 @@ #include "gc/shared/gcCause.hpp" #include "memory/allStatic.hpp" +#include "runtime/atomic.hpp" #include "runtime/mutex.hpp" // GCLocker provides synchronization between the garbage collector (GC) and @@ -43,11 +44,11 @@ class GCLocker: public AllStatic { static Monitor* _lock; - static volatile bool _is_gc_request_pending; + static Atomic _is_gc_request_pending; #ifdef ASSERT // Debug-only: to track the number of java threads in critical-region. - static uint64_t _verify_in_cr_count; + static Atomic _verify_in_cr_count; #endif static void enter_slow(JavaThread* current_thread); diff --git a/src/hotspot/share/gc/shared/gcLocker.inline.hpp b/src/hotspot/share/gc/shared/gcLocker.inline.hpp index 050b9570280..135bd9eab62 100644 --- a/src/hotspot/share/gc/shared/gcLocker.inline.hpp +++ b/src/hotspot/share/gc/shared/gcLocker.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. * 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,13 +38,13 @@ void GCLocker::enter(JavaThread* current_thread) { // Matching the fence in GCLocker::block. OrderAccess::fence(); - if (AtomicAccess::load(&_is_gc_request_pending)) { + if (_is_gc_request_pending.load_relaxed()) { current_thread->exit_critical(); // slow-path enter_slow(current_thread); } - DEBUG_ONLY(AtomicAccess::add(&_verify_in_cr_count, (uint64_t)1);) + DEBUG_ONLY(_verify_in_cr_count.add_then_fetch(1u);) } else { current_thread->enter_critical(); } @@ -55,7 +55,7 @@ void GCLocker::exit(JavaThread* current_thread) { #ifdef ASSERT if (current_thread->in_last_critical()) { - AtomicAccess::add(&_verify_in_cr_count, (uint64_t)-1); + _verify_in_cr_count.sub_then_fetch(1u); // Matching the loadload in GCLocker::block. OrderAccess::storestore(); } diff --git a/src/hotspot/share/gc/shared/pretouchTask.cpp b/src/hotspot/share/gc/shared/pretouchTask.cpp index cc84c8c449d..c999c98ea99 100644 --- a/src/hotspot/share/gc/shared/pretouchTask.cpp +++ b/src/hotspot/share/gc/shared/pretouchTask.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 @@ -25,7 +25,7 @@ #include "gc/shared/gc_globals.hpp" #include "gc/shared/pretouchTask.hpp" #include "logging/log.hpp" -#include "runtime/atomicAccess.hpp" +#include "runtime/atomic.hpp" #include "runtime/globals.hpp" #include "runtime/os.hpp" #include "utilities/align.hpp" @@ -52,11 +52,11 @@ size_t PretouchTask::chunk_size() { void PretouchTask::work(uint worker_id) { while (true) { - char* cur_start = AtomicAccess::load(&_cur_addr); + char* cur_start = _cur_addr.load_relaxed(); char* cur_end = cur_start + MIN2(_chunk_size, pointer_delta(_end_addr, cur_start, 1)); if (cur_start >= cur_end) { break; - } else if (cur_start == AtomicAccess::cmpxchg(&_cur_addr, cur_start, cur_end)) { + } else if (cur_start == _cur_addr.compare_exchange(cur_start, cur_end)) { os::pretouch_memory(cur_start, cur_end, _page_size); } // Else attempt to claim chunk failed, so try again. } diff --git a/src/hotspot/share/gc/shared/pretouchTask.hpp b/src/hotspot/share/gc/shared/pretouchTask.hpp index 7c66c8b717c..6355d61edf7 100644 --- a/src/hotspot/share/gc/shared/pretouchTask.hpp +++ b/src/hotspot/share/gc/shared/pretouchTask.hpp @@ -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 @@ -26,9 +26,11 @@ #define SHARE_GC_SHARED_PRETOUCH_HPP #include "gc/shared/workerThread.hpp" +#include "runtime/atomic.hpp" +#include "utilities/globalDefinitions.hpp" class PretouchTask : public WorkerTask { - char* volatile _cur_addr; + Atomic _cur_addr; char* const _end_addr; size_t _page_size; size_t _chunk_size; diff --git a/src/hotspot/share/gc/shared/suspendibleThreadSet.cpp b/src/hotspot/share/gc/shared/suspendibleThreadSet.cpp index 83783b31ad9..834a3d04c00 100644 --- a/src/hotspot/share/gc/shared/suspendibleThreadSet.cpp +++ b/src/hotspot/share/gc/shared/suspendibleThreadSet.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 @@ -30,7 +30,7 @@ uint SuspendibleThreadSet::_nthreads = 0; uint SuspendibleThreadSet::_nthreads_stopped = 0; -volatile bool SuspendibleThreadSet::_suspend_all = false; +Atomic SuspendibleThreadSet::_suspend_all{false}; double SuspendibleThreadSet::_suspend_all_start = 0.0; static Semaphore* _synchronize_wakeup = nullptr; @@ -96,7 +96,7 @@ void SuspendibleThreadSet::synchronize() { { MonitorLocker ml(STS_lock, Mutex::_no_safepoint_check_flag); assert(!should_yield(), "Only one at a time"); - AtomicAccess::store(&_suspend_all, true); + _suspend_all.store_relaxed(true); if (is_synchronized()) { return; } @@ -127,6 +127,6 @@ void SuspendibleThreadSet::desynchronize() { MonitorLocker ml(STS_lock, Mutex::_no_safepoint_check_flag); assert(should_yield(), "STS not synchronizing"); assert(is_synchronized(), "STS not synchronized"); - AtomicAccess::store(&_suspend_all, false); + _suspend_all.store_relaxed(false); ml.notify_all(); } diff --git a/src/hotspot/share/gc/shared/suspendibleThreadSet.hpp b/src/hotspot/share/gc/shared/suspendibleThreadSet.hpp index 38568c015bc..72fca5302e7 100644 --- a/src/hotspot/share/gc/shared/suspendibleThreadSet.hpp +++ b/src/hotspot/share/gc/shared/suspendibleThreadSet.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,7 +26,7 @@ #define SHARE_GC_SHARED_SUSPENDIBLETHREADSET_HPP #include "memory/allocation.hpp" -#include "runtime/atomicAccess.hpp" +#include "runtime/atomic.hpp" // A SuspendibleThreadSet is a set of threads that can be suspended. // A thread can join and later leave the set, and periodically yield. @@ -43,7 +43,7 @@ class SuspendibleThreadSet : public AllStatic { private: static uint _nthreads; static uint _nthreads_stopped; - static volatile bool _suspend_all; + static Atomic _suspend_all; static double _suspend_all_start; static bool is_synchronized(); @@ -59,7 +59,7 @@ private: public: // Returns true if an suspension is in progress. - static bool should_yield() { return AtomicAccess::load(&_suspend_all); } + static bool should_yield() { return _suspend_all.load_relaxed(); } // Suspends the current thread if a suspension is in progress. static void yield() { diff --git a/src/hotspot/share/gc/shared/workerThread.cpp b/src/hotspot/share/gc/shared/workerThread.cpp index 3a999da59dc..7a9404a195a 100644 --- a/src/hotspot/share/gc/shared/workerThread.cpp +++ b/src/hotspot/share/gc/shared/workerThread.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 @@ -42,7 +42,7 @@ WorkerTaskDispatcher::WorkerTaskDispatcher() : void WorkerTaskDispatcher::coordinator_distribute_task(WorkerTask* task, uint num_workers) { // No workers are allowed to read the state variables until they have been signaled. _task = task; - _not_finished = num_workers; + _not_finished.store_relaxed(num_workers); // Dispatch 'num_workers' number of tasks. _start_semaphore.signal(num_workers); @@ -51,9 +51,12 @@ void WorkerTaskDispatcher::coordinator_distribute_task(WorkerTask* task, uint nu _end_semaphore.wait(); // No workers are allowed to read the state variables after the coordinator has been signaled. - assert(_not_finished == 0, "%d not finished workers?", _not_finished); +#ifdef ASSERT + uint not_finished = _not_finished.load_relaxed(); + assert(not_finished == 0, "%u not finished workers?", not_finished); +#endif // ASSERT _task = nullptr; - _started = 0; + _started.store_relaxed(0); } void WorkerTaskDispatcher::worker_run_task() { @@ -61,7 +64,7 @@ void WorkerTaskDispatcher::worker_run_task() { _start_semaphore.wait(); // Get and set worker id. - const uint worker_id = AtomicAccess::fetch_then_add(&_started, 1u); + const uint worker_id = _started.fetch_then_add(1u); WorkerThread::set_worker_id(worker_id); // Run task. @@ -70,7 +73,7 @@ void WorkerTaskDispatcher::worker_run_task() { // Mark that the worker is done with the task. // The worker is not allowed to read the state variables after this line. - const uint not_finished = AtomicAccess::sub(&_not_finished, 1u); + const uint not_finished = _not_finished.sub_then_fetch(1u); // The last worker signals to the coordinator that all work is completed. if (not_finished == 0) { diff --git a/src/hotspot/share/gc/shared/workerThread.hpp b/src/hotspot/share/gc/shared/workerThread.hpp index d4e92797039..a1f7282abe4 100644 --- a/src/hotspot/share/gc/shared/workerThread.hpp +++ b/src/hotspot/share/gc/shared/workerThread.hpp @@ -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 @@ -27,6 +27,7 @@ #include "gc/shared/gcId.hpp" #include "memory/allocation.hpp" +#include "runtime/atomic.hpp" #include "runtime/nonJavaThread.hpp" #include "runtime/semaphore.hpp" #include "utilities/debug.hpp" @@ -58,8 +59,8 @@ class WorkerTaskDispatcher { // The task currently being dispatched to the WorkerThreads. WorkerTask* _task; - volatile uint _started; - volatile uint _not_finished; + Atomic _started; + Atomic _not_finished; // Semaphore used to start the WorkerThreads. Semaphore _start_semaphore; From 78b1ca6cc14e1a92bf25cbcfb687067ac17af92b Mon Sep 17 00:00:00 2001 From: Matthias Baesken Date: Thu, 8 Jan 2026 12:44:08 +0000 Subject: [PATCH 093/712] 8374711: Hotspot runtime/CommandLine/OptionsValidation/TestOptionsWithRanges fails without printing the option name Reviewed-by: mdoerr, dholmes --- .../OptionsValidation/common/optionsvalidation/JVMOption.java | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/test/hotspot/jtreg/runtime/CommandLine/OptionsValidation/common/optionsvalidation/JVMOption.java b/test/hotspot/jtreg/runtime/CommandLine/OptionsValidation/common/optionsvalidation/JVMOption.java index 78a508343d6..d87ca25fc3c 100644 --- a/test/hotspot/jtreg/runtime/CommandLine/OptionsValidation/common/optionsvalidation/JVMOption.java +++ b/test/hotspot/jtreg/runtime/CommandLine/OptionsValidation/common/optionsvalidation/JVMOption.java @@ -116,7 +116,7 @@ public abstract class JVMOption { default: throw new Error("Expected only \"int\", \"intx\", \"size_t\", " + "\"uint\", \"uintx\", \"uint64_t\", or \"double\" " - + "option types! Got " + type + " type!"); + + "option types! Got " + type + " type for option " + name + "!"); } return parameter; From ec657349ff654dcb41b9f17178aeea638329101e Mon Sep 17 00:00:00 2001 From: Brian Burkhalter Date: Thu, 8 Jan 2026 16:28:10 +0000 Subject: [PATCH 094/712] 8374641: Remove java/nio/channels/AsyncCloseAndInterrupt.java from problem list Reviewed-by: iris --- test/jdk/ProblemList.txt | 4 +--- 1 file changed, 1 insertion(+), 3 deletions(-) diff --git a/test/jdk/ProblemList.txt b/test/jdk/ProblemList.txt index addcc8830af..9cfc23ea8da 100644 --- a/test/jdk/ProblemList.txt +++ b/test/jdk/ProblemList.txt @@ -1,6 +1,6 @@ ########################################################################### # -# 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 @@ -561,8 +561,6 @@ java/net/MulticastSocket/Test.java 7145658,8308807 # jdk_nio -java/nio/channels/AsyncCloseAndInterrupt.java 8368290 macosx-26.0.1 - java/nio/channels/DatagramChannel/AdaptorMulticasting.java 8308807,8144003 aix-ppc64,macosx-all java/nio/channels/DatagramChannel/AfterDisconnect.java 8308807 aix-ppc64 java/nio/channels/DatagramChannel/ManySourcesAndTargets.java 8264385 macosx-aarch64 From 677572b42d6d0ee62063c3f19ffad1e501ac9bf3 Mon Sep 17 00:00:00 2001 From: Brian Burkhalter Date: Thu, 8 Jan 2026 16:28:43 +0000 Subject: [PATCH 095/712] 8372377: Test java/io/File/GetXSpace.java failed: The system cannot find the path specified Reviewed-by: alanb, jpai --- test/jdk/java/io/File/GetXSpace.java | 46 ++++++++++++++++------------ test/jdk/java/io/File/libGetXSpace.c | 11 +++---- 2 files changed, 31 insertions(+), 26 deletions(-) diff --git a/test/jdk/java/io/File/GetXSpace.java b/test/jdk/java/io/File/GetXSpace.java index 96ce4ede1b2..f1529c18fb2 100644 --- a/test/jdk/java/io/File/GetXSpace.java +++ b/test/jdk/java/io/File/GetXSpace.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 @@ -44,7 +44,6 @@ import java.util.ArrayList; import java.util.regex.Matcher; import java.util.regex.Pattern; import jdk.test.lib.Platform; -import jdk.test.lib.Platform; import static java.lang.System.err; import static java.lang.System.out; @@ -103,16 +102,11 @@ public class GetXSpace { private final long free; private final long available; - Space(String name) { + Space(String name) throws IOException { this.name = name; long[] sizes = new long[4]; if (Platform.isWindows() && isCDDrive(name)) { - try { - getCDDriveSpace(name, sizes); - } catch (IOException e) { - e.printStackTrace(); - throw new RuntimeException("can't get CDDrive sizes"); - } + getCDDriveSpace(name, sizes); } else { if (getSpace(name, sizes)) System.err.println("WARNING: total space is estimated"); @@ -170,7 +164,7 @@ public class GetXSpace { return al; } - private static void compare(Space s) { + private static void compare(Space s) throws IOException { File f = new File(s.name()); long ts = f.getTotalSpace(); long fs = f.getFreeSpace(); @@ -318,7 +312,7 @@ public class GetXSpace { } } - private static int testFile(Path dir) { + private static int testFile(Path dir) throws IOException { String dirName = dir.toString(); out.format("--- Testing %s%n", dirName); compare(new Space(dir.getRoot().toString())); @@ -333,10 +327,11 @@ public class GetXSpace { return fail != 0 ? 1 : 0; } - private static int testVolumes() { + private static int testVolumes() throws IOException { out.println("--- Testing volumes"); // Find all of the partitions on the machine and verify that the sizes - // returned by File::getXSpace are equivalent to those from getSpace or getCDDriveSpace + // returned by File::getXSpace are equivalent to those from getSpace + // or getCDDriveSpace ArrayList l; try { l = paths(); @@ -350,7 +345,18 @@ public class GetXSpace { throw new RuntimeException("no partitions?"); for (var p : l) { - Space s = new Space(p); + Space s; + try { + s = new Space(p); + } catch (IOException x) { + // Avoid failing for transient file systems on Windows + if (Platform.isWindows()) { + File f = new File(p); + if (!f.exists()) + continue; + } + throw new IOException("Failure for volume " + p, x); + } compare(s); compareZeroNonExist(); compareZeroExist(); @@ -408,19 +414,19 @@ public class GetXSpace { // size[2] free space: number of free bytes in the volume // size[3] usable space: number of bytes available to the caller // - private static native boolean getSpace0(String root, long[] space); + private static native boolean getSpace0(String root, long[] space) + throws IOException; private static native boolean isCDDrive(String root); - private static boolean getSpace(String root, long[] space) { + private static boolean getSpace(String root, long[] space) + throws IOException { try { return getSpace0(root, space); - } catch (RuntimeException e) { + } catch (IOException e) { File f = new File(root); - boolean exists = f.exists(); - boolean readable = f.canRead(); System.err.printf("getSpace0 failed for %s (%s, %s)%n", - root, exists, readable); + root, f.exists(), f.canRead()); throw e; } } diff --git a/test/jdk/java/io/File/libGetXSpace.c b/test/jdk/java/io/File/libGetXSpace.c index 59805e0adcb..9297721b8f4 100644 --- a/test/jdk/java/io/File/libGetXSpace.c +++ b/test/jdk/java/io/File/libGetXSpace.c @@ -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 @@ -85,7 +85,7 @@ Java_GetXSpace_getSpace0 BOOL hres = pfnGetDiskSpaceInformation(path, &diskSpaceInfo); (*env)->ReleaseStringChars(env, root, strchars); if (FAILED(hres)) { - JNU_ThrowByNameWithLastError(env, "java/lang/RuntimeException", + JNU_ThrowByNameWithLastError(env, "java/io/IOException", "GetDiskSpaceInformationW"); return totalSpaceIsEstimated; } @@ -113,7 +113,7 @@ Java_GetXSpace_getSpace0 &totalNumberOfBytes, &totalNumberOfFreeBytes); (*env)->ReleaseStringChars(env, root, strchars); if (FAILED(hres)) { - JNU_ThrowByNameWithLastError(env, "java/lang/RuntimeException", + JNU_ThrowByNameWithLastError(env, "java/io/IOException", "GetDiskFreeSpaceExW"); return totalSpaceIsEstimated; } @@ -131,8 +131,7 @@ Java_GetXSpace_getSpace0 char* chars = (char*)malloc((len + 1)*sizeof(char)); if (chars == NULL) { (*env)->ReleaseStringChars(env, root, strchars); - JNU_ThrowByNameWithLastError(env, "java/lang/RuntimeException", - "malloc"); + JNU_ThrowOutOfMemoryError(env, "malloc"); return JNI_FALSE; } @@ -146,7 +145,7 @@ Java_GetXSpace_getSpace0 int result = statfs(chars, &buf); free(chars); if (result < 0) { - JNU_ThrowByNameWithLastError(env, "java/lang/RuntimeException", + JNU_ThrowByNameWithLastError(env, "java/io/IOException", strerror(errno)); return totalSpaceIsEstimated; } From fa2eb626478806dc64fe03d8729f53f7ed26a172 Mon Sep 17 00:00:00 2001 From: Erik Gahlin Date: Thu, 8 Jan 2026 16:34:39 +0000 Subject: [PATCH 096/712] 8367949: JFR: MethodTrace double-counts methods that catch their own exceptions Reviewed-by: mgronlun --- .../jfr/internal/tracing/Instrumentation.java | 22 +- .../jdk/jfr/internal/tracing/Method.java | 2 +- .../jdk/jfr/internal/tracing/Transform.java | 199 ++++++++++++++++-- .../jfr/event/tracing/TestConstructors.java | 167 +++++++++++++++ .../event/tracing/TestInstrumentation.java | 4 + 5 files changed, 363 insertions(+), 31 deletions(-) create mode 100644 test/jdk/jdk/jfr/event/tracing/TestConstructors.java diff --git a/src/jdk.jfr/share/classes/jdk/jfr/internal/tracing/Instrumentation.java b/src/jdk.jfr/share/classes/jdk/jfr/internal/tracing/Instrumentation.java index dbafca4ed3c..e06d361b203 100644 --- a/src/jdk.jfr/share/classes/jdk/jfr/internal/tracing/Instrumentation.java +++ b/src/jdk.jfr/share/classes/jdk/jfr/internal/tracing/Instrumentation.java @@ -58,7 +58,13 @@ final class Instrumentation { } public void addMethod(long methodId, String name, String signature, int modification) { - modificationMap.put(name + signature, new Method(methodId, Modification.valueOf(modification), className + "::" + name)); + Method method = new Method( + methodId, + Modification.valueOf(modification), + name.equals(""), + className + "::" + name + ); + modificationMap.put(name + signature, method); } public List getMethods() { @@ -71,7 +77,7 @@ final class Instrumentation { ClassModel classModel = classFile.parse(bytecode); byte[] generated = classFile.build(classModel.thisClass().asSymbol(), classBuilder -> { for (var ce : classModel) { - if (modifyClassElement(classBuilder, ce)) { + if (modifyClassElement(classModel, classBuilder, ce)) { modified[0] = true; } else { classBuilder.with(ce); @@ -93,7 +99,7 @@ final class Instrumentation { } } - private boolean modifyClassElement(ClassBuilder classBuilder, ClassElement ce) { + private boolean modifyClassElement(ClassModel classModel, ClassBuilder classBuilder, ClassElement ce) { if (ce instanceof MethodModel mm) { String method = mm.methodName().stringValue(); String signature = mm.methodType().stringValue(); @@ -102,15 +108,15 @@ final class Instrumentation { if (tm != null) { Modification m = tm.modification(); if (m.tracing() || m.timing()) { - return modifyMethod(classBuilder, mm, tm); + return modifyMethod(classModel, classBuilder, mm, tm); } } } return false; } - private boolean modifyMethod(ClassBuilder classBuilder, MethodModel m, Method method) { - var code = m.code(); + private boolean modifyMethod(ClassModel classModel, ClassBuilder classBuilder, MethodModel methodModel, Method method) { + var code = methodModel.code(); if (code.isPresent()) { if (classLoader == null && ExcludeList.containsMethod(method.name())) { String msg = "Risk of recursion, skipping bytecode generation of " + method.name(); @@ -118,9 +124,9 @@ final class Instrumentation { return false; } MethodTransform s = MethodTransform.ofStateful( - () -> MethodTransform.transformingCode(new Transform(method)) + () -> MethodTransform.transformingCode(new Transform(classModel, code.get(), method)) ); - classBuilder.transformMethod(m, s); + classBuilder.transformMethod(methodModel, s); return true; } return false; diff --git a/src/jdk.jfr/share/classes/jdk/jfr/internal/tracing/Method.java b/src/jdk.jfr/share/classes/jdk/jfr/internal/tracing/Method.java index d685083153d..d85e458e9d5 100644 --- a/src/jdk.jfr/share/classes/jdk/jfr/internal/tracing/Method.java +++ b/src/jdk.jfr/share/classes/jdk/jfr/internal/tracing/Method.java @@ -31,7 +31,7 @@ import jdk.jfr.internal.Logger; /** * Class that holds information about an instrumented method. */ -record Method(long methodId, Modification modification, String name) { +record Method(long methodId, Modification modification, boolean constructor, String name) { @Override public String toString() { return name + (modification.timing() ? " +timing" : " -timing") + (modification.tracing() ? " +tracing" : " -tracing") + " (Method ID: " + String.format("0x%08X)", methodId); diff --git a/src/jdk.jfr/share/classes/jdk/jfr/internal/tracing/Transform.java b/src/jdk.jfr/share/classes/jdk/jfr/internal/tracing/Transform.java index cd65a119cee..377eede7925 100644 --- a/src/jdk.jfr/share/classes/jdk/jfr/internal/tracing/Transform.java +++ b/src/jdk.jfr/share/classes/jdk/jfr/internal/tracing/Transform.java @@ -24,13 +24,19 @@ */ package jdk.jfr.internal.tracing; +import java.lang.classfile.ClassModel; import java.lang.classfile.CodeBuilder; import java.lang.classfile.CodeElement; +import java.lang.classfile.CodeModel; import java.lang.classfile.CodeTransform; +import java.lang.classfile.Label; import java.lang.classfile.TypeKind; +import java.lang.classfile.instruction.InvokeInstruction; import java.lang.classfile.instruction.ReturnInstruction; import java.lang.classfile.instruction.ThrowInstruction; import java.lang.constant.ClassDesc; +import java.util.ArrayList; +import java.util.List; import jdk.jfr.internal.util.Bytecode; import jdk.jfr.internal.util.Bytecode.MethodDesc; @@ -43,59 +49,208 @@ import jdk.jfr.tracing.MethodTracer; * The method ID is determined by native code. */ final class Transform implements CodeTransform { + private static class TryBlock { + Label start; + Label end; + } private static final ClassDesc METHOD_TRACER_CLASS = ClassDesc.of(MethodTracer.class.getName()); private static final MethodDesc TRACE_METHOD = MethodDesc.of("trace", "(JJ)V"); private static final MethodDesc TIMING_METHOD = MethodDesc.of("timing", "(JJ)V"); private static final MethodDesc TRACE_TIMING_METHOD = MethodDesc.of("traceTiming", "(JJ)V"); private static final MethodDesc TIMESTAMP_METHOD = MethodDesc.of("timestamp", "()J"); + private final List tryBlocks = new ArrayList<>(); + private final boolean simplifiedInstrumentation; + private final ClassModel classModel; private final Method method; private int timestampSlot = -1; - Transform(Method method) { + Transform(ClassModel classModel, CodeModel model, Method method) { this.method = method; + this.classModel = classModel; + // The JVMS (not the JLS) allows multiple mutually exclusive super/this. + // invocations in a constructor body as long as only one lies on any given + // execution path. For example, this is valid bytecode: + // + // Foo(boolean value) { + // if (value) { + // staticMethodThatMayThrow(); + // super(); + // } else { + // try { + // if (value == 0) { + // throw new Exception(""); + // } + // } catch (Throwable t) { + // throw t; + // } + // super(); + // } + // } + // + // If such a method is found, instrumentation falls back to instrumenting only + // RET and ATHROW. This can cause exceptions to be missed or counted twice. + // + // An effect of this heuristic is that constructors like the one below + // will also trigger simplified instrumentation. + // + // class Bar { + // } + // + // class Foo extends Bar { + // Foo() { + // new Bar(); + // } + // } + // + // java.lang.Object:: with zero constructor invocations should use simplified instrumentation + this.simplifiedInstrumentation = method.constructor() && constructorInvocations(model.elementList()) != 1; + } + + private int constructorInvocations(List elementList) { + int count = 0; + for (CodeElement e : elementList) { + if (isConstructorInvocation(e)) { + count++; + } + } + return count; + } + + private boolean isConstructorInvocation(CodeElement element) { + if (element instanceof InvokeInstruction inv && inv.name().equalsString("")) { + if (classModel.thisClass().equals(inv.owner())) { + return true; + } + if (classModel.superclass().isPresent()) { + return classModel.superclass().get().equals(inv.owner()); + } + } + return false; } @Override - public final void accept(CodeBuilder builder, CodeElement element) { + public void accept(CodeBuilder builder, CodeElement element) { + if (simplifiedInstrumentation) { + acceptSimplifiedInstrumentation(builder, element); + return; + } + if (method.constructor()) { + acceptConstructor(builder, element, isConstructorInvocation(element)); + } else { + acceptMethod(builder, element); + } + } + + @Override + public void atEnd(CodeBuilder builder) { + endTryBlock(builder); + for (TryBlock block : tryBlocks) { + addCatchHandler(block, builder); + } + } + + private void acceptConstructor(CodeBuilder builder, CodeElement element, boolean isConstructorInvocation) { + if (timestampSlot == -1) { + timestampSlot = invokeTimestamp(builder); + builder.lstore(timestampSlot); + if (!isConstructorInvocation) { + beginTryBlock(builder); + } + } + if (isConstructorInvocation) { + endTryBlock(builder); + builder.with(element); + beginTryBlock(builder); + return; + } + if (element instanceof ReturnInstruction) { + addTracing(builder); + } + builder.with(element); + } + + private void endTryBlock(CodeBuilder builder) { + if (tryBlocks.isEmpty()) { + return; + } + TryBlock last = tryBlocks.getLast(); + if (last.end == null) { + last.end = builder.newBoundLabel(); + } + } + + private void beginTryBlock(CodeBuilder builder) { + TryBlock block = new TryBlock(); + block.start = builder.newBoundLabel(); + tryBlocks.add(block); + } + + private void acceptSimplifiedInstrumentation(CodeBuilder builder, CodeElement element) { if (timestampSlot == -1) { timestampSlot = invokeTimestamp(builder); builder.lstore(timestampSlot); } if (element instanceof ReturnInstruction || element instanceof ThrowInstruction) { - builder.lload(timestampSlot); - builder.ldc(method.methodId()); - Modification modification = method.modification(); - boolean objectInit = method.name().equals("java.lang.Object::"); - String suffix = objectInit ? "ObjectInit" : ""; - if (modification.timing()) { - if (modification.tracing()) { - invokeTraceTiming(builder, suffix); - } else { - invokeTiming(builder, suffix); - } - } else { - if (modification.tracing()) { - invokeTrace(builder, suffix); - } - } + addTracing(builder); } builder.with(element); } - public static void invokeTiming(CodeBuilder builder, String suffix) { + private void acceptMethod(CodeBuilder builder, CodeElement element) { + if (timestampSlot == -1) { + timestampSlot = invokeTimestamp(builder); + builder.lstore(timestampSlot); + beginTryBlock(builder); + } + if (element instanceof ReturnInstruction) { + addTracing(builder); + } + builder.with(element); + } + + private void addCatchHandler(TryBlock block, CodeBuilder builder) { + Label catchHandler = builder.newBoundLabel(); + int exceptionSlot = builder.allocateLocal(TypeKind.REFERENCE); + builder.astore(exceptionSlot); + addTracing(builder); + builder.aload(exceptionSlot); + builder.athrow(); + builder.exceptionCatchAll(block.start, block.end, catchHandler); + } + + private void addTracing(CodeBuilder builder) { + builder.lload(timestampSlot); + builder.ldc(method.methodId()); + Modification modification = method.modification(); + boolean objectInit = method.name().equals("java.lang.Object::"); + String suffix = objectInit ? "ObjectInit" : ""; + if (modification.timing()) { + if (modification.tracing()) { + invokeTraceTiming(builder, suffix); + } else { + invokeTiming(builder, suffix); + } + } else { + if (modification.tracing()) { + invokeTrace(builder, suffix); + } + } + } + + private static void invokeTiming(CodeBuilder builder, String suffix) { builder.invokestatic(METHOD_TRACER_CLASS, TIMING_METHOD.name() + suffix, TIMING_METHOD.descriptor()); } - public static void invokeTrace(CodeBuilder builder, String suffix) { + private static void invokeTrace(CodeBuilder builder, String suffix) { builder.invokestatic(METHOD_TRACER_CLASS, TRACE_METHOD.name() + suffix, TRACE_METHOD.descriptor()); } - public static void invokeTraceTiming(CodeBuilder builder, String suffix) { + private static void invokeTraceTiming(CodeBuilder builder, String suffix) { builder.invokestatic(METHOD_TRACER_CLASS, TRACE_TIMING_METHOD.name() + suffix, TRACE_TIMING_METHOD.descriptor()); } - public static int invokeTimestamp(CodeBuilder builder) { + private static int invokeTimestamp(CodeBuilder builder) { Bytecode.invokestatic(builder, METHOD_TRACER_CLASS, TIMESTAMP_METHOD); return builder.allocateLocal(TypeKind.LONG); } diff --git a/test/jdk/jdk/jfr/event/tracing/TestConstructors.java b/test/jdk/jdk/jfr/event/tracing/TestConstructors.java new file mode 100644 index 00000000000..26548646b49 --- /dev/null +++ b/test/jdk/jdk/jfr/event/tracing/TestConstructors.java @@ -0,0 +1,167 @@ +/* + * Copyright (c) 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 jdk.jfr.event.tracing; + +import java.nio.file.Path; +import java.util.List; +import java.util.Map; +import java.util.TreeMap; + +import jdk.jfr.Recording; +import jdk.jfr.consumer.RecordedEvent; +import jdk.jfr.consumer.RecordedMethod; +import jdk.jfr.consumer.RecordingFile; +import jdk.test.lib.jfr.Events; + +/** + * @test + * @summary Tests that constructors are instrumented correctly. + * @requires vm.flagless + * @requires vm.hasJFR + * @library /test/lib + * @run main/othervm -Xlog:jfr+methodtrace=debug + * jdk.jfr.event.tracing.TestConstructors + **/ +public class TestConstructors { + static private void methodThatThrows() { + throw new RuntimeException(); + } + + public static class Cat { + Cat() { + new String(); + methodThatThrows(); + super(); + methodThatThrows(); + } + } + + public static class Dog { + Dog() { + super(); + methodThatThrows(); + } + } + + public static class Tiger { + Tiger() { + methodThatThrows(); + super(); + } + } + + public static class Zebra { + Zebra(boolean shouldThrow) { + this(shouldThrow ? 1 : 0); + } + + Zebra(int shouldThrow) { + if (shouldThrow == 1) { + throw new RuntimeException(); + } + } + } + + public static class Snake { + Snake() { + try { + throw new RuntimeException(); + } catch (Exception e) { + // Ignore + } + super(); + } + } + + public static void main(String... args) throws Exception { + try (Recording r = new Recording()) { + r.enable("jdk.MethodTrace").with("filter", Dog.class.getName() + ";" + Cat.class.getName() + ";" + Tiger.class.getName() + ";" + Zebra.class.getName() + ";" + Snake.class.getName()); + r.start(); + try { + new Cat(); + } catch (Exception e) { + // ignore + } + try { + new Dog(); + } catch (Exception e) { + // ignore + } + try { + new Tiger(); + } catch (Exception e) { + // ignore + } + try { + new Zebra(true); + } catch (Exception e) { + // ignore + } + try { + new Zebra(false); + } catch (Exception e) { + // ignore + } + try { + new Snake(); + } catch (Exception e) { + // ignore + } + r.stop(); + List events = Events.fromRecording(r); + var methods = buildMethodMap(events); + if (methods.size() != 5) { + throw new Exception("Expected 5 different methods"); + } + assertMethodCount(methods, "Cat", 1); + assertMethodCount(methods, "Dog", 1); + assertMethodCount(methods, "Snake", 1); + assertMethodCount(methods, "Tiger", 1); + assertMethodCount(methods, "Zebra", 3); + } + } + + private static void assertMethodCount(Map methods, String className, int expectedCount) throws Exception { + String name = TestConstructors.class.getName() + "$" + className + "::"; + Long count = methods.get(name); + if (count == null) { + throw new Exception("Could not find traced method " + name); + } + if (count != expectedCount) { + throw new Exception("Expected " + expectedCount + " trace event for " + name); + } + } + + private static Map buildMethodMap(List events) { + Map map = new TreeMap<>(); + for (RecordedEvent e : events) { + RecordedMethod m = e.getValue("method"); + String name = m.getType().getName() + "::" + m.getName(); + map.compute(name, (_, value) -> (value == null) ? 1 : value + 1); + } + for (var e : map.entrySet()) { + System.out.println(e.getKey() + " " + e.getValue()); + } + return map; + } +} \ No newline at end of file diff --git a/test/jdk/jdk/jfr/event/tracing/TestInstrumentation.java b/test/jdk/jdk/jfr/event/tracing/TestInstrumentation.java index 834d4ab4989..5709c95812a 100644 --- a/test/jdk/jdk/jfr/event/tracing/TestInstrumentation.java +++ b/test/jdk/jdk/jfr/event/tracing/TestInstrumentation.java @@ -93,6 +93,8 @@ public class TestInstrumentation { assertMethod(map, "exception", 2); assertMethod(map, "switchExpression", 3); assertMethod(map, "recursive", 4); + assertMethod(map, "deepException", 1); + assertMethod(map, "whileTrue", 1); assertMethod(map, "multipleReturns", 5); if (!map.isEmpty()) { throw new Exception("Found unexpected methods " + map.keySet()); @@ -105,6 +107,8 @@ public class TestInstrumentation { assertMethod(map, "exception", 2); assertMethod(map, "switchExpression", 3); assertMethod(map, "recursive", 4); + assertMethod(map, "deepException", 1); + assertMethod(map, "whileTrue", 1); assertMethod(map, "multipleReturns", 5); for (var entry : map.entrySet()) { long invocations = entry.getValue(); From c834e4c641bf6c73e88b93c0cdba40a83f3192c1 Mon Sep 17 00:00:00 2001 From: Jonas Norlinder Date: Thu, 8 Jan 2026 16:46:28 +0000 Subject: [PATCH 097/712] 8373647: Avoid fstat when opening file for write with RandomAccessFile or FileOutputStream Reviewed-by: redestad, alanb --- .../unix/native/libjava/io_util_md.c | 31 ++++++++++++------- .../org/openjdk/bench/java/io/FileWrite.java | 28 ++++++++++++++++- 2 files changed, 46 insertions(+), 13 deletions(-) diff --git a/src/java.base/unix/native/libjava/io_util_md.c b/src/java.base/unix/native/libjava/io_util_md.c index 2e81cbd05c2..bcac334191c 100644 --- a/src/java.base/unix/native/libjava/io_util_md.c +++ b/src/java.base/unix/native/libjava/io_util_md.c @@ -1,5 +1,5 @@ /* - * Copyright (c) 2001, 2024, Oracle and/or its affiliates. All rights reserved. + * 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 @@ -27,6 +27,7 @@ #include "jvm.h" #include "io_util.h" #include "io_util_md.h" +#include #include #include @@ -75,20 +76,26 @@ FD handleOpen(const char *path, int oflag, int mode) { FD fd; RESTARTABLE(open(path, oflag, mode), fd); - if (fd != -1) { - struct stat buf; - int result; - RESTARTABLE(fstat(fd, &buf), result); - if (result != -1) { - if (S_ISDIR(buf.st_mode)) { - close(fd); - errno = EISDIR; - fd = -1; - } - } else { + // No further checking is needed if the file is not a + // directory or open returned an error + if (fd == -1 || ((oflag & O_ACCMODE) != O_RDONLY) != 0) { + return fd; + } + + // FileInputStream is specified to throw if the + // file is a directory + struct stat buf; + int result; + RESTARTABLE(fstat(fd, &buf), result); + if (result != -1) { + if (S_ISDIR(buf.st_mode)) { close(fd); + errno = EISDIR; fd = -1; } + } else { + close(fd); + fd = -1; } return fd; } diff --git a/test/micro/org/openjdk/bench/java/io/FileWrite.java b/test/micro/org/openjdk/bench/java/io/FileWrite.java index 21b0c2f8f54..c5a5aee70d8 100644 --- a/test/micro/org/openjdk/bench/java/io/FileWrite.java +++ b/test/micro/org/openjdk/bench/java/io/FileWrite.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,6 +25,7 @@ package org.openjdk.bench.java.io; import java.io.File; import java.io.FileNotFoundException; import java.io.FileOutputStream; +import java.io.RandomAccessFile; import java.io.IOException; import java.util.concurrent.TimeUnit; @@ -81,4 +82,29 @@ public class FileWrite { } } + @State(Scope.Benchmark) + @Warmup(iterations = 3, time = 2) + @Measurement(iterations = 5, time = 5) + @BenchmarkMode(Mode.SampleTime) + @OutputTimeUnit(TimeUnit.NANOSECONDS) + @Threads(1) + @Fork(value = 10) + public static class OpenFileForWritingBench { + final byte[] payload = "something".getBytes(); + final String path = System.getProperty("os.name", "unknown").toLowerCase().contains("win") ? "NUL" : "/dev/null"; + + @Benchmark + public void testFileOutputStream() throws IOException { + try (FileOutputStream f = new FileOutputStream(path)) { + f.write(payload); + } + } + + @Benchmark + public void testRandomAccessFile() throws IOException { + try (RandomAccessFile f = new RandomAccessFile(path, "rw")) { + f.write(payload); + } + } + } } From 7e1051bfcc01aad538376c86354e16e25d2eaf7a Mon Sep 17 00:00:00 2001 From: Francisco Ferrari Bihurriet Date: Thu, 8 Jan 2026 16:46:48 +0000 Subject: [PATCH 098/712] 8352728: InternalError loading java.security due to Windows parent folder permissions Reviewed-by: weijun, mullan --- .../share/classes/java/security/Security.java | 37 +++-- .../ExtraFileAndIncludes.java} | 154 ++++++++++-------- .../SecurityPropFile/LinuxAnonymousFiles.java | 83 ++++++++++ .../SecurityPropFile/SecurityPropFile.file | 1 - .../SecurityPropFile/SecurityPropFile.java | 42 ----- .../WindowsParentDirPermissions.java | 84 ++++++++++ 6 files changed, 273 insertions(+), 128 deletions(-) rename test/jdk/java/security/Security/{ConfigFileTest.java => SecurityPropFile/ExtraFileAndIncludes.java} (88%) create mode 100644 test/jdk/java/security/Security/SecurityPropFile/LinuxAnonymousFiles.java delete mode 100644 test/jdk/java/security/Security/SecurityPropFile/SecurityPropFile.file delete mode 100644 test/jdk/java/security/Security/SecurityPropFile/SecurityPropFile.java create mode 100644 test/jdk/java/security/Security/SecurityPropFile/WindowsParentDirPermissions.java diff --git a/src/java.base/share/classes/java/security/Security.java b/src/java.base/share/classes/java/security/Security.java index 6969fe8a8e1..30a22b05742 100644 --- a/src/java.base/share/classes/java/security/Security.java +++ b/src/java.base/share/classes/java/security/Security.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 @@ -34,6 +34,7 @@ import java.net.URL; import java.nio.file.Files; import java.nio.file.InvalidPathException; import java.nio.file.Path; +import java.util.ArrayList; import java.util.Arrays; import java.util.Collections; import java.util.Enumeration; @@ -112,7 +113,7 @@ public final class Security { private static Path currentPath; - private static final Set activePaths = new HashSet<>(); + private static final List activePaths = new ArrayList<>(); static void loadAll() { // first load the master properties file to @@ -262,30 +263,40 @@ public final class Security { } } + private static void checkCyclicInclude(Path path) { + for (Path activePath : activePaths) { + try { + if (Files.isSameFile(path, activePath)) { + throw new InternalError( + "Cyclic include of '" + path + "'"); + } + } catch (IOException e) { + if (sdebug != null) { + sdebug.println("skipped exception when checking for " + + "cyclic inclusion of " + path + ":"); + e.printStackTrace(); + } + } + } + } + private static void loadFromPath(Path path, LoadingMode mode) throws IOException { - boolean isRegularFile = Files.isRegularFile(path); - if (isRegularFile) { - path = path.toRealPath(); - } else if (Files.isDirectory(path)) { + if (Files.isDirectory(path)) { throw new IOException("Is a directory"); - } else { - path = path.toAbsolutePath(); - } - if (activePaths.contains(path)) { - throw new InternalError("Cyclic include of '" + path + "'"); } try (InputStream is = Files.newInputStream(path)) { + checkCyclicInclude(path); reset(mode); Path previousPath = currentPath; - currentPath = isRegularFile ? path : null; + currentPath = Files.isRegularFile(path) ? path : null; activePaths.add(path); try { debugLoad(true, path); props.load(is); debugLoad(false, path); } finally { - activePaths.remove(path); + activePaths.removeLast(); currentPath = previousPath; } } diff --git a/test/jdk/java/security/Security/ConfigFileTest.java b/test/jdk/java/security/Security/SecurityPropFile/ExtraFileAndIncludes.java similarity index 88% rename from test/jdk/java/security/Security/ConfigFileTest.java rename to test/jdk/java/security/Security/SecurityPropFile/ExtraFileAndIncludes.java index caf657005e1..4cf723f856a 100644 --- a/test/jdk/java/security/Security/ConfigFileTest.java +++ b/test/jdk/java/security/Security/SecurityPropFile/ExtraFileAndIncludes.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 @@ -62,13 +62,13 @@ import java.util.stream.Stream; * @test * @summary Tests security properties passed through java.security, * java.security.properties or included from other properties files. - * @bug 8155246 8292297 8292177 8281658 8319332 + * @bug 4303068 8155246 8292297 8292177 8281658 8319332 * @modules java.base/sun.net.www * @library /test/lib - * @run main ConfigFileTest + * @run main ExtraFileAndIncludes */ -public class ConfigFileTest { +public class ExtraFileAndIncludes { static final String SEPARATOR_THIN = "----------------------------"; private static void printTestHeader(String testName) { @@ -91,7 +91,8 @@ public class ConfigFileTest { } else { // Executed by the test JVM. try (FilesManager filesMgr = new FilesManager()) { - for (Method m : ConfigFileTest.class.getDeclaredMethods()) { + for (Method m : + ExtraFileAndIncludes.class.getDeclaredMethods()) { if (m.getName().startsWith("test")) { printTestHeader(m.getName()); Executor.run(m, filesMgr); @@ -120,7 +121,7 @@ public class ConfigFileTest { static void testIncludeBasic(Executor ex, FilesManager filesMgr) throws Exception { PropsFile masterFile = filesMgr.newMasterFile(); - ExtraPropsFile extraFile = filesMgr.newExtraFile(); + ExtraPropsFile extraFile = filesMgr.newExtraFile(ExtraMode.FILE_URI); PropsFile file0 = filesMgr.newFile("file0.properties"); PropsFile file1 = filesMgr.newFile("dir1/file1.properties"); PropsFile file2 = filesMgr.newFile("dir1/dir2/file2.properties"); @@ -130,7 +131,7 @@ public class ConfigFileTest { file2.addAbsoluteInclude(file1); ex.setMasterFile(masterFile); - ex.setExtraFile(extraFile, Executor.ExtraMode.FILE_URI, false); + ex.setExtraFile(extraFile, false); ex.assertSuccess(); } @@ -152,7 +153,7 @@ public class ConfigFileTest { static void testIncludeWithOverrideAll(Executor ex, FilesManager filesMgr) throws Exception { PropsFile masterFile = filesMgr.newMasterFile(); - ExtraPropsFile extraFile = filesMgr.newExtraFile(); + ExtraPropsFile extraFile = filesMgr.newExtraFile(ExtraMode.HTTP_SERVED); PropsFile file0 = filesMgr.newFile("file0.properties"); PropsFile file1 = filesMgr.newFile("dir1/file1.properties"); @@ -160,40 +161,40 @@ public class ConfigFileTest { extraFile.addAbsoluteInclude(file1); ex.setMasterFile(masterFile); - ex.setExtraFile(extraFile, Executor.ExtraMode.HTTP_SERVED, true); + ex.setExtraFile(extraFile, true); ex.assertSuccess(); } static void extraPropertiesByHelper(Executor ex, FilesManager filesMgr, - Executor.ExtraMode mode) throws Exception { - ExtraPropsFile extraFile = filesMgr.newExtraFile(); + ExtraMode mode) throws Exception { + ExtraPropsFile extraFile = filesMgr.newExtraFile(mode); PropsFile file0 = filesMgr.newFile("file0.properties"); extraFile.addRelativeInclude(file0); ex.setMasterFile(filesMgr.newMasterFile()); - ex.setExtraFile(extraFile, mode, true); + ex.setExtraFile(extraFile, true); ex.assertSuccess(); } static void testExtraPropertiesByPathAbsolute(Executor ex, FilesManager filesMgr) throws Exception { - extraPropertiesByHelper(ex, filesMgr, Executor.ExtraMode.PATH_ABS); + extraPropertiesByHelper(ex, filesMgr, ExtraMode.PATH_ABS); } static void testExtraPropertiesByPathRelative(Executor ex, FilesManager filesMgr) throws Exception { - extraPropertiesByHelper(ex, filesMgr, Executor.ExtraMode.PATH_REL); + extraPropertiesByHelper(ex, filesMgr, ExtraMode.PATH_REL); } static void specialCharsIncludes(Executor ex, FilesManager filesMgr, - char specialChar, Executor.ExtraMode extraMode, - boolean useRelativeIncludes) throws Exception { + char specialChar, ExtraMode extraMode, boolean useRelativeIncludes) + throws Exception { String suffix = specialChar + ".properties"; ExtraPropsFile extraFile; PropsFile file0, file1; try { - extraFile = filesMgr.newExtraFile("extra" + suffix); + extraFile = filesMgr.newExtraFile("extra" + suffix, extraMode); file0 = filesMgr.newFile("file0" + suffix); file1 = filesMgr.newFile("file1" + suffix); } catch (InvalidPathException ipe) { @@ -210,20 +211,18 @@ public class ConfigFileTest { extraFile.addAbsoluteInclude(file1); ex.setMasterFile(filesMgr.newMasterFile()); - ex.setExtraFile(extraFile, extraMode, false); + ex.setExtraFile(extraFile, false); ex.assertSuccess(); } static void testUnicodeIncludes1(Executor ex, FilesManager filesMgr) throws Exception { - specialCharsIncludes(ex, filesMgr, '\u2022', - Executor.ExtraMode.PATH_ABS, true); + specialCharsIncludes(ex, filesMgr, '\u2022', ExtraMode.PATH_ABS, true); } static void testUnicodeIncludes2(Executor ex, FilesManager filesMgr) throws Exception { - specialCharsIncludes(ex, filesMgr, '\u2022', - Executor.ExtraMode.FILE_URI, true); + specialCharsIncludes(ex, filesMgr, '\u2022', ExtraMode.FILE_URI, true); } static void testUnicodeIncludes3(Executor ex, FilesManager filesMgr) @@ -232,7 +231,7 @@ public class ConfigFileTest { // file:/tmp/extra•.properties are supported for the extra file. // However, relative includes are not allowed in these cases. specialCharsIncludes(ex, filesMgr, '\u2022', - Executor.ExtraMode.RAW_FILE_URI1, false); + ExtraMode.RAW_FILE_URI1, false); } static void testUnicodeIncludes4(Executor ex, FilesManager filesMgr) @@ -241,19 +240,17 @@ public class ConfigFileTest { // file:///tmp/extra•.properties are supported for the extra file. // However, relative includes are not allowed in these cases. specialCharsIncludes(ex, filesMgr, '\u2022', - Executor.ExtraMode.RAW_FILE_URI2, false); + ExtraMode.RAW_FILE_URI2, false); } static void testSpaceIncludes1(Executor ex, FilesManager filesMgr) throws Exception { - specialCharsIncludes(ex, filesMgr, ' ', - Executor.ExtraMode.PATH_ABS, true); + specialCharsIncludes(ex, filesMgr, ' ', ExtraMode.PATH_ABS, true); } static void testSpaceIncludes2(Executor ex, FilesManager filesMgr) throws Exception { - specialCharsIncludes(ex, filesMgr, ' ', - Executor.ExtraMode.FILE_URI, true); + specialCharsIncludes(ex, filesMgr, ' ', ExtraMode.FILE_URI, true); } static void testSpaceIncludes3(Executor ex, FilesManager filesMgr) @@ -261,8 +258,7 @@ public class ConfigFileTest { // Backward compatibility check. Malformed URLs such as // file:/tmp/extra .properties are supported for the extra file. // However, relative includes are not allowed in these cases. - specialCharsIncludes(ex, filesMgr, ' ', - Executor.ExtraMode.RAW_FILE_URI1, false); + specialCharsIncludes(ex, filesMgr, ' ', ExtraMode.RAW_FILE_URI1, false); } static void testSpaceIncludes4(Executor ex, FilesManager filesMgr) @@ -270,8 +266,7 @@ public class ConfigFileTest { // Backward compatibility check. Malformed URLs such as // file:///tmp/extra .properties are supported for the extra file. // However, relative includes are not allowed in these cases. - specialCharsIncludes(ex, filesMgr, ' ', - Executor.ExtraMode.RAW_FILE_URI2, false); + specialCharsIncludes(ex, filesMgr, ' ', ExtraMode.RAW_FILE_URI2, false); } static void notOverrideOnFailureHelper(Executor ex, FilesManager filesMgr, @@ -370,13 +365,13 @@ public class ConfigFileTest { static void testCannotResolveRelativeFromHTTPServed(Executor ex, FilesManager filesMgr) throws Exception { - ExtraPropsFile extraFile = filesMgr.newExtraFile(); + ExtraPropsFile extraFile = filesMgr.newExtraFile(ExtraMode.HTTP_SERVED); PropsFile file0 = filesMgr.newFile("file0.properties"); extraFile.addRelativeInclude(file0); ex.setMasterFile(filesMgr.newMasterFile()); - ex.setExtraFile(extraFile, Executor.ExtraMode.HTTP_SERVED, true); + ex.setExtraFile(extraFile, true); ex.assertError("InternalError: Cannot resolve '" + file0.fileName + "' relative path when included from a non-regular " + "properties file (e.g. HTTP served file)"); @@ -394,14 +389,15 @@ public class ConfigFileTest { masterFile.addRelativeInclude(file0); ex.setMasterFile(masterFile); - ex.assertError( - "InternalError: Cyclic include of '" + masterFile.path + "'"); + ex.assertError("Cyclic include"); + ex.getOutputAnalyzer().stderrShouldMatch("\\QInternalError: Cyclic " + + "include of '\\E[^']+\\Q" + masterFile.fileName + "'\\E"); } static void testCannotIncludeURL(Executor ex, FilesManager filesMgr) throws Exception { PropsFile masterFile = filesMgr.newMasterFile(); - ExtraPropsFile extraFile = filesMgr.newExtraFile(); + ExtraPropsFile extraFile = filesMgr.newExtraFile(ExtraMode.HTTP_SERVED); masterFile.addRawProperty("include", extraFile.url.toString()); @@ -432,8 +428,7 @@ public class ConfigFileTest { // Launch a JDK without a master java.security file present, but with an // extra file passed. Since the "security.overridePropertiesFile=true" // security property is missing, it should fail anyway. - ex.setExtraFile( - filesMgr.newExtraFile(), Executor.ExtraMode.FILE_URI, true); + ex.setExtraFile(filesMgr.newExtraFile(ExtraMode.FILE_URI), true); ex.assertError("InternalError: Error loading java.security file"); } } @@ -455,17 +450,24 @@ sealed class PropsFile permits ExtraPropsFile { static Include of(PropsFile propsFile, String value) { return new Include(propsFile, value); } + + void assertProcessed(OutputAnalyzer oa) { + oa.shouldContain("processing include: '" + value + "'"); + oa.shouldContain("finished processing " + propsFile.displayPath); + } } protected final List includes = new ArrayList<>(); protected final PrintWriter writer; protected boolean includedFromExtra = false; + protected Path displayPath; final String fileName; final Path path; PropsFile(String fileName, Path path) throws IOException { this.fileName = fileName; this.path = path; + this.displayPath = path; this.writer = new PrintWriter(Files.newOutputStream(path, StandardOpenOption.CREATE, StandardOpenOption.APPEND), true); } @@ -513,8 +515,9 @@ sealed class PropsFile permits ExtraPropsFile { } void addRelativeInclude(PropsFile propsFile) { - addIncludeDefinition(Include.of(propsFile, - path.getParent().relativize(propsFile.path).toString())); + Path rel = path.getParent().relativize(propsFile.path); + addIncludeDefinition(Include.of(propsFile, rel.toString())); + propsFile.displayPath = displayPath.getParent().resolve(rel); } void assertApplied(OutputAnalyzer oa) { @@ -522,8 +525,7 @@ sealed class PropsFile permits ExtraPropsFile { FilesManager.APPLIED_PROP_VALUE); for (Include include : includes) { include.propsFile.assertApplied(oa); - oa.shouldContain("processing include: '" + include.value + "'"); - oa.shouldContain("finished processing " + include.propsFile.path); + include.assertProcessed(oa); } } @@ -534,8 +536,7 @@ sealed class PropsFile permits ExtraPropsFile { if (!include.propsFile.includedFromExtra) { include.propsFile.assertWasOverwritten(oa); } - oa.shouldContain("processing include: '" + include.value + "'"); - oa.shouldContain("finished processing " + include.propsFile.path); + include.assertProcessed(oa); } } @@ -556,13 +557,24 @@ sealed class PropsFile permits ExtraPropsFile { } } +enum ExtraMode { + HTTP_SERVED, FILE_URI, RAW_FILE_URI1, RAW_FILE_URI2, PATH_ABS, PATH_REL +} + final class ExtraPropsFile extends PropsFile { + private static final Path CWD = Path.of(".").toAbsolutePath(); private final Map systemProps = new LinkedHashMap<>(); + private final ExtraMode mode; final URI url; - ExtraPropsFile(String fileName, URI url, Path path) throws IOException { + ExtraPropsFile(String fileName, URI url, Path path, ExtraMode mode) + throws IOException { super(fileName, path); this.url = url; + this.mode = mode; + if (mode == ExtraMode.PATH_REL) { + this.displayPath = CWD.relativize(path); + } } @Override @@ -578,14 +590,25 @@ final class ExtraPropsFile extends PropsFile { super.addIncludeDefinition(include); } + String getSysPropValue() { + return switch (mode) { + case HTTP_SERVED -> url.toString(); + case FILE_URI -> path.toUri().toString(); + case RAW_FILE_URI1 -> "file:" + path; + case RAW_FILE_URI2 -> + "file://" + (path.startsWith("/") ? "" : "/") + path; + case PATH_ABS, PATH_REL -> displayPath.toString(); + }; + } + Map getSystemProperties() { return Collections.unmodifiableMap(systemProps); } } final class FilesManager implements Closeable { - private static final Path ROOT_DIR = - Path.of(ConfigFileTest.class.getSimpleName()).toAbsolutePath(); + private static final Path ROOT_DIR = Path.of( + ExtraFileAndIncludes.class.getSimpleName()).toAbsolutePath(); private static final Path PROPS_DIR = ROOT_DIR.resolve("properties"); private static final Path JDK_DIR = ROOT_DIR.resolve("jdk"); private static final Path MASTER_FILE = @@ -684,11 +707,11 @@ final class FilesManager implements Closeable { propsFile.addComment("Property to determine if this properties file " + "was parsed and not overwritten:"); propsFile.addRawProperty(fileName, APPLIED_PROP_VALUE); - propsFile.addComment(ConfigFileTest.SEPARATOR_THIN); + propsFile.addComment(ExtraFileAndIncludes.SEPARATOR_THIN); propsFile.addComment("Property to be overwritten by every properties " + "file (master, extra or included):"); propsFile.addRawProperty(LAST_FILE_PROP_NAME, fileName); - propsFile.addComment(ConfigFileTest.SEPARATOR_THIN); + propsFile.addComment(ExtraFileAndIncludes.SEPARATOR_THIN); createdFiles.add(propsFile); return propsFile; } @@ -702,16 +725,17 @@ final class FilesManager implements Closeable { return newFile(MASTER_FILE, PropsFile::new); } - ExtraPropsFile newExtraFile() throws IOException { - return newExtraFile("extra.properties"); + ExtraPropsFile newExtraFile(ExtraMode mode) throws IOException { + return newExtraFile("extra.properties", mode); } - ExtraPropsFile newExtraFile(String extraFileName) throws IOException { + ExtraPropsFile newExtraFile(String extraFileName, ExtraMode mode) + throws IOException { return (ExtraPropsFile) newFile(PROPS_DIR.resolve(extraFileName), (fileName, path) -> { URI uri = serverUri.resolve(ParseUtil.encodePath( ROOT_DIR.relativize(path).toString())); - return new ExtraPropsFile(fileName, uri, path); + return new ExtraPropsFile(fileName, uri, path, mode); }); } @@ -719,7 +743,7 @@ final class FilesManager implements Closeable { for (PropsFile propsFile : createdFiles) { System.err.println(); System.err.println(propsFile.path.toString()); - System.err.println(ConfigFileTest.SEPARATOR_THIN.repeat(3)); + System.err.println(ExtraFileAndIncludes.SEPARATOR_THIN.repeat(3)); try (Stream lines = Files.lines(propsFile.path)) { long lineNumber = 1L; Iterator it = lines.iterator(); @@ -757,9 +781,6 @@ final class FilesManager implements Closeable { } final class Executor { - enum ExtraMode { - HTTP_SERVED, FILE_URI, RAW_FILE_URI1, RAW_FILE_URI2, PATH_ABS, PATH_REL - } static final String RUNNER_ARG = "runner"; static final String INITIAL_PROP_LOG_MSG = "Initial security property: "; private static final String OVERRIDING_LOG_MSG = @@ -769,7 +790,6 @@ final class Executor { INITIAL_PROP_LOG_MSG + "postInitTest=shouldNotRecord", INITIAL_PROP_LOG_MSG + "include=", }; - private static final Path CWD = Path.of(".").toAbsolutePath(); private static final String JAVA_SEC_PROPS = "java.security.properties"; private static final String CLASS_PATH = Objects.requireNonNull( System.getProperty("test.classes"), "unspecified test.classes"); @@ -812,20 +832,10 @@ final class Executor { this.masterPropsFile = masterPropsFile; } - void setExtraFile(ExtraPropsFile extraPropsFile, ExtraMode mode, - boolean overrideAll) { + void setExtraFile(ExtraPropsFile extraPropsFile, boolean overrideAll) { this.extraPropsFile = extraPropsFile; expectedOverrideAll = overrideAll; - setRawExtraFile(switch (mode) { - case HTTP_SERVED -> extraPropsFile.url.toString(); - case FILE_URI -> extraPropsFile.path.toUri().toString(); - case RAW_FILE_URI1 -> "file:" + extraPropsFile.path; - case RAW_FILE_URI2 -> "file://" + - (extraPropsFile.path.startsWith("/") ? "" : "/") + - extraPropsFile.path; - case PATH_ABS -> extraPropsFile.path.toString(); - case PATH_REL -> CWD.relativize(extraPropsFile.path).toString(); - }, overrideAll); + setRawExtraFile(extraPropsFile.getSysPropValue(), overrideAll); } void setIgnoredExtraFile(String extraPropsFile, boolean overrideAll) { @@ -841,7 +851,7 @@ final class Executor { List command = new ArrayList<>(jvmArgs); Collections.addAll(command, Utils.getTestJavaOpts()); addSystemPropertiesAsJvmArgs(command); - command.add(ConfigFileTest.class.getSimpleName()); + command.add(ExtraFileAndIncludes.class.getSimpleName()); command.add(RUNNER_ARG); oa = ProcessTools.executeProcess(new ProcessBuilder(command)); oa.shouldHaveExitValue(successExpected ? 0 : 1); diff --git a/test/jdk/java/security/Security/SecurityPropFile/LinuxAnonymousFiles.java b/test/jdk/java/security/Security/SecurityPropFile/LinuxAnonymousFiles.java new file mode 100644 index 00000000000..7ca2a7c0f8b --- /dev/null +++ b/test/jdk/java/security/Security/SecurityPropFile/LinuxAnonymousFiles.java @@ -0,0 +1,83 @@ +/* + * Copyright (c) 2026, Red Hat, Inc. + * + * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. + * + * This code is free software; you can redistribute 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.process.ProcessTools; + +import java.io.FileDescriptor; +import java.io.FileInputStream; +import java.io.IOException; +import java.lang.reflect.Field; +import java.nio.file.Files; +import java.nio.file.Path; + +/* + * @test + * @summary Ensures the java executable is able to load extra security + * properties files from anonymous files and pipes. + * @bug 8352728 + * @requires os.family == "linux" + * @modules java.base/java.io:+open + * @library /test/lib + * @run main LinuxAnonymousFiles + */ + +public class LinuxAnonymousFiles { + private static final String TEST_PROP = "property.name=PROPERTY_VALUE"; + + private static final class AnonymousFile implements AutoCloseable { + public final Path fdPath; + private final FileInputStream fis; + + private AnonymousFile(CharSequence content) throws Exception { + Path tmp = Files.createTempFile("anonymous-file-", ""); + Files.writeString(tmp, content + System.lineSeparator()); + fis = new FileInputStream(tmp.toFile()); + Files.delete(tmp); + // Now the file is regular but anonymous, and will be unlinked + // when we close the last file descriptor referring to it. The + // fis instance ensures we keep it alive until close() is invoked. + Field field = FileDescriptor.class.getDeclaredField("fd"); + field.setAccessible(true); + int fd = field.getInt(fis.getFD()); + fdPath = Path.of("/proc/self").toRealPath().resolve("fd/" + fd); + } + + @Override + public void close() throws IOException { + fis.close(); + } + } + + public static void main(String[] args) throws Exception { + Path java = Path.of(System.getProperty("test.jdk"), "bin", "java"); + try (AnonymousFile af = new AnonymousFile("include /dev/stdin")) { + ProcessTools.executeProcess(new ProcessBuilder(java.toString(), + "-Djava.security.debug=properties", + "-Djava.security.properties=" + af.fdPath, + "-XshowSettings:security:properties", "-version"), + TEST_PROP).shouldHaveExitValue(0).shouldContain(TEST_PROP); + } + System.out.println("TEST PASS - OK"); + } +} diff --git a/test/jdk/java/security/Security/SecurityPropFile/SecurityPropFile.file b/test/jdk/java/security/Security/SecurityPropFile/SecurityPropFile.file deleted file mode 100644 index 2b4c08c6903..00000000000 --- a/test/jdk/java/security/Security/SecurityPropFile/SecurityPropFile.file +++ /dev/null @@ -1 +0,0 @@ -policy.url.2=file:${test.src}/SecurityPropFile.policy diff --git a/test/jdk/java/security/Security/SecurityPropFile/SecurityPropFile.java b/test/jdk/java/security/Security/SecurityPropFile/SecurityPropFile.java deleted file mode 100644 index b0ba6c60854..00000000000 --- a/test/jdk/java/security/Security/SecurityPropFile/SecurityPropFile.java +++ /dev/null @@ -1,42 +0,0 @@ -/* - * Copyright (c) 2001, 2024, Oracle and/or its affiliates. All rights reserved. - * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. - * - * This code is free software; you can redistribute it and/or modify it - * under the terms of the GNU General Public License version 2 only, as - * published by the Free Software Foundation. - * - * This code is distributed in the hope that it will be useful, but WITHOUT - * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or - * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License - * version 2 for more details (a copy is included in the LICENSE file that - * accompanied this code). - * - * You should have received a copy of the GNU General Public License version - * 2 along with this work; if not, write to the Free Software Foundation, - * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. - * - * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA - * or visit www.oracle.com if you need additional information or have any - * questions. - */ - -/* - * @test - * @bug 4303068 - * @summary be allowed to specify the security properties file - * as a -D system property - * - * @run main/othervm -Djava.security.properties=${test.src}/SecurityPropFile.file -Djava.security.debug=properties SecurityPropFile - */ - -public class SecurityPropFile { - public static void main(String[] args) { - System.out.println(java.security.Security.getProperty - ("policy.provider")); - System.out.println(java.security.Security.getProperty - ("policy.url.1")); - System.out.println(java.security.Security.getProperty - ("policy.url.2")); - } -} diff --git a/test/jdk/java/security/Security/SecurityPropFile/WindowsParentDirPermissions.java b/test/jdk/java/security/Security/SecurityPropFile/WindowsParentDirPermissions.java new file mode 100644 index 00000000000..a41fd2f3535 --- /dev/null +++ b/test/jdk/java/security/Security/SecurityPropFile/WindowsParentDirPermissions.java @@ -0,0 +1,84 @@ +/* + * Copyright (c) 2026, Red Hat, Inc. + * + * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. + * + * This code is free software; you can redistribute 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.process.ProcessTools; +import jdk.test.lib.util.FileUtils; + +import java.io.IOException; +import java.nio.file.Files; +import java.nio.file.Path; +import java.nio.file.attribute.AclEntry; +import java.nio.file.attribute.AclEntryType; +import java.nio.file.attribute.AclFileAttributeView; +import java.util.List; + +/* + * @test + * @summary Ensures java.security is loadable in Windows, even when the user + * does not have permissions on one of the parent directories. + * @bug 8352728 + * @requires os.family == "windows" + * @library /test/lib + * @run main WindowsParentDirPermissions + */ + +public class WindowsParentDirPermissions { + private static AutoCloseable restrictedAcl(Path path) throws IOException { + AclFileAttributeView view = + Files.getFileAttributeView(path, AclFileAttributeView.class); + List originalAcl = List.copyOf(view.getAcl()); + view.setAcl(List.of(AclEntry.newBuilder().setType(AclEntryType.DENY) + .setPrincipal(Files.getOwner(path)).build())); + return () -> view.setAcl(originalAcl); + } + + public static void main(String[] args) throws Exception { + Path temp = Files.createTempDirectory("JDK-8352728-tmp-"); + try (AutoCloseable a1 = () -> FileUtils.deleteFileTreeUnchecked(temp)) { + // Copy the jdk to a different directory + Path originalJdk = Path.of(System.getProperty("test.jdk")); + Path jdk = temp.resolve("jdk-parent-dir", "jdk"); + Files.createDirectories(jdk); + FileUtils.copyDirectory(originalJdk, jdk); + + // Remove current user permissions from jdk-parent-dir + try (AutoCloseable a2 = restrictedAcl(jdk.getParent())) { + // Make sure the permissions are affecting the current user + try { + jdk.toRealPath(); + throw new jtreg.SkippedException("Must run non-elevated!"); + } catch (IOException expected) { } + + // Execute the copied jdk, ensuring java.security.Security is + // loaded (i.e. use -XshowSettings:security:properties) + ProcessTools.executeProcess(new ProcessBuilder( + List.of(jdk.resolve("bin", "java.exe").toString(), + "-Djava.security.debug=properties", + "-XshowSettings:security:properties", + "-version"))).shouldHaveExitValue(0); + } + } + System.out.println("TEST PASS - OK"); + } +} From afd216ec3f5bfd1be88c6f4d4f53b763205c4fee Mon Sep 17 00:00:00 2001 From: Joe Darcy Date: Thu, 8 Jan 2026 17:19:12 +0000 Subject: [PATCH 099/712] 8374752: Add more JLS links to javax.lang.model.element.* Reviewed-by: liach --- .../javax/lang/model/element/ExecutableElement.java | 9 ++++++++- .../javax/lang/model/element/PackageElement.java | 5 ++++- .../javax/lang/model/element/Parameterizable.java | 6 +++++- .../javax/lang/model/element/QualifiedNameable.java | 6 +++++- .../classes/javax/lang/model/element/TypeElement.java | 11 ++++++++++- .../lang/model/element/TypeParameterElement.java | 7 ++++++- .../javax/lang/model/element/VariableElement.java | 10 +++++++++- 7 files changed, 47 insertions(+), 7 deletions(-) diff --git a/src/java.compiler/share/classes/javax/lang/model/element/ExecutableElement.java b/src/java.compiler/share/classes/javax/lang/model/element/ExecutableElement.java index 18923463248..cc0924fda61 100644 --- a/src/java.compiler/share/classes/javax/lang/model/element/ExecutableElement.java +++ b/src/java.compiler/share/classes/javax/lang/model/element/ExecutableElement.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 @@ -37,6 +37,13 @@ import javax.lang.model.type.*; * clause, among other restrictions; see JLS {@jls 9.6.1} for details. * * @see ExecutableType + * @jls 8.4 Method Declarations + * @jls 8.6 Instance Initializers + * @jls 8.7 Static Initializers + * @jls 8.8 Constructor Declarations + * @jls 9.4 Method Declarations + * @jls 9.6.1 Annotation Interface Elements + * * @since 1.6 */ public interface ExecutableElement extends Element, Parameterizable { diff --git a/src/java.compiler/share/classes/javax/lang/model/element/PackageElement.java b/src/java.compiler/share/classes/javax/lang/model/element/PackageElement.java index 651bbe70eee..79b1fb84683 100644 --- a/src/java.compiler/share/classes/javax/lang/model/element/PackageElement.java +++ b/src/java.compiler/share/classes/javax/lang/model/element/PackageElement.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2005, 2023, 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 @@ -58,6 +58,8 @@ import javax.lang.model.type.TypeMirror; * * * @see javax.lang.model.util.Elements#getPackageOf + * @jls 7.4 Package Declarations + * * @since 1.6 */ public interface PackageElement extends Element, QualifiedNameable { @@ -87,6 +89,7 @@ public interface PackageElement extends Element, QualifiedNameable { * @return the fully qualified name of this package, or an * empty name if this is an unnamed package * @jls 6.7 Fully Qualified Names and Canonical Names + * @jls 7.4.1 Named Packages */ Name getQualifiedName(); diff --git a/src/java.compiler/share/classes/javax/lang/model/element/Parameterizable.java b/src/java.compiler/share/classes/javax/lang/model/element/Parameterizable.java index cf0bbdfba37..a4280fbcf29 100644 --- a/src/java.compiler/share/classes/javax/lang/model/element/Parameterizable.java +++ b/src/java.compiler/share/classes/javax/lang/model/element/Parameterizable.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2009, 2022, 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 @@ -30,6 +30,10 @@ import java.util.List; /** * A mixin interface for an element that has type parameters. * + * @jls 4.5 Parameterized Types + * @jls 8.4.4 Generic Methods + * @jls 8.8.4 Generic Constructors + * * @since 1.7 */ public interface Parameterizable extends Element { diff --git a/src/java.compiler/share/classes/javax/lang/model/element/QualifiedNameable.java b/src/java.compiler/share/classes/javax/lang/model/element/QualifiedNameable.java index 1b0316f893f..555d90c1b13 100644 --- a/src/java.compiler/share/classes/javax/lang/model/element/QualifiedNameable.java +++ b/src/java.compiler/share/classes/javax/lang/model/element/QualifiedNameable.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2009, 2022, 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 @@ -28,6 +28,10 @@ package javax.lang.model.element; /** * A mixin interface for an element that has a qualified name. * + * @jls 6.5.3.2 Qualified Package Names + * @jls 6.5.5.2 Qualified Type Names + * @jls 6.7 Fully Qualified Names and Canonical Names + * * @since 1.7 */ public interface QualifiedNameable extends Element { diff --git a/src/java.compiler/share/classes/javax/lang/model/element/TypeElement.java b/src/java.compiler/share/classes/javax/lang/model/element/TypeElement.java index abf95bcefad..3dcc8e8c7fd 100644 --- a/src/java.compiler/share/classes/javax/lang/model/element/TypeElement.java +++ b/src/java.compiler/share/classes/javax/lang/model/element/TypeElement.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 @@ -80,7 +80,16 @@ import javax.lang.model.util.*; * javax.lang.model.util.Elements#getAllTypeElements(CharSequence) * queried for} in the configured environment * + * * @see DeclaredType + * @jls 8.1 Class Declarations + * @jls 8.5 Member Class and Interface Declarations + * @jls 8.9 Enum Classes + * @jls 8.10 Record Classes + * @jls 9.1 Interface Declarations + * @jls 9.5 Member Class and Interface Declarations + * @jls 9.6 Annotation Interfaces + * * @since 1.6 */ public interface TypeElement extends Element, Parameterizable, QualifiedNameable { diff --git a/src/java.compiler/share/classes/javax/lang/model/element/TypeParameterElement.java b/src/java.compiler/share/classes/javax/lang/model/element/TypeParameterElement.java index cbaa8969126..abd06a3e038 100644 --- a/src/java.compiler/share/classes/javax/lang/model/element/TypeParameterElement.java +++ b/src/java.compiler/share/classes/javax/lang/model/element/TypeParameterElement.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2005, 2022, 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 @@ -35,6 +35,11 @@ import javax.lang.model.type.TypeVariable; * A type parameter declares a {@link TypeVariable}. * * @see TypeVariable + * @jls 8.1.2 Generic Classes and Type Parameters + * @jls 8.4.4 Generic Methods + * @jls 8.8.4 Generic Constructors + * @jls 9.1.2 Generic Interfaces and Type Parameters + * * @since 1.6 */ public interface TypeParameterElement extends Element { diff --git a/src/java.compiler/share/classes/javax/lang/model/element/VariableElement.java b/src/java.compiler/share/classes/javax/lang/model/element/VariableElement.java index 4d2b2582901..b8f42c46b1e 100644 --- a/src/java.compiler/share/classes/javax/lang/model/element/VariableElement.java +++ b/src/java.compiler/share/classes/javax/lang/model/element/VariableElement.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 @@ -34,6 +34,14 @@ import javax.lang.model.type.TypeKind; * parameter, local variable, resource variable, or exception * parameter. * + * @jls 8.3 Field Declaration + * @jls 8.9.1 Enum Constants + * @jls 8.4.1 Formal Parameters + * @jls 8.8.1 Formal Parameters + * @jls 14.4 Local Variable Declarations + * @jls 14.20 The {@code try} statement + * @jls 14.20.3 {@code try}-with-resources + * @since 1.6 */ public interface VariableElement extends Element { From 92abc6dfe43a2c1f10dcfcf1e197fc9369f70ee3 Mon Sep 17 00:00:00 2001 From: Mark Powers Date: Thu, 8 Jan 2026 17:35:43 +0000 Subject: [PATCH 100/712] 8369282: Distrust TLS server certificates anchored by Chunghwa ePKI Root CA Reviewed-by: mullan --- .../security/validator/CADistrustPolicy.java | 18 ++- .../security/validator/ChunghwaTLSPolicy.java | 103 ++++++++++++++++++ .../share/conf/security/java.security | 6 +- .../distrust/Chunghwa.java | 69 ++++++++++++ .../chunghwa/chunghwaepkirootca-chain.pem | 50 +++++++++ 5 files changed, 244 insertions(+), 2 deletions(-) create mode 100644 src/java.base/share/classes/sun/security/validator/ChunghwaTLSPolicy.java create mode 100644 test/jdk/sun/security/ssl/X509TrustManagerImpl/distrust/Chunghwa.java create mode 100644 test/jdk/sun/security/ssl/X509TrustManagerImpl/distrust/chains/chunghwa/chunghwaepkirootca-chain.pem diff --git a/src/java.base/share/classes/sun/security/validator/CADistrustPolicy.java b/src/java.base/share/classes/sun/security/validator/CADistrustPolicy.java index 9c64402c123..44c9ed2d075 100644 --- a/src/java.base/share/classes/sun/security/validator/CADistrustPolicy.java +++ b/src/java.base/share/classes/sun/security/validator/CADistrustPolicy.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 @@ -83,6 +83,22 @@ enum CADistrustPolicy { } CamerfirmaTLSPolicy.checkDistrust(chain); } + }, + + /** + * Distrust TLS Server certificates anchored by the Chunghwa ePKI root CA + * and issued after March 17, 2026. If enabled, this policy is currently + * enforced by the PKIX and SunX509 TrustManager implementations + * of the SunJSSE provider implementation. + */ + CHUNGHWA_TLS { + void checkDistrust(String variant, X509Certificate[] chain) + throws ValidatorException { + if (!variant.equals(Validator.VAR_TLS_SERVER)) { + return; + } + ChunghwaTLSPolicy.checkDistrust(chain); + } }; /** diff --git a/src/java.base/share/classes/sun/security/validator/ChunghwaTLSPolicy.java b/src/java.base/share/classes/sun/security/validator/ChunghwaTLSPolicy.java new file mode 100644 index 00000000000..114f5043fbf --- /dev/null +++ b/src/java.base/share/classes/sun/security/validator/ChunghwaTLSPolicy.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. 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.validator; + +import java.security.cert.X509Certificate; +import java.time.LocalDate; +import java.time.Month; +import java.time.ZoneOffset; +import java.util.Date; +import java.util.Map; +import java.util.Set; + +import sun.security.util.Debug; +import sun.security.x509.X509CertImpl; + +/** + * This class checks if Chunghwa issued TLS Server certificates should be + * restricted. + */ +final class ChunghwaTLSPolicy { + + private static final Debug debug = Debug.getInstance("certpath"); + + // SHA-256 certificate fingerprint of distrusted root for TLS + // cacerts alias: chunghwaepkirootca + // DN: OU=ePKI Root Certification Authority, + // O="Chunghwa Telecom Co., Ltd.", C=TW + private static final String FINGERPRINT = + "C0A6F4DC63A24BFDCF54EF2A6A082A0A72DE35803E2FF5FF527AE5D87206DFD5"; + + // Any TLS Server certificate that is anchored by the Chunghwa + // root above and is issued after this date will be distrusted. + private static final LocalDate MARCH_17_2026 = + LocalDate.of(2026, Month.MARCH, 17); + + /** + * This method assumes the eeCert is a TLS Server Cert and chains back to + * the anchor. + * + * @param chain the end-entity's certificate chain. The end entity cert + * is at index 0, the trust anchor at index n-1. + * @throws ValidatorException if the certificate is distrusted + */ + static void checkDistrust(X509Certificate[] chain) + throws ValidatorException { + X509Certificate anchor = chain[chain.length-1]; + String fp = fingerprint(anchor); + if (fp == null) { + throw new ValidatorException("Cannot generate fingerprint for " + + "trust anchor of TLS server certificate"); + } + if (FINGERPRINT.equalsIgnoreCase(fp)) { + Date notBefore = chain[0].getNotBefore(); + LocalDate ldNotBefore = LocalDate.ofInstant(notBefore.toInstant(), + ZoneOffset.UTC); + // reject if certificate is issued after March 17, 2026 + checkNotBefore(ldNotBefore, MARCH_17_2026, anchor); + } + } + + private static String fingerprint(X509Certificate cert) { + return X509CertImpl.getFingerprint("SHA-256", cert, debug); + } + + // Check whether the certificate's notBeforeDate is after the + // distrust date for the anchor (root CA). Throw ValidatorException + // if it is after the distrust date. + private static void checkNotBefore(LocalDate notBeforeDate, + LocalDate distrustDate, X509Certificate anchor) + throws ValidatorException { + if (notBeforeDate.isAfter(distrustDate)) { + throw new ValidatorException + ("TLS Server certificate issued after " + distrustDate + + " and anchored by a distrusted legacy Chunghwa root CA: " + + anchor.getSubjectX500Principal(), + ValidatorException.T_UNTRUSTED_CERT, anchor); + } + } + + private ChunghwaTLSPolicy() {} +} diff --git a/src/java.base/share/conf/security/java.security b/src/java.base/share/conf/security/java.security index 3d26c1dcd96..b5cbce413b2 100644 --- a/src/java.base/share/conf/security/java.security +++ b/src/java.base/share/conf/security/java.security @@ -1437,6 +1437,9 @@ jdk.sasl.disabledMechanisms= # CAMERFIRMA_TLS : Distrust TLS Server certificates anchored by # a Camerfirma root CA and issued after April 15, 2025. # +# CHUNGHWA_TLS : Distrust TLS Server certificates anchored by +# a Chunghwa root CA and issued after March 17, 2026. +# # Leading and trailing whitespace surrounding each value are ignored. # Unknown values are ignored. If the property is commented out or set to the # empty String, no policies are enforced. @@ -1448,7 +1451,8 @@ jdk.sasl.disabledMechanisms= # jdk.certpath.disabledAlgorithms; those restrictions are still enforced even # if this property is not enabled. # -jdk.security.caDistrustPolicies=SYMANTEC_TLS,ENTRUST_TLS,CAMERFIRMA_TLS +jdk.security.caDistrustPolicies=SYMANTEC_TLS,ENTRUST_TLS,CAMERFIRMA_TLS,\ + CHUNGHWA_TLS # # FilePermission path canonicalization diff --git a/test/jdk/sun/security/ssl/X509TrustManagerImpl/distrust/Chunghwa.java b/test/jdk/sun/security/ssl/X509TrustManagerImpl/distrust/Chunghwa.java new file mode 100644 index 00000000000..8512640bb01 --- /dev/null +++ b/test/jdk/sun/security/ssl/X509TrustManagerImpl/distrust/Chunghwa.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. + */ + +import javax.net.ssl.X509TrustManager; +import java.io.File; +import java.security.Security; +import java.time.LocalDate; +import java.time.ZoneOffset; +import java.time.ZonedDateTime; +import java.util.Date; + +/* + * @test + * @bug 8369282 + * @summary Check that TLS Server certificates chaining back to distrusted + * Chunghwa root are invalid + * @library /test/lib + * @modules java.base/sun.security.validator + * @run main/othervm Chunghwa after policyOn invalid + * @run main/othervm Chunghwa after policyOff valid + * @run main/othervm Chunghwa before policyOn valid + * @run main/othervm Chunghwa before policyOff valid + */ + +public class Chunghwa { + + private static final String CERT_PATH = "chains" + File.separator + "chunghwa"; + + // The ePKI root has a test certificate chain stored in a file + // named "-chain.pem". + private static final String ROOT_TO_TEST = "chunghwaepkirootca"; + + // Date after the restrictions take effect + private static final ZonedDateTime DISTRUST_DATE = + LocalDate.of(2026, 03, 18).atStartOfDay(ZoneOffset.UTC); + + public static void main(String[] args) throws Exception { + + Distrust distrust = new Distrust(args); + + X509TrustManager[] tms = new X509TrustManager[]{ + distrust.getTMF("PKIX", null), + distrust.getTMF("SunX509", null) + }; + + Date notBefore = distrust.getNotBefore(DISTRUST_DATE); + distrust.testCertificateChain(CERT_PATH, notBefore, tms, ROOT_TO_TEST); + } +} diff --git a/test/jdk/sun/security/ssl/X509TrustManagerImpl/distrust/chains/chunghwa/chunghwaepkirootca-chain.pem b/test/jdk/sun/security/ssl/X509TrustManagerImpl/distrust/chains/chunghwa/chunghwaepkirootca-chain.pem new file mode 100644 index 00000000000..fdaa6ee04df --- /dev/null +++ b/test/jdk/sun/security/ssl/X509TrustManagerImpl/distrust/chains/chunghwa/chunghwaepkirootca-chain.pem @@ -0,0 +1,50 @@ +Owner: CN=HiPKI Root CA - G1, + O="Chunghwa Telecom Co., Ltd.", C=TW +Issuer: OU=ePKI Root Certification Authority, + O="Chunghwa Telecom Co., Ltd.", C=TW +Serial number: 23fba648360e15e92ba78aedb67a0ae5 +Valid from: Wed Dec 20 19:11:23 MST 2023 until: Tue Dec 19 08:59:59 MST 2034 +Certificate fingerprints: + SHA1: 87:F1:DD:3B:8E:F1:E0:8C:A8:CA:CB:9B:CE:4E:26:5A:E4:4E:05:F2 + SHA256: 68:07:C9:72:35:C5:EC:60:90:26:9A:4B:5F:ED:FA:B4:69:86:E4:2F:4D:67:D2:ED:DD:CF:6E:45:CF:0D:FA:80 +Signature algorithm name: SHA256withRSA +Subject Public Key Algorithm: 4096-bit RSA key +Version: 3 + +-----BEGIN CERTIFICATE----- +MIIGjDCCBHSgAwIBAgIQI/umSDYOFekrp4rttnoK5TANBgkqhkiG9w0BAQsFADBe +MQswCQYDVQQGEwJUVzEjMCEGA1UECgwaQ2h1bmdod2EgVGVsZWNvbSBDby4sIEx0 +ZC4xKjAoBgNVBAsMIWVQS0kgUm9vdCBDZXJ0aWZpY2F0aW9uIEF1dGhvcml0eTAe +Fw0yMzEyMjEwMjExMjNaFw0zNDEyMTkxNTU5NTlaME8xCzAJBgNVBAYTAlRXMSMw +IQYDVQQKDBpDaHVuZ2h3YSBUZWxlY29tIENvLiwgTHRkLjEbMBkGA1UEAwwSSGlQ +S0kgUm9vdCBDQSAtIEcxMIICIjANBgkqhkiG9w0BAQEFAAOCAg8AMIICCgKCAgEA +9B5/UnMyDHPkvRN0o9QwqNCuS9i233VHZvR85zkEHmpwINJaR3JnVfSl6J3VHiGh +8Ge6zCFovkRTv4354twvVcg3Px+kwJyz5HdcoEb+d/oaoDjq7Zpy3iu9lFc6uux5 +5199QmQ5eiY29yTw1S+6lZgRZq2XNdZ1AYDgr/SEYYwNHl98h5ZeQa/rh+r4XfEu +iAU+TCK72h8q3VJGZDnzQs7ZngyzsHeXZJzA9KMuH5UHsBffMNsAGJZMoYFL3QRt +U6M9/Aes1MU3guvklQgZKILSQjqj2FPseYlgSGDIcpJQ3AOPgz+yQlda22rpEZfd +hSi8MEyr48KxRURHH+CKFgeW0iEPU8DtqX7UTuybCeyvQqww1r/REEXgphaypcXT +T3OUM3ECoWqj1jOXTyFjHluP2cFeRXF3D4FdXyGarYPM+l7WjSNfGz1BryB1ZlpK +9p/7qxj3ccC2HTHsOyDry+K49a6SsvfhhEvyovKTmiKe0xRvNlS9H15ZFblzqMF8 +b3ti6RZsR1pl8w4Rm0bZ/W3c1pzAtH2lsN0/Vm+h+fbkEkj9Bn8SV7apI09bA8Pg +cSojt/ewsTu8mL3WmKgMa/aOEmem8rJY5AIJEzypuxC00jBF8ez3ABHfZfjcK0NV +vxaXxA/VLGGEqnKG/uY6fsI/fe78LxQ+5oXdUG+3Se0CAwEAAaOCAVMwggFPMB8G +A1UdIwQYMBaAFB4M97Zn8uGSJglFwFU5Lnc/QkqiMB0GA1UdDgQWBBTydxf6Xqj+ +9j1x1Wi6yUYMONivsDAOBgNVHQ8BAf8EBAMCAYYwQAYDVR0fBDkwNzA1oDOgMYYv +aHR0cDovL2VjYS5oaW5ldC5uZXQvcmVwb3NpdG9yeS9DUkxfU0hBMi9DQS5jcmww +gYIGCCsGAQUFBwEBBHYwdDA7BggrBgEFBQcwAoYvaHR0cDovL2VjYS5oaW5ldC5u +ZXQvcmVwb3NpdG9yeS9DZXJ0cy9lQ0FHMS5jcnQwNQYIKwYBBQUHMAGGKWh0dHA6 +Ly9vY3NwLmVjYS5oaW5ldC5uZXQvT0NTUC9vY3NwRzFzaGEyMBIGA1UdEwEB/wQI +MAYBAf8CAQEwIgYDVR0gBBswGTAIBgZngQwBAgIwDQYLKwYBBAGBtyNkAAMwDQYJ +KoZIhvcNAQELBQADggIBACY9pps8fqk3p8Xqv/qr26I1aFA4jOEG3VWd2bqn68Y9 +InOMZozTMVh7iOnOfat7mEqn/RNhikvR5MOV3qAeg4gwgNb1OMuGltwfXWGiuGeT +vhimsV6E2hhJFAmZyXtfuoV9vSrnr1a5pCWqhVYWSCvoAQ/8Kv0tATKbIe21CYXz +NIo7O9QBSXt0BiaP9+CVQtJAYYuy2MNAcXgzgL4rownrYYAixhPmkxQE0Dt1gVbW +s2htBLJGse0z1fJDblY0Zar4t2ly+kIScx5DhRrrd8XKMK0YvID9Ythb+ao8m7Wd +Kymqr36benGL3GsvmSypLPlqZtfEqVITFhXwQiL8ruxoL+3WfNQJ09x0iV4xaP+E +bZSLLVzIiyhU49YdFHaqKyAJQvzgF2Za3DOwQWlP7OngtUx0ScEGHsoo78AM+Y0T +eLFxmr82kuyH18wZkUT9bLZlot11P2aC8VTprBGr+jEAMJjpmEjSA83ja/ttmqgh +qjj29Jnw3Lgy91XIhzBFMxMYo+hhYeBRmBFWl5+Y5oxBgPVLZpDJvg2rKa8xdqim +KgvF0DMKHntE0hhVy7JfUCnKovNQ0pf0NodLfjpqcCS2GBZ1mNcsW2MG2uBPANcn +LRXmt7N4XX11mctQTADwt8yZZ+2HDrST4kghOz+FXgftrPBdtDtM0T6WJcHWR1uS +-----END CERTIFICATE----- From 1fb5030ab351a52b4a7455cbdd57f5b50aab9bd5 Mon Sep 17 00:00:00 2001 From: Aleksey Shipilev Date: Thu, 8 Jan 2026 17:58:35 +0000 Subject: [PATCH 101/712] 8374767: Amend JDK-8374521 with new option name Reviewed-by: clanger, krk --- .github/workflows/build-alpine-linux.yml | 2 +- .github/workflows/build-cross-compile.yml | 2 +- .github/workflows/build-linux.yml | 2 +- .github/workflows/build-macos.yml | 2 +- make/autoconf/flags-cflags.m4 | 28 +++++++++++------------ 5 files changed, 18 insertions(+), 18 deletions(-) diff --git a/.github/workflows/build-alpine-linux.yml b/.github/workflows/build-alpine-linux.yml index 569893d5ccc..c39962fa07f 100644 --- a/.github/workflows/build-alpine-linux.yml +++ b/.github/workflows/build-alpine-linux.yml @@ -97,7 +97,7 @@ jobs: --with-zlib=system --with-jmod-compress=zip-1 --with-external-symbols-in-bundles=none - --with-debug-info-level=1 + --with-native-debug-symbols-level=1 ${{ inputs.extra-conf-options }} ${{ inputs.configure-arguments }} || ( echo "Dumping config.log:" && cat config.log && diff --git a/.github/workflows/build-cross-compile.yml b/.github/workflows/build-cross-compile.yml index 4860228c7de..a0642d469aa 100644 --- a/.github/workflows/build-cross-compile.yml +++ b/.github/workflows/build-cross-compile.yml @@ -180,7 +180,7 @@ jobs: --with-sysroot=sysroot --with-jmod-compress=zip-1 --with-external-symbols-in-bundles=none - --with-debug-info-level=1 + --with-native-debug-symbols-level=1 CC=${{ matrix.gnu-arch }}-linux-gnu${{ matrix.gnu-abi}}-gcc-${{ inputs.gcc-major-version }} CXX=${{ matrix.gnu-arch }}-linux-gnu${{ matrix.gnu-abi}}-g++-${{ inputs.gcc-major-version }} ${{ inputs.extra-conf-options }} ${{ inputs.configure-arguments }} || ( diff --git a/.github/workflows/build-linux.yml b/.github/workflows/build-linux.yml index 121416106f2..791b53a3f04 100644 --- a/.github/workflows/build-linux.yml +++ b/.github/workflows/build-linux.yml @@ -144,7 +144,7 @@ jobs: --with-zlib=system --with-jmod-compress=zip-1 --with-external-symbols-in-bundles=none - --with-debug-info-level=1 + --with-native-debug-symbols-level=1 ${{ inputs.extra-conf-options }} ${{ inputs.configure-arguments }} || ( echo "Dumping config.log:" && cat config.log && diff --git a/.github/workflows/build-macos.yml b/.github/workflows/build-macos.yml index 32c5d43acbc..484e616fad7 100644 --- a/.github/workflows/build-macos.yml +++ b/.github/workflows/build-macos.yml @@ -111,7 +111,7 @@ jobs: --with-zlib=system --with-jmod-compress=zip-1 --with-external-symbols-in-bundles=none - --with-debug-info-level=1 + --with-native-debug-symbols-level=1 ${{ inputs.extra-conf-options }} ${{ inputs.configure-arguments }} || ( echo "Dumping config.log:" && cat config.log && diff --git a/make/autoconf/flags-cflags.m4 b/make/autoconf/flags-cflags.m4 index b7b2a6b5e17..5a9fdc57c74 100644 --- a/make/autoconf/flags-cflags.m4 +++ b/make/autoconf/flags-cflags.m4 @@ -69,20 +69,20 @@ AC_DEFUN([FLAGS_SETUP_DEBUG_SYMBOLS], # Debug prefix mapping if supported by compiler DEBUG_PREFIX_CFLAGS= - UTIL_ARG_WITH(NAME: debug-info-level, TYPE: string, + UTIL_ARG_WITH(NAME: native-debug-symbols-level, TYPE: string, DEFAULT: "", - RESULT: DEBUG_INFO_LEVEL, - DESC: [Sets the debug info level, when debug info generation is enabled (GCC and Clang only)], - DEFAULT_DESC: [default]) - AC_SUBST(DEBUG_INFO_LEVEL) + RESULT: DEBUG_SYMBOLS_LEVEL, + DESC: [set the native debug symbol level (GCC and Clang only)], + DEFAULT_DESC: [toolchain default]) + AC_SUBST(DEBUG_SYMBOLS_LEVEL) if test "x${TOOLCHAIN_TYPE}" = xgcc || \ test "x${TOOLCHAIN_TYPE}" = xclang; then - DEBUG_INFO_LEVEL_FLAGS="-g" - if test "x${DEBUG_INFO_LEVEL}" != "x"; then - DEBUG_INFO_LEVEL_FLAGS="-g${DEBUG_INFO_LEVEL}" - FLAGS_COMPILER_CHECK_ARGUMENTS(ARGUMENT: [${DEBUG_INFO_LEVEL_FLAGS}], - IF_FALSE: AC_MSG_ERROR("Debug info level ${DEBUG_INFO_LEVEL} is not supported")) + DEBUG_SYMBOLS_LEVEL_FLAGS="-g" + if test "x${DEBUG_SYMBOLS_LEVEL}" != "x"; then + DEBUG_SYMBOLS_LEVEL_FLAGS="-g${DEBUG_SYMBOLS_LEVEL}" + FLAGS_COMPILER_CHECK_ARGUMENTS(ARGUMENT: [${DEBUG_SYMBOLS_LEVEL_FLAGS}], + IF_FALSE: AC_MSG_ERROR("Debug info level ${DEBUG_SYMBOLS_LEVEL} is not supported")) fi fi @@ -111,8 +111,8 @@ AC_DEFUN([FLAGS_SETUP_DEBUG_SYMBOLS], fi # Debug info level should follow the debug format to be effective. - CFLAGS_DEBUG_SYMBOLS="-gdwarf-4 ${DEBUG_INFO_LEVEL_FLAGS}" - ASFLAGS_DEBUG_SYMBOLS="${DEBUG_INFO_LEVEL_FLAGS}" + CFLAGS_DEBUG_SYMBOLS="-gdwarf-4 ${DEBUG_SYMBOLS_LEVEL_FLAGS}" + ASFLAGS_DEBUG_SYMBOLS="${DEBUG_SYMBOLS_LEVEL_FLAGS}" elif test "x$TOOLCHAIN_TYPE" = xclang; then if test "x$ALLOW_ABSOLUTE_PATHS_IN_OUTPUT" = "xfalse"; then # Check if compiler supports -fdebug-prefix-map. If so, use that to make @@ -132,8 +132,8 @@ AC_DEFUN([FLAGS_SETUP_DEBUG_SYMBOLS], IF_FALSE: [GDWARF_FLAGS=""]) # Debug info level should follow the debug format to be effective. - CFLAGS_DEBUG_SYMBOLS="${GDWARF_FLAGS} ${DEBUG_INFO_LEVEL_FLAGS}" - ASFLAGS_DEBUG_SYMBOLS="${DEBUG_INFO_LEVEL_FLAGS}" + CFLAGS_DEBUG_SYMBOLS="${GDWARF_FLAGS} ${DEBUG_SYMBOLS_LEVEL_FLAGS}" + ASFLAGS_DEBUG_SYMBOLS="${DEBUG_SYMBOLS_LEVEL_FLAGS}" elif test "x$TOOLCHAIN_TYPE" = xmicrosoft; then CFLAGS_DEBUG_SYMBOLS="-Z7" fi From 9fd86e37492c419fbae0837f69aab26a201c927e Mon Sep 17 00:00:00 2001 From: Ioi Lam Date: Thu, 8 Jan 2026 18:42:20 +0000 Subject: [PATCH 102/712] 8374639: Static archive with AOTClassLinking breaks dynamic archive Reviewed-by: coleenp, matsaave --- .../share/cds/aotConstantPoolResolver.cpp | 6 +- src/hotspot/share/cds/aotMetaspace.cpp | 3 +- src/hotspot/share/cds/archiveBuilder.cpp | 4 +- src/hotspot/share/cds/dynamicArchive.cpp | 119 +----------- src/hotspot/share/cds/dynamicArchive.hpp | 16 +- ...DynamicDumpWithAOTLinkedStaticArchive.java | 60 +++++++ .../appcds/dynamicArchive/ArrayKlasses.java | 170 ------------------ .../test-classes/ArrayKlassesApp.java | 77 -------- test/lib/jdk/test/lib/cds/CDSAppTester.java | 17 +- .../jdk/test/lib/cds/SimpleCDSAppTester.java | 25 ++- 10 files changed, 106 insertions(+), 391 deletions(-) create mode 100644 test/hotspot/jtreg/runtime/cds/appcds/aotClassLinking/DynamicDumpWithAOTLinkedStaticArchive.java delete mode 100644 test/hotspot/jtreg/runtime/cds/appcds/dynamicArchive/ArrayKlasses.java delete mode 100644 test/hotspot/jtreg/runtime/cds/appcds/dynamicArchive/test-classes/ArrayKlassesApp.java diff --git a/src/hotspot/share/cds/aotConstantPoolResolver.cpp b/src/hotspot/share/cds/aotConstantPoolResolver.cpp index c4bb26f6fb1..93145940955 100644 --- a/src/hotspot/share/cds/aotConstantPoolResolver.cpp +++ b/src/hotspot/share/cds/aotConstantPoolResolver.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 @@ -116,6 +116,10 @@ bool AOTConstantPoolResolver::is_class_resolution_deterministic(InstanceKlass* c return false; } } else if (resolved_class->is_objArray_klass()) { + if (CDSConfig::is_dumping_dynamic_archive()) { + // This is difficult to handle. See JDK-8374639 + return false; + } Klass* elem = ObjArrayKlass::cast(resolved_class)->bottom_klass(); if (elem->is_instance_klass()) { return is_class_resolution_deterministic(cp_holder, InstanceKlass::cast(elem)); diff --git a/src/hotspot/share/cds/aotMetaspace.cpp b/src/hotspot/share/cds/aotMetaspace.cpp index 3824a2be3e2..79d789e0c70 100644 --- a/src/hotspot/share/cds/aotMetaspace.cpp +++ b/src/hotspot/share/cds/aotMetaspace.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 @@ -2159,7 +2159,6 @@ void AOTMetaspace::initialize_shared_spaces() { intptr_t* buffer = (intptr_t*)dynamic_mapinfo->serialized_data(); ReadClosure rc(&buffer, (intptr_t)SharedBaseAddress); DynamicArchive::serialize(&rc); - DynamicArchive::setup_array_klasses(); } LogStreamHandle(Info, aot) lsh; diff --git a/src/hotspot/share/cds/archiveBuilder.cpp b/src/hotspot/share/cds/archiveBuilder.cpp index 3c7f25a950b..6bbefea5cd9 100644 --- a/src/hotspot/share/cds/archiveBuilder.cpp +++ b/src/hotspot/share/cds/archiveBuilder.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 @@ -984,8 +984,6 @@ void ArchiveBuilder::make_klasses_shareable() { #undef STATS_FORMAT #undef STATS_PARAMS - - DynamicArchive::make_array_klasses_shareable(); } void ArchiveBuilder::make_training_data_shareable() { diff --git a/src/hotspot/share/cds/dynamicArchive.cpp b/src/hotspot/share/cds/dynamicArchive.cpp index 8fae8dabf8c..d39cf3775e4 100644 --- a/src/hotspot/share/cds/dynamicArchive.cpp +++ b/src/hotspot/share/cds/dynamicArchive.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 @@ -48,6 +48,7 @@ #include "logging/log.hpp" #include "memory/metaspaceClosure.hpp" #include "memory/resourceArea.hpp" +#include "oops/array.hpp" #include "oops/klass.inline.hpp" #include "runtime/arguments.hpp" #include "runtime/os.hpp" @@ -95,7 +96,6 @@ public: void sort_methods(InstanceKlass* ik) const; void remark_pointers_for_instance_klass(InstanceKlass* k, bool should_mark) const; void write_archive(char* serialized_data, AOTClassLocationConfig* cl_config); - void gather_array_klasses(); public: // Do this before and after the archive dump to see if any corruption @@ -132,7 +132,6 @@ public: init_header(); gather_source_objs(); - gather_array_klasses(); reserve_buffer(); log_info(cds, dynamic)("Copying %d klasses and %d symbols", @@ -159,7 +158,6 @@ public: ArchiveBuilder::OtherROAllocMark mark; SystemDictionaryShared::write_to_archive(false); cl_config = AOTClassLocationConfig::dumptime()->write_to_archive(); - DynamicArchive::dump_array_klasses(); serialized_data = ro_region()->top(); WriteClosure wc(ro_region()); @@ -175,8 +173,6 @@ public: write_archive(serialized_data, cl_config); release_header(); - DynamicArchive::post_dump(); - post_dump(); verify_universe("After CDS dynamic dump"); @@ -185,30 +181,6 @@ public: virtual void iterate_roots(MetaspaceClosure* it) { AOTArtifactFinder::all_cached_classes_do(it); SystemDictionaryShared::dumptime_classes_do(it); - iterate_primitive_array_klasses(it); - } - - void iterate_primitive_array_klasses(MetaspaceClosure* it) { - for (int i = T_BOOLEAN; i <= T_LONG; i++) { - assert(is_java_primitive((BasicType)i), "sanity"); - Klass* k = Universe::typeArrayKlass((BasicType)i); // this give you "[I", etc - assert(AOTMetaspace::in_aot_cache_static_region((void*)k), - "one-dimensional primitive array should be in static archive"); - ArrayKlass* ak = ArrayKlass::cast(k); - while (ak != nullptr && ak->in_aot_cache()) { - Klass* next_k = ak->array_klass_or_null(); - if (next_k != nullptr) { - ak = ArrayKlass::cast(next_k); - } else { - ak = nullptr; - } - } - if (ak != nullptr) { - assert(ak->dimension() > 1, "sanity"); - // this is the lowest dimension that's not in the static archive - it->push(&ak); - } - } } }; @@ -367,26 +339,6 @@ void DynamicArchiveBuilder::write_archive(char* serialized_data, AOTClassLocatio log_info(cds, dynamic)("%d klasses; %d symbols", klasses()->length(), symbols()->length()); } -void DynamicArchiveBuilder::gather_array_klasses() { - for (int i = 0; i < klasses()->length(); i++) { - if (klasses()->at(i)->is_objArray_klass()) { - ObjArrayKlass* oak = ObjArrayKlass::cast(klasses()->at(i)); - Klass* elem = oak->element_klass(); - if (AOTMetaspace::in_aot_cache_static_region(elem)) { - // Only capture the array klass whose element_klass is in the static archive. - // During run time, setup (see DynamicArchive::setup_array_klasses()) is needed - // so that the element_klass can find its array klasses from the dynamic archive. - DynamicArchive::append_array_klass(oak); - } else { - // The element_klass and its array klasses are in the same archive. - assert(!AOTMetaspace::in_aot_cache_static_region(oak), - "we should not gather klasses that are already in the static archive"); - } - } - } - log_debug(aot)("Total array klasses gathered for dynamic archive: %d", DynamicArchive::num_array_klasses()); -} - class VM_PopulateDynamicDumpSharedSpace: public VM_Heap_Sync_Operation { DynamicArchiveBuilder _builder; public: @@ -403,76 +355,9 @@ public: } }; -// _array_klasses and _dynamic_archive_array_klasses only hold the array klasses -// which have element klass in the static archive. -GrowableArray* DynamicArchive::_array_klasses = nullptr; -Array* DynamicArchive::_dynamic_archive_array_klasses = nullptr; - void DynamicArchive::serialize(SerializeClosure* soc) { SymbolTable::serialize_shared_table_header(soc, false); SystemDictionaryShared::serialize_dictionary_headers(soc, false); - soc->do_ptr(&_dynamic_archive_array_klasses); -} - -void DynamicArchive::append_array_klass(ObjArrayKlass* ak) { - if (_array_klasses == nullptr) { - _array_klasses = new (mtClassShared) GrowableArray(50, mtClassShared); - } - _array_klasses->append(ak); -} - -void DynamicArchive::dump_array_klasses() { - assert(CDSConfig::is_dumping_dynamic_archive(), "sanity"); - if (_array_klasses != nullptr) { - ArchiveBuilder* builder = ArchiveBuilder::current(); - int num_array_klasses = _array_klasses->length(); - _dynamic_archive_array_klasses = - ArchiveBuilder::new_ro_array(num_array_klasses); - for (int i = 0; i < num_array_klasses; i++) { - builder->write_pointer_in_buffer(_dynamic_archive_array_klasses->adr_at(i), _array_klasses->at(i)); - } - } -} - -void DynamicArchive::setup_array_klasses() { - if (_dynamic_archive_array_klasses != nullptr) { - for (int i = 0; i < _dynamic_archive_array_klasses->length(); i++) { - ObjArrayKlass* oak = _dynamic_archive_array_klasses->at(i); - Klass* elm = oak->element_klass(); - assert(AOTMetaspace::in_aot_cache_static_region((void*)elm), "must be"); - - if (elm->is_instance_klass()) { - assert(InstanceKlass::cast(elm)->array_klasses() == nullptr, "must be"); - InstanceKlass::cast(elm)->set_array_klasses(oak); - } else { - assert(elm->is_array_klass(), "sanity"); - assert(ArrayKlass::cast(elm)->higher_dimension() == nullptr, "must be"); - ArrayKlass::cast(elm)->set_higher_dimension(oak); - } - } - log_debug(aot)("Total array klasses read from dynamic archive: %d", _dynamic_archive_array_klasses->length()); - } -} - -void DynamicArchive::make_array_klasses_shareable() { - if (_array_klasses != nullptr) { - int num_array_klasses = _array_klasses->length(); - for (int i = 0; i < num_array_klasses; i++) { - ObjArrayKlass* k = ArchiveBuilder::current()->get_buffered_addr(_array_klasses->at(i)); - k->remove_unshareable_info(); - } - } -} - -void DynamicArchive::post_dump() { - if (_array_klasses != nullptr) { - delete _array_klasses; - _array_klasses = nullptr; - } -} - -int DynamicArchive::num_array_klasses() { - return _array_klasses != nullptr ? _array_klasses->length() : 0; } void DynamicArchive::dump_impl(bool jcmd_request, const char* archive_name, TRAPS) { diff --git a/src/hotspot/share/cds/dynamicArchive.hpp b/src/hotspot/share/cds/dynamicArchive.hpp index c42c4b7dfde..63a48e252ee 100644 --- a/src/hotspot/share/cds/dynamicArchive.hpp +++ b/src/hotspot/share/cds/dynamicArchive.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,13 +26,8 @@ #define SHARE_CDS_DYNAMICARCHIVE_HPP #include "cds/filemap.hpp" -#include "classfile/compactHashtable.hpp" #include "memory/allStatic.hpp" -#include "memory/memRegion.hpp" -#include "oops/array.hpp" -#include "oops/oop.hpp" #include "utilities/exceptions.hpp" -#include "utilities/growableArray.hpp" #include "utilities/macros.hpp" #if INCLUDE_CDS @@ -59,22 +54,13 @@ public: }; class DynamicArchive : AllStatic { -private: - static GrowableArray* _array_klasses; - static Array* _dynamic_archive_array_klasses; public: static void dump_for_jcmd(const char* archive_name, TRAPS); static void dump_at_exit(JavaThread* current); static void dump_impl(bool jcmd_request, const char* archive_name, TRAPS); static bool is_mapped() { return FileMapInfo::dynamic_info() != nullptr; } static bool validate(FileMapInfo* dynamic_info); - static void dump_array_klasses(); - static void setup_array_klasses(); - static void append_array_klass(ObjArrayKlass* oak); static void serialize(SerializeClosure* soc); - static void make_array_klasses_shareable(); - static void post_dump(); - static int num_array_klasses(); }; #endif // INCLUDE_CDS #endif // SHARE_CDS_DYNAMICARCHIVE_HPP diff --git a/test/hotspot/jtreg/runtime/cds/appcds/aotClassLinking/DynamicDumpWithAOTLinkedStaticArchive.java b/test/hotspot/jtreg/runtime/cds/appcds/aotClassLinking/DynamicDumpWithAOTLinkedStaticArchive.java new file mode 100644 index 00000000000..8014ed685ee --- /dev/null +++ b/test/hotspot/jtreg/runtime/cds/appcds/aotClassLinking/DynamicDumpWithAOTLinkedStaticArchive.java @@ -0,0 +1,60 @@ +/* + * 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 8374639 + * @requires vm.cds.supports.aot.class.linking + * @library /test/lib + * @build DynamicDumpWithAOTLinkedStaticArchive jdk.test.whitebox.WhiteBox + * @run driver jdk.test.lib.helpers.ClassFileInstaller jdk.test.whitebox.WhiteBox + * @run driver jdk.test.lib.helpers.ClassFileInstaller -jar app.jar TestApp + * @run main/othervm -XX:+UnlockDiagnosticVMOptions -XX:+WhiteBoxAPI -Xbootclasspath/a:. DynamicDumpWithAOTLinkedStaticArchive + */ + +import jdk.test.lib.cds.SimpleCDSAppTester; +import jdk.test.lib.process.OutputAnalyzer; + +public class DynamicDumpWithAOTLinkedStaticArchive { + public static void main(String... args) throws Exception { + SimpleCDSAppTester.of("DynamicDumpWithAOTLinkedStaticArchive") + .classpath("app.jar") + .appCommandLine("TestApp") + .setGenerateBaseArchive(true) + .setBaseArchiveOptions("-XX:+AOTClassLinking") + .setProductionChecker((OutputAnalyzer out) -> { + out.shouldContain("HelloWorld"); + }) + .runDynamicWorkflow(); + } +} + +class TestApp { + public static void main(String[] args) { + System.out.println("HelloWorld"); + System[][][] x = new System[0][0][0]; + System.out.println(x); + } +} diff --git a/test/hotspot/jtreg/runtime/cds/appcds/dynamicArchive/ArrayKlasses.java b/test/hotspot/jtreg/runtime/cds/appcds/dynamicArchive/ArrayKlasses.java deleted file mode 100644 index e476382c8c9..00000000000 --- a/test/hotspot/jtreg/runtime/cds/appcds/dynamicArchive/ArrayKlasses.java +++ /dev/null @@ -1,170 +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. - * - */ - -/* - * @test - * @summary handling of the existence of InstanceKlass::array_klasses() - * @requires vm.cds - * @library /test/lib /test/hotspot/jtreg/runtime/cds/appcds - * /test/hotspot/jtreg/runtime/cds/appcds/dynamicArchive/test-classes - * @build ArrayKlassesApp - * @build jdk.test.whitebox.WhiteBox - * @run driver jdk.test.lib.helpers.ClassFileInstaller -jar ArrayKlasses.jar ArrayKlassesApp - * @run driver jdk.test.lib.helpers.ClassFileInstaller jdk.test.whitebox.WhiteBox - * @run main/othervm -XX:+UnlockDiagnosticVMOptions -XX:+WhiteBoxAPI -Xbootclasspath/a:. ArrayKlasses - */ - -import jdk.test.lib.helpers.ClassFileInstaller; - -public class ArrayKlasses extends DynamicArchiveTestBase { - public static void main(String[] args) throws Exception { - runTest(ArrayKlasses::test); - } - - static void test() throws Exception { - String topArchiveName = getNewArchiveName(); - final String appJar = ClassFileInstaller.getJarPath("ArrayKlasses.jar"); - final String mainClass = "ArrayKlassesApp"; - final String runtimeLogOptions = - "-Xlog:class+load,class+load+array=debug,cds+dynamic=debug,cds=debug,aot+unshareable=trace"; - - // Case 1 - // Create a dynamic archive with the ArrayKlassesApp app class and its - // array classes. - dump2(null, topArchiveName, - "-Xlog:cds+dynamic=debug,cds+class=debug", - "-cp", appJar, mainClass) - .assertNormalExit(output -> { - output.shouldMatch("cds.class.*klasses.*array \\[LArrayKlassesApp;") - .shouldMatch("cds.class.*klasses.*array \\[\\[LArrayKlassesApp;") - .shouldMatch("cds.class.*klasses.*array \\[\\[\\[LArrayKlassesApp;"); - }); - - // Case 1 - // At runtime , the ArrayKlasesApp and its array class should be loaded - // from the dynamic archive. - run2(null, topArchiveName, runtimeLogOptions, - "-cp", appJar, mainClass) - .assertNormalExit(output -> { - output.shouldContain("ArrayKlassesApp source: shared objects file (top)") - .shouldContain("restore: ArrayKlassesApp with class loader: jdk.internal.loader.ClassLoaders$AppClassLoader") - .shouldContain("[LArrayKlassesApp; source: shared objects file (top)") - .shouldContain("restore: [LArrayKlassesApp; with class loader: jdk.internal.loader.ClassLoaders$AppClassLoader") - .shouldContain("[[LArrayKlassesApp; source: shared objects file (top)") - .shouldContain("restore: [[LArrayKlassesApp; with class loader: jdk.internal.loader.ClassLoaders$AppClassLoader") - .shouldContain("[[[LArrayKlassesApp; source: shared objects file (top)") - .shouldContain("restore: [[[LArrayKlassesApp; with class loader: jdk.internal.loader.ClassLoaders$AppClassLoader") - .shouldHaveExitValue(0); - }); - - // Case 2 - // Create a dynamic archive with the array classes of java/util/Date which - // is in the default CDS archive. - topArchiveName = getNewArchiveName(); - dump2(null, topArchiveName, - "-Xlog:class+load,cds+dynamic=debug,cds+class=debug", - "-cp", appJar, mainClass, "system") - .assertNormalExit(output -> { - output.shouldContain("java.util.Date source: shared objects file") - .shouldMatch("cds.class.*klasses.*array \\[Ljava.util.Date;") - .shouldMatch("cds.class.*klasses.*array \\[\\[Ljava.util.Date;") - .shouldMatch("cds.class.*klasses.*array \\[\\[\\[Ljava.util.Date;"); - }); - - // Case 2 - // At runtime, the java/util/Date class should be loaded from the default - // CDS archive; its array class should be loaded from the dynamic archive. - run2(null, topArchiveName, runtimeLogOptions, - "-cp", appJar, mainClass, "system") - .assertNormalExit(output -> { - output.shouldContain("java.util.Date source: shared objects file") - .shouldContain("restore: java.util.Date with class loader: boot") - .shouldContain("[Ljava.util.Date; source: shared objects file (top)") - .shouldContain("restore: [Ljava.util.Date; with class loader: boot") - .shouldContain("[[Ljava.util.Date; source: shared objects file (top)") - .shouldContain("restore: [[Ljava.util.Date; with class loader: boot") - .shouldContain("[[[Ljava.util.Date; source: shared objects file (top)") - .shouldContain("restore: [[[Ljava.util.Date; with class loader: boot") - .shouldHaveExitValue(0); - }); - - // Case 3 - // Create a dynamic archive with primitive arrays [[J and [[[J with [J - // already in the default CDS archive - topArchiveName = getNewArchiveName(); - dump2(null, topArchiveName, - "-Xlog:class+load,cds+dynamic=debug,cds+class=debug", - "-cp", appJar, mainClass, "primitive") - .assertNormalExit(output -> { - output.shouldMatch("cds.class.*klasses.*array \\[\\[J") - .shouldMatch("cds.class.*klasses.*array \\[\\[\\[J"); - }); - - // Case 3 - // At runtime, the [J should be loaded from the default CDS archive; - // the higher-dimension array should be loaded from the dynamic archive. - run2(null, topArchiveName, runtimeLogOptions, - "-cp", appJar, mainClass, "primitive") - .assertNormalExit(output -> { - output.shouldContain("[J source: shared objects file") - .shouldContain("restore: [J with class loader: boot") - .shouldContain("[[J source: shared objects file (top)") - .shouldContain("restore: [[J with class loader: boot") - .shouldContain("[[[J source: shared objects file (top)") - .shouldContain("restore: [[[J with class loader: boot") - .shouldHaveExitValue(0); - }); - - // Case 4 - // Create a dynamic archive with 2-, 3- and 4-dimension arrays of java/lang/Integer. - // The java/lang/Integer class and the 1-dimension array is in the default archive. - topArchiveName = getNewArchiveName(); - dump2(null, topArchiveName, - "-Xlog:class+load,cds+dynamic=debug,cds+class=debug", - "-cp", appJar, mainClass, "integer-array") - .assertNormalExit(output -> { - output.shouldMatch("cds.class.*klasses.*array \\[\\[Ljava.lang.Integer;") - .shouldMatch("cds.class.*klasses.*array \\[\\[\\[Ljava.lang.Integer;") - .shouldMatch("cds.class.*klasses.*array \\[\\[\\[\\[Ljava.lang.Integer;"); - }); - - // Case 4 - // At runtime, the 4-dimension array of java/lang/Integer should be - // loaded from the dynamic archive. - run2(null, topArchiveName, runtimeLogOptions, - "-cp", appJar, mainClass, "integer-array") - .assertNormalExit(output -> { - output.shouldContain("java.lang.Integer source: shared objects file") - .shouldContain("restore: java.lang.Integer with class loader: boot") - .shouldContain("restore: [Ljava.lang.Integer; with class loader: boot") - .shouldContain("[[Ljava.lang.Integer; source: shared objects file (top)") - .shouldContain("restore: [[Ljava.lang.Integer; with class loader: boot") - .shouldContain("[[[Ljava.lang.Integer; source: shared objects file (top)") - .shouldContain("restore: [[[Ljava.lang.Integer; with class loader: boot") - .shouldContain("[[[[Ljava.lang.Integer; source: shared objects file (top)") - .shouldContain("restore: [[[[Ljava.lang.Integer; with class loader: boot") - .shouldHaveExitValue(0); - }); - } -} diff --git a/test/hotspot/jtreg/runtime/cds/appcds/dynamicArchive/test-classes/ArrayKlassesApp.java b/test/hotspot/jtreg/runtime/cds/appcds/dynamicArchive/test-classes/ArrayKlassesApp.java deleted file mode 100644 index 3c78e3e8dbe..00000000000 --- a/test/hotspot/jtreg/runtime/cds/appcds/dynamicArchive/test-classes/ArrayKlassesApp.java +++ /dev/null @@ -1,77 +0,0 @@ -/* - * Copyright (c) 2019, 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.lang.reflect.Array; -import java.util.Date; - -public class ArrayKlassesApp { - public static void main(String args[]) { - if (args.length == 1) { - if (args[0].equals("system")) { - Date[][][] array = new Date[1][2][2]; - int count = 0; - for (int i=0; i<1; i++) { - for (int j=0; j<2; j++) { - for (int k=0; k<2; k++) { - array[i][j][k] = new Date(); - count++; - array[i][j][k].setTime(20000 * count); - } - } - } - } else if (args[0].equals("primitive")) { - long[][][] larray = new long[1][2][2]; - long lcount = 0; - for (int i=0; i<1; i++) { - for (int j=0; j<2; j++) { - for (int k=0; k<2; k++) { - lcount++; - larray[i][j][k] = lcount; - } - } - } - } else if (args[0].equals("integer-array")) { - Integer[][][][] iarray = new Integer[4][4][4][4]; - int count = 0; - for (int i = 0; i < 4; i++) { - for (int j = 0; j < 4; j++) { - for (int k = 0; k < 4; k++) { - for (int l = 0; l < 4; l++) { - count++; - iarray[i][j][k][l] = new Integer(count); - } - } - } - } - System.out.println(iarray); - System.out.println(iarray.getClass()); - } - } else { - Object x = Array.newInstance(ArrayKlassesApp.class, 3,3,3); - System.out.println(x); - System.out.println(x.getClass()); - System.out.println(Array.getLength(x)); - } - } -} diff --git a/test/lib/jdk/test/lib/cds/CDSAppTester.java b/test/lib/jdk/test/lib/cds/CDSAppTester.java index fd244c6acc6..18356dd8aa9 100644 --- a/test/lib/jdk/test/lib/cds/CDSAppTester.java +++ b/test/lib/jdk/test/lib/cds/CDSAppTester.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 @@ -57,6 +57,8 @@ abstract public class CDSAppTester { private int numProductionRuns = 0; private String whiteBoxJar = null; private boolean inOneStepTraining = false; + private boolean generateBaseArchive = false; + private String[] baseArchiveOptions = new String[0]; /** * All files created in the CDS/AOT workflow will be name + extension. E.g. @@ -343,7 +345,7 @@ abstract public class CDSAppTester { // VM options used by this test, we need to create a temporary static archive to be used with -XX:ArchiveClassesAtExit. private String getBaseArchiveForDynamicArchive() throws Exception { WhiteBox wb = WhiteBox.getWhiteBox(); - if (wb.isSharingEnabled()) { + if (wb.isSharingEnabled() && !generateBaseArchive) { // This current JVM is able to use a default CDS archive included by the JDK, so // if we launch a JVM child process (with the same set of options as the current JVM), // that process is also able to use the same default CDS archive for creating @@ -356,6 +358,7 @@ abstract public class CDSAppTester { if (!f.exists()) { CDSOptions opts = new CDSOptions(); opts.setArchiveName(tempBaseArchiveFile); + opts.addSuffix(baseArchiveOptions); opts.addSuffix("-Djava.class.path="); OutputAnalyzer out = CDSTestUtils.createArchive(opts); CDSTestUtils.checkBaseDump(out); @@ -364,6 +367,16 @@ abstract public class CDSAppTester { } } + public CDSAppTester setGenerateBaseArchive(boolean b) { + this.generateBaseArchive = b; + return this; + } + + public CDSAppTester setBaseArchiveOptions(String... opts) { + this.baseArchiveOptions = opts; + return this; + } + private OutputAnalyzer dumpDynamicArchive() throws Exception { RunMode runMode = RunMode.DUMP_DYNAMIC; String[] cmdLine = new String[0]; diff --git a/test/lib/jdk/test/lib/cds/SimpleCDSAppTester.java b/test/lib/jdk/test/lib/cds/SimpleCDSAppTester.java index c869cfa366b..a8bba9c76e2 100644 --- a/test/lib/jdk/test/lib/cds/SimpleCDSAppTester.java +++ b/test/lib/jdk/test/lib/cds/SimpleCDSAppTester.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 @@ -58,9 +58,11 @@ public class SimpleCDSAppTester { private String modulepath; private String[] appCommandLine; private String[] vmArgs = new String[] {}; + private Tester tester; private SimpleCDSAppTester(String name) { this.name = name; + this.tester = new Tester(name); } public static SimpleCDSAppTester of(String name) { @@ -101,6 +103,16 @@ public class SimpleCDSAppTester { return this; } + public SimpleCDSAppTester setGenerateBaseArchive(boolean b) { + tester.setGenerateBaseArchive(b); + return this; + } + + public SimpleCDSAppTester setBaseArchiveOptions(String... opts) { + tester.setBaseArchiveOptions(opts); + return this; + } + public SimpleCDSAppTester setTrainingChecker(BiConsumer checker) { this.trainingChecker = checker; return this; @@ -181,17 +193,22 @@ public class SimpleCDSAppTester { } public SimpleCDSAppTester runStaticWorkflow() throws Exception { - (new Tester(name)).runStaticWorkflow(); + tester.runStaticWorkflow(); + return this; + } + + public SimpleCDSAppTester runDynamicWorkflow() throws Exception { + tester.runDynamicWorkflow(); return this; } public SimpleCDSAppTester runAOTWorkflow() throws Exception { - (new Tester(name)).runAOTWorkflow(); + tester.runAOTWorkflow(); return this; } public SimpleCDSAppTester run(String args[]) throws Exception { - (new Tester(name)).run(args); + tester.run(args); return this; } } From 8212993ac331d8761ddb7c0eef23dbfcc6ca0c7d Mon Sep 17 00:00:00 2001 From: Joe Darcy Date: Thu, 8 Jan 2026 18:51:25 +0000 Subject: [PATCH 103/712] 8374540: Add comment describing implementation choices of Math.fma Reviewed-by: rgiulietti --- .../share/classes/java/lang/Math.java | 18 +++++++++++++++++- 1 file changed, 17 insertions(+), 1 deletion(-) diff --git a/src/java.base/share/classes/java/lang/Math.java b/src/java.base/share/classes/java/lang/Math.java index 0f39ecf0a8a..55659bed57b 100644 --- a/src/java.base/share/classes/java/lang/Math.java +++ b/src/java.base/share/classes/java/lang/Math.java @@ -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 @@ -2378,6 +2378,20 @@ public final class Math { */ @IntrinsicCandidate public static double fma(double a, double b, double c) { + // Implementation note: this method is intentionally coded in + // a straightforward manner relying on BigDecimal for the + // heavy-lifting of the numerical computation. It would be + // possible for the computation to be done solely using binary + // floating-point and integer operations, at the cost of more + // complicated logic. Since most processors have hardware + // support for fma and this method is an intrinsic candidate, + // the software implementation below would only be used on + // processors without native fma support (and also possibly on + // processors with native fma support while running in the + // interpreter). Therefore, the direct performance of the code + // is less of a concern than the code's simplicity, + // maintainability, and testability. + /* * Infinity and NaN arithmetic is not quite the same with two * roundings as opposed to just one so the simple expression @@ -2492,6 +2506,8 @@ public final class Math { */ @IntrinsicCandidate public static float fma(float a, float b, float c) { + // See implementation note in fma(double, double, double). + if (Float.isFinite(a) && Float.isFinite(b) && Float.isFinite(c)) { if (a == 0.0 || b == 0.0) { return a * b + c; // Handled signed zero cases From 1342db0bde25c111b25f4339ae2a858dc3b15687 Mon Sep 17 00:00:00 2001 From: Justin Lu Date: Thu, 8 Jan 2026 19:02:06 +0000 Subject: [PATCH 104/712] 8374051: Incorrect parameterized testing of exceptions in AbstractDateTimeTest.java Reviewed-by: naoto, rriggs --- .../tck/java/time/AbstractDateTimeTest.java | 227 +++++++----------- .../java/time/tck/java/time/TCKInstant.java | 5 +- .../java/time/tck/java/time/TCKLocalDate.java | 4 +- .../java/time/tck/java/time/TCKLocalTime.java | 5 +- .../java/time/tck/java/time/TCKMonthDay.java | 4 +- .../time/tck/java/time/TCKOffsetDateTime.java | 5 +- .../time/tck/java/time/TCKOffsetTime.java | 5 +- .../java/time/tck/java/time/TCKYearMonth.java | 4 +- .../time/tck/java/time/TCKZonedDateTime.java | 4 +- 9 files changed, 112 insertions(+), 151 deletions(-) diff --git a/test/jdk/java/time/tck/java/time/AbstractDateTimeTest.java b/test/jdk/java/time/tck/java/time/AbstractDateTimeTest.java index f96ab522517..cf138419c83 100644 --- a/test/jdk/java/time/tck/java/time/AbstractDateTimeTest.java +++ b/test/jdk/java/time/tck/java/time/AbstractDateTimeTest.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 @@ -59,8 +59,11 @@ */ package tck.java.time; +import static org.junit.jupiter.api.Assertions.assertDoesNotThrow; import static org.junit.jupiter.api.Assertions.assertEquals; -import static org.junit.jupiter.api.Assertions.fail; +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 java.time.DateTimeException; import java.time.temporal.TemporalAccessor; @@ -68,8 +71,8 @@ import java.time.temporal.TemporalField; import java.time.temporal.TemporalQuery; import java.util.List; -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 test.java.time.temporal.MockFieldNoValue; @@ -99,183 +102,137 @@ public abstract class AbstractDateTimeTest extends AbstractTCKTest { //----------------------------------------------------------------------- // isSupported(TemporalField) //----------------------------------------------------------------------- - @Test() - public void basicTest_isSupported_TemporalField_supported() { - for (TemporalAccessor sample : samples()) { - for (TemporalField field : validFields()) { - assertEquals(true, sample.isSupported(field), "Failed on " + sample + " " + field); - } + @ParameterizedTest + @MethodSource("samples") + public void basicTest_isSupported_TemporalField_supported(TemporalAccessor sample) { + for (TemporalField field : validFields()) { + assertTrue(sample.isSupported(field), "Failed on " + sample + " " + field); } } - @Test() - public void basicTest_isSupported_TemporalField_unsupported() { - for (TemporalAccessor sample : samples()) { - for (TemporalField field : invalidFields()) { - assertEquals(false, sample.isSupported(field), "Failed on " + sample + " " + field); - } + @ParameterizedTest + @MethodSource("samples") + public void basicTest_isSupported_TemporalField_unsupported(TemporalAccessor sample) { + for (TemporalField field : invalidFields()) { + assertFalse(sample.isSupported(field), "Failed on " + sample + " " + field); } } - @Test() - public void basicTest_isSupported_TemporalField_null() { - for (TemporalAccessor sample : samples()) { - assertEquals(false, sample.isSupported(null), "Failed on " + sample); - } + @ParameterizedTest + @MethodSource("samples") + public void basicTest_isSupported_TemporalField_null(TemporalAccessor sample) { + assertFalse(sample.isSupported(null), "Failed on " + sample); } //----------------------------------------------------------------------- // range(TemporalField) //----------------------------------------------------------------------- - @Test() - public void basicTest_range_TemporalField_supported() { - for (TemporalAccessor sample : samples()) { - for (TemporalField field : validFields()) { - sample.range(field); // no exception - } + @ParameterizedTest + @MethodSource("samples") + public void basicTest_range_TemporalField_supported(TemporalAccessor sample) { + for (TemporalField field : validFields()) { + assertDoesNotThrow(() -> sample.range(field)); } } - @Test() - public void basicTest_range_TemporalField_unsupported() { - for (TemporalAccessor sample : samples()) { - for (TemporalField field : invalidFields()) { - try { - sample.range(field); - fail("Failed on " + sample + " " + field); - } catch (DateTimeException ex) { - // expected - } - } + @ParameterizedTest + @MethodSource("samples") + public void basicTest_range_TemporalField_unsupported(TemporalAccessor sample) { + for (TemporalField field : invalidFields()) { + assertThrows(DateTimeException.class, + () -> sample.range(field), "Failed on " + sample + " " + field); } } - @Test() - public void basicTest_range_TemporalField_null() { - for (TemporalAccessor sample : samples()) { - try { - sample.range(null); - fail("Failed on " + sample); - } catch (NullPointerException ex) { - // expected - } - } + @ParameterizedTest + @MethodSource("samples") + public void basicTest_range_TemporalField_null(TemporalAccessor sample) { + assertThrows(NullPointerException.class, + () -> sample.range(null), "Failed on " + sample); } //----------------------------------------------------------------------- // get(TemporalField) //----------------------------------------------------------------------- - @Test() - public void basicTest_get_TemporalField_supported() { - for (TemporalAccessor sample : samples()) { - for (TemporalField field : validFields()) { - if (sample.range(field).isIntValue()) { - sample.get(field); // no exception - } else { - try { - sample.get(field); - fail("Failed on " + sample + " " + field); - } catch (DateTimeException ex) { - // expected - } - } + @ParameterizedTest + @MethodSource("samples") + public void basicTest_get_TemporalField_supported(TemporalAccessor sample) { + for (TemporalField field : validFields()) { + if (sample.range(field).isIntValue()) { + assertDoesNotThrow(() -> sample.get(field)); + } else { + assertThrows(DateTimeException.class, + () -> sample.get(field), "Failed on " + sample + " " + field); } } } - @Test() - public void basicTest_get_TemporalField_unsupported() { - for (TemporalAccessor sample : samples()) { - for (TemporalField field : invalidFields()) { - try { - sample.get(field); - fail("Failed on " + sample + " " + field); - } catch (DateTimeException ex) { - // expected - } - } + @ParameterizedTest + @MethodSource("samples") + public void basicTest_get_TemporalField_unsupported(TemporalAccessor sample) { + for (TemporalField field : invalidFields()) { + assertThrows(DateTimeException.class, + () -> sample.get(field), "Failed on " + sample + " " + field); } } - @Test - public void test_get_TemporalField_invalidField() { - Assertions.assertThrows(DateTimeException.class, () -> { - for (TemporalAccessor sample : samples()) { - sample.get(MockFieldNoValue.INSTANCE); - } - }); + @ParameterizedTest + @MethodSource("samples") + public void test_get_TemporalField_invalidField(TemporalAccessor sample) { + assertThrows(DateTimeException.class, + () -> sample.get(MockFieldNoValue.INSTANCE)); } - @Test() - public void basicTest_get_TemporalField_null() { - for (TemporalAccessor sample : samples()) { - try { - sample.get(null); - fail("Failed on " + sample); - } catch (NullPointerException ex) { - // expected - } - } + @ParameterizedTest + @MethodSource("samples") + public void basicTest_get_TemporalField_null(TemporalAccessor sample) { + assertThrows(NullPointerException.class, + () -> sample.get(null), "Failed on " + sample); } //----------------------------------------------------------------------- // getLong(TemporalField) //----------------------------------------------------------------------- - @Test() - public void basicTest_getLong_TemporalField_supported() { - for (TemporalAccessor sample : samples()) { - for (TemporalField field : validFields()) { - sample.getLong(field); // no exception - } + @ParameterizedTest + @MethodSource("samples") + public void basicTest_getLong_TemporalField_supported(TemporalAccessor sample) { + for (TemporalField field : validFields()) { + sample.getLong(field); } } - @Test() - public void basicTest_getLong_TemporalField_unsupported() { - for (TemporalAccessor sample : samples()) { - for (TemporalField field : invalidFields()) { - try { - sample.getLong(field); - fail("Failed on " + sample + " " + field); - } catch (DateTimeException ex) { - // expected - } - } + @ParameterizedTest + @MethodSource("samples") + public void basicTest_getLong_TemporalField_unsupported(TemporalAccessor sample) { + for (TemporalField field : invalidFields()) { + assertThrows(DateTimeException.class, + () -> sample.getLong(field), "Failed on " + sample + " " + field); } } - @Test - public void test_getLong_TemporalField_invalidField() { - Assertions.assertThrows(DateTimeException.class, () -> { - for (TemporalAccessor sample : samples()) { - sample.getLong(MockFieldNoValue.INSTANCE); - } - }); + @ParameterizedTest + @MethodSource("samples") + public void test_getLong_TemporalField_invalidField(TemporalAccessor sample) { + assertThrows(DateTimeException.class, + () -> sample.getLong(MockFieldNoValue.INSTANCE)); } - @Test() - public void basicTest_getLong_TemporalField_null() { - for (TemporalAccessor sample : samples()) { - try { - sample.getLong(null); - fail("Failed on " + sample); - } catch (NullPointerException ex) { - // expected - } - } + @ParameterizedTest + @MethodSource("samples") + public void basicTest_getLong_TemporalField_null(TemporalAccessor sample) { + assertThrows(NullPointerException.class, + () -> sample.getLong(null), "Failed on " + sample); } //----------------------------------------------------------------------- - @Test - public void basicTest_query() { - for (TemporalAccessor sample : samples()) { - assertEquals("foo", sample.query(new TemporalQuery() { - @Override - public String queryFrom(TemporalAccessor temporal) { - return "foo"; - } - })); - } + @ParameterizedTest + @MethodSource("samples") + public void basicTest_query(TemporalAccessor sample) { + assertEquals("foo", sample.query(new TemporalQuery() { + @Override + public String queryFrom(TemporalAccessor temporal) { + return "foo"; + } + })); } - } diff --git a/test/jdk/java/time/tck/java/time/TCKInstant.java b/test/jdk/java/time/tck/java/time/TCKInstant.java index 4a512d37665..8c245d69810 100644 --- a/test/jdk/java/time/tck/java/time/TCKInstant.java +++ b/test/jdk/java/time/tck/java/time/TCKInstant.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 @@ -139,7 +139,8 @@ public class TCKInstant extends AbstractDateTimeTest { //----------------------------------------------------------------------- @Override protected List samples() { - TemporalAccessor[] array = {TEST_12345_123456789, Instant.MIN, Instant.MAX, Instant.EPOCH}; + TemporalAccessor[] array = {Instant.ofEpochSecond(12345, 123456789), + Instant.MIN, Instant.MAX, Instant.EPOCH}; return Arrays.asList(array); } diff --git a/test/jdk/java/time/tck/java/time/TCKLocalDate.java b/test/jdk/java/time/tck/java/time/TCKLocalDate.java index 281007e7665..132aa31ed97 100644 --- a/test/jdk/java/time/tck/java/time/TCKLocalDate.java +++ b/test/jdk/java/time/tck/java/time/TCKLocalDate.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 @@ -170,7 +170,7 @@ public class TCKLocalDate extends AbstractDateTimeTest { //----------------------------------------------------------------------- @Override protected List samples() { - TemporalAccessor[] array = {TEST_2007_07_15, LocalDate.MAX, LocalDate.MIN, }; + TemporalAccessor[] array = {LocalDate.of(2007, 7, 15), LocalDate.MAX, LocalDate.MIN, }; return Arrays.asList(array); } diff --git a/test/jdk/java/time/tck/java/time/TCKLocalTime.java b/test/jdk/java/time/tck/java/time/TCKLocalTime.java index bdec611ad76..e2fc4ea2ca7 100644 --- a/test/jdk/java/time/tck/java/time/TCKLocalTime.java +++ b/test/jdk/java/time/tck/java/time/TCKLocalTime.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 @@ -161,7 +161,8 @@ public class TCKLocalTime extends AbstractDateTimeTest { //----------------------------------------------------------------------- @Override protected List samples() { - TemporalAccessor[] array = {TEST_12_30_40_987654321, LocalTime.MIN, LocalTime.MAX, LocalTime.MIDNIGHT, LocalTime.NOON}; + TemporalAccessor[] array = {LocalTime.of(12, 30, 40, 987654321), + LocalTime.MIN, LocalTime.MAX, LocalTime.MIDNIGHT, LocalTime.NOON}; return Arrays.asList(array); } diff --git a/test/jdk/java/time/tck/java/time/TCKMonthDay.java b/test/jdk/java/time/tck/java/time/TCKMonthDay.java index 84326a4c47a..36ad4af069e 100644 --- a/test/jdk/java/time/tck/java/time/TCKMonthDay.java +++ b/test/jdk/java/time/tck/java/time/TCKMonthDay.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 @@ -118,7 +118,7 @@ public class TCKMonthDay extends AbstractDateTimeTest { //----------------------------------------------------------------------- @Override protected List samples() { - TemporalAccessor[] array = {TEST_07_15, }; + TemporalAccessor[] array = {MonthDay.of(7, 15), }; return Arrays.asList(array); } diff --git a/test/jdk/java/time/tck/java/time/TCKOffsetDateTime.java b/test/jdk/java/time/tck/java/time/TCKOffsetDateTime.java index f2b98ee9972..6ba0318890f 100644 --- a/test/jdk/java/time/tck/java/time/TCKOffsetDateTime.java +++ b/test/jdk/java/time/tck/java/time/TCKOffsetDateTime.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 @@ -167,7 +167,8 @@ public class TCKOffsetDateTime extends AbstractDateTimeTest { //----------------------------------------------------------------------- @Override protected List samples() { - TemporalAccessor[] array = {TEST_2008_6_30_11_30_59_000000500, OffsetDateTime.MIN, OffsetDateTime.MAX}; + TemporalAccessor[] array = {OffsetDateTime.of(2008, 6, 30, 11, 30, 59, 500, OFFSET_PONE), + OffsetDateTime.MIN, OffsetDateTime.MAX}; return Arrays.asList(array); } diff --git a/test/jdk/java/time/tck/java/time/TCKOffsetTime.java b/test/jdk/java/time/tck/java/time/TCKOffsetTime.java index 350b21574fa..7ea9504edbc 100644 --- a/test/jdk/java/time/tck/java/time/TCKOffsetTime.java +++ b/test/jdk/java/time/tck/java/time/TCKOffsetTime.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 @@ -149,7 +149,8 @@ public class TCKOffsetTime extends AbstractDateTimeTest { //----------------------------------------------------------------------- @Override protected List samples() { - TemporalAccessor[] array = {TEST_11_30_59_500_PONE, OffsetTime.MIN, OffsetTime.MAX}; + TemporalAccessor[] array = {OffsetTime.of(11, 30, 59, 500, OFFSET_PONE), + OffsetTime.MIN, OffsetTime.MAX}; return Arrays.asList(array); } diff --git a/test/jdk/java/time/tck/java/time/TCKYearMonth.java b/test/jdk/java/time/tck/java/time/TCKYearMonth.java index 3f4fda2a924..e39bbe90cf9 100644 --- a/test/jdk/java/time/tck/java/time/TCKYearMonth.java +++ b/test/jdk/java/time/tck/java/time/TCKYearMonth.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 @@ -134,7 +134,7 @@ public class TCKYearMonth extends AbstractDateTimeTest { //----------------------------------------------------------------------- @Override protected List samples() { - TemporalAccessor[] array = {TEST_2008_06, }; + TemporalAccessor[] array = {YearMonth.of(2008, 6), }; return Arrays.asList(array); } diff --git a/test/jdk/java/time/tck/java/time/TCKZonedDateTime.java b/test/jdk/java/time/tck/java/time/TCKZonedDateTime.java index 847035f121a..73adbbba88c 100644 --- a/test/jdk/java/time/tck/java/time/TCKZonedDateTime.java +++ b/test/jdk/java/time/tck/java/time/TCKZonedDateTime.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 @@ -176,7 +176,7 @@ public class TCKZonedDateTime extends AbstractDateTimeTest { //----------------------------------------------------------------------- @Override protected List samples() { - TemporalAccessor[] array = {TEST_DATE_TIME, }; + TemporalAccessor[] array = {ZonedDateTime.of(LocalDateTime.of(2008, 6, 30, 11, 30, 59, 500), ZONE_0100), }; return Arrays.asList(array); } From 982aa3f8ead84817be5373c3257d48feab1758d3 Mon Sep 17 00:00:00 2001 From: Phil Race Date: Thu, 8 Jan 2026 19:47:01 +0000 Subject: [PATCH 105/712] 8336654: [lworld] Tests depending on sun.awt.AppContext can fail when run with migrated classes Reviewed-by: serb, azvegint --- .../classes/com/apple/laf/AquaUtils.java | 41 +++++-- .../share/classes/sun/awt/AppContext.java | 19 --- .../classes/sun/awt/image/ImageCache.java | 8 +- .../swing/Security/6657138/bug6657138.java | 108 ------------------ 4 files changed, 33 insertions(+), 143 deletions(-) delete mode 100644 test/jdk/javax/swing/Security/6657138/bug6657138.java diff --git a/src/java.desktop/macosx/classes/com/apple/laf/AquaUtils.java b/src/java.desktop/macosx/classes/com/apple/laf/AquaUtils.java index da1785a9a63..5e68cc7a82c 100644 --- a/src/java.desktop/macosx/classes/com/apple/laf/AquaUtils.java +++ b/src/java.desktop/macosx/classes/com/apple/laf/AquaUtils.java @@ -35,8 +35,6 @@ import javax.swing.*; import javax.swing.border.Border; import javax.swing.plaf.UIResource; -import sun.awt.AppContext; - import sun.lwawt.macosx.CPlatformWindow; import sun.swing.SwingUtilities2; @@ -150,13 +148,34 @@ final class AquaUtils { protected abstract T create(); } - abstract static class RecyclableSingleton { - final T get() { - return AppContext.getSoftReferenceValue(this, () -> getInstance()); - } + abstract static class LazySingleton { + T instance; - void reset() { - AppContext.getAppContext().remove(this); + final T get() { + if (instance == null) { + instance = getInstance(); + } + return instance; + } + + abstract T getInstance(); + } + + abstract static class RecyclableSingleton { + + SoftReference ref; + + final T get() { + T instance; + if (ref != null) { + instance = ref.get(); + if (instance != null) { + return instance; + } + } + instance = getInstance(); + ref = new SoftReference<>(instance); + return instance; } abstract T getInstance(); @@ -197,11 +216,11 @@ final class AquaUtils { protected abstract V getInstance(K key); } - private static final RecyclableSingleton enableAnimations = new RecyclableSingleton() { + private static final LazySingleton enableAnimations = new LazySingleton() { @Override protected Boolean getInstance() { - final String sizeProperty = System.getProperty(ANIMATIONS_PROPERTY); - return !"false".equals(sizeProperty); // should be true by default + final String animationsProperty = System.getProperty(ANIMATIONS_PROPERTY); + return !"false".equals(animationsProperty); // should be true by default } }; private static boolean animationsEnabled() { diff --git a/src/java.desktop/share/classes/sun/awt/AppContext.java b/src/java.desktop/share/classes/sun/awt/AppContext.java index 39df737badb..01b1dd09887 100644 --- a/src/java.desktop/share/classes/sun/awt/AppContext.java +++ b/src/java.desktop/share/classes/sun/awt/AppContext.java @@ -47,7 +47,6 @@ import java.util.concurrent.locks.Condition; import java.util.concurrent.locks.Lock; import java.util.concurrent.locks.ReentrantLock; import java.util.concurrent.atomic.AtomicInteger; -import java.util.function.Supplier; /** * The AppContext is a table referenced by ThreadGroup which stores @@ -735,24 +734,6 @@ public final class AppContext { } return changeSupport.getPropertyChangeListeners(propertyName); } - - public static T getSoftReferenceValue(Object key, - Supplier supplier) { - - final AppContext appContext = AppContext.getAppContext(); - @SuppressWarnings("unchecked") - SoftReference ref = (SoftReference) appContext.get(key); - if (ref != null) { - final T object = ref.get(); - if (object != null) { - return object; - } - } - final T object = supplier.get(); - ref = new SoftReference<>(object); - appContext.put(key, ref); - return object; - } } final class MostRecentKeyValue { diff --git a/src/java.desktop/share/classes/sun/awt/image/ImageCache.java b/src/java.desktop/share/classes/sun/awt/image/ImageCache.java index eed1aa5bdb7..b7ac69923da 100644 --- a/src/java.desktop/share/classes/sun/awt/image/ImageCache.java +++ b/src/java.desktop/share/classes/sun/awt/image/ImageCache.java @@ -29,7 +29,6 @@ import java.awt.*; import java.lang.ref.*; import java.util.*; import java.util.concurrent.locks.*; -import sun.awt.AppContext; /** * ImageCache - A fixed pixel count sized cache of Images keyed by arbitrary @@ -37,8 +36,6 @@ import sun.awt.AppContext; * dropped by the GC if heap memory gets tight. When our size hits max pixel * count least recently requested images are removed first. * - * The ImageCache must be used from the thread with an AppContext only. - * */ public final class ImageCache { @@ -56,9 +53,10 @@ public final class ImageCache { // Reference queue for tracking lost softreferences to images in the cache private final ReferenceQueue referenceQueue = new ReferenceQueue<>(); + private static final ImageCache instance = new ImageCache(); + public static ImageCache getInstance() { - return AppContext.getSoftReferenceValue(ImageCache.class, - () -> new ImageCache()); + return instance; } ImageCache(final int maxPixelCount) { diff --git a/test/jdk/javax/swing/Security/6657138/bug6657138.java b/test/jdk/javax/swing/Security/6657138/bug6657138.java deleted file mode 100644 index 4670d57595c..00000000000 --- a/test/jdk/javax/swing/Security/6657138/bug6657138.java +++ /dev/null @@ -1,108 +0,0 @@ -/* - * Copyright (c) 2009, 2018, Oracle and/or its affiliates. All rights reserved. - * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. - * - * This code is free software; you can redistribute 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 6657138 - * @summary Verifies that buttons and labels don't share their ui's across appContexts - * @author Alexander Potochkin - * @modules java.desktop/sun.awt - */ - -import sun.awt.SunToolkit; - -import javax.swing.*; -import javax.swing.plaf.ButtonUI; -import javax.swing.plaf.ComponentUI; -import java.util.Collections; -import java.util.HashMap; -import java.util.Map; -import java.util.Set; - -public class bug6657138 implements Runnable { - - private static Map> componentMap = - Collections.synchronizedMap( - new HashMap>()); - - public void run() { - SunToolkit.createNewAppContext(); - try { - testUIMap(); - } catch (Exception e) { - throw new RuntimeException(e); - } - } - - private static void testUIMap() throws Exception { - UIManager.LookAndFeelInfo[] lafs = UIManager.getInstalledLookAndFeels(); - Set components = componentMap.keySet(); - for (JComponent c : components) { - Map uiMap = componentMap.get(c); - - for (UIManager.LookAndFeelInfo laf : lafs) { - if ("Nimbus".equals(laf.getName())) { - // for some unclear reasons - // Nimbus ui delegate for a button is null - // when this method is called from the new AppContext - continue; - } - String className = laf.getClassName(); - try { - UIManager.setLookAndFeel(className); - } catch (final UnsupportedLookAndFeelException ignored) { - continue; - } - ComponentUI ui = UIManager.getUI(c); - if (ui == null) { - throw new RuntimeException("UI is null for " + c); - } - if (ui == uiMap.get(laf.getName())) { - throw new RuntimeException( - "Two AppContexts share the same UI delegate! \n" + - c + "\n" + ui); - } - uiMap.put(laf.getName(), ui); - } - } - } - - public static void main(String[] args) throws Exception { - componentMap.put(new JButton("JButton"), - new HashMap()); - componentMap.put(new JToggleButton("JToggleButton"), - new HashMap()); - componentMap.put(new JRadioButton("JRadioButton"), - new HashMap()); - componentMap.put(new JCheckBox("JCheckBox"), - new HashMap()); - componentMap.put(new JCheckBox("JLabel"), - new HashMap()); - testUIMap(); - ThreadGroup group = new ThreadGroup("6657138"); - Thread thread = new Thread(group, new bug6657138()); - thread.start(); - thread.join(); - } -} - From 385c4f8180d30c0e41b848eb4b2c1c8788211422 Mon Sep 17 00:00:00 2001 From: Kelvin Nilsen Date: Thu, 8 Jan 2026 20:46:38 +0000 Subject: [PATCH 106/712] 8373714: Shenandoah: Register heuristic penalties following a degenerated GC Reviewed-by: wkemper --- .../gc/shenandoah/heuristics/shenandoahAdaptiveHeuristics.cpp | 4 ++-- .../gc/shenandoah/heuristics/shenandoahAdaptiveHeuristics.hpp | 2 +- .../share/gc/shenandoah/heuristics/shenandoahHeuristics.cpp | 2 +- .../share/gc/shenandoah/heuristics/shenandoahHeuristics.hpp | 2 +- .../gc/shenandoah/heuristics/shenandoahOldHeuristics.cpp | 4 ++-- .../gc/shenandoah/heuristics/shenandoahOldHeuristics.hpp | 2 +- src/hotspot/share/gc/shenandoah/shenandoahDegeneratedGC.cpp | 4 ++++ 7 files changed, 12 insertions(+), 8 deletions(-) diff --git a/src/hotspot/share/gc/shenandoah/heuristics/shenandoahAdaptiveHeuristics.cpp b/src/hotspot/share/gc/shenandoah/heuristics/shenandoahAdaptiveHeuristics.cpp index 41535f302d7..7a8bd55c795 100644 --- a/src/hotspot/share/gc/shenandoah/heuristics/shenandoahAdaptiveHeuristics.cpp +++ b/src/hotspot/share/gc/shenandoah/heuristics/shenandoahAdaptiveHeuristics.cpp @@ -183,8 +183,8 @@ void ShenandoahAdaptiveHeuristics::record_success_concurrent() { } } -void ShenandoahAdaptiveHeuristics::record_success_degenerated() { - ShenandoahHeuristics::record_success_degenerated(); +void ShenandoahAdaptiveHeuristics::record_degenerated() { + ShenandoahHeuristics::record_degenerated(); // 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); diff --git a/src/hotspot/share/gc/shenandoah/heuristics/shenandoahAdaptiveHeuristics.hpp b/src/hotspot/share/gc/shenandoah/heuristics/shenandoahAdaptiveHeuristics.hpp index 66bfc3375a3..1ba18f37c2b 100644 --- a/src/hotspot/share/gc/shenandoah/heuristics/shenandoahAdaptiveHeuristics.hpp +++ b/src/hotspot/share/gc/shenandoah/heuristics/shenandoahAdaptiveHeuristics.hpp @@ -114,7 +114,7 @@ public: virtual void record_cycle_start() override; virtual void record_success_concurrent() override; - virtual void record_success_degenerated() override; + virtual void record_degenerated() override; virtual void record_success_full() override; virtual bool should_start_gc() override; diff --git a/src/hotspot/share/gc/shenandoah/heuristics/shenandoahHeuristics.cpp b/src/hotspot/share/gc/shenandoah/heuristics/shenandoahHeuristics.cpp index 478c5696188..eb740cfac61 100644 --- a/src/hotspot/share/gc/shenandoah/heuristics/shenandoahHeuristics.cpp +++ b/src/hotspot/share/gc/shenandoah/heuristics/shenandoahHeuristics.cpp @@ -243,7 +243,7 @@ void ShenandoahHeuristics::record_success_concurrent() { adjust_penalty(Concurrent_Adjust); } -void ShenandoahHeuristics::record_success_degenerated() { +void ShenandoahHeuristics::record_degenerated() { adjust_penalty(Degenerated_Penalty); } diff --git a/src/hotspot/share/gc/shenandoah/heuristics/shenandoahHeuristics.hpp b/src/hotspot/share/gc/shenandoah/heuristics/shenandoahHeuristics.hpp index 3cd2cb1d171..fb8cfb36353 100644 --- a/src/hotspot/share/gc/shenandoah/heuristics/shenandoahHeuristics.hpp +++ b/src/hotspot/share/gc/shenandoah/heuristics/shenandoahHeuristics.hpp @@ -218,7 +218,7 @@ public: virtual void record_success_concurrent(); - virtual void record_success_degenerated(); + virtual void record_degenerated(); virtual void record_success_full(); diff --git a/src/hotspot/share/gc/shenandoah/heuristics/shenandoahOldHeuristics.cpp b/src/hotspot/share/gc/shenandoah/heuristics/shenandoahOldHeuristics.cpp index 8bf068df0a8..029a4dd98fb 100644 --- a/src/hotspot/share/gc/shenandoah/heuristics/shenandoahOldHeuristics.cpp +++ b/src/hotspot/share/gc/shenandoah/heuristics/shenandoahOldHeuristics.cpp @@ -766,10 +766,10 @@ void ShenandoahOldHeuristics::record_success_concurrent() { this->ShenandoahHeuristics::record_success_concurrent(); } -void ShenandoahOldHeuristics::record_success_degenerated() { +void ShenandoahOldHeuristics::record_degenerated() { // Forget any triggers that occurred while OLD GC was ongoing. If we really need to start another, it will retrigger. clear_triggers(); - this->ShenandoahHeuristics::record_success_degenerated(); + this->ShenandoahHeuristics::record_degenerated(); } void ShenandoahOldHeuristics::record_success_full() { diff --git a/src/hotspot/share/gc/shenandoah/heuristics/shenandoahOldHeuristics.hpp b/src/hotspot/share/gc/shenandoah/heuristics/shenandoahOldHeuristics.hpp index 288d3d68e56..f38194c1ee7 100644 --- a/src/hotspot/share/gc/shenandoah/heuristics/shenandoahOldHeuristics.hpp +++ b/src/hotspot/share/gc/shenandoah/heuristics/shenandoahOldHeuristics.hpp @@ -201,7 +201,7 @@ public: void record_success_concurrent() override; - void record_success_degenerated() override; + void record_degenerated() override; void record_success_full() override; diff --git a/src/hotspot/share/gc/shenandoah/shenandoahDegeneratedGC.cpp b/src/hotspot/share/gc/shenandoah/shenandoahDegeneratedGC.cpp index cd079d29afe..333bdbc6e72 100644 --- a/src/hotspot/share/gc/shenandoah/shenandoahDegeneratedGC.cpp +++ b/src/hotspot/share/gc/shenandoah/shenandoahDegeneratedGC.cpp @@ -313,8 +313,12 @@ void ShenandoahDegenGC::op_degenerated() { policy->record_degenerated(_generation->is_young(), _abbreviated, progress); if (progress) { heap->notify_gc_progress(); + _generation->heuristics()->record_degenerated(); } else if (!heap->mode()->is_generational() || policy->generational_should_upgrade_degenerated_gc()) { + // Upgrade to full GC, register full-GC impact on heuristics. op_degenerated_futile(); + } else { + _generation->heuristics()->record_degenerated(); } } From 368de9ff2e46e4c66ee57b5fb961804c5d25c42a Mon Sep 17 00:00:00 2001 From: SendaoYan Date: Fri, 9 Jan 2026 02:09:37 +0000 Subject: [PATCH 107/712] 8374721: containers/docker/ShareTmpDir.java timed out after 8362087 Reviewed-by: cnorrbin, sgehwolf --- test/hotspot/jtreg/containers/docker/ShareTmpDir.java | 11 ++++++++--- 1 file changed, 8 insertions(+), 3 deletions(-) diff --git a/test/hotspot/jtreg/containers/docker/ShareTmpDir.java b/test/hotspot/jtreg/containers/docker/ShareTmpDir.java index bbf08c0dae7..986cd044737 100644 --- a/test/hotspot/jtreg/containers/docker/ShareTmpDir.java +++ b/test/hotspot/jtreg/containers/docker/ShareTmpDir.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 @@ -88,6 +88,11 @@ public class ShareTmpDir { }; t1.start(); + while (!started1.exists()) { + System.out.println("Waiting for first JVM to start"); + Thread.sleep(1000); + } + Thread t2 = new Thread() { public void run() { synchronized(lock) { @@ -98,8 +103,8 @@ public class ShareTmpDir { }; t2.start(); - while (!started1.exists() || !started2.exists()) { - System.out.println("Waiting for all two JVMs to start"); + while (!started2.exists()) { + System.out.println("Waiting for second JVM to start"); Thread.sleep(1000); } From 9932c78c238f9b7959e28a056c37a88a7f6ce958 Mon Sep 17 00:00:00 2001 From: Joe Darcy Date: Fri, 9 Jan 2026 02:27:16 +0000 Subject: [PATCH 108/712] 8374749: Clarify AnnotationValue specification Reviewed-by: liach, iris --- .../lang/model/element/AnnotationMirror.java | 4 +++- .../lang/model/element/AnnotationValue.java | 18 ++++++++++-------- 2 files changed, 13 insertions(+), 9 deletions(-) diff --git a/src/java.compiler/share/classes/javax/lang/model/element/AnnotationMirror.java b/src/java.compiler/share/classes/javax/lang/model/element/AnnotationMirror.java index 2d92504edb6..2ffed3f7942 100644 --- a/src/java.compiler/share/classes/javax/lang/model/element/AnnotationMirror.java +++ b/src/java.compiler/share/classes/javax/lang/model/element/AnnotationMirror.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 @@ -36,6 +36,8 @@ import javax.lang.model.type.DeclaredType; * method. There is no guarantee that any particular annotation will * always be represented by the same object. * + * @jls 9.6 Annotation Interfaces + * @jls 9.7 Annotations * @since 1.6 */ public interface AnnotationMirror { diff --git a/src/java.compiler/share/classes/javax/lang/model/element/AnnotationValue.java b/src/java.compiler/share/classes/javax/lang/model/element/AnnotationValue.java index 77521dac191..71594d31150 100644 --- a/src/java.compiler/share/classes/javax/lang/model/element/AnnotationValue.java +++ b/src/java.compiler/share/classes/javax/lang/model/element/AnnotationValue.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2005, 2022, 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,14 +27,16 @@ package javax.lang.model.element; /** * Represents a value of an annotation interface element. - * A value is of one of the following types: - *