Version in base suite: 17.0.17+10-1~deb12u1 Base version: openjdk-17_17.0.17+10-1~deb12u1 Target version: openjdk-17_17.0.18+8-1~deb12u1 Base file: /srv/ftp-master.debian.org/ftp/pool/main/o/openjdk-17/openjdk-17_17.0.17+10-1~deb12u1.dsc Target file: /srv/ftp-master.debian.org/policy/pool/main/o/openjdk-17/openjdk-17_17.0.18+8-1~deb12u1.dsc /srv/release.debian.org/tmp/x_MuUtmaH2/openjdk-17-17.0.18+8/test/jdk/java/awt/color/ICC_Profile/ValidateICCHeaderData/invalidSRGB.icc |binary /srv/release.debian.org/tmp/x_MuUtmaH2/openjdk-17-17.0.18+8/test/jdk/javax/swing/JTabbedPane/4287208/duke.gif |binary openjdk-17-17.0.18+8/.jcheck/conf | 2 openjdk-17-17.0.18+8/debian/JB-doc.overrides.in | 8 openjdk-17-17.0.18+8/debian/JB-jre-headless.overrides.in | 6 openjdk-17-17.0.18+8/debian/JB-jre-zero.overrides.in | 3 openjdk-17-17.0.18+8/debian/JB-jre.overrides.in | 4 openjdk-17-17.0.18+8/debian/changelog | 37 openjdk-17-17.0.18+8/debian/patches/jdk-8369450-proposed.patch | 18 openjdk-17-17.0.18+8/debian/patches/series | 1 openjdk-17-17.0.18+8/debian/rules | 5 openjdk-17-17.0.18+8/debian/source/lintian-overrides | 4 openjdk-17-17.0.18+8/debian/tests/jtreg-autopkgtest.in | 14 openjdk-17-17.0.18+8/debian/tests/jtreg-autopkgtest.sh | 15 openjdk-17-17.0.18+8/make/RunTests.gmk | 6 openjdk-17-17.0.18+8/make/autoconf/basic_tools.m4 | 2 openjdk-17-17.0.18+8/make/autoconf/flags-cflags.m4 | 4 openjdk-17-17.0.18+8/make/autoconf/flags.m4 | 10 openjdk-17-17.0.18+8/make/common/MakeBase.gmk | 2 openjdk-17-17.0.18+8/make/common/NativeCompilation.gmk | 7 openjdk-17-17.0.18+8/make/conf/jib-profiles.js | 2 openjdk-17-17.0.18+8/make/conf/version-numbers.conf | 6 openjdk-17-17.0.18+8/make/hotspot/lib/CompileGtest.gmk | 3 openjdk-17-17.0.18+8/make/hotspot/lib/CompileJvm.gmk | 61 openjdk-17-17.0.18+8/make/hotspot/lib/JvmOverrideFiles.gmk | 5 openjdk-17-17.0.18+8/make/modules/java.desktop/lib/Awt2dLibraries.gmk | 15 openjdk-17-17.0.18+8/make/test/BuildTestLib.gmk | 6 openjdk-17-17.0.18+8/src/hotspot/cpu/aarch64/aarch64.ad | 2 openjdk-17-17.0.18+8/src/hotspot/cpu/aarch64/interp_masm_aarch64.cpp | 12 openjdk-17-17.0.18+8/src/hotspot/cpu/aarch64/interp_masm_aarch64.hpp | 2 openjdk-17-17.0.18+8/src/hotspot/cpu/aarch64/templateTable_aarch64.cpp | 27 openjdk-17-17.0.18+8/src/hotspot/cpu/arm/templateTable_arm.cpp | 10 openjdk-17-17.0.18+8/src/hotspot/cpu/ppc/frame_ppc.cpp | 17 openjdk-17-17.0.18+8/src/hotspot/cpu/ppc/interp_masm_ppc.hpp | 3 openjdk-17-17.0.18+8/src/hotspot/cpu/ppc/interp_masm_ppc_64.cpp | 10 openjdk-17-17.0.18+8/src/hotspot/cpu/ppc/templateTable_ppc_64.cpp | 23 openjdk-17-17.0.18+8/src/hotspot/cpu/riscv/templateTable_riscv.cpp | 10 openjdk-17-17.0.18+8/src/hotspot/cpu/s390/templateTable_s390.cpp | 10 openjdk-17-17.0.18+8/src/hotspot/cpu/x86/assembler_x86.cpp | 5 openjdk-17-17.0.18+8/src/hotspot/cpu/x86/c1_Runtime1_x86.cpp | 7 openjdk-17-17.0.18+8/src/hotspot/cpu/x86/frame_x86.inline.hpp | 5 openjdk-17-17.0.18+8/src/hotspot/cpu/x86/gc/z/zBarrierSetAssembler_x86.cpp | 5 openjdk-17-17.0.18+8/src/hotspot/cpu/x86/macroAssembler_x86_exp.cpp | 2 openjdk-17-17.0.18+8/src/hotspot/cpu/x86/macroAssembler_x86_log.cpp | 2 openjdk-17-17.0.18+8/src/hotspot/cpu/x86/macroAssembler_x86_pow.cpp | 2 openjdk-17-17.0.18+8/src/hotspot/cpu/x86/sharedRuntime_x86_64.cpp | 5 openjdk-17-17.0.18+8/src/hotspot/cpu/x86/templateTable_x86.cpp | 10 openjdk-17-17.0.18+8/src/hotspot/cpu/x86/universalUpcallHandler_x86_64.cpp | 5 openjdk-17-17.0.18+8/src/hotspot/os/linux/cgroupSubsystem_linux.cpp | 10 openjdk-17-17.0.18+8/src/hotspot/os/posix/signals_posix.cpp | 12 openjdk-17-17.0.18+8/src/hotspot/os/windows/os_windows.cpp | 4 openjdk-17-17.0.18+8/src/hotspot/os_cpu/aix_ppc/thread_aix_ppc.cpp | 21 openjdk-17-17.0.18+8/src/hotspot/os_cpu/linux_ppc/thread_linux_ppc.cpp | 21 openjdk-17-17.0.18+8/src/hotspot/share/c1/c1_Canonicalizer.hpp | 6 openjdk-17-17.0.18+8/src/hotspot/share/classfile/classLoaderData.cpp | 17 openjdk-17-17.0.18+8/src/hotspot/share/classfile/dictionary.cpp | 8 openjdk-17-17.0.18+8/src/hotspot/share/classfile/dictionary.hpp | 3 openjdk-17-17.0.18+8/src/hotspot/share/classfile/verifier.cpp | 229 openjdk-17-17.0.18+8/src/hotspot/share/classfile/verifier.hpp | 13 openjdk-17-17.0.18+8/src/hotspot/share/gc/g1/g1GCPhaseTimes.cpp | 2 openjdk-17-17.0.18+8/src/hotspot/share/gc/shared/weakProcessorTimes.cpp | 2 openjdk-17-17.0.18+8/src/hotspot/share/gc/shared/workerDataArray.cpp | 9 openjdk-17-17.0.18+8/src/hotspot/share/gc/shenandoah/c2/shenandoahSupport.cpp | 87 openjdk-17-17.0.18+8/src/hotspot/share/gc/shenandoah/c2/shenandoahSupport.hpp | 11 openjdk-17-17.0.18+8/src/hotspot/share/gc/shenandoah/shenandoahHeap.cpp | 27 openjdk-17-17.0.18+8/src/hotspot/share/gc/shenandoah/shenandoahHeap.hpp | 2 openjdk-17-17.0.18+8/src/hotspot/share/interpreter/templateTable.cpp | 12 openjdk-17-17.0.18+8/src/hotspot/share/interpreter/templateTable.hpp | 12 openjdk-17-17.0.18+8/src/hotspot/share/memory/guardedMemory.cpp | 9 openjdk-17-17.0.18+8/src/hotspot/share/memory/guardedMemory.hpp | 58 openjdk-17-17.0.18+8/src/hotspot/share/opto/compile.cpp | 2 openjdk-17-17.0.18+8/src/hotspot/share/opto/vector.cpp | 11 openjdk-17-17.0.18+8/src/hotspot/share/prims/jniCheck.cpp | 48 openjdk-17-17.0.18+8/src/hotspot/share/runtime/abstract_vm_version.cpp | 12 openjdk-17-17.0.18+8/src/hotspot/share/runtime/flags/jvmFlagConstraintsRuntime.cpp | 10 openjdk-17-17.0.18+8/src/hotspot/share/runtime/flags/jvmFlagConstraintsRuntime.hpp | 3 openjdk-17-17.0.18+8/src/hotspot/share/runtime/globals.hpp | 4 openjdk-17-17.0.18+8/src/hotspot/share/utilities/compilerWarnings.hpp | 4 openjdk-17-17.0.18+8/src/hotspot/share/utilities/compilerWarnings_gcc.hpp | 3 openjdk-17-17.0.18+8/src/hotspot/share/utilities/exceptions.cpp | 4 openjdk-17-17.0.18+8/src/java.base/share/classes/java/net/InMemoryCookieStore.java | 18 openjdk-17-17.0.18+8/src/java.base/share/classes/java/text/Collator.java | 9 openjdk-17-17.0.18+8/src/java.base/share/classes/java/text/RuleBasedCollator.java | 11 openjdk-17-17.0.18+8/src/java.base/share/classes/java/util/SimpleTimeZone.java | 27 openjdk-17-17.0.18+8/src/java.base/share/classes/java/util/concurrent/CopyOnWriteArraySet.java | 41 openjdk-17-17.0.18+8/src/java.base/share/classes/java/util/regex/Pattern.java | 8 openjdk-17-17.0.18+8/src/java.base/share/classes/jdk/internal/module/ModuleInfoWriter.java | 231 openjdk-17-17.0.18+8/src/java.base/share/classes/sun/nio/ch/Net.java | 13 openjdk-17-17.0.18+8/src/java.base/share/classes/sun/nio/ch/SocketChannelImpl.java | 31 openjdk-17-17.0.18+8/src/java.base/share/classes/sun/nio/cs/StreamDecoder.java | 1 openjdk-17-17.0.18+8/src/java.base/share/classes/sun/security/provider/certpath/URICertStore.java | 358 + openjdk-17-17.0.18+8/src/java.base/share/classes/sun/security/ssl/DTLSInputRecord.java | 9 openjdk-17-17.0.18+8/src/java.base/share/classes/sun/security/ssl/SignatureScheme.java | 5 openjdk-17-17.0.18+8/src/java.base/share/classes/sun/util/calendar/ZoneInfo.java | 10 openjdk-17-17.0.18+8/src/java.base/share/classes/sun/util/calendar/ZoneInfoFile.java | 26 openjdk-17-17.0.18+8/src/java.base/share/conf/security/java.security | 48 openjdk-17-17.0.18+8/src/java.base/unix/native/libjava/TimeZone_md.c | 32 openjdk-17-17.0.18+8/src/java.base/unix/native/libnio/ch/Net.c | 5 openjdk-17-17.0.18+8/src/java.base/windows/native/include/jni_md.h | 7 openjdk-17-17.0.18+8/src/java.base/windows/native/libnio/ch/Net.c | 7 openjdk-17-17.0.18+8/src/java.desktop/macosx/classes/com/apple/laf/AquaFileChooserUI.java | 6 openjdk-17-17.0.18+8/src/java.desktop/macosx/classes/com/apple/laf/AquaKeyBindings.java | 6 openjdk-17-17.0.18+8/src/java.desktop/macosx/classes/sun/lwawt/macosx/CDesktopPeer.java | 57 openjdk-17-17.0.18+8/src/java.desktop/macosx/native/libawt_lwawt/awt/CDesktopPeer.m | 126 openjdk-17-17.0.18+8/src/java.desktop/macosx/native/libjsound/PLATFORM_API_MacOSX_Ports.cpp | 83 openjdk-17-17.0.18+8/src/java.desktop/share/classes/com/sun/beans/introspect/MethodInfo.java | 14 openjdk-17-17.0.18+8/src/java.desktop/share/classes/com/sun/beans/introspect/PropertyInfo.java | 20 openjdk-17-17.0.18+8/src/java.desktop/share/classes/com/sun/java/swing/SwingUtilities3.java | 164 openjdk-17-17.0.18+8/src/java.desktop/share/classes/com/sun/java/swing/plaf/gtk/GTKFileChooserUI.java | 6 openjdk-17-17.0.18+8/src/java.desktop/share/classes/com/sun/java/swing/plaf/motif/MotifFileChooserUI.java | 6 openjdk-17-17.0.18+8/src/java.desktop/share/classes/com/sun/media/sound/AudioFileSoundbankReader.java | 9 openjdk-17-17.0.18+8/src/java.desktop/share/classes/java/awt/AWTEventMulticaster.java | 62 openjdk-17-17.0.18+8/src/java.desktop/share/classes/java/awt/color/ICC_ColorSpace.java | 5 openjdk-17-17.0.18+8/src/java.desktop/share/classes/java/awt/color/ICC_Profile.java | 65 openjdk-17-17.0.18+8/src/java.desktop/share/classes/java/beans/Introspector.java | 10 openjdk-17-17.0.18+8/src/java.desktop/share/classes/javax/swing/JFileChooser.java | 1 openjdk-17-17.0.18+8/src/java.desktop/share/classes/javax/swing/JViewport.java | 2 openjdk-17-17.0.18+8/src/java.desktop/share/classes/javax/swing/TablePrintable.java | 15 openjdk-17-17.0.18+8/src/java.desktop/share/classes/javax/swing/border/EtchedBorder.java | 61 openjdk-17-17.0.18+8/src/java.desktop/share/classes/javax/swing/border/LineBorder.java | 63 openjdk-17-17.0.18+8/src/java.desktop/share/classes/javax/swing/plaf/basic/BasicOptionPaneUI.java | 107 openjdk-17-17.0.18+8/src/java.desktop/share/classes/javax/swing/plaf/basic/BasicPasswordFieldUI.java | 21 openjdk-17-17.0.18+8/src/java.desktop/share/classes/javax/swing/plaf/basic/BasicTableUI.java | 17 openjdk-17-17.0.18+8/src/java.desktop/share/classes/javax/swing/plaf/basic/BasicTextUI.java | 18 openjdk-17-17.0.18+8/src/java.desktop/share/classes/javax/swing/plaf/metal/MetalBorders.java | 68 openjdk-17-17.0.18+8/src/java.desktop/share/classes/javax/swing/plaf/metal/MetalFileChooserUI.java | 2 openjdk-17-17.0.18+8/src/java.desktop/share/classes/javax/swing/plaf/synth/SynthPasswordFieldUI.java | 17 openjdk-17-17.0.18+8/src/java.desktop/share/classes/sun/awt/datatransfer/SunClipboard.java | 22 openjdk-17-17.0.18+8/src/java.desktop/share/classes/sun/java2d/SunGraphics2D.java | 6 openjdk-17-17.0.18+8/src/java.desktop/share/classes/sun/java2d/pipe/SpanClipRenderer.java | 8 openjdk-17-17.0.18+8/src/java.desktop/share/classes/sun/print/PathGraphics.java | 18 openjdk-17-17.0.18+8/src/java.desktop/share/classes/sun/swing/FilePane.java | 4 openjdk-17-17.0.18+8/src/java.desktop/share/classes/sun/swing/SwingUtilities2.java | 2 openjdk-17-17.0.18+8/src/java.desktop/share/classes/sun/swing/plaf/synth/SynthFileChooserUIImpl.java | 2 openjdk-17-17.0.18+8/src/java.desktop/share/legal/libpng.md | 12 openjdk-17-17.0.18+8/src/java.desktop/share/native/common/java2d/opengl/OGLContext.c | 1 openjdk-17-17.0.18+8/src/java.desktop/share/native/libmlib_image/mlib_ImageConvMxN_Fp.c | 9 openjdk-17-17.0.18+8/src/java.desktop/share/native/libmlib_image/mlib_ImageConvMxN_ext.c | 6 openjdk-17-17.0.18+8/src/java.desktop/share/native/libmlib_image/mlib_ImageConv_16ext.c | 23 openjdk-17-17.0.18+8/src/java.desktop/share/native/libmlib_image/mlib_ImageConv_16nw.c | 7 openjdk-17-17.0.18+8/src/java.desktop/share/native/libmlib_image/mlib_ImageConv_32nw.c | 7 openjdk-17-17.0.18+8/src/java.desktop/share/native/libmlib_image/mlib_ImageConv_8ext.c | 23 openjdk-17-17.0.18+8/src/java.desktop/share/native/libmlib_image/mlib_ImageConv_8nw.c | 7 openjdk-17-17.0.18+8/src/java.desktop/share/native/libmlib_image/mlib_ImageConv_u16ext.c | 23 openjdk-17-17.0.18+8/src/java.desktop/share/native/libmlib_image/mlib_ImageConv_u16nw.c | 7 openjdk-17-17.0.18+8/src/java.desktop/share/native/libmlib_image/mlib_ImageLookUp_Bit.c | 12 openjdk-17-17.0.18+8/src/java.desktop/share/native/libmlib_image/mlib_ImageScanPoly.c | 11 openjdk-17-17.0.18+8/src/java.desktop/share/native/libsplashscreen/splashscreen_gif.c | 6 openjdk-17-17.0.18+8/src/java.desktop/unix/classes/sun/awt/PlatformGraphicsInfo.java | 41 openjdk-17-17.0.18+8/src/java.desktop/unix/native/libawt_xawt/awt/awt_GraphicsEnv.c | 10 openjdk-17-17.0.18+8/src/java.desktop/windows/classes/com/sun/java/swing/plaf/windows/WindowsFileChooserUI.java | 2 openjdk-17-17.0.18+8/src/java.desktop/windows/classes/com/sun/java/swing/plaf/windows/WindowsIconFactory.java | 28 openjdk-17-17.0.18+8/src/java.desktop/windows/classes/com/sun/java/swing/plaf/windows/WindowsInternalFrameTitlePane.java | 60 openjdk-17-17.0.18+8/src/java.desktop/windows/classes/com/sun/java/swing/plaf/windows/WindowsMenuItemUI.java | 20 openjdk-17-17.0.18+8/src/java.desktop/windows/classes/sun/awt/windows/ThemeReader.java | 19 openjdk-17-17.0.18+8/src/java.desktop/windows/classes/sun/awt/windows/WClipboard.java | 52 openjdk-17-17.0.18+8/src/java.desktop/windows/classes/sun/awt/windows/WDesktopPeer.java | 53 openjdk-17-17.0.18+8/src/java.desktop/windows/classes/sun/awt/windows/WInputMethod.java | 6 openjdk-17-17.0.18+8/src/java.desktop/windows/native/libawt/java2d/windows/GDIRenderer.cpp | 8 openjdk-17-17.0.18+8/src/java.desktop/windows/native/libawt/java2d/windows/GDIWindowSurfaceData.cpp | 4 openjdk-17-17.0.18+8/src/java.desktop/windows/native/libawt/windows/ShellFolder2.cpp | 8 openjdk-17-17.0.18+8/src/java.desktop/windows/native/libawt/windows/WPrinterJob.cpp | 6 openjdk-17-17.0.18+8/src/java.desktop/windows/native/libawt/windows/awt_Clipboard.cpp | 45 openjdk-17-17.0.18+8/src/java.desktop/windows/native/libawt/windows/awt_Debug.cpp | 2 openjdk-17-17.0.18+8/src/java.desktop/windows/native/libawt/windows/awt_Desktop.cpp | 49 openjdk-17-17.0.18+8/src/java.desktop/windows/native/libawt/windows/awt_DesktopProperties.cpp | 14 openjdk-17-17.0.18+8/src/java.desktop/windows/native/libawt/windows/awt_DrawingSurface.cpp | 2 openjdk-17-17.0.18+8/src/java.desktop/windows/native/libawt/windows/awt_Font.cpp | 6 openjdk-17-17.0.18+8/src/java.desktop/windows/native/libawt/windows/awt_Font.h | 2 openjdk-17-17.0.18+8/src/java.desktop/windows/native/libawt/windows/awt_Menu.h | 4 openjdk-17-17.0.18+8/src/java.desktop/windows/native/libawt/windows/awt_MenuBar.cpp | 4 openjdk-17-17.0.18+8/src/java.desktop/windows/native/libawt/windows/awt_MenuBar.h | 4 openjdk-17-17.0.18+8/src/java.desktop/windows/native/libawt/windows/awt_PrintControl.cpp | 2 openjdk-17-17.0.18+8/src/java.desktop/windows/native/libawt/windows/awt_PrintJob.cpp | 6 openjdk-17-17.0.18+8/src/java.desktop/windows/native/libawt/windows/awt_Toolkit.cpp | 2 openjdk-17-17.0.18+8/src/java.desktop/windows/native/libawt/windows/awt_Win32GraphicsEnv.cpp | 2 openjdk-17-17.0.18+8/src/java.management/share/classes/javax/management/remote/package.html | 30 openjdk-17-17.0.18+8/src/java.net.http/share/classes/jdk/internal/net/http/Http1Request.java | 26 openjdk-17-17.0.18+8/src/java.rmi/share/classes/javax/rmi/ssl/SslRMIClientSocketFactory.java | 13 openjdk-17-17.0.18+8/src/java.security.jgss/windows/native/libsspi_bridge/sspi.cpp | 10 openjdk-17-17.0.18+8/src/jdk.accessibility/windows/native/common/AccessBridgeDebug.cpp | 12 openjdk-17-17.0.18+8/src/jdk.accessibility/windows/native/common/AccessBridgeDebug.h | 12 openjdk-17-17.0.18+8/src/jdk.accessibility/windows/native/jabswitch/jabswitch.cpp | 7 openjdk-17-17.0.18+8/src/jdk.accessibility/windows/native/jaccessinspector/jaccessinspector.cpp | 2 openjdk-17-17.0.18+8/src/jdk.accessibility/windows/native/jaccesswalker/jaccesswalker.cpp | 2 openjdk-17-17.0.18+8/src/jdk.accessibility/windows/native/libwindowsaccessbridge/AccessBridgeEventHandler.cpp | 2 openjdk-17-17.0.18+8/src/jdk.accessibility/windows/native/libwindowsaccessbridge/AccessBridgeJavaVMInstance.cpp | 2 openjdk-17-17.0.18+8/src/jdk.accessibility/windows/native/libwindowsaccessbridge/AccessBridgeMessageQueue.cpp | 2 openjdk-17-17.0.18+8/src/jdk.accessibility/windows/native/libwindowsaccessbridge/WinAccessBridge.cpp | 2 openjdk-17-17.0.18+8/src/jdk.accessibility/windows/native/toolscommon/AccessInfo.cpp | 8 openjdk-17-17.0.18+8/src/jdk.accessibility/windows/native/toolscommon/AccessInfo.h | 2 openjdk-17-17.0.18+8/src/jdk.compiler/share/classes/com/sun/tools/sjavac/server/PortFile.java | 44 openjdk-17-17.0.18+8/src/jdk.crypto.cryptoki/share/native/libj2pkcs11/p11_convert.c | 3 openjdk-17-17.0.18+8/src/jdk.crypto.cryptoki/share/native/libj2pkcs11/p11_crypt.c | 38 openjdk-17-17.0.18+8/src/jdk.crypto.cryptoki/share/native/libj2pkcs11/p11_keymgmt.c | 103 openjdk-17-17.0.18+8/src/jdk.crypto.cryptoki/share/native/libj2pkcs11/p11_util.c | 2 openjdk-17-17.0.18+8/src/jdk.crypto.mscapi/windows/native/libsunmscapi/security.cpp | 6 openjdk-17-17.0.18+8/src/jdk.httpserver/share/classes/com/sun/net/httpserver/Headers.java | 36 openjdk-17-17.0.18+8/src/jdk.httpserver/share/classes/sun/net/httpserver/ExchangeImpl.java | 25 openjdk-17-17.0.18+8/src/jdk.httpserver/share/classes/sun/net/httpserver/Utils.java | 65 openjdk-17-17.0.18+8/src/jdk.jartool/share/classes/sun/security/tools/jarsigner/Main.java | 148 openjdk-17-17.0.18+8/src/jdk.jartool/share/classes/sun/security/tools/jarsigner/Resources.java | 28 openjdk-17-17.0.18+8/src/jdk.jartool/share/man/jarsigner.1 | 7 openjdk-17-17.0.18+8/src/jdk.jfr/share/conf/jfr/default.jfc | 12 openjdk-17-17.0.18+8/src/jdk.jpackage/windows/classes/jdk/jpackage/internal/WindowsAppImageBuilder.java | 7 openjdk-17-17.0.18+8/src/jdk.jpackage/windows/classes/jdk/jpackage/internal/WixAppImageFragmentBuilder.java | 6 openjdk-17-17.0.18+8/src/jdk.jpackage/windows/native/applauncher/WinLauncher.cpp | 25 openjdk-17-17.0.18+8/src/jdk.jpackage/windows/native/common/Executor.cpp | 6 openjdk-17-17.0.18+8/src/jdk.jpackage/windows/native/common/Executor.h | 13 openjdk-17-17.0.18+8/src/jdk.jpackage/windows/native/libwixhelper/libwixhelper.cpp | 2 openjdk-17-17.0.18+8/src/jdk.management/linux/native/libmanagement_ext/UnixOperatingSystem.c | 4 openjdk-17-17.0.18+8/src/utils/LogCompilation/src/main/java/com/sun/hotspot/tools/compiler/LogParser.java | 1 openjdk-17-17.0.18+8/src/utils/LogCompilation/src/test/java/com/sun/hotspot/tools/compiler/TestPrebuiltLogs.java | 87 openjdk-17-17.0.18+8/src/utils/LogCompilation/src/test/resources/8314319.xml | 526 ++ openjdk-17-17.0.18+8/test/failure_handler/src/share/conf/linux.properties | 5 openjdk-17-17.0.18+8/test/failure_handler/src/share/conf/mac.properties | 5 openjdk-17-17.0.18+8/test/failure_handler/src/share/conf/windows.properties | 6 openjdk-17-17.0.18+8/test/hotspot/gtest/gc/shared/test_workerDataArray.cpp | 10 openjdk-17-17.0.18+8/test/hotspot/gtest/logging/test_asynclog.cpp | 38 openjdk-17-17.0.18+8/test/hotspot/gtest/memory/test_guardedMemory.cpp | 17 openjdk-17-17.0.18+8/test/hotspot/gtest/os/linux/test_cgroupSubsystem_linux.cpp | 11 openjdk-17-17.0.18+8/test/hotspot/gtest/runtime/test_arguments.cpp | 5 openjdk-17-17.0.18+8/test/hotspot/gtest/runtime/test_os_windows.cpp | 20 openjdk-17-17.0.18+8/test/hotspot/jtreg/TEST.ROOT | 9 openjdk-17-17.0.18+8/test/hotspot/jtreg/compiler/arraycopy/TestIllegalArrayCopyBeforeInfiniteLoop.java | 2 openjdk-17-17.0.18+8/test/hotspot/jtreg/compiler/arraycopy/TestNegArrayLengthAsIndex1.java | 2 openjdk-17-17.0.18+8/test/hotspot/jtreg/compiler/arraycopy/TestNegArrayLengthAsIndex2.java | 2 openjdk-17-17.0.18+8/test/hotspot/jtreg/compiler/arraycopy/TestNegativeArrayCopyAfterLoop.java | 2 openjdk-17-17.0.18+8/test/hotspot/jtreg/compiler/c1/TestRangeCheckEliminated.java | 2 openjdk-17-17.0.18+8/test/hotspot/jtreg/compiler/c2/Test7046096.java | 14 openjdk-17-17.0.18+8/test/hotspot/jtreg/compiler/c2/Test7179138_2.java | 13 openjdk-17-17.0.18+8/test/hotspot/jtreg/compiler/c2/cr6865031/Test.java | 2 openjdk-17-17.0.18+8/test/hotspot/jtreg/compiler/debug/TraceIterativeGVN.java | 2 openjdk-17-17.0.18+8/test/hotspot/jtreg/compiler/intrinsics/math/TestPow0Dot5Opt.java | 2 openjdk-17-17.0.18+8/test/hotspot/jtreg/compiler/intrinsics/math/TestPow2Opt.java | 2 openjdk-17-17.0.18+8/test/hotspot/jtreg/compiler/intrinsics/sha/cli/TestUseSHA3IntrinsicsOptionOnSupportedCPU.java | 2 openjdk-17-17.0.18+8/test/hotspot/jtreg/compiler/intrinsics/sha/cli/TestUseSHA3IntrinsicsOptionOnUnsupportedCPU.java | 2 openjdk-17-17.0.18+8/test/hotspot/jtreg/compiler/jvmci/errors/TestInvalidTieredStopAtLevel.java | 2 openjdk-17-17.0.18+8/test/hotspot/jtreg/compiler/lib/compile_framework/Compile.java | 6 openjdk-17-17.0.18+8/test/hotspot/jtreg/compiler/lib/ir_framework/driver/TestVMProcess.java | 4 openjdk-17-17.0.18+8/test/hotspot/jtreg/compiler/loopopts/TestLoopEndNodeEliminate.java | 2 openjdk-17-17.0.18+8/test/hotspot/jtreg/compiler/loopopts/TestLoopPredicateDep.java | 2 openjdk-17-17.0.18+8/test/hotspot/jtreg/compiler/loopopts/TestSkeletonPredicateNegation.java | 2 openjdk-17-17.0.18+8/test/hotspot/jtreg/compiler/oracle/TestInvalidCompileCommand.java | 2 openjdk-17-17.0.18+8/test/hotspot/jtreg/compiler/regalloc/TestGCMRecalcPressureNodes.java | 3 openjdk-17-17.0.18+8/test/hotspot/jtreg/compiler/unsafe/TestMisalignedUnsafeAccess.java | 2 openjdk-17-17.0.18+8/test/hotspot/jtreg/compiler/vectorapi/TestIntrinsicBailOut.java | 2 openjdk-17-17.0.18+8/test/hotspot/jtreg/compiler/vectorapi/TestLoopStoreVector.java | 10 openjdk-17-17.0.18+8/test/hotspot/jtreg/compiler/vectorapi/TestVectorErgonomics.java | 2 openjdk-17-17.0.18+8/test/hotspot/jtreg/compiler/vectorapi/VectorReinterpretTest.java | 2 openjdk-17-17.0.18+8/test/hotspot/jtreg/containers/docker/DockerBasicTest.java | 4 openjdk-17-17.0.18+8/test/hotspot/jtreg/containers/docker/ShareTmpDir.java | 4 openjdk-17-17.0.18+8/test/hotspot/jtreg/containers/docker/TestCPUAwareness.java | 4 openjdk-17-17.0.18+8/test/hotspot/jtreg/containers/docker/TestCPUSets.java | 4 openjdk-17-17.0.18+8/test/hotspot/jtreg/containers/docker/TestContainerInfo.java | 3 openjdk-17-17.0.18+8/test/hotspot/jtreg/containers/docker/TestJFREvents.java | 2 openjdk-17-17.0.18+8/test/hotspot/jtreg/containers/docker/TestJFRNetworkEvents.java | 4 openjdk-17-17.0.18+8/test/hotspot/jtreg/containers/docker/TestJFRWithJMX.java | 4 openjdk-17-17.0.18+8/test/hotspot/jtreg/containers/docker/TestJcmd.java | 24 openjdk-17-17.0.18+8/test/hotspot/jtreg/containers/docker/TestJcmdWithSideCar.java | 4 openjdk-17-17.0.18+8/test/hotspot/jtreg/containers/docker/TestLimitsUpdating.java | 3 openjdk-17-17.0.18+8/test/hotspot/jtreg/containers/docker/TestMemoryAwareness.java | 4 openjdk-17-17.0.18+8/test/hotspot/jtreg/containers/docker/TestMemoryWithCgroupV1.java | 2 openjdk-17-17.0.18+8/test/hotspot/jtreg/containers/docker/TestMisc.java | 4 openjdk-17-17.0.18+8/test/hotspot/jtreg/containers/docker/TestPids.java | 2 openjdk-17-17.0.18+8/test/hotspot/jtreg/gc/g1/TestBuffersToCardsOverflow.java | 2 openjdk-17-17.0.18+8/test/hotspot/jtreg/gc/g1/plab/TestPLABEvacuationFailure.java | 1 openjdk-17-17.0.18+8/test/hotspot/jtreg/gc/g1/plab/lib/PLABUtils.java | 14 openjdk-17-17.0.18+8/test/hotspot/jtreg/gc/shenandoah/compiler/TestLostAntiDependencyAtExpansion.java | 67 openjdk-17-17.0.18+8/test/hotspot/jtreg/gtest/GTestWrapper.java | 3 openjdk-17-17.0.18+8/test/hotspot/jtreg/gtest/MetaspaceUtilsGtests.java | 2 openjdk-17-17.0.18+8/test/hotspot/jtreg/runtime/ClassUnload/ConstantPoolDependsTest.java | 7 openjdk-17-17.0.18+8/test/hotspot/jtreg/runtime/ClassUnload/DictionaryDependsTest.java | 12 openjdk-17-17.0.18+8/test/hotspot/jtreg/runtime/ClassUnload/KeepAliveClass.java | 14 openjdk-17-17.0.18+8/test/hotspot/jtreg/runtime/ClassUnload/KeepAliveClassLoader.java | 13 openjdk-17-17.0.18+8/test/hotspot/jtreg/runtime/ClassUnload/KeepAliveObject.java | 19 openjdk-17-17.0.18+8/test/hotspot/jtreg/runtime/ClassUnload/KeepAliveSoftReference.java | 6 openjdk-17-17.0.18+8/test/hotspot/jtreg/runtime/ClassUnload/SuperDependsTest.java | 10 openjdk-17-17.0.18+8/test/hotspot/jtreg/runtime/ClassUnload/UnloadInterfaceTest.java | 11 openjdk-17-17.0.18+8/test/hotspot/jtreg/runtime/ClassUnload/UnloadTest.java | 23 openjdk-17-17.0.18+8/test/hotspot/jtreg/runtime/LoadClass/TestResize.java | 62 openjdk-17-17.0.18+8/test/hotspot/jtreg/runtime/Thread/TooSmallStackSize.java | 1 openjdk-17-17.0.18+8/test/hotspot/jtreg/runtime/cds/appcds/customLoader/test-classes/HelloUnload.java | 8 openjdk-17-17.0.18+8/test/hotspot/jtreg/runtime/cds/appcds/customLoader/test-classes/UnloadUnregisteredLoader.java | 8 openjdk-17-17.0.18+8/test/hotspot/jtreg/runtime/jni/checked/TestCharArrayReleasing.java | 129 openjdk-17-17.0.18+8/test/hotspot/jtreg/runtime/jni/checked/libCharArrayReleasing.c | 125 openjdk-17-17.0.18+8/test/hotspot/jtreg/runtime/logging/ClassLoadUnloadTest.java | 4 openjdk-17-17.0.18+8/test/hotspot/jtreg/runtime/signal/SigTestDriver.java | 10 openjdk-17-17.0.18+8/test/hotspot/jtreg/runtime/signal/TestSigusr2.java | 35 openjdk-17-17.0.18+8/test/hotspot/jtreg/serviceability/dcmd/framework/TestProcessModuleLauncher.java | 4 openjdk-17-17.0.18+8/test/hotspot/jtreg/serviceability/dcmd/framework/VMVersionTest.java | 12 openjdk-17-17.0.18+8/test/hotspot/jtreg/serviceability/jvmti/VMEvent/libVMEventTest.c | 42 openjdk-17-17.0.18+8/test/hotspot/jtreg/serviceability/tmtools/jstat/GarbageProducerTest.java | 15 openjdk-17-17.0.18+8/test/hotspot/jtreg/serviceability/tmtools/jstat/GcNewTest.java | 11 openjdk-17-17.0.18+8/test/hotspot/jtreg/serviceability/tmtools/jstat/GcTest01.java | 15 openjdk-17-17.0.18+8/test/hotspot/jtreg/serviceability/tmtools/jstat/GcTest02.java | 4 openjdk-17-17.0.18+8/test/hotspot/jtreg/serviceability/tmtools/jstat/utils/JstatGcCapacityTool.java | 5 openjdk-17-17.0.18+8/test/hotspot/jtreg/serviceability/tmtools/jstat/utils/JstatGcCauseTool.java | 5 openjdk-17-17.0.18+8/test/hotspot/jtreg/serviceability/tmtools/jstat/utils/JstatGcNewTool.java | 5 openjdk-17-17.0.18+8/test/hotspot/jtreg/serviceability/tmtools/jstat/utils/JstatGcTool.java | 5 openjdk-17-17.0.18+8/test/hotspot/jtreg/serviceability/tmtools/jstat/utils/JstatResults.java | 6 openjdk-17-17.0.18+8/test/hotspot/jtreg/serviceability/tmtools/jstat/utils/JstatTool.java | 59 openjdk-17-17.0.18+8/test/hotspot/jtreg/testlibrary/jittester/src/jdk/test/lib/jittester/Automatic.java | 122 openjdk-17-17.0.18+8/test/hotspot/jtreg/testlibrary/jittester/src/jdk/test/lib/jittester/ByteCodeGenerator.java | 26 openjdk-17-17.0.18+8/test/hotspot/jtreg/testlibrary/jittester/src/jdk/test/lib/jittester/IRTreeGenerator.java | 97 openjdk-17-17.0.18+8/test/hotspot/jtreg/testlibrary/jittester/src/jdk/test/lib/jittester/JavaCodeGenerator.java | 23 openjdk-17-17.0.18+8/test/hotspot/jtreg/testlibrary/jittester/src/jdk/test/lib/jittester/ProductionLimiter.java | 26 openjdk-17-17.0.18+8/test/hotspot/jtreg/testlibrary/jittester/src/jdk/test/lib/jittester/ProductionParams.java | 27 openjdk-17-17.0.18+8/test/hotspot/jtreg/testlibrary/jittester/src/jdk/test/lib/jittester/TestsGenerator.java | 9 openjdk-17-17.0.18+8/test/hotspot/jtreg/testlibrary/jittester/src/jdk/test/lib/jittester/utils/OptionResolver.java | 22 openjdk-17-17.0.18+8/test/hotspot/jtreg/vmTestbase/gc/gctests/AllocateWithoutOomTest/AllocateWithoutOomTest.java | 4 openjdk-17-17.0.18+8/test/hotspot/jtreg/vmTestbase/nsk/share/jdb/Launcher.java | 6 openjdk-17-17.0.18+8/test/hotspot/jtreg/vmTestbase/nsk/share/jpda/BindServer.java | 1888 ------- openjdk-17-17.0.18+8/test/hotspot/jtreg/vmTestbase/nsk/share/jpda/DebugeeArgumentHandler.java | 44 openjdk-17-17.0.18+8/test/hotspot/jtreg/vmTestbase/nsk/share/jpda/DebugeeBinder.java | 4 openjdk-17-17.0.18+8/test/hotspot/jtreg/vmTestbase/nsk/share/jpda/DebugeeProcess.java | 4 openjdk-17-17.0.18+8/test/hotspot/jtreg/vmTestbase/nsk/share/jpda/IOPipe.java | 10 openjdk-17-17.0.18+8/test/hotspot/jtreg/vmTestbase/nsk/share/test/Stresser.java | 38 openjdk-17-17.0.18+8/test/hotspot/jtreg/vmTestbase/vm/compiler/optimizations/stringconcat/implicit/Implicit01/cs_disabled/TestDescription.java | 16 openjdk-17-17.0.18+8/test/hotspot/jtreg/vmTestbase/vm/compiler/optimizations/stringconcat/implicit/Implicit01/cs_enabled/TestDescription.java | 16 openjdk-17-17.0.18+8/test/hotspot/jtreg/vmTestbase/vm/compiler/optimizations/stringconcat/implicit/Merge01/cs_disabled/TestDescription.java | 16 openjdk-17-17.0.18+8/test/hotspot/jtreg/vmTestbase/vm/compiler/optimizations/stringconcat/implicit/Merge01/cs_enabled/TestDescription.java | 16 openjdk-17-17.0.18+8/test/hotspot/jtreg/vmTestbase/vm/gc/compact/Compact_InternedStrings_Strings/TestDescription.java | 4 openjdk-17-17.0.18+8/test/hotspot/jtreg/vmTestbase/vm/gc/compact/Compact_NonbranchyTree/TestDescription.java | 4 openjdk-17-17.0.18+8/test/hotspot/jtreg/vmTestbase/vm/gc/compact/Compact_NonbranchyTree_ArrayOf/TestDescription.java | 4 openjdk-17-17.0.18+8/test/hotspot/jtreg/vmTestbase/vm/gc/compact/Compact_NonbranchyTree_TwoFields/TestDescription.java | 4 openjdk-17-17.0.18+8/test/hotspot/jtreg/vmTestbase/vm/gc/compact/Compact_Strings/TestDescription.java | 4 openjdk-17-17.0.18+8/test/hotspot/jtreg/vmTestbase/vm/gc/compact/Compact_Strings_InternedStrings/TestDescription.java | 4 openjdk-17-17.0.18+8/test/hotspot/jtreg/vmTestbase/vm/gc/compact/Compact_Strings_TwoFields/TestDescription.java | 4 openjdk-17-17.0.18+8/test/hotspot/jtreg/vmTestbase/vm/gc/compact/Humongous_NonbranchyTree/TestDescription.java | 4 openjdk-17-17.0.18+8/test/hotspot/jtreg/vmTestbase/vm/gc/compact/Humongous_Strings/TestDescription.java | 4 openjdk-17-17.0.18+8/test/hotspot/jtreg/vmTestbase/vm/mlvm/indy/func/jvmti/stepBreakPopReturn/stepBreakPopReturn.cpp | 6 openjdk-17-17.0.18+8/test/jdk/ProblemList.txt | 45 openjdk-17-17.0.18+8/test/jdk/TEST.ROOT | 13 openjdk-17-17.0.18+8/test/jdk/TEST.groups | 3 openjdk-17-17.0.18+8/test/jdk/com/sun/java/swing/plaf/windows/MenuItem/AcceleratorDelimiter/WindowsLAFMenuAcceleratorDelimiter.java | 95 openjdk-17-17.0.18+8/test/jdk/com/sun/java/swing/plaf/windows/WindowsDesktopManager/4227768/bug4227768.java | 99 openjdk-17-17.0.18+8/test/jdk/com/sun/java/swing/plaf/windows/WindowsDesktopManager/4305725/bug4305725.java | 97 openjdk-17-17.0.18+8/test/jdk/com/sun/net/httpserver/ExchangeAttributeTest.java | 115 openjdk-17-17.0.18+8/test/jdk/com/sun/net/httpserver/FileServerHandler.java | 28 openjdk-17-17.0.18+8/test/jdk/com/sun/net/httpserver/Test12.java | 179 openjdk-17-17.0.18+8/test/jdk/com/sun/nio/sctp/SctpChannel/CloseDescriptors.java | 12 openjdk-17-17.0.18+8/test/jdk/com/sun/security/auth/login/ConfigFile/TEST.properties | 2 openjdk-17-17.0.18+8/test/jdk/com/sun/security/sasl/gsskerb/AuthOnly.java | 174 openjdk-17-17.0.18+8/test/jdk/com/sun/security/sasl/gsskerb/ConfSecurityLayer.java | 213 openjdk-17-17.0.18+8/test/jdk/com/sun/security/sasl/gsskerb/NoSecurityLayer.java | 215 openjdk-17-17.0.18+8/test/jdk/com/sun/security/sasl/gsskerb/PropertiesFileCallbackHandler.java | 145 openjdk-17-17.0.18+8/test/jdk/com/sun/security/sasl/gsskerb/gsseg_jaas.conf | 21 openjdk-17-17.0.18+8/test/jdk/com/sun/security/sasl/gsskerb/log.properties | 3 openjdk-17-17.0.18+8/test/jdk/com/sun/security/sasl/gsskerb/run-conf-wjaas.csh | 29 openjdk-17-17.0.18+8/test/jdk/com/sun/security/sasl/gsskerb/run-nosec-wjaas.csh | 24 openjdk-17-17.0.18+8/test/jdk/com/sun/security/sasl/gsskerb/runwjaas.csh | 24 openjdk-17-17.0.18+8/test/jdk/java/awt/Clipboard/ClipboardSecurity.java | 156 openjdk-17-17.0.18+8/test/jdk/java/awt/Clipboard/ConcurrentClipboardAccessTest.java | 77 openjdk-17-17.0.18+8/test/jdk/java/awt/Clipboard/GetAltContentsTest/SystemClipboardTest.java | 227 openjdk-17-17.0.18+8/test/jdk/java/awt/Clipboard/ImageTransferTest.java | 519 ++ openjdk-17-17.0.18+8/test/jdk/java/awt/Clipboard/NoDataConversionFailureTest.java | 173 openjdk-17-17.0.18+8/test/jdk/java/awt/Cursor/CursorDragTest/ListDragCursor.java | 100 openjdk-17-17.0.18+8/test/jdk/java/awt/Cursor/MultiResolutionCursorTest.java | 99 openjdk-17-17.0.18+8/test/jdk/java/awt/Cursor/MultiResolutionCursorTest/MultiResolutionCursorTest.html | 32 openjdk-17-17.0.18+8/test/jdk/java/awt/Cursor/MultiResolutionCursorTest/MultiResolutionCursorTest.java | 233 openjdk-17-17.0.18+8/test/jdk/java/awt/Desktop/BrowseTest.java | 26 openjdk-17-17.0.18+8/test/jdk/java/awt/Desktop/EditAndPrintTest/EditAndPrintTest.java | 2 openjdk-17-17.0.18+8/test/jdk/java/awt/DesktopProperties/FontSmoothing.java | 93 openjdk-17-17.0.18+8/test/jdk/java/awt/DesktopProperties/ThreeDBackgroundColor.java | 100 openjdk-17-17.0.18+8/test/jdk/java/awt/FileDialog/DoubleActionESC.java | 50 openjdk-17-17.0.18+8/test/jdk/java/awt/Focus/ComponentLostFocusTest.java | 38 openjdk-17-17.0.18+8/test/jdk/java/awt/Focus/MinimizeNonfocusableWindowTest.java | 76 openjdk-17-17.0.18+8/test/jdk/java/awt/Focus/WindowDisposeFocusTest.java | 98 openjdk-17-17.0.18+8/test/jdk/java/awt/Focus/bug6435715.java | 91 openjdk-17-17.0.18+8/test/jdk/java/awt/FontClass/FontTransformAttributeTest.java | 84 openjdk-17-17.0.18+8/test/jdk/java/awt/FontClass/FontUnderscoreTest.java | 77 openjdk-17-17.0.18+8/test/jdk/java/awt/Frame/ShownOnPack/ShownOnPack.html | 43 openjdk-17-17.0.18+8/test/jdk/java/awt/Frame/ShownOnPack/ShownOnPack.java | 240 openjdk-17-17.0.18+8/test/jdk/java/awt/FullScreen/NonfocusableFrameFullScreenTest.java | 139 openjdk-17-17.0.18+8/test/jdk/java/awt/Graphics/GDIResourceExhaustionTest.java | 121 openjdk-17-17.0.18+8/test/jdk/java/awt/Graphics/RepeatedRepaintTest.java | 137 openjdk-17-17.0.18+8/test/jdk/java/awt/Graphics/SmallPrimitives.java | 224 openjdk-17-17.0.18+8/test/jdk/java/awt/Graphics/TextAfterXor.java | 123 openjdk-17-17.0.18+8/test/jdk/java/awt/GridBagLayout/ComponentShortage.java | 99 openjdk-17-17.0.18+8/test/jdk/java/awt/Icon/ChildFrameIconTest.java | 76 openjdk-17-17.0.18+8/test/jdk/java/awt/InputMethods/DiacriticsTest/DiacriticsTest.html | 53 openjdk-17-17.0.18+8/test/jdk/java/awt/InputMethods/DiacriticsTest/DiacriticsTest.java | 108 openjdk-17-17.0.18+8/test/jdk/java/awt/InputMethods/SpanishDiacriticsTest.java | 92 openjdk-17-17.0.18+8/test/jdk/java/awt/InputMethods/SpanishDiacriticsTest/SpanishDiacriticsTest.html | 40 openjdk-17-17.0.18+8/test/jdk/java/awt/InputMethods/SpanishDiacriticsTest/SpanishDiacriticsTest.java | 57 openjdk-17-17.0.18+8/test/jdk/java/awt/Label/ContainerValidateTest.java | 169 openjdk-17-17.0.18+8/test/jdk/java/awt/List/ListEnterExitTest.java | 79 openjdk-17-17.0.18+8/test/jdk/java/awt/List/ListScrollbarCursorTest.java | 70 openjdk-17-17.0.18+8/test/jdk/java/awt/List/ListScrollbarTest.java | 197 openjdk-17-17.0.18+8/test/jdk/java/awt/List/MouseDraggedOriginatedByScrollBarTest.java | 84 openjdk-17-17.0.18+8/test/jdk/java/awt/Menu/MenuActionEventTest.java | 98 openjdk-17-17.0.18+8/test/jdk/java/awt/Menu/MenuVisibilityTest.java | 71 openjdk-17-17.0.18+8/test/jdk/java/awt/Menu/RmInHideTest.java | 152 openjdk-17-17.0.18+8/test/jdk/java/awt/Menu/SetShortCutTest.java | 132 openjdk-17-17.0.18+8/test/jdk/java/awt/Modal/AddRemoveTransientForsTest.java | 123 openjdk-17-17.0.18+8/test/jdk/java/awt/Modal/DialogLosesFocusTest.java | 107 openjdk-17-17.0.18+8/test/jdk/java/awt/Modal/NativeDialogToFrontBackTest.java | 118 openjdk-17-17.0.18+8/test/jdk/java/awt/Multiscreen/DialogTest.java | 236 openjdk-17-17.0.18+8/test/jdk/java/awt/Multiscreen/FillThisScreen.java | 140 openjdk-17-17.0.18+8/test/jdk/java/awt/Multiscreen/IMCandidateWindowTest.java | 104 openjdk-17-17.0.18+8/test/jdk/java/awt/PrintJob/PrintCompatibilityTest.java | 446 + openjdk-17-17.0.18+8/test/jdk/java/awt/PrintJob/PrintComponentTest.java | 486 + openjdk-17-17.0.18+8/test/jdk/java/awt/PrintJob/ScaledImagePrintingTest.java | 102 openjdk-17-17.0.18+8/test/jdk/java/awt/ScrollPane/ScrollPaneAsNeededTest.java | 67 openjdk-17-17.0.18+8/test/jdk/java/awt/ScrollPane/ScrollPaneComponentTest.java | 125 openjdk-17-17.0.18+8/test/jdk/java/awt/ScrollPane/ScrollPaneEventType.java | 81 openjdk-17-17.0.18+8/test/jdk/java/awt/ScrollPane/ScrollPaneFlicker.java | 215 openjdk-17-17.0.18+8/test/jdk/java/awt/ScrollPane/ScrollPanePaint.java | 132 openjdk-17-17.0.18+8/test/jdk/java/awt/ScrollPane/ScrollPaneSize.java | 97 openjdk-17-17.0.18+8/test/jdk/java/awt/ScrollPane/ScrollPanechildViewportTest.java | 146 openjdk-17-17.0.18+8/test/jdk/java/awt/ScrollPane/ScrollPositionTest.java | 100 openjdk-17-17.0.18+8/test/jdk/java/awt/ScrollPane/ScrollbarsAsNeededTest.java | 72 openjdk-17-17.0.18+8/test/jdk/java/awt/Scrollbar/ListScrollbarTest.java | 139 openjdk-17-17.0.18+8/test/jdk/java/awt/Scrollbar/ScrollbarCtrlClickTest.java | 114 openjdk-17-17.0.18+8/test/jdk/java/awt/Scrollbar/UnitIncrementTest.java | 129 openjdk-17-17.0.18+8/test/jdk/java/awt/Selection/TestClipboard.java | 113 openjdk-17-17.0.18+8/test/jdk/java/awt/TextComponent/AltPlusNumberKeyCombinationsTest.java | 74 openjdk-17-17.0.18+8/test/jdk/java/awt/TextComponent/BackgroundTest.java | 127 openjdk-17-17.0.18+8/test/jdk/java/awt/TextComponent/CorrectTextComponentSelectionTest.java | 139 openjdk-17-17.0.18+8/test/jdk/java/awt/TextComponent/DisableTest.java | 98 openjdk-17-17.0.18+8/test/jdk/java/awt/TextComponent/ModifiersTest.java | 85 openjdk-17-17.0.18+8/test/jdk/java/awt/TextComponent/SelectionAndCaretColor.java | 162 openjdk-17-17.0.18+8/test/jdk/java/awt/TextComponent/SelectionTest.java | 73 openjdk-17-17.0.18+8/test/jdk/java/awt/TextComponent/TextFieldMargin.java | 67 openjdk-17-17.0.18+8/test/jdk/java/awt/TextField/SetEchoCharTest.java | 178 openjdk-17-17.0.18+8/test/jdk/java/awt/TextField/SetEchoCharTest4/SetEchoCharTest4.java | 27 openjdk-17-17.0.18+8/test/jdk/java/awt/TextField/SetEchoCharWordOpsTest.java | 90 openjdk-17-17.0.18+8/test/jdk/java/awt/Toolkit/DesktopProperties/DesktopPropertyTest.java | 272 + openjdk-17-17.0.18+8/test/jdk/java/awt/Toolkit/Headless/WrappedToolkitTest/TestWrapped.java | 77 openjdk-17-17.0.18+8/test/jdk/java/awt/Toolkit/Headless/WrappedToolkitTest/WrappedToolkitTest.sh | 221 openjdk-17-17.0.18+8/test/jdk/java/awt/Toolkit/TimeUnsignedConversionTest.java | 128 openjdk-17-17.0.18+8/test/jdk/java/awt/color/ICC_Profile/SerializedFormSize.java | 72 openjdk-17-17.0.18+8/test/jdk/java/awt/color/ICC_Profile/ValidateICCHeaderData/ValidateICCHeaderData.java | 261 + openjdk-17-17.0.18+8/test/jdk/java/awt/datatransfer/ClipboardPerformanceTest.java | 133 openjdk-17-17.0.18+8/test/jdk/java/awt/datatransfer/HTMLTransferConsoleOutputTest.java | 182 openjdk-17-17.0.18+8/test/jdk/java/awt/datatransfer/ImageTransferCrashTest.java | 147 openjdk-17-17.0.18+8/test/jdk/java/awt/dnd/DnDFileGroupDescriptor/DnDFileGroupDescriptor.html | 43 openjdk-17-17.0.18+8/test/jdk/java/awt/dnd/DnDFileGroupDescriptor/DnDFileGroupDescriptor.java | 252 openjdk-17-17.0.18+8/test/jdk/java/awt/event/InputEvent/InputEventTimeTest.java | 115 openjdk-17-17.0.18+8/test/jdk/java/awt/event/KeyEvent/AltGrTest.java | 90 openjdk-17-17.0.18+8/test/jdk/java/awt/event/KeyEvent/CRTest.java | 124 openjdk-17-17.0.18+8/test/jdk/java/awt/event/KeyEvent/CharUndefinedTest.java | 95 openjdk-17-17.0.18+8/test/jdk/java/awt/event/KeyEvent/ExtendedKeysTest.java | 66 openjdk-17-17.0.18+8/test/jdk/java/awt/event/KeyEvent/KeyDownCaptureTest.java | 111 openjdk-17-17.0.18+8/test/jdk/java/awt/event/KeyEvent/KeyEventToLightweight.java | 125 openjdk-17-17.0.18+8/test/jdk/java/awt/event/KeyEvent/KeyModifiers.java | 134 openjdk-17-17.0.18+8/test/jdk/java/awt/event/KeyEvent/KeyPressedModifiers.java | 108 openjdk-17-17.0.18+8/test/jdk/java/awt/event/KeyEvent/KeyTest.java | 104 openjdk-17-17.0.18+8/test/jdk/java/awt/event/KeyEvent/NumpadTest2.java | 108 openjdk-17-17.0.18+8/test/jdk/java/awt/event/KeyEvent/TestDoubleKeyEvent.java | 87 openjdk-17-17.0.18+8/test/jdk/java/awt/event/MouseWheelEvent/HWWheelScroll.java | 160 openjdk-17-17.0.18+8/test/jdk/java/awt/event/MouseWheelEvent/WheelEventCoord.java | 95 openjdk-17-17.0.18+8/test/jdk/java/awt/event/MouseWheelEvent/WheelScrollEnabled.java | 129 openjdk-17-17.0.18+8/test/jdk/java/awt/event/StressTest/LargeAWTEventMulticasterTest.java | 96 openjdk-17-17.0.18+8/test/jdk/java/awt/font/FontNames/LocaleFamilyNames.java | 13 openjdk-17-17.0.18+8/test/jdk/java/awt/font/GlyphVector/TestOutline.java | 104 openjdk-17-17.0.18+8/test/jdk/java/awt/font/NumericShaper/ShaperTest.java | 180 openjdk-17-17.0.18+8/test/jdk/java/awt/font/TextLayout/TestGASPHint.java | 113 openjdk-17-17.0.18+8/test/jdk/java/awt/font/TextLayout/TestSelection.java | 134 openjdk-17-17.0.18+8/test/jdk/java/awt/font/TextLayout/TestStrikethrough.java | 92 openjdk-17-17.0.18+8/test/jdk/java/awt/print/Dialog/DialogType.java | 96 openjdk-17-17.0.18+8/test/jdk/java/awt/regtesthelpers/PassFailJFrame.java | 25 openjdk-17-17.0.18+8/test/jdk/java/beans/Introspector/DefaultMethodBeanPropertyTest.java | 462 + openjdk-17-17.0.18+8/test/jdk/java/io/File/MacPathTest.java | 11 openjdk-17-17.0.18+8/test/jdk/java/io/File/MaxPath.java | 10 openjdk-17-17.0.18+8/test/jdk/java/io/File/MaxPathLength.java | 43 openjdk-17-17.0.18+8/test/jdk/java/io/File/SymLinks.java | 39 openjdk-17-17.0.18+8/test/jdk/java/io/File/TimeZoneLastModified.java | 10 openjdk-17-17.0.18+8/test/jdk/java/io/File/WinDeviceName.java | 7 openjdk-17-17.0.18+8/test/jdk/java/io/File/WinMaxPath.java | 7 openjdk-17-17.0.18+8/test/jdk/java/io/File/WinSpecialFiles.java | 7 openjdk-17-17.0.18+8/test/jdk/java/io/FileDescriptor/Sync.java | 2 openjdk-17-17.0.18+8/test/jdk/java/io/FileOutputStream/ManyFiles.java | 11 openjdk-17-17.0.18+8/test/jdk/java/io/InputStreamReader/StatefulDecoderNearEOF.java | 79 openjdk-17-17.0.18+8/test/jdk/java/io/ObjectStreamClass/ObjectStreamClassCaching.java | 32 openjdk-17-17.0.18+8/test/jdk/java/io/pathNames/win32/SJIS.java | 17 openjdk-17-17.0.18+8/test/jdk/java/lang/ClassLoader/securityManager/ClassLoaderTest.java | 9 openjdk-17-17.0.18+8/test/jdk/java/lang/Math/FusedMultiplyAddTests.java | 9 openjdk-17-17.0.18+8/test/jdk/java/lang/ModuleTests/AnnotationsTest.java | 6 openjdk-17-17.0.18+8/test/jdk/java/lang/ProcessBuilder/Basic.java | 35 openjdk-17-17.0.18+8/test/jdk/java/lang/System/LoggerFinder/internal/BootstrapLogger/BootstrapLoggerTest.java | 6 openjdk-17-17.0.18+8/test/jdk/java/lang/module/ClassFileVersionsTest.java | 10 openjdk-17-17.0.18+8/test/jdk/java/lang/module/ConfigurationTest.java | 9 openjdk-17-17.0.18+8/test/jdk/java/lang/module/ModuleDescriptorTest.java | 8 openjdk-17-17.0.18+8/test/jdk/java/lang/module/ModuleFinderTest.java | 11 openjdk-17-17.0.18+8/test/jdk/java/lang/module/ModuleNamesTest.java | 9 openjdk-17-17.0.18+8/test/jdk/java/lang/module/MultiReleaseJarTest.java | 12 openjdk-17-17.0.18+8/test/jdk/java/net/CookieStoreTest.java | 113 openjdk-17-17.0.18+8/test/jdk/java/net/NetworkInterface/IPv4Only.java | 14 openjdk-17-17.0.18+8/test/jdk/java/net/httpclient/CancelRequestTest.java | 111 openjdk-17-17.0.18+8/test/jdk/java/net/httpclient/ContentLengthHeaderTest.java | 232 openjdk-17-17.0.18+8/test/jdk/java/net/httpclient/HttpsTunnelAuthTest.java | 10 openjdk-17-17.0.18+8/test/jdk/java/net/httpclient/ManyRequests.java | 1 openjdk-17-17.0.18+8/test/jdk/java/net/httpclient/ProxyServer.java | 64 openjdk-17-17.0.18+8/test/jdk/java/net/ipv6tests/TcpTest.java | 9 openjdk-17-17.0.18+8/test/jdk/java/nio/channels/DatagramChannel/StressNativeSignal.java | 87 openjdk-17-17.0.18+8/test/jdk/java/nio/channels/FileChannel/directio/DirectIOTest.java | 90 openjdk-17-17.0.18+8/test/jdk/java/nio/channels/FileChannel/directio/libDirectIO.c | 34 openjdk-17-17.0.18+8/test/jdk/java/nio/channels/SocketChannel/PeerReadsAfterAsyncClose.java | 198 openjdk-17-17.0.18+8/test/jdk/java/nio/charset/Charset/AvailableCharsetNames.java | 29 openjdk-17-17.0.18+8/test/jdk/java/nio/charset/Charset/CharsetContainmentTest.java | 185 openjdk-17-17.0.18+8/test/jdk/java/nio/charset/Charset/Contains.java | 306 - openjdk-17-17.0.18+8/test/jdk/java/nio/charset/Charset/EmptyCharsetName.java | 84 openjdk-17-17.0.18+8/test/jdk/java/nio/charset/Charset/EncDec.java | 39 openjdk-17-17.0.18+8/test/jdk/java/nio/charset/Charset/IllegalCharsetName.java | 108 openjdk-17-17.0.18+8/test/jdk/java/nio/charset/Charset/NullCharsetName.java | 30 openjdk-17-17.0.18+8/test/jdk/java/nio/charset/Charset/RegisteredCharsets.java | 2556 +++++----- openjdk-17-17.0.18+8/test/jdk/java/rmi/transport/checkLeaseInfoLeak/CheckLeaseLeak.java | 104 openjdk-17-17.0.18+8/test/jdk/java/rmi/transport/checkLeaseInfoLeak/LeaseLeakClient.java | 3 openjdk-17-17.0.18+8/test/jdk/java/security/Provider/SecurityProviderModularTest.java | 13 openjdk-17-17.0.18+8/test/jdk/java/security/Security/SecurityPropFile/TEST.properties | 2 openjdk-17-17.0.18+8/test/jdk/java/text/Format/ChoiceFormat/ParseTest.java | 76 openjdk-17-17.0.18+8/test/jdk/java/text/Format/ChoiceFormat/PatternsTest.java | 153 openjdk-17-17.0.18+8/test/jdk/java/text/Format/DateFormat/DateFormatRegression.java | 14 openjdk-17-17.0.18+8/test/jdk/java/text/Format/DateFormat/DateFormatTest.java | 16 openjdk-17-17.0.18+8/test/jdk/java/text/Format/DateFormat/SDFTCKZoneNamesTest.java | 8 openjdk-17-17.0.18+8/test/jdk/java/text/Format/DateFormat/bug4358730.java | 6 openjdk-17-17.0.18+8/test/jdk/java/util/Calendar/CalendarRegression.java | 27 openjdk-17-17.0.18+8/test/jdk/java/util/Calendar/JavatimeTest.java | 17 openjdk-17-17.0.18+8/test/jdk/java/util/Calendar/bug4316678.java | 6 openjdk-17-17.0.18+8/test/jdk/java/util/Calendar/bug4372743.java | 6 openjdk-17-17.0.18+8/test/jdk/java/util/Date/Bug4955000.java | 6 openjdk-17-17.0.18+8/test/jdk/java/util/Date/DateRegression.java | 7 openjdk-17-17.0.18+8/test/jdk/java/util/Date/DateTest.java | 10 openjdk-17-17.0.18+8/test/jdk/java/util/PluggableLocale/LocaleNameProviderTest.java | 153 openjdk-17-17.0.18+8/test/jdk/java/util/PluggableLocale/TimeZoneNameProviderTest.java | 49 openjdk-17-17.0.18+8/test/jdk/java/util/Properties/StoreDeadlock.java | 6 openjdk-17-17.0.18+8/test/jdk/java/util/TimeZone/Bug5097350.java | 11 openjdk-17-17.0.18+8/test/jdk/java/util/TimeZone/Bug6329116.java | 13 openjdk-17-17.0.18+8/test/jdk/java/util/TimeZone/Bug6772689.java | 11 openjdk-17-17.0.18+8/test/jdk/java/util/TimeZone/DaylightTimeTest.java | 10 openjdk-17-17.0.18+8/test/jdk/java/util/TimeZone/IDTest.java | 22 openjdk-17-17.0.18+8/test/jdk/java/util/TimeZone/ListTimeZones.java | 10 openjdk-17-17.0.18+8/test/jdk/java/util/TimeZone/NegativeDSTTest.java | 7 openjdk-17-17.0.18+8/test/jdk/java/util/TimeZone/SimpleTimeZoneEqualsHashCodeTest.java | 83 openjdk-17-17.0.18+8/test/jdk/java/util/TimeZone/TimeZoneBoundaryTest.java | 12 openjdk-17-17.0.18+8/test/jdk/java/util/TimeZone/TimeZoneRegression.java | 20 openjdk-17-17.0.18+8/test/jdk/java/util/TimeZone/bug4096952.java | 6 openjdk-17-17.0.18+8/test/jdk/java/util/concurrent/CopyOnWriteArraySet/SerializationTest.java | 84 openjdk-17-17.0.18+8/test/jdk/java/util/jar/Manifest/ValueUtf8Coding.java | 8 openjdk-17-17.0.18+8/test/jdk/java/util/logging/LocalizedLevelName.java | 3 openjdk-17-17.0.18+8/test/jdk/java/util/logging/SimpleFormatterFormat.java | 8 openjdk-17-17.0.18+8/test/jdk/java/util/zip/ZipFile/TestCleaner.java | 56 openjdk-17-17.0.18+8/test/jdk/javax/management/remote/mandatory/notif/ListenerScaleTest.java | 6 openjdk-17-17.0.18+8/test/jdk/javax/management/security/SecurityTest.java | 11 openjdk-17-17.0.18+8/test/jdk/javax/net/ssl/DTLS/CipherSuite.java | 8 openjdk-17-17.0.18+8/test/jdk/javax/net/ssl/DTLS/DTLSOverDatagram.java | 12 openjdk-17-17.0.18+8/test/jdk/javax/net/ssl/DTLS/FragmentedFinished.java | 72 openjdk-17-17.0.18+8/test/jdk/javax/net/ssl/DTLS/PacketLossRetransmission.java | 27 openjdk-17-17.0.18+8/test/jdk/javax/net/ssl/SSLEngine/Basics.java | 5 openjdk-17-17.0.18+8/test/jdk/javax/net/ssl/SSLEngine/EngineCloseOnAlert.java | 8 openjdk-17-17.0.18+8/test/jdk/javax/net/ssl/ServerName/EndingDotHostname.java | 3 openjdk-17-17.0.18+8/test/jdk/javax/net/ssl/TLSCommon/TLSTest.java | 116 openjdk-17-17.0.18+8/test/jdk/javax/net/ssl/TLSv11/GenericBlockCipher.java | 6 openjdk-17-17.0.18+8/test/jdk/javax/net/ssl/TLSv12/ProtocolFilter.java | 7 openjdk-17-17.0.18+8/test/jdk/javax/net/ssl/ciphersuites/DisabledAlgorithms.java | 12 openjdk-17-17.0.18+8/test/jdk/javax/net/ssl/sanity/ciphersuites/CheckCipherSuites.java | 22 openjdk-17-17.0.18+8/test/jdk/javax/net/ssl/sanity/ciphersuites/SystemPropCipherSuitesOrder.java | 19 openjdk-17-17.0.18+8/test/jdk/javax/net/ssl/sanity/ciphersuites/TLSCipherSuitesOrder.java | 4 openjdk-17-17.0.18+8/test/jdk/javax/net/ssl/templates/SSLExampleCert.java | 2 openjdk-17-17.0.18+8/test/jdk/javax/net/ssl/templates/SSLSocketTemplate.java | 17 openjdk-17-17.0.18+8/test/jdk/javax/print/PrintServiceLookup/CountPrintServices.java | 28 openjdk-17-17.0.18+8/test/jdk/javax/rmi/ssl/SSLSocketParametersTest.java | 5 openjdk-17-17.0.18+8/test/jdk/javax/security/auth/callback/PasswordCallback/CheckCleanerBound.java | 3 openjdk-17-17.0.18+8/test/jdk/javax/security/auth/callback/PasswordCallback/PasswordCleanup.java | 3 openjdk-17-17.0.18+8/test/jdk/javax/security/auth/login/TEST.properties | 2 openjdk-17-17.0.18+8/test/jdk/javax/security/auth/login/modules/JaasModularClientTest.java | 10 openjdk-17-17.0.18+8/test/jdk/javax/security/auth/login/modules/JaasModularDefaultHandlerTest.java | 10 openjdk-17-17.0.18+8/test/jdk/javax/sound/midi/BulkSoundBank/BulkSoundBank.java | 53 openjdk-17-17.0.18+8/test/jdk/javax/swing/JButton/bug4151763.java | 94 openjdk-17-17.0.18+8/test/jdk/javax/swing/JButton/bug4415505.java | 77 openjdk-17-17.0.18+8/test/jdk/javax/swing/JButton/bug4978274.java | 108 openjdk-17-17.0.18+8/test/jdk/javax/swing/JCheckBox/4449413/bug4449413.java | 29 openjdk-17-17.0.18+8/test/jdk/javax/swing/JComboBox/bug4139900.java | 119 openjdk-17-17.0.18+8/test/jdk/javax/swing/JComboBox/bug4166593.java | 98 openjdk-17-17.0.18+8/test/jdk/javax/swing/JComboBox/bug4174876.java | 78 openjdk-17-17.0.18+8/test/jdk/javax/swing/JComboBox/bug4180054.java | 112 openjdk-17-17.0.18+8/test/jdk/javax/swing/JComboBox/bug4185024.java | 109 openjdk-17-17.0.18+8/test/jdk/javax/swing/JComboBox/bug4201964.java | 77 openjdk-17-17.0.18+8/test/jdk/javax/swing/JComboBox/bug4249732.java | 72 openjdk-17-17.0.18+8/test/jdk/javax/swing/JComboBox/bug4368848.java | 129 openjdk-17-17.0.18+8/test/jdk/javax/swing/JComboBox/bug4474400.java | 78 openjdk-17-17.0.18+8/test/jdk/javax/swing/JComboBox/bug4530952.java | 147 openjdk-17-17.0.18+8/test/jdk/javax/swing/JComboBox/bug4530953.java | 98 openjdk-17-17.0.18+8/test/jdk/javax/swing/JComponent/bug4235215.java | 64 openjdk-17-17.0.18+8/test/jdk/javax/swing/JComponent/bug4247610.java | 128 openjdk-17-17.0.18+8/test/jdk/javax/swing/JComponent/bug4254995.java | 60 openjdk-17-17.0.18+8/test/jdk/javax/swing/JEditorPane/ScrollToReferenceTest/ScrollToReferenceTest.java | 91 openjdk-17-17.0.18+8/test/jdk/javax/swing/JEditorPane/ScrollToReferenceTest/test.html | 93 openjdk-17-17.0.18+8/test/jdk/javax/swing/JFileChooser/6798062/bug6798062.html | 36 openjdk-17-17.0.18+8/test/jdk/javax/swing/JFileChooser/6798062/bug6798062.java | 202 openjdk-17-17.0.18+8/test/jdk/javax/swing/JFileChooser/FileFilterDescription.java | 98 openjdk-17-17.0.18+8/test/jdk/javax/swing/JFileChooser/FileFilterDescription/FileFilterDescription.java | 98 openjdk-17-17.0.18+8/test/jdk/javax/swing/JFileChooser/HTMLFileName.java | 175 openjdk-17-17.0.18+8/test/jdk/javax/swing/JFileChooser/bug4357012.java | 99 openjdk-17-17.0.18+8/test/jdk/javax/swing/JFileChooser/bug4464774.java | 62 openjdk-17-17.0.18+8/test/jdk/javax/swing/JFileChooser/bug4522756.java | 64 openjdk-17-17.0.18+8/test/jdk/javax/swing/JFileChooser/bug4759934.java | 124 openjdk-17-17.0.18+8/test/jdk/javax/swing/JFileChooser/bug4926884.java | 114 openjdk-17-17.0.18+8/test/jdk/javax/swing/JFileChooser/bug4943900.java | 118 openjdk-17-17.0.18+8/test/jdk/javax/swing/JFileChooser/bug5045464.java | 68 openjdk-17-17.0.18+8/test/jdk/javax/swing/JFileChooser/bug6515169.java | 106 openjdk-17-17.0.18+8/test/jdk/javax/swing/JFileChooser/bug6798062.java | 230 openjdk-17-17.0.18+8/test/jdk/javax/swing/JFrame/bug4419914.java | 128 openjdk-17-17.0.18+8/test/jdk/javax/swing/JInternalFrame/6726866/bug6726866.java | 87 openjdk-17-17.0.18+8/test/jdk/javax/swing/JInternalFrame/8160248/JInternalFrameDraggingTest.java | 17 openjdk-17-17.0.18+8/test/jdk/javax/swing/JInternalFrame/InternalFrameTitleButtonTest.java | 127 openjdk-17-17.0.18+8/test/jdk/javax/swing/JInternalFrame/bug4151444.java | 84 openjdk-17-17.0.18+8/test/jdk/javax/swing/JInternalFrame/bug4190516.java | 75 openjdk-17-17.0.18+8/test/jdk/javax/swing/JInternalFrame/bug4215380.java | 109 openjdk-17-17.0.18+8/test/jdk/javax/swing/JInternalFrame/bug4242045.java | 123 openjdk-17-17.0.18+8/test/jdk/javax/swing/JInternalFrame/bug4321312.java | 126 openjdk-17-17.0.18+8/test/jdk/javax/swing/JInternalFrame/bug4322726.java | 109 openjdk-17-17.0.18+8/test/jdk/javax/swing/JInternalFrame/bug6726866.java | 87 openjdk-17-17.0.18+8/test/jdk/javax/swing/JLabel/bug4106007.java | 66 openjdk-17-17.0.18+8/test/jdk/javax/swing/JLabel/bug4945795.java | 73 openjdk-17-17.0.18+8/test/jdk/javax/swing/JList/bug4193267.java | 117 openjdk-17-17.0.18+8/test/jdk/javax/swing/JList/bug4249161.java | 96 openjdk-17-17.0.18+8/test/jdk/javax/swing/JList/bug4618767.java | 127 openjdk-17-17.0.18+8/test/jdk/javax/swing/JMenuBar/RightLeftOrientation.java | 85 openjdk-17-17.0.18+8/test/jdk/javax/swing/JMenuItem/MenuItemTest/MenuItemTestHelper.java | 163 openjdk-17-17.0.18+8/test/jdk/javax/swing/JMenuItem/MenuItemTest/bug4729669.java | 61 openjdk-17-17.0.18+8/test/jdk/javax/swing/JMenuItem/MenuItemTest/bug6197830.java | 67 openjdk-17-17.0.18+8/test/jdk/javax/swing/JMenuItem/RightLeftOrientation.java | 105 openjdk-17-17.0.18+8/test/jdk/javax/swing/JMenuItem/bug4207339.java | 67 openjdk-17-17.0.18+8/test/jdk/javax/swing/JMenuItem/bug4327146.java | 114 openjdk-17-17.0.18+8/test/jdk/javax/swing/JMenuItem/bug4402082.java | 81 openjdk-17-17.0.18+8/test/jdk/javax/swing/JMenuItem/bug4729669.java | 186 openjdk-17-17.0.18+8/test/jdk/javax/swing/JOptionPane/TestJOptionHTMLTag.java | 68 openjdk-17-17.0.18+8/test/jdk/javax/swing/JOptionPane/bug4194862.java | 94 openjdk-17-17.0.18+8/test/jdk/javax/swing/JPasswordField/PasswordFieldInputMapWordTest.java | 118 openjdk-17-17.0.18+8/test/jdk/javax/swing/JPasswordField/bug4382819.java | 86 openjdk-17-17.0.18+8/test/jdk/javax/swing/JPopupMenu/bug4119993.java | 112 openjdk-17-17.0.18+8/test/jdk/javax/swing/JPopupMenu/bug4187004.java | 97 openjdk-17-17.0.18+8/test/jdk/javax/swing/JPopupMenu/bug4188832.java | 82 openjdk-17-17.0.18+8/test/jdk/javax/swing/JPopupMenu/bug4212464.java | 142 openjdk-17-17.0.18+8/test/jdk/javax/swing/JPopupMenu/bug4234793.java | 242 openjdk-17-17.0.18+8/test/jdk/javax/swing/JPopupMenu/bug4530303.java | 85 openjdk-17-17.0.18+8/test/jdk/javax/swing/JProgressBar/RightLeftOrientation.java | 147 openjdk-17-17.0.18+8/test/jdk/javax/swing/JProgressBar/bug4230391.java | 139 openjdk-17-17.0.18+8/test/jdk/javax/swing/JProgressBar/bug4393042.java | 90 openjdk-17-17.0.18+8/test/jdk/javax/swing/JProgressBar/bug5003022.java | 82 openjdk-17-17.0.18+8/test/jdk/javax/swing/JRadioButton/bug4673850.java | 104 openjdk-17-17.0.18+8/test/jdk/javax/swing/JRootPane/bug4614623.java | 84 openjdk-17-17.0.18+8/test/jdk/javax/swing/JSlider/6524424/bug6524424.html | 34 openjdk-17-17.0.18+8/test/jdk/javax/swing/JSlider/6524424/bug6524424.java | 101 openjdk-17-17.0.18+8/test/jdk/javax/swing/JSlider/bug4186062.java | 99 openjdk-17-17.0.18+8/test/jdk/javax/swing/JSlider/bug4275631.java | 132 openjdk-17-17.0.18+8/test/jdk/javax/swing/JSlider/bug4382876.java | 110 openjdk-17-17.0.18+8/test/jdk/javax/swing/JSlider/bug6524424.java | 120 openjdk-17-17.0.18+8/test/jdk/javax/swing/JSplitPane/bug4820080.java | 94 openjdk-17-17.0.18+8/test/jdk/javax/swing/JTabbedPane/4287208/bug4287208.java | 90 openjdk-17-17.0.18+8/test/jdk/javax/swing/JTabbedPane/bug4273320.java | 90 openjdk-17-17.0.18+8/test/jdk/javax/swing/JTabbedPane/bug4287268.java | 102 openjdk-17-17.0.18+8/test/jdk/javax/swing/JTabbedPane/bug4362226.java | 76 openjdk-17-17.0.18+8/test/jdk/javax/swing/JTabbedPane/bug4499556.java | 5 openjdk-17-17.0.18+8/test/jdk/javax/swing/JTabbedPane/bug4613811.java | 82 openjdk-17-17.0.18+8/test/jdk/javax/swing/JTabbedPane/bug4668865.java | 112 openjdk-17-17.0.18+8/test/jdk/javax/swing/JTable/8236907/LastVisibleRow.java | 221 openjdk-17-17.0.18+8/test/jdk/javax/swing/JTable/CheckBoxFirstClick.java | 185 openjdk-17-17.0.18+8/test/jdk/javax/swing/JTable/IllegalStateException.java | 187 openjdk-17-17.0.18+8/test/jdk/javax/swing/JTable/InternationalCharacters.java | 172 openjdk-17-17.0.18+8/test/jdk/javax/swing/JTable/JTableScrollPrintTest.java | 180 openjdk-17-17.0.18+8/test/jdk/javax/swing/JTable/NullTableHeader.java | 44 openjdk-17-17.0.18+8/test/jdk/javax/swing/JTable/PrintAllPagesTest.java | 114 openjdk-17-17.0.18+8/test/jdk/javax/swing/JTable/ShiftClick.java | 187 openjdk-17-17.0.18+8/test/jdk/javax/swing/JTable/bug4118307.java | 182 openjdk-17-17.0.18+8/test/jdk/javax/swing/JTable/bug4128506.java | 84 openjdk-17-17.0.18+8/test/jdk/javax/swing/JTable/bug4129401.java | 87 openjdk-17-17.0.18+8/test/jdk/javax/swing/JTable/bug4138158.java | 62 openjdk-17-17.0.18+8/test/jdk/javax/swing/JTable/bug4139910.java | 68 openjdk-17-17.0.18+8/test/jdk/javax/swing/JTable/bug4188504.java | 71 openjdk-17-17.0.18+8/test/jdk/javax/swing/JTable/bug4190222.java | 103 openjdk-17-17.0.18+8/test/jdk/javax/swing/JTable/bug4193727.java | 135 openjdk-17-17.0.18+8/test/jdk/javax/swing/JTable/bug4224179.java | 74 openjdk-17-17.0.18+8/test/jdk/javax/swing/JTable/bug4226181.java | 87 openjdk-17-17.0.18+8/test/jdk/javax/swing/JTable/bug4239157.java | 85 openjdk-17-17.0.18+8/test/jdk/javax/swing/JTable/bug4242631.java | 144 openjdk-17-17.0.18+8/test/jdk/javax/swing/JTableHeader/6884066/bug6884066.java | 88 openjdk-17-17.0.18+8/test/jdk/javax/swing/JTextField/bug4232716.java | 81 openjdk-17-17.0.18+8/test/jdk/javax/swing/JTextField/bug5027332.java | 70 openjdk-17-17.0.18+8/test/jdk/javax/swing/JToggleButton/4128979/bug4128979.html | 41 openjdk-17-17.0.18+8/test/jdk/javax/swing/JToggleButton/4128979/bug4128979.java | 143 openjdk-17-17.0.18+8/test/jdk/javax/swing/JToggleButton/bug4128979.java | 149 openjdk-17-17.0.18+8/test/jdk/javax/swing/JToolTip/TooltipTest.java | 90 openjdk-17-17.0.18+8/test/jdk/javax/swing/JToolTip/bug4225314.java | 72 openjdk-17-17.0.18+8/test/jdk/javax/swing/JToolTip/bug4255441.java | 64 openjdk-17-17.0.18+8/test/jdk/javax/swing/JViewport/ScrollRectToVisibleTest3.java | 165 openjdk-17-17.0.18+8/test/jdk/javax/swing/JViewport/SetViewRepaint.java | 114 openjdk-17-17.0.18+8/test/jdk/javax/swing/JWindow/bug4251781.java | 76 openjdk-17-17.0.18+8/test/jdk/javax/swing/SwingUtilities/bug4967768.java | 12 openjdk-17-17.0.18+8/test/jdk/javax/swing/ToolTipManager/bug4250178.java | 66 openjdk-17-17.0.18+8/test/jdk/javax/swing/ToolTipManager/bug4294808.java | 64 openjdk-17-17.0.18+8/test/jdk/javax/swing/ToolTipManager/bug6178004.java | 152 openjdk-17-17.0.18+8/test/jdk/javax/swing/border/EtchedBorder/ScaledEtchedBorderTest.java | 358 - openjdk-17-17.0.18+8/test/jdk/javax/swing/border/LineBorder/ScaledLineBorderTest.java | 130 openjdk-17-17.0.18+8/test/jdk/javax/swing/border/LineBorder/ScaledTextFieldBorderTest.java | 10 openjdk-17-17.0.18+8/test/jdk/javax/swing/border/TransparentTitleTest.java | 122 openjdk-17-17.0.18+8/test/jdk/javax/swing/plaf/basic/BasicTableHeaderUI/6394566/bug6394566.java | 73 openjdk-17-17.0.18+8/test/jdk/javax/swing/plaf/basic/BasicTextUI/PasswordSelectionWordTest.java | 94 openjdk-17-17.0.18+8/test/jdk/javax/swing/plaf/metal/MetalIconFactory/bug4952462.java | 66 openjdk-17-17.0.18+8/test/jdk/javax/swing/plaf/windows/bug4991587.java | 95 openjdk-17-17.0.18+8/test/jdk/javax/swing/text/BoxView/BaselineTest.java | 182 openjdk-17-17.0.18+8/test/jdk/javax/swing/text/DefaultEditorKit/4278839/bug4278839.java | 73 openjdk-17-17.0.18+8/test/jdk/javax/swing/text/GlyphView/bug4188841.java | 93 openjdk-17-17.0.18+8/test/jdk/javax/swing/text/html/FormView/4473401/bug4473401.java | 90 openjdk-17-17.0.18+8/test/jdk/javax/swing/text/html/FormView/4473401/frame1.html | 9 openjdk-17-17.0.18+8/test/jdk/javax/swing/text/html/FormView/4473401/frame2.html | 4 openjdk-17-17.0.18+8/test/jdk/javax/swing/text/html/FormView/4473401/frameresult.html | 5 openjdk-17-17.0.18+8/test/jdk/javax/swing/text/html/FormView/4473401/frameset.html | 11 openjdk-17-17.0.18+8/test/jdk/javax/swing/text/html/FormView/bug4529702.java | 62 openjdk-17-17.0.18+8/test/jdk/javax/swing/text/html/FrameSetView/4890934/bug4890934.java | 91 openjdk-17-17.0.18+8/test/jdk/javax/swing/text/html/FrameSetView/4890934/frame1.html | 8 openjdk-17-17.0.18+8/test/jdk/javax/swing/text/html/FrameSetView/4890934/frame2.html | 4 openjdk-17-17.0.18+8/test/jdk/javax/swing/text/html/FrameSetView/4890934/frameresult.html | 7 openjdk-17-17.0.18+8/test/jdk/javax/swing/text/html/FrameSetView/4890934/frameset.html | 11 openjdk-17-17.0.18+8/test/jdk/jdk/internal/platform/docker/GetFreeSwapSpaceSize.java | 2 openjdk-17-17.0.18+8/test/jdk/jdk/internal/platform/docker/MetricsMemoryTester.java | 6 openjdk-17-17.0.18+8/test/jdk/jdk/internal/platform/docker/TestDockerBasic.java | 3 openjdk-17-17.0.18+8/test/jdk/jdk/internal/platform/docker/TestDockerCpuMetrics.java | 4 openjdk-17-17.0.18+8/test/jdk/jdk/internal/platform/docker/TestDockerMemoryMetrics.java | 20 openjdk-17-17.0.18+8/test/jdk/jdk/internal/platform/docker/TestGetFreeSwapSpaceSize.java | 5 openjdk-17-17.0.18+8/test/jdk/jdk/internal/platform/docker/TestLimitsUpdating.java | 3 openjdk-17-17.0.18+8/test/jdk/jdk/internal/platform/docker/TestPidsLimit.java | 4 openjdk-17-17.0.18+8/test/jdk/jdk/internal/platform/docker/TestSystemMetrics.java | 4 openjdk-17-17.0.18+8/test/jdk/jdk/internal/platform/docker/TestUseContainerSupport.java | 3 openjdk-17-17.0.18+8/test/jdk/jdk/jfr/event/compiler/TestCompilerCompile.java | 4 openjdk-17-17.0.18+8/test/jdk/jdk/jfr/event/compiler/TestCompilerInlining.java | 2 openjdk-17-17.0.18+8/test/jdk/jdk/jfr/event/compiler/TestDeoptimization.java | 4 openjdk-17-17.0.18+8/test/jdk/jdk/jfr/event/os/TestCPULoad.java | 26 openjdk-17-17.0.18+8/test/jdk/jdk/modules/incubator/ServiceBinding.java | 11 openjdk-17-17.0.18+8/test/jdk/sun/awt/font/TestDevTransform.java | 48 openjdk-17-17.0.18+8/test/jdk/sun/jvmstat/monitor/MonitoredVm/MonitorVmStartTerminate.java | 22 openjdk-17-17.0.18+8/test/jdk/sun/management/jmxremote/bootstrap/AbstractFilePermissionTest.java | 7 openjdk-17-17.0.18+8/test/jdk/sun/management/jmxremote/bootstrap/JMXInterfaceBindingTest.java | 2 openjdk-17-17.0.18+8/test/jdk/sun/management/jmxremote/bootstrap/LocalManagementTest.java | 12 openjdk-17-17.0.18+8/test/jdk/sun/management/jmxremote/bootstrap/RmiBootstrapTest.java | 3 openjdk-17-17.0.18+8/test/jdk/sun/management/jmxremote/bootstrap/RmiRegistrySslTest.java | 7 openjdk-17-17.0.18+8/test/jdk/sun/net/www/protocol/file/FileURLTest.java | 7 openjdk-17-17.0.18+8/test/jdk/sun/net/www/protocol/https/HttpsURLConnection/IPIdentities.java | 716 -- openjdk-17-17.0.18+8/test/jdk/sun/net/www/protocol/https/HttpsURLConnection/TEST.properties | 3 openjdk-17-17.0.18+8/test/jdk/sun/security/krb5/Krb5NameEquals.java | 66 openjdk-17-17.0.18+8/test/jdk/sun/security/krb5/MicroTime.java | 9 openjdk-17-17.0.18+8/test/jdk/sun/security/krb5/auto/SaslBasic.java | 97 openjdk-17-17.0.18+8/test/jdk/sun/security/krb5/runNameEquals.sh | 127 openjdk-17-17.0.18+8/test/jdk/sun/security/pkcs11/KeyAgreement/SupportedDHKeys.java | 7 openjdk-17-17.0.18+8/test/jdk/sun/security/pkcs11/KeyAgreement/TestDH.java | 6 openjdk-17-17.0.18+8/test/jdk/sun/security/pkcs11/KeyAgreement/TestInterop.java | 6 openjdk-17-17.0.18+8/test/jdk/sun/security/pkcs11/KeyAgreement/TestShort.java | 35 openjdk-17-17.0.18+8/test/jdk/sun/security/pkcs11/KeyAgreement/UnsupportedDHKeys.java | 7 openjdk-17-17.0.18+8/test/jdk/sun/security/pkcs11/KeyGenerator/DESParity.java | 11 openjdk-17-17.0.18+8/test/jdk/sun/security/pkcs11/KeyGenerator/TestChaCha20.java | 7 openjdk-17-17.0.18+8/test/jdk/sun/security/pkcs11/KeyGenerator/TestKeyGenerator.java | 2 openjdk-17-17.0.18+8/test/jdk/sun/security/pkcs11/KeyPairGenerator/TestDH2048.java | 7 openjdk-17-17.0.18+8/test/jdk/sun/security/pkcs11/KeyStore/ClientAuth.java | 5 openjdk-17-17.0.18+8/test/jdk/sun/security/pkcs11/PKCS11Test.java | 2 openjdk-17-17.0.18+8/test/jdk/sun/security/pkcs11/SecretKeyFactory/TestGeneral.java | 55 openjdk-17-17.0.18+8/test/jdk/sun/security/pkcs11/SecureRandom/Basic.java | 7 openjdk-17-17.0.18+8/test/jdk/sun/security/pkcs11/SecureRandom/TestDeserialization.java | 12 openjdk-17-17.0.18+8/test/jdk/sun/security/pkcs11/Serialize/SerializeProvider.java | 8 openjdk-17-17.0.18+8/test/jdk/sun/security/pkcs11/tls/tls12/FipsModeTLS12.java | 5 openjdk-17-17.0.18+8/test/jdk/sun/security/ssl/ClientHandshaker/LengthCheckTest.java | 6 openjdk-17-17.0.18+8/test/jdk/sun/security/ssl/EngineArgs/DebugReportsOneExtraByte.java | 6 openjdk-17-17.0.18+8/test/jdk/sun/security/ssl/SignatureScheme/DisableSHA1inHandshakeSignatureDTLS12.java | 54 openjdk-17-17.0.18+8/test/jdk/sun/security/ssl/SignatureScheme/DisableSHA1inHandshakeSignatureTLS12.java | 120 openjdk-17-17.0.18+8/test/jdk/sun/security/ssl/SignatureScheme/DisableSHA1inHandshakeSignatureTLS13.java | 70 openjdk-17-17.0.18+8/test/jdk/sun/security/ssl/SignatureScheme/SigAlgosExtTestWithTLS12.java | 2 openjdk-17-17.0.18+8/test/jdk/sun/security/ssl/SignatureScheme/SigAlgosExtTestWithTLS13.java | 2 openjdk-17-17.0.18+8/test/jdk/sun/security/tools/jarsigner/EC.java | 3 openjdk-17-17.0.18+8/test/jdk/sun/security/tools/jarsigner/VerifyJarEntryName.java | 142 openjdk-17-17.0.18+8/test/jdk/sun/security/util/Resources/TEST.properties | 2 openjdk-17-17.0.18+8/test/jdk/sun/security/x509/URICertStore/AIACertTimeout.java | 2 openjdk-17-17.0.18+8/test/jdk/sun/security/x509/URICertStore/ExtensionsWithLDAP.java | 92 openjdk-17-17.0.18+8/test/jdk/sun/security/x509/X509CertImpl/V3Certificate.java | 6 openjdk-17-17.0.18+8/test/jdk/sun/tools/jcmd/JcmdBase.java | 4 openjdk-17-17.0.18+8/test/jdk/sun/tools/jcmd/TestProcessHelper.java | 10 openjdk-17-17.0.18+8/test/jdk/sun/util/calendar/zi/TestZoneInfo310.java | 19 openjdk-17-17.0.18+8/test/jdk/sun/util/calendar/zi/ZoneInfoOld.java | 10 openjdk-17-17.0.18+8/test/jdk/sun/util/calendar/zi/Zoneinfo.java | 4 openjdk-17-17.0.18+8/test/jdk/sun/util/logging/SourceClassName.java | 6 openjdk-17-17.0.18+8/test/jdk/sun/util/resources/TimeZone/Bug4640234.java | 11 openjdk-17-17.0.18+8/test/jdk/sun/util/resources/cldr/Bug8134384.java | 7 openjdk-17-17.0.18+8/test/jdk/sun/util/resources/cldr/Bug8202764.java | 5 openjdk-17-17.0.18+8/test/jdk/tools/jlink/JLinkNegativeTest.java | 14 openjdk-17-17.0.18+8/test/jdk/tools/jpackage/TEST.properties | 3 openjdk-17-17.0.18+8/test/jdk/tools/jpackage/apps/UseShutdownHook.java | 88 openjdk-17-17.0.18+8/test/jdk/tools/jpackage/helpers-test/jdk/jpackage/test/JavaAppDescTest.java | 98 openjdk-17-17.0.18+8/test/jdk/tools/jpackage/helpers-test/jdk/jpackage/test/TKitTest.java | 244 openjdk-17-17.0.18+8/test/jdk/tools/jpackage/helpers-test/jdk/jpackage/test/TestSuite.java | 63 openjdk-17-17.0.18+8/test/jdk/tools/jpackage/helpers/jdk/jpackage/test/CfgFile.java | 121 openjdk-17-17.0.18+8/test/jdk/tools/jpackage/helpers/jdk/jpackage/test/Comm.java | 39 openjdk-17-17.0.18+8/test/jdk/tools/jpackage/helpers/jdk/jpackage/test/Executor.java | 169 openjdk-17-17.0.18+8/test/jdk/tools/jpackage/helpers/jdk/jpackage/test/Functional.java | 17 openjdk-17-17.0.18+8/test/jdk/tools/jpackage/helpers/jdk/jpackage/test/HelloApp.java | 113 openjdk-17-17.0.18+8/test/jdk/tools/jpackage/helpers/jdk/jpackage/test/JPackageCommand.java | 38 openjdk-17-17.0.18+8/test/jdk/tools/jpackage/helpers/jdk/jpackage/test/JavaAppDesc.java | 62 openjdk-17-17.0.18+8/test/jdk/tools/jpackage/helpers/jdk/jpackage/test/LauncherIconVerifier.java | 186 openjdk-17-17.0.18+8/test/jdk/tools/jpackage/helpers/jdk/jpackage/test/PackageTest.java | 10 openjdk-17-17.0.18+8/test/jdk/tools/jpackage/helpers/jdk/jpackage/test/TKit.java | 228 openjdk-17-17.0.18+8/test/jdk/tools/jpackage/helpers/jdk/jpackage/test/WindowsHelper.java | 117 openjdk-17-17.0.18+8/test/jdk/tools/jpackage/linux/AppAboutUrlTest.java | 8 openjdk-17-17.0.18+8/test/jdk/tools/jpackage/linux/AppCategoryTest.java | 5 openjdk-17-17.0.18+8/test/jdk/tools/jpackage/linux/LicenseTypeTest.java | 5 openjdk-17-17.0.18+8/test/jdk/tools/jpackage/linux/LinuxBundleNameTest.java | 5 openjdk-17-17.0.18+8/test/jdk/tools/jpackage/linux/LinuxResourceTest.java | 5 openjdk-17-17.0.18+8/test/jdk/tools/jpackage/linux/LinuxWeirdOutputDirTest.java | 5 openjdk-17-17.0.18+8/test/jdk/tools/jpackage/linux/MaintainerTest.java | 5 openjdk-17-17.0.18+8/test/jdk/tools/jpackage/linux/PackageDepsTest.java | 5 openjdk-17-17.0.18+8/test/jdk/tools/jpackage/linux/ReleaseTest.java | 5 openjdk-17-17.0.18+8/test/jdk/tools/jpackage/linux/ShortcutHintTest.java | 8 openjdk-17-17.0.18+8/test/jdk/tools/jpackage/linux/UsrTreeTest.java | 126 openjdk-17-17.0.18+8/test/jdk/tools/jpackage/linux/jdk/jpackage/tests/UsrTreeTest.java | 127 openjdk-17-17.0.18+8/test/jdk/tools/jpackage/macosx/ArgumentsFilteringTest.java | 26 openjdk-17-17.0.18+8/test/jdk/tools/jpackage/macosx/HostArchPkgTest.java | 5 openjdk-17-17.0.18+8/test/jdk/tools/jpackage/macosx/MacAppStoreJlinkOptionsTest.java | 6 openjdk-17-17.0.18+8/test/jdk/tools/jpackage/macosx/MacAppStoreRuntimeTest.java | 6 openjdk-17-17.0.18+8/test/jdk/tools/jpackage/macosx/MacFileAssociationsTest.java | 5 openjdk-17-17.0.18+8/test/jdk/tools/jpackage/macosx/MacPropertiesTest.java | 5 openjdk-17-17.0.18+8/test/jdk/tools/jpackage/macosx/NameWithSpaceTest.java | 5 openjdk-17-17.0.18+8/test/jdk/tools/jpackage/macosx/SigningAppImageTest.java | 5 openjdk-17-17.0.18+8/test/jdk/tools/jpackage/macosx/SigningPackageTest.java | 5 openjdk-17-17.0.18+8/test/jdk/tools/jpackage/resources/Win8365790Test.ps1 | 83 openjdk-17-17.0.18+8/test/jdk/tools/jpackage/share/AddLauncherTest.java | 23 openjdk-17-17.0.18+8/test/jdk/tools/jpackage/share/AppImagePackageTest.java | 5 openjdk-17-17.0.18+8/test/jdk/tools/jpackage/share/AppLauncherEnvTest.java | 17 openjdk-17-17.0.18+8/test/jdk/tools/jpackage/share/AppVersionTest.java | 130 openjdk-17-17.0.18+8/test/jdk/tools/jpackage/share/ArgumentsTest.java | 28 openjdk-17-17.0.18+8/test/jdk/tools/jpackage/share/BasicTest.java | 363 + openjdk-17-17.0.18+8/test/jdk/tools/jpackage/share/CookedRuntimeTest.java | 140 openjdk-17-17.0.18+8/test/jdk/tools/jpackage/share/DotInNameTest.java | 59 openjdk-17-17.0.18+8/test/jdk/tools/jpackage/share/EmptyFolderTest.java | 8 openjdk-17-17.0.18+8/test/jdk/tools/jpackage/share/ErrorTest.java | 133 openjdk-17-17.0.18+8/test/jdk/tools/jpackage/share/FileAssociationsTest.java | 8 openjdk-17-17.0.18+8/test/jdk/tools/jpackage/share/IconTest.java | 9 openjdk-17-17.0.18+8/test/jdk/tools/jpackage/share/InstallDirTest.java | 8 openjdk-17-17.0.18+8/test/jdk/tools/jpackage/share/JLinkOptionsTest.java | 142 openjdk-17-17.0.18+8/test/jdk/tools/jpackage/share/JavaOptionsEqualsTest.java | 93 openjdk-17-17.0.18+8/test/jdk/tools/jpackage/share/JavaOptionsTest.java | 99 openjdk-17-17.0.18+8/test/jdk/tools/jpackage/share/LicenseTest.java | 8 openjdk-17-17.0.18+8/test/jdk/tools/jpackage/share/MainClassTest.java | 319 + openjdk-17-17.0.18+8/test/jdk/tools/jpackage/share/ModulePathTest.java | 145 openjdk-17-17.0.18+8/test/jdk/tools/jpackage/share/ModulePathTest2.java | 74 openjdk-17-17.0.18+8/test/jdk/tools/jpackage/share/ModulePathTest3.java | 138 openjdk-17-17.0.18+8/test/jdk/tools/jpackage/share/MultiLauncherTwoPhaseTest.java | 10 openjdk-17-17.0.18+8/test/jdk/tools/jpackage/share/MultiNameTwoPhaseTest.java | 6 openjdk-17-17.0.18+8/test/jdk/tools/jpackage/share/MultipleJarAppTest.java | 55 openjdk-17-17.0.18+8/test/jdk/tools/jpackage/share/NoMPathRuntimeTest.java | 134 openjdk-17-17.0.18+8/test/jdk/tools/jpackage/share/NonExistentTest.java | 91 openjdk-17-17.0.18+8/test/jdk/tools/jpackage/share/RuntimeImageTest.java | 3 openjdk-17-17.0.18+8/test/jdk/tools/jpackage/share/RuntimePackageTest.java | 31 openjdk-17-17.0.18+8/test/jdk/tools/jpackage/share/SimplePackageTest.java | 5 openjdk-17-17.0.18+8/test/jdk/tools/jpackage/share/UnicodeArgsTest.java | 80 openjdk-17-17.0.18+8/test/jdk/tools/jpackage/share/VendorTest.java | 104 openjdk-17-17.0.18+8/test/jdk/tools/jpackage/share/jdk/jpackage/tests/AppVersionTest.java | 132 openjdk-17-17.0.18+8/test/jdk/tools/jpackage/share/jdk/jpackage/tests/BasicTest.java | 371 - openjdk-17-17.0.18+8/test/jdk/tools/jpackage/share/jdk/jpackage/tests/CookedRuntimeTest.java | 142 openjdk-17-17.0.18+8/test/jdk/tools/jpackage/share/jdk/jpackage/tests/DotInNameTest.java | 61 openjdk-17-17.0.18+8/test/jdk/tools/jpackage/share/jdk/jpackage/tests/ErrorTest.java | 136 openjdk-17-17.0.18+8/test/jdk/tools/jpackage/share/jdk/jpackage/tests/JLinkOptionsTest.java | 144 openjdk-17-17.0.18+8/test/jdk/tools/jpackage/share/jdk/jpackage/tests/JavaOptionsEqualsTest.java | 96 openjdk-17-17.0.18+8/test/jdk/tools/jpackage/share/jdk/jpackage/tests/JavaOptionsTest.java | 101 openjdk-17-17.0.18+8/test/jdk/tools/jpackage/share/jdk/jpackage/tests/MainClassTest.java | 321 - openjdk-17-17.0.18+8/test/jdk/tools/jpackage/share/jdk/jpackage/tests/ModulePathTest.java | 147 openjdk-17-17.0.18+8/test/jdk/tools/jpackage/share/jdk/jpackage/tests/ModulePathTest2.java | 76 openjdk-17-17.0.18+8/test/jdk/tools/jpackage/share/jdk/jpackage/tests/ModulePathTest3.java | 140 openjdk-17-17.0.18+8/test/jdk/tools/jpackage/share/jdk/jpackage/tests/MultipleJarAppTest.java | 57 openjdk-17-17.0.18+8/test/jdk/tools/jpackage/share/jdk/jpackage/tests/NoMPathRuntimeTest.java | 136 openjdk-17-17.0.18+8/test/jdk/tools/jpackage/share/jdk/jpackage/tests/NonExistentTest.java | 93 openjdk-17-17.0.18+8/test/jdk/tools/jpackage/share/jdk/jpackage/tests/UnicodeArgsTest.java | 82 openjdk-17-17.0.18+8/test/jdk/tools/jpackage/share/jdk/jpackage/tests/VendorTest.java | 107 openjdk-17-17.0.18+8/test/jdk/tools/jpackage/windows/Win8282351Test.java | 5 openjdk-17-17.0.18+8/test/jdk/tools/jpackage/windows/Win8301247Test.java | 5 openjdk-17-17.0.18+8/test/jdk/tools/jpackage/windows/Win8365790Test.java | 130 openjdk-17-17.0.18+8/test/jdk/tools/jpackage/windows/WinChildProcessTest.java | 28 openjdk-17-17.0.18+8/test/jdk/tools/jpackage/windows/WinConsoleTest.java | 5 openjdk-17-17.0.18+8/test/jdk/tools/jpackage/windows/WinDirChooserTest.java | 5 openjdk-17-17.0.18+8/test/jdk/tools/jpackage/windows/WinInstallerIconTest.java | 5 openjdk-17-17.0.18+8/test/jdk/tools/jpackage/windows/WinInstallerUiTest.java | 5 openjdk-17-17.0.18+8/test/jdk/tools/jpackage/windows/WinL10nTest.java | 6 openjdk-17-17.0.18+8/test/jdk/tools/jpackage/windows/WinMenuGroupTest.java | 5 openjdk-17-17.0.18+8/test/jdk/tools/jpackage/windows/WinMenuTest.java | 5 openjdk-17-17.0.18+8/test/jdk/tools/jpackage/windows/WinPerUserInstallTest.java | 5 openjdk-17-17.0.18+8/test/jdk/tools/jpackage/windows/WinRenameTest.java | 15 openjdk-17-17.0.18+8/test/jdk/tools/jpackage/windows/WinResourceTest.java | 5 openjdk-17-17.0.18+8/test/jdk/tools/jpackage/windows/WinScriptTest.java | 5 openjdk-17-17.0.18+8/test/jdk/tools/jpackage/windows/WinShortcutPromptTest.java | 5 openjdk-17-17.0.18+8/test/jdk/tools/jpackage/windows/WinShortcutTest.java | 5 openjdk-17-17.0.18+8/test/jdk/tools/jpackage/windows/WinUpgradeUUIDTest.java | 8 openjdk-17-17.0.18+8/test/jdk/tools/jpackage/windows/WinUrlTest.java | 5 openjdk-17-17.0.18+8/test/jtreg-ext/requires/VMProps.java | 31 openjdk-17-17.0.18+8/test/langtools/tools/javac/jvm/ClassRefDupInConstantPoolTest.java | 4 openjdk-17-17.0.18+8/test/lib-test/jdk/test/whitebox/vm_flags/SizeTTest.java | 4 openjdk-17-17.0.18+8/test/lib/jdk/test/lib/Container.java | 5 openjdk-17-17.0.18+8/test/lib/jdk/test/lib/cli/CommandLineOptionTest.java | 11 openjdk-17-17.0.18+8/test/lib/jdk/test/lib/containers/cgroup/MetricsTesterCgroupV2.java | 5 openjdk-17-17.0.18+8/test/lib/jdk/test/lib/security/CertificateBuilder.java | 98 openjdk-17-17.0.18+8/test/lib/jdk/test/lib/util/ModuleInfoWriter.java | 232 openjdk-17-17.0.18+8/test/lib/jdk/test/whitebox/WhiteBox.java | 51 openjdk-17-17.0.18+8/test/micro/org/openjdk/bench/java/lang/StringDecode.java | 207 openjdk-17-17.0.18+8/test/micro/org/openjdk/bench/java/lang/StringEncode.java | 214 openjdk-17-17.0.18+8/test/micro/org/openjdk/bench/java/security/Signatures.java | 3 openjdk-17-17.0.18+8/test/micro/org/openjdk/bench/java/util/concurrent/ProducerConsumer.java | 9 openjdk-17-17.0.18+8/test/micro/org/openjdk/bench/java/util/concurrent/Queues.java | 9 openjdk-17-17.0.18+8/test/micro/org/openjdk/bench/vm/compiler/LoopUnroll.java | 2 905 files changed, 40628 insertions(+), 14375 deletions(-) dpkg-source: warning: cannot verify inline signature for /srv/release.debian.org/tmp/tmp5zaevcws/openjdk-17_17.0.17+10-1~deb12u1.dsc: no acceptable signature found dpkg-source: warning: cannot verify inline signature for /srv/release.debian.org/tmp/tmp5zaevcws/openjdk-17_17.0.18+8-1~deb12u1.dsc: no acceptable signature found diff -Nru openjdk-17-17.0.17+10/.jcheck/conf openjdk-17-17.0.18+8/.jcheck/conf --- openjdk-17-17.0.17+10/.jcheck/conf 2025-10-13 07:48:04.000000000 +0000 +++ openjdk-17-17.0.18+8/.jcheck/conf 2026-01-15 15:23:06.000000000 +0000 @@ -1,7 +1,7 @@ [general] project=jdk-updates jbs=JDK -version=17.0.17 +version=17.0.18 [checks] error=author,committer,reviewers,merge,issues,executable,symlink,message,hg-tag,whitespace,problemlists diff -Nru openjdk-17-17.0.17+10/debian/JB-doc.overrides.in openjdk-17-17.0.18+8/debian/JB-doc.overrides.in --- openjdk-17-17.0.17+10/debian/JB-doc.overrides.in 2025-07-18 14:36:10.000000000 +0000 +++ openjdk-17-17.0.18+8/debian/JB-doc.overrides.in 2026-01-21 21:50:48.000000000 +0000 @@ -3,3 +3,11 @@ # chromium and firefox snaps are unable to load scripts from /usr/share/javascript # LP: 2032992 @basename@-doc binary: embedded-javascript-library + +# repeated path segments due to upstream code structure: +# usr/share/doc/openjdk-11-jre-headless/api/jdk.scripting.nashorn/jdk/nashorn/api/ +# usr/share/doc/openjdk-11-jre-headless/api/jquery/external/jquery/ +@basename@-doc binary: repeated-path-segment + +# override warning for the old mailing address in upstream copyright +@basename@-doc binary: old-fsf-address-in-copyright-file diff -Nru openjdk-17-17.0.17+10/debian/JB-jre-headless.overrides.in openjdk-17-17.0.18+8/debian/JB-jre-headless.overrides.in --- openjdk-17-17.0.17+10/debian/JB-jre-headless.overrides.in 2025-07-18 14:36:10.000000000 +0000 +++ openjdk-17-17.0.18+8/debian/JB-jre-headless.overrides.in 2026-01-21 21:50:48.000000000 +0000 @@ -1,4 +1,5 @@ -# Strip libjvm.so with --strip-debug instead of --strip-unneeded. LP: #574997. +# keep symbols so that native memory tracking works +# See https://bugs.launchpad.net/ubuntu/+source/openjdk-20/+bug/2012326 @basename@-jre-headless binary: unstripped-binary-or-object # Ignore the mouse cursors @@ -16,3 +17,6 @@ # repeated lib due to upstream implementation directory layout @basename@-jre-headless binary: repeated-path-segment + +# override warning for the old mailing address in upstream copyright +@basename@-jre-headless binary: old-fsf-address-in-copyright-file diff -Nru openjdk-17-17.0.17+10/debian/JB-jre-zero.overrides.in openjdk-17-17.0.18+8/debian/JB-jre-zero.overrides.in --- openjdk-17-17.0.17+10/debian/JB-jre-zero.overrides.in 2025-07-18 14:36:10.000000000 +0000 +++ openjdk-17-17.0.18+8/debian/JB-jre-zero.overrides.in 2026-01-12 00:57:31.000000000 +0000 @@ -1,4 +1,5 @@ -# Strip libjvm.so with --strip-debug instead of --strip-unneeded. LP: #574997. +# keep symbols so that native memory tracking works +# See https://bugs.launchpad.net/ubuntu/+source/openjdk-20/+bug/2012326 @basename@-jre-zero binary: unstripped-binary-or-object # Upstream implementation diff -Nru openjdk-17-17.0.17+10/debian/JB-jre.overrides.in openjdk-17-17.0.18+8/debian/JB-jre.overrides.in --- openjdk-17-17.0.17+10/debian/JB-jre.overrides.in 2025-07-18 14:36:10.000000000 +0000 +++ openjdk-17-17.0.18+8/debian/JB-jre.overrides.in 2026-01-12 00:57:31.000000000 +0000 @@ -1,8 +1,8 @@ # these are in the -jre-headless package, -jre depends on it @basename@-jre binary: desktop-command-not-in-package -# LP: #2012326 - in order to print allocation locations, -# the libraries need to retain symbols +# keep symbols so that native memory tracking works +# See https://bugs.launchpad.net/ubuntu/+source/openjdk-20/+bug/2012326 @basename@-jre binary: unstripped-binary-or-object # repeated lib due to upstream implementation directory layout diff -Nru openjdk-17-17.0.17+10/debian/changelog openjdk-17-17.0.18+8/debian/changelog --- openjdk-17-17.0.17+10/debian/changelog 2025-10-23 10:33:48.000000000 +0000 +++ openjdk-17-17.0.18+8/debian/changelog 2026-01-22 22:15:41.000000000 +0000 @@ -1,8 +1,41 @@ -openjdk-17 (17.0.17+10-1~deb12u1) bookworm-security; urgency=medium +openjdk-17 (17.0.18+8-1~deb12u1) bookworm-security; urgency=medium * Rebuild for bookworm - -- Moritz Mühlenhoff Thu, 23 Oct 2025 12:33:48 +0200 + -- Moritz Mühlenhoff Thu, 22 Jan 2026 23:15:51 +0100 + +openjdk-17 (17.0.18+8-1) unstable; urgency=medium + + * OpenJDK 17.0.18 release, build 8. + - CVEs: + + CVE-2026-21945: 8368032: Enhance Certificate Checking. + + CVE-2026-21932: 8359501: Enhance Handling of URIs. + + CVE-2026-21933: 8362632: Improve HttpServer Request handling. + + CVE-2026-21925: 8341496: Improve JMX connections. + + -- Vladimir Petko Thu, 22 Jan 2026 12:38:58 +1300 + +openjdk-17 (17.0.18~7ea-1) unstable; urgency=medium + + * OpenJDK 17.0.18 early access, build 7. + + [ Matthias Klose ] + * d/rules: Run the testsuite for loong64, don't run on riscv64. + + [ Pushkar Kulkarni ] + * d/t/jtreg-autopkgtest.*: use locale name "C.UTF-8" on bionic + and focal. + + [ Vladimir Petko ] + * d/p/jdk-8369450-proposed.patch: Drop patch applied upstream. + * Update override comments for unstripped-binary-or-object. We need to + keep symbols for Native Memory Tracking to work. + * d/{JB-doc.overrides.in, JB-jre-headless.overrides.in}: Add override + for old FSF copyright address. + * d/s/lintian-overrides: Override false positive debian-rules-calls- + nproc. The utility is used to log the number of processors. + + -- Vladimir Petko Mon, 05 Jan 2026 15:55:38 +1300 openjdk-17 (17.0.17+10-1) unstable; urgency=medium diff -Nru openjdk-17-17.0.17+10/debian/patches/jdk-8369450-proposed.patch openjdk-17-17.0.18+8/debian/patches/jdk-8369450-proposed.patch --- openjdk-17-17.0.17+10/debian/patches/jdk-8369450-proposed.patch 2025-10-09 08:04:30.000000000 +0000 +++ openjdk-17-17.0.18+8/debian/patches/jdk-8369450-proposed.patch 1970-01-01 00:00:00.000000000 +0000 @@ -1,18 +0,0 @@ -Description: [Ubuntu 25.10] openjdk fails to build due to rust-coreutils date - Add uutils as a GNU-compatible date provider. -Author: Vladimir Petko -Origin: upstream, https://github.com/openjdk/jdk/pull/27705 -Bug: https://bugs.openjdk.org/browse/JDK-8369450 -Bug-Ubuntu: https://bugs.launchpad.net/ubuntu/+source/openjdk-25/+bug/2127120 -Last-Update: 2025-10-09 ---- a/make/autoconf/basic_tools.m4 -+++ b/make/autoconf/basic_tools.m4 -@@ -378,7 +378,7 @@ - - # Check if it's a GNU date compatible version - AC_MSG_CHECKING([if date is a GNU compatible version]) -- check_date=`$DATE --version 2>&1 | $GREP "GNU\|BusyBox"` -+ check_date=`$DATE --version 2>&1 | $GREP "GNU\|BusyBox\|uutils"` - if test "x$check_date" != x; then - AC_MSG_RESULT([yes]) - IS_GNU_DATE=yes diff -Nru openjdk-17-17.0.17+10/debian/patches/series openjdk-17-17.0.18+8/debian/patches/series --- openjdk-17-17.0.17+10/debian/patches/series 2025-10-09 08:04:30.000000000 +0000 +++ openjdk-17-17.0.18+8/debian/patches/series 2026-01-21 22:34:38.000000000 +0000 @@ -39,4 +39,3 @@ jdk-8336529-proposed.patch jdk-8312488.patch jdk-8359735.patch -jdk-8369450-proposed.patch diff -Nru openjdk-17-17.0.17+10/debian/rules openjdk-17-17.0.18+8/debian/rules --- openjdk-17-17.0.17+10/debian/rules 2025-10-22 06:13:30.000000000 +0000 +++ openjdk-17-17.0.18+8/debian/rules 2026-01-21 22:34:38.000000000 +0000 @@ -83,7 +83,6 @@ endif is_upstream_release = yes -#is_upstream_release = srcdir = . builddir = build @@ -162,7 +161,7 @@ testng_pkg= libtestng7-java with_check = $(if $(findstring nocheck, $(DEB_BUILD_OPTIONS)),,yes) -ifneq (,$(filter $(DEB_HOST_ARCH), alpha armel ia64 loong64 mipsel mips64el powerpc x32)) +ifneq (,$(filter $(DEB_HOST_ARCH), alpha armel mipsel mips64el powerpc riscv64 x32)) with_check = disabled running check on $(DEB_HOST_ARCH) endif ifeq ($(distribution)-$(DEB_HOST_ARCH),Ubuntu-riscv64) @@ -2007,7 +2006,7 @@ dh_builddeb -a $(nodemo) $(nojrez) #$(bd_options) git_project = jdk17u -git_tag = jdk-17.0.17+10 +git_tag = jdk-17.0.18+8 package_version = $(subst jdk-,,$(git_tag)) package_version = $(shell echo $(PKGVERSION) | sed 's/-[^-][^-]*$$//') ifneq ($(is_upstream_release),yes) diff -Nru openjdk-17-17.0.17+10/debian/source/lintian-overrides openjdk-17-17.0.18+8/debian/source/lintian-overrides --- openjdk-17-17.0.17+10/debian/source/lintian-overrides 2025-07-18 14:36:10.000000000 +0000 +++ openjdk-17-17.0.18+8/debian/source/lintian-overrides 2026-01-21 22:34:38.000000000 +0000 @@ -22,3 +22,7 @@ # chromium and firefox snaps are unable to load scripts from /usr/share/javascript # LP: 2032992 openjdk-17 source: source-contains-prebuilt-javascript-object + +# false positive: nproc is called to print the number of processors +# to the log +openjdk-17 source: debian-rules-calls-nproc diff -Nru openjdk-17-17.0.17+10/debian/tests/jtreg-autopkgtest.in openjdk-17-17.0.18+8/debian/tests/jtreg-autopkgtest.in --- openjdk-17-17.0.17+10/debian/tests/jtreg-autopkgtest.in 2025-10-17 07:06:28.000000000 +0000 +++ openjdk-17-17.0.18+8/debian/tests/jtreg-autopkgtest.in 2026-01-21 22:34:38.000000000 +0000 @@ -98,14 +98,24 @@ output_dir="${AUTOPKGTEST_ARTIFACTS}/${testsuite}/" # force utf-8 for tests -LANG=C.UTF8 +distrel=$(lsb_release --codename --short) +case "$distrel" in + bionic|focal) + c_utf8="C.UTF-8" + ;; + *) + c_utf8="C.UTF8" + ;; +esac + +LANG=${c_utf8} # retry tests with "fail" or "error" status at most 3 times for i in 0 1; do # save each try under its own folder to preserve history report_path="${i}/JTreport" report_dir="${output_dir}/${report_path}" - LANG=C.UTF8 LC_ALL=C.UTF8 jtreg ${jt_options} \ + LANG=${c_utf8} LC_ALL=${c_utf8} jtreg ${jt_options} \ -vmoption:-Djtreg.home=/usr/share/jtreg \ -verbose:summary \ -automatic \ diff -Nru openjdk-17-17.0.17+10/debian/tests/jtreg-autopkgtest.sh openjdk-17-17.0.18+8/debian/tests/jtreg-autopkgtest.sh --- openjdk-17-17.0.17+10/debian/tests/jtreg-autopkgtest.sh 2025-10-17 07:06:36.000000000 +0000 +++ openjdk-17-17.0.18+8/debian/tests/jtreg-autopkgtest.sh 2026-01-21 22:34:38.000000000 +0000 @@ -97,12 +97,25 @@ jtwork_dir="${AUTOPKGTEST_TMP}/${testsuite}/JTwork" output_dir="${AUTOPKGTEST_ARTIFACTS}/${testsuite}/" +# force utf-8 for tests +distrel=$(lsb_release --codename --short) +case "$distrel" in + bionic|focal) + c_utf8="C.UTF-8" + ;; + *) + c_utf8="C.UTF8" + ;; +esac + +LANG=${c_utf8} + # retry tests with "fail" or "error" status at most 3 times for i in 0 1; do # save each try under its own folder to preserve history report_path="${i}/JTreport" report_dir="${output_dir}/${report_path}" - LANG=C.UTF8 LC_ALL=C.UTF8 jtreg ${jt_options} \ + LANG=${c_utf8} LC_ALL=${c_utf8} jtreg ${jt_options} \ -vmoption:-Djtreg.home=/usr/share/jtreg \ -verbose:summary \ -automatic \ diff -Nru openjdk-17-17.0.17+10/make/RunTests.gmk openjdk-17-17.0.18+8/make/RunTests.gmk --- openjdk-17-17.0.17+10/make/RunTests.gmk 2025-10-13 07:48:04.000000000 +0000 +++ openjdk-17-17.0.18+8/make/RunTests.gmk 2026-01-15 15:23:06.000000000 +0000 @@ -1055,7 +1055,7 @@ # Now process each test to run and setup a proper make rule $(foreach test, $(TESTS_TO_RUN), \ $(eval TEST_ID := $(shell $(ECHO) $(strip $(test)) | \ - $(TR) -cs '[a-z][A-Z][0-9]\n' '[_*1000]')) \ + $(TR) -cs '[a-z][A-Z][0-9]\n' '_')) \ $(eval ALL_TEST_IDS += $(TEST_ID)) \ $(if $(call UseCustomTestHandler, $(test)), \ $(eval $(call SetupRunCustomTest, $(TEST_ID), \ @@ -1135,9 +1135,9 @@ TEST TOTAL PASS FAIL ERROR " " $(foreach test, $(TESTS_TO_RUN), \ $(eval TEST_ID := $(shell $(ECHO) $(strip $(test)) | \ - $(TR) -cs '[a-z][A-Z][0-9]\n' '[_*1000]')) \ + $(TR) -cs '[a-z][A-Z][0-9]\n' '_')) \ $(ECHO) >> $(TEST_LAST_IDS) $(TEST_ID) $(NEWLINE) \ - $(eval NAME_PATTERN := $(shell $(ECHO) $(test) | $(TR) -c '\n' '[_*1000]')) \ + $(eval NAME_PATTERN := $(shell $(ECHO) $(test) | $(TR) -c '\n' '_')) \ $(if $(filter __________________________________________________%, $(NAME_PATTERN)), \ $(eval TEST_NAME := ) \ $(PRINTF) >> $(TEST_SUMMARY) "%2s %-49s\n" " " "$(test)" $(NEWLINE) \ diff -Nru openjdk-17-17.0.17+10/make/autoconf/basic_tools.m4 openjdk-17-17.0.18+8/make/autoconf/basic_tools.m4 --- openjdk-17-17.0.17+10/make/autoconf/basic_tools.m4 2025-10-13 07:48:04.000000000 +0000 +++ openjdk-17-17.0.18+8/make/autoconf/basic_tools.m4 2026-01-15 15:23:06.000000000 +0000 @@ -373,7 +373,7 @@ # Check if it's a GNU date compatible version AC_MSG_CHECKING([if date is a GNU compatible version]) - check_date=`$DATE --version 2>&1 | $GREP "GNU\|BusyBox"` + check_date=`$DATE --version 2>&1 | $GREP "GNU\|BusyBox\|uutils"` if test "x$check_date" != x; then AC_MSG_RESULT([yes]) IS_GNU_DATE=yes diff -Nru openjdk-17-17.0.17+10/make/autoconf/flags-cflags.m4 openjdk-17-17.0.18+8/make/autoconf/flags-cflags.m4 --- openjdk-17-17.0.17+10/make/autoconf/flags-cflags.m4 2025-10-13 07:48:04.000000000 +0000 +++ openjdk-17-17.0.18+8/make/autoconf/flags-cflags.m4 2026-01-15 15:23:06.000000000 +0000 @@ -544,8 +544,8 @@ TOOLCHAIN_CFLAGS_JVM="-qtbtable=full -qtune=balanced \ -qalias=noansi -qstrict -qtls=default -qnortti -qnoeh -qignerrno -qstackprotect" elif test "x$TOOLCHAIN_TYPE" = xmicrosoft; then - TOOLCHAIN_CFLAGS_JVM="-nologo -MD -MP" - TOOLCHAIN_CFLAGS_JDK="-nologo -MD -Zc:wchar_t-" + TOOLCHAIN_CFLAGS_JVM="-nologo -MD -Zc:strictStrings -MP" + TOOLCHAIN_CFLAGS_JDK="-nologo -MD -Zc:strictStrings -Zc:wchar_t-" fi # CFLAGS C language level for JDK sources (hotspot only uses C++) diff -Nru openjdk-17-17.0.17+10/make/autoconf/flags.m4 openjdk-17-17.0.18+8/make/autoconf/flags.m4 --- openjdk-17-17.0.17+10/make/autoconf/flags.m4 2025-10-13 07:48:04.000000000 +0000 +++ openjdk-17-17.0.18+8/make/autoconf/flags.m4 2026-01-15 15:23:06.000000000 +0000 @@ -1,5 +1,5 @@ # -# Copyright (c) 2011, 2021, Oracle and/or its affiliates. All rights reserved. +# Copyright (c) 2011, 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 @@ -128,16 +128,12 @@ # The expected format for is either nn.n.n or nn.nn.nn. See # /Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX.sdk/usr/include/AvailabilityVersions.h - # MACOSX_VERSION_MIN specifies the lowest version of Macosx that the built + # MACOSX_VERSION_MIN specifies the lowest version of macOS that the built # binaries should be compatible with, even if compiled on a newer version # of the OS. It currently has a hard coded value. Setting this also limits # exposure to API changes in header files. Bumping this is likely to # require code changes to build. - if test "x$OPENJDK_TARGET_CPU_ARCH" = xaarch64; then - MACOSX_VERSION_MIN=11.00.00 - else - MACOSX_VERSION_MIN=10.12.0 - fi + MACOSX_VERSION_MIN=11.00.00 MACOSX_VERSION_MIN_NODOTS=${MACOSX_VERSION_MIN//\./} AC_SUBST(MACOSX_VERSION_MIN) diff -Nru openjdk-17-17.0.17+10/make/common/MakeBase.gmk openjdk-17-17.0.18+8/make/common/MakeBase.gmk --- openjdk-17-17.0.17+10/make/common/MakeBase.gmk 2025-10-13 07:48:04.000000000 +0000 +++ openjdk-17-17.0.18+8/make/common/MakeBase.gmk 2026-01-15 15:23:06.000000000 +0000 @@ -199,7 +199,7 @@ ################################################################################ -MAX_PARAMS := 36 +MAX_PARAMS := 96 PARAM_SEQUENCE := $(call sequence, 2, $(MAX_PARAMS)) # Template for creating a macro taking named parameters. To use it, assign the diff -Nru openjdk-17-17.0.17+10/make/common/NativeCompilation.gmk openjdk-17-17.0.18+8/make/common/NativeCompilation.gmk --- openjdk-17-17.0.17+10/make/common/NativeCompilation.gmk 2025-10-13 07:48:04.000000000 +0000 +++ openjdk-17-17.0.18+8/make/common/NativeCompilation.gmk 2026-01-15 15:23:06.000000000 +0000 @@ -363,18 +363,20 @@ endif $1_BASE_CFLAGS := $$($$($1_BASE)_CFLAGS) $$($$($1_BASE)_EXTRA_CFLAGS) \ - $$($$($1_BASE)_SYSROOT_CFLAGS) $$($1_WARNINGS_FLAGS) + $$($$($1_BASE)_SYSROOT_CFLAGS) $1_BASE_CXXFLAGS := $$($$($1_BASE)_CXXFLAGS) $$($$($1_BASE)_EXTRA_CXXFLAGS) \ - $$($$($1_BASE)_SYSROOT_CFLAGS) $$($1_EXTRA_CXXFLAGS) $$($1_WARNINGS_FLAGS) + $$($$($1_BASE)_SYSROOT_CFLAGS) $$($1_EXTRA_CXXFLAGS) $1_BASE_ASFLAGS := $$($$($1_BASE)_ASFLAGS) $$($$($1_BASE)_EXTRA_ASFLAGS) ifneq ($$(filter %.c, $$($1_FILENAME)), ) # Compile as a C file + $1_CFLAGS += $$($1_WARNINGS_FLAGS) $1_FLAGS := $(CFLAGS_CCACHE) $$($1_USE_PCH_FLAGS) $$($1_BASE_CFLAGS) \ $$($1_OPT_CFLAGS) $$($1_CFLAGS) -c $1_COMPILER := $$($$($1_BASE)_CC) else ifneq ($$(filter %.m, $$($1_FILENAME)), ) # Compile as an Objective-C file + $1_CFLAGS += $$($1_WARNINGS_FLAGS) $1_FLAGS := -x objective-c $(CFLAGS_CCACHE) $$($1_USE_PCH_FLAGS) \ $$($1_BASE_CFLAGS) $$($1_OPT_CFLAGS) $$($1_CFLAGS) -c $1_COMPILER := $$($$($1_BASE)_CC) @@ -398,6 +400,7 @@ endif else ifneq ($$(filter %.cpp %.cc %.mm, $$($1_FILENAME)), ) # Compile as a C++ or Objective-C++ file + $1_CXXFLAGS += $$($1_WARNINGS_FLAGS) $1_FLAGS := $(CFLAGS_CCACHE) $$($1_USE_PCH_FLAGS) $$($1_BASE_CXXFLAGS) \ $$($1_OPT_CXXFLAGS) $$($1_CXXFLAGS) -c $1_COMPILER := $$($$($1_BASE)_CXX) diff -Nru openjdk-17-17.0.17+10/make/conf/jib-profiles.js openjdk-17-17.0.18+8/make/conf/jib-profiles.js --- openjdk-17-17.0.17+10/make/conf/jib-profiles.js 2025-10-13 07:48:04.000000000 +0000 +++ openjdk-17-17.0.18+8/make/conf/jib-profiles.js 2026-01-15 15:23:06.000000000 +0000 @@ -446,7 +446,7 @@ target_cpu: "x64", dependencies: ["devkit", "gtest", "pandoc"], configure_args: concat(common.configure_args_64bit, "--with-zlib=system", - "--with-macosx-version-max=10.12.00", + "--with-macosx-version-max=11.00.00", "--enable-compatible-cds-alignment", // Use system SetFile instead of the one in the devkit as the // devkit one may not work on Catalina. diff -Nru openjdk-17-17.0.17+10/make/conf/version-numbers.conf openjdk-17-17.0.18+8/make/conf/version-numbers.conf --- openjdk-17-17.0.17+10/make/conf/version-numbers.conf 2025-10-13 07:48:04.000000000 +0000 +++ openjdk-17-17.0.18+8/make/conf/version-numbers.conf 2026-01-15 15:23:06.000000000 +0000 @@ -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 @@ -28,12 +28,12 @@ DEFAULT_VERSION_FEATURE=17 DEFAULT_VERSION_INTERIM=0 -DEFAULT_VERSION_UPDATE=17 +DEFAULT_VERSION_UPDATE=18 DEFAULT_VERSION_PATCH=0 DEFAULT_VERSION_EXTRA1=0 DEFAULT_VERSION_EXTRA2=0 DEFAULT_VERSION_EXTRA3=0 -DEFAULT_VERSION_DATE=2025-10-21 +DEFAULT_VERSION_DATE=2026-01-20 DEFAULT_VERSION_CLASSFILE_MAJOR=61 # "`$EXPR $DEFAULT_VERSION_FEATURE + 44`" DEFAULT_VERSION_CLASSFILE_MINOR=0 DEFAULT_VERSION_DOCS_API_SINCE=11 diff -Nru openjdk-17-17.0.17+10/make/hotspot/lib/CompileGtest.gmk openjdk-17-17.0.18+8/make/hotspot/lib/CompileGtest.gmk --- openjdk-17-17.0.17+10/make/hotspot/lib/CompileGtest.gmk 2025-10-13 07:48:04.000000000 +0000 +++ openjdk-17-17.0.18+8/make/hotspot/lib/CompileGtest.gmk 2026-01-15 15:23:06.000000000 +0000 @@ -103,9 +103,12 @@ CFLAGS_macosx := -DGTEST_OS_MAC=1, \ DISABLED_WARNINGS_gcc := $(DISABLED_WARNINGS_gcc) \ undef stringop-overflow, \ + DISABLED_WARNINGS_gcc_test_threadCpuLoad.cpp := address, \ DISABLED_WARNINGS_clang := $(DISABLED_WARNINGS_clang) \ undef switch format-nonliteral tautological-undefined-compare \ self-assign-overloaded, \ + DISABLED_WARNINGS_clang_test_g1ServiceThread.cpp := delete-abstract-non-virtual-dtor, \ + DISABLED_WARNINGS_clang_test_logDecorations.cpp := missing-field-initializers, \ DISABLED_WARNINGS_microsoft := $(DISABLED_WARNINGS_microsoft), \ LDFLAGS := $(JVM_LDFLAGS), \ LDFLAGS_unix := -L$(JVM_OUTPUTDIR)/libgtest, \ diff -Nru openjdk-17-17.0.17+10/make/hotspot/lib/CompileJvm.gmk openjdk-17-17.0.18+8/make/hotspot/lib/CompileJvm.gmk --- openjdk-17-17.0.17+10/make/hotspot/lib/CompileJvm.gmk 2025-10-13 07:48:04.000000000 +0000 +++ openjdk-17-17.0.18+8/make/hotspot/lib/CompileJvm.gmk 2026-01-15 15:23:06.000000000 +0000 @@ -77,14 +77,17 @@ ################################################################################ # Disabled warnings -DISABLED_WARNINGS_gcc := parentheses comment unknown-pragmas address \ - delete-non-virtual-dtor char-subscripts array-bounds int-in-bool-context \ - ignored-qualifiers missing-field-initializers implicit-fallthrough \ - empty-body strict-overflow sequence-point maybe-uninitialized \ - misleading-indentation cast-function-type shift-negative-value - -ifeq ($(call check-jvm-feature, zero), true) - DISABLED_WARNINGS_gcc += return-type switch clobbered +DISABLED_WARNINGS_gcc := array-bounds comment delete-non-virtual-dtor \ + empty-body ignored-qualifiers implicit-fallthrough int-in-bool-context \ + maybe-uninitialized missing-field-initializers parentheses \ + shift-negative-value unknown-pragmas strict-overflow + +DISABLED_WARNINGS_clang := ignored-qualifiers sometimes-uninitialized \ + missing-braces delete-non-abstract-non-virtual-dtor unknown-pragmas + +ifneq ($(DEBUG_LEVEL), release) + # Assert macro gives warning + DISABLED_WARNINGS_clang += tautological-constant-out-of-range-compare endif ifeq ($(DEBUG_LEVEL), fastdebug) @@ -94,16 +97,9 @@ endif endif -DISABLED_WARNINGS_clang := tautological-compare \ - undefined-var-template sometimes-uninitialized unknown-pragmas \ - delete-non-virtual-dtor missing-braces char-subscripts \ - ignored-qualifiers missing-field-initializers mismatched-tags \ - shift-negative-value misleading-indentation - DISABLED_WARNINGS_xlc := tautological-compare shift-negative-value -DISABLED_WARNINGS_microsoft := 4100 4127 4146 4201 4244 4291 4351 \ - 4511 4512 4514 4624 4996 +DISABLED_WARNINGS_microsoft := 4624 4244 4291 4146 4127 4996 ################################################################################ # Platform specific setup @@ -157,9 +153,42 @@ abstract_vm_version.cpp_CXXFLAGS := $(CFLAGS_VM_VERSION), \ arguments.cpp_CXXFLAGS := $(CFLAGS_VM_VERSION), \ DISABLED_WARNINGS_gcc := $(DISABLED_WARNINGS_gcc), \ + DISABLED_WARNINGS_gcc_ad_$(HOTSPOT_TARGET_CPU_ARCH).cpp := nonnull, \ + DISABLED_WARNINGS_gcc_assembler_aarch64.cpp := misleading-indentation, \ + DISABLED_WARNINGS_gcc_c1_LIR.cpp := misleading-indentation, \ + DISABLED_WARNINGS_gcc_cgroupV1Subsystem_linux.cpp := address, \ + DISABLED_WARNINGS_gcc_cgroupV2Subsystem_linux.cpp := address, \ + DISABLED_WARNINGS_gcc_dict.cpp := char-subscripts, \ + DISABLED_WARNINGS_gcc_interp_masm_x86.cpp := uninitialized, \ + DISABLED_WARNINGS_gcc_javaClasses.cpp := misleading-indentation, \ + DISABLED_WARNINGS_gcc_loopnode.cpp := sequence-point, \ + DISABLED_WARNINGS_gcc_postaloc.cpp := address, \ + DISABLED_WARNINGS_gcc_sharedRuntimeTrig.cpp := misleading-indentation, \ + DISABLED_WARNINGS_gcc_shenandoahBarrierSet.cpp := misleading-indentation, \ + DISABLED_WARNINGS_gcc_shenandoahBarrierSetAssembler_aarch64.cpp := misleading-indentation, \ + DISABLED_WARNINGS_gcc_shenandoahBarrierSetAssembler_ppc.cpp := misleading-indentation, \ + DISABLED_WARNINGS_gcc_shenandoahBarrierSetAssembler_riscv.cpp := misleading-indentation, \ + DISABLED_WARNINGS_gcc_shenandoahBarrierSetAssembler_x86.cpp := misleading-indentation, \ + DISABLED_WARNINGS_gcc_shenandoahBarrierSetC1_aarch64.cpp := misleading-indentation, \ + DISABLED_WARNINGS_gcc_shenandoahBarrierSetC1_ppc.cpp := misleading-indentation, \ + DISABLED_WARNINGS_gcc_shenandoahBarrierSetC1_riscv.cpp := misleading-indentation, \ + DISABLED_WARNINGS_gcc_shenandoahBarrierSetC1_x86.cpp := misleading-indentation, \ + DISABLED_WARNINGS_gcc_shenandoahBarrierSetC1.cpp := misleading-indentation, \ DISABLED_WARNINGS_clang := $(DISABLED_WARNINGS_clang), \ + DISABLED_WARNINGS_clang_arguments.cpp := missing-field-initializers, \ + DISABLED_WARNINGS_clang_codeBuffer.cpp := tautological-undefined-compare, \ + DISABLED_WARNINGS_clang_dict.cpp := char-subscripts, \ + DISABLED_WARNINGS_clang_directivesParser.cpp := missing-field-initializers, \ + DISABLED_WARNINGS_clang_g1ParScanThreadState.cpp := delete-abstract-non-virtual-dtor, \ + DISABLED_WARNINGS_clang_g1YoungGCPostEvacuateTasks.cpp := delete-abstract-non-virtual-dtor, \ + DISABLED_WARNINGS_clang_heapShared.cpp := missing-field-initializers, \ + DISABLED_WARNINGS_clang_management.cpp := missing-field-initializers, \ DISABLED_WARNINGS_clang_notificationThread.cpp := bitwise-instead-of-logical, \ + DISABLED_WARNINGS_clang_os_posix.cpp := mismatched-tags missing-field-initializers, \ + DISABLED_WARNINGS_clang_postaloc.cpp := tautological-undefined-compare, \ DISABLED_WARNINGS_clang_serviceThread.cpp := bitwise-instead-of-logical, \ + DISABLED_WARNINGS_clang_vm_version_x86.cpp := missing-field-initializers, \ + DISABLED_WARNINGS_clang_zTracer.cpp := undefined-var-template, \ DISABLED_WARNINGS_xlc := $(DISABLED_WARNINGS_xlc), \ DISABLED_WARNINGS_microsoft := $(DISABLED_WARNINGS_microsoft), \ ASFLAGS := $(JVM_ASFLAGS), \ diff -Nru openjdk-17-17.0.17+10/make/hotspot/lib/JvmOverrideFiles.gmk openjdk-17-17.0.18+8/make/hotspot/lib/JvmOverrideFiles.gmk --- openjdk-17-17.0.17+10/make/hotspot/lib/JvmOverrideFiles.gmk 2025-10-13 07:48:04.000000000 +0000 +++ openjdk-17-17.0.18+8/make/hotspot/lib/JvmOverrideFiles.gmk 2026-01-15 15:23:06.000000000 +0000 @@ -1,5 +1,5 @@ # -# Copyright (c) 2013, 2020, 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 @@ -33,9 +33,6 @@ BUILD_LIBJVM_vmStructs.cpp_CXXFLAGS := -fno-var-tracking-assignments BUILD_LIBJVM_jvmciCompilerToVM.cpp_CXXFLAGS := -fno-var-tracking-assignments BUILD_LIBJVM_jvmciCompilerToVMInit.cpp_CXXFLAGS := -fno-var-tracking-assignments - BUILD_LIBJVM_assembler_x86.cpp_CXXFLAGS := -Wno-maybe-uninitialized - BUILD_LIBJVM_cardTableBarrierSetAssembler_x86.cpp_CXXFLAGS := -Wno-maybe-uninitialized - BUILD_LIBJVM_interp_masm_x86.cpp_CXXFLAGS := -Wno-uninitialized ifeq ($(DEBUG_LEVEL), release) # Need extra inlining to collapse shared marking code into the hot marking loop BUILD_LIBJVM_shenandoahMark.cpp_CXXFLAGS := --param inline-unit-growth=1000 diff -Nru openjdk-17-17.0.17+10/make/modules/java.desktop/lib/Awt2dLibraries.gmk openjdk-17-17.0.18+8/make/modules/java.desktop/lib/Awt2dLibraries.gmk --- openjdk-17-17.0.17+10/make/modules/java.desktop/lib/Awt2dLibraries.gmk 2025-10-13 07:48:04.000000000 +0000 +++ openjdk-17-17.0.18+8/make/modules/java.desktop/lib/Awt2dLibraries.gmk 2026-01-15 15:23:06.000000000 +0000 @@ -870,19 +870,6 @@ ################################################################################ -# MACOSX_METAL_VERSION_MIN specifies the lowest version of Macosx -# that should be used to compile Metal shaders. We support Metal -# pipeline only on Macosx >=10.14. For Macosx versions <10.14 even if -# we enable Metal pipeline using -Dsun.java2d.metal=true, at -# runtime we force it to use OpenGL pipeline. And MACOSX_VERSION_MIN -# for aarch64 has always been >10.14 so we use continue to use -# MACOSX_VERSION_MIN for aarch64. -ifeq ($(OPENJDK_TARGET_CPU_ARCH), xaarch64) - MACOSX_METAL_VERSION_MIN=$(MACOSX_VERSION_MIN) -else - MACOSX_METAL_VERSION_MIN=10.14.0 -endif - ifeq ($(call isTargetOs, macosx), true) SHADERS_SRC := $(TOPDIR)/src/java.desktop/macosx/native/libawt_lwawt/java2d/metal/shaders.metal SHADERS_SUPPORT_DIR := $(SUPPORT_OUTPUTDIR)/native/java.desktop/libosxui @@ -895,7 +882,7 @@ OUTPUT_FILE := $(SHADERS_AIR), \ SUPPORT_DIR := $(SHADERS_SUPPORT_DIR), \ COMMAND := $(METAL) -c -std=osx-metal2.0 \ - -mmacosx-version-min=$(MACOSX_METAL_VERSION_MIN) \ + -mmacosx-version-min=$(MACOSX_VERSION_MIN) \ -o $(SHADERS_AIR) $(SHADERS_SRC), \ )) diff -Nru openjdk-17-17.0.17+10/make/test/BuildTestLib.gmk openjdk-17-17.0.18+8/make/test/BuildTestLib.gmk --- openjdk-17-17.0.17+10/make/test/BuildTestLib.gmk 2025-10-13 07:48:04.000000000 +0000 +++ openjdk-17-17.0.18+8/make/test/BuildTestLib.gmk 2026-01-15 15:23:06.000000000 +0000 @@ -54,11 +54,9 @@ JAR := $(TEST_LIB_SUPPORT)/test-lib.jar, \ DISABLED_WARNINGS := try deprecation rawtypes unchecked serial cast removal preview, \ JAVAC_FLAGS := --add-exports java.base/sun.security.util=ALL-UNNAMED \ - --add-exports java.base/jdk.internal.classfile=ALL-UNNAMED \ - --add-exports java.base/jdk.internal.classfile.attribute=ALL-UNNAMED \ - --add-exports java.base/jdk.internal.classfile.constantpool=ALL-UNNAMED \ - --add-exports java.base/jdk.internal.classfile.java.lang.constant=ALL-UNNAMED \ --add-exports java.base/jdk.internal.module=ALL-UNNAMED \ + --add-exports java.base/jdk.internal.org.objectweb.asm=ALL-UNNAMED \ + --add-exports java.base/jdk.internal.org.objectweb.asm.commons=ALL-UNNAMED \ --enable-preview, \ )) diff -Nru openjdk-17-17.0.17+10/src/hotspot/cpu/aarch64/aarch64.ad openjdk-17-17.0.18+8/src/hotspot/cpu/aarch64/aarch64.ad --- openjdk-17-17.0.17+10/src/hotspot/cpu/aarch64/aarch64.ad 2025-10-13 07:48:04.000000000 +0000 +++ openjdk-17-17.0.18+8/src/hotspot/cpu/aarch64/aarch64.ad 2026-01-15 15:23:06.000000000 +0000 @@ -3398,7 +3398,7 @@ } %} - /// mov envcodings + // mov encodings enc_class aarch64_enc_movw_imm(iRegI dst, immI src) %{ C2_MacroAssembler _masm(&cbuf); diff -Nru openjdk-17-17.0.17+10/src/hotspot/cpu/aarch64/interp_masm_aarch64.cpp openjdk-17-17.0.18+8/src/hotspot/cpu/aarch64/interp_masm_aarch64.cpp --- openjdk-17-17.0.17+10/src/hotspot/cpu/aarch64/interp_masm_aarch64.cpp 2025-10-13 07:48:04.000000000 +0000 +++ openjdk-17-17.0.18+8/src/hotspot/cpu/aarch64/interp_masm_aarch64.cpp 2026-01-15 15:23:06.000000000 +0000 @@ -1850,3 +1850,15 @@ bind(profile_continue); } } + +#ifdef ASSERT +void InterpreterMacroAssembler::verify_field_offset(Register reg) { + // Verify the field offset is not in the header, implicitly checks for 0 + Label L; + subs(zr, reg, static_cast(sizeof(markWord) + (UseCompressedClassPointers ? sizeof(narrowKlass) : sizeof(Klass*)))); + br(Assembler::GE, L); + stop("bad field offset"); + bind(L); +} +#endif + diff -Nru openjdk-17-17.0.17+10/src/hotspot/cpu/aarch64/interp_masm_aarch64.hpp openjdk-17-17.0.18+8/src/hotspot/cpu/aarch64/interp_masm_aarch64.hpp --- openjdk-17-17.0.17+10/src/hotspot/cpu/aarch64/interp_masm_aarch64.hpp 2025-10-13 07:48:04.000000000 +0000 +++ openjdk-17-17.0.18+8/src/hotspot/cpu/aarch64/interp_masm_aarch64.hpp 2026-01-15 15:23:06.000000000 +0000 @@ -292,6 +292,8 @@ set_last_Java_frame(esp, rfp, (address) pc(), rscratch1); MacroAssembler::_call_Unimplemented(call_site); } + + void verify_field_offset(Register reg) NOT_DEBUG_RETURN; }; #endif // CPU_AARCH64_INTERP_MASM_AARCH64_HPP diff -Nru openjdk-17-17.0.17+10/src/hotspot/cpu/aarch64/templateTable_aarch64.cpp openjdk-17-17.0.18+8/src/hotspot/cpu/aarch64/templateTable_aarch64.cpp --- openjdk-17-17.0.17+10/src/hotspot/cpu/aarch64/templateTable_aarch64.cpp 2025-10-13 07:48:04.000000000 +0000 +++ openjdk-17-17.0.18+8/src/hotspot/cpu/aarch64/templateTable_aarch64.cpp 2026-01-15 15:23:06.000000000 +0000 @@ -165,6 +165,7 @@ Register temp_reg, bool load_bc_into_bc_reg/*=true*/, int byte_no) { + assert_different_registers(bc_reg, temp_reg); if (!RewriteBytecodes) return; Label L_patch_done; @@ -222,8 +223,12 @@ __ bind(L_okay); #endif - // patch bytecode - __ strb(bc_reg, at_bcp(0)); + // Patch bytecode with release store to coordinate with ConstantPoolCacheEntry loads + // in fast bytecode codelets. The fast bytecode codelets have a memory barrier that gains + // the needed ordering, together with control dependency on entering the fast codelet + // itself. + __ lea(temp_reg, at_bcp(0)); + __ stlrb(bc_reg, temp_reg); __ bind(L_patch_done); } @@ -309,12 +314,12 @@ __ asrw(r0, r0, 16); } -void TemplateTable::ldc(bool wide) +void TemplateTable::ldc(LdcType type) { transition(vtos, vtos); Label call_ldc, notFloat, notClass, notInt, Done; - if (wide) { + if (is_ldc_wide(type)) { __ get_unsigned_2_byte_index_at_bcp(r1, 1); } else { __ load_unsigned_byte(r1, at_bcp(1)); @@ -343,7 +348,7 @@ __ br(Assembler::NE, notClass); __ bind(call_ldc); - __ mov(c_rarg1, wide); + __ mov(c_rarg1, is_ldc_wide(type) ? 1 : 0); call_VM(r0, CAST_FROM_FN_PTR(address, InterpreterRuntime::ldc), c_rarg1); __ push_ptr(r0); __ verify_oop(r0); @@ -376,7 +381,7 @@ } // Fast path for caching oop constants. -void TemplateTable::fast_aldc(bool wide) +void TemplateTable::fast_aldc(LdcType type) { transition(vtos, atos); @@ -384,7 +389,7 @@ Register tmp = r1; Register rarg = r2; - int index_size = wide ? sizeof(u2) : sizeof(u1); + int index_size = is_ldc_wide(type) ? sizeof(u2) : sizeof(u1); Label resolved; @@ -2914,6 +2919,7 @@ // replace index with field offset from cache entry __ ldr(r1, Address(r2, in_bytes(base + ConstantPoolCacheEntry::f2_offset()))); + __ verify_field_offset(r1); { Label notVolatile; @@ -3007,6 +3013,8 @@ __ ldr(r1, Address(r2, in_bytes(ConstantPoolCache::base_offset() + ConstantPoolCacheEntry::f2_offset()))); + __ verify_field_offset(r1); + __ ldrw(r3, Address(r2, in_bytes(ConstantPoolCache::base_offset() + ConstantPoolCacheEntry::flags_offset()))); @@ -3074,8 +3082,13 @@ __ ldr(r0, aaddress(0)); // access constant pool cache __ get_cache_and_index_at_bcp(r2, r3, 2); + + // Must prevent reordering of the following cp cache loads with bytecode load + __ membar(MacroAssembler::LoadLoad); + __ ldr(r1, Address(r2, in_bytes(ConstantPoolCache::base_offset() + ConstantPoolCacheEntry::f2_offset()))); + __ verify_field_offset(r1); // 8179954: We need to make sure that the code generated for // volatile accesses forms a sequentially-consistent set of diff -Nru openjdk-17-17.0.17+10/src/hotspot/cpu/arm/templateTable_arm.cpp openjdk-17-17.0.18+8/src/hotspot/cpu/arm/templateTable_arm.cpp --- openjdk-17-17.0.17+10/src/hotspot/cpu/arm/templateTable_arm.cpp 2025-10-13 07:48:04.000000000 +0000 +++ openjdk-17-17.0.18+8/src/hotspot/cpu/arm/templateTable_arm.cpp 2026-01-15 15:23:06.000000000 +0000 @@ -364,7 +364,7 @@ } -void TemplateTable::ldc(bool wide) { +void TemplateTable::ldc(LdcType type) { transition(vtos, vtos); Label fastCase, Condy, Done; @@ -373,7 +373,7 @@ const Register Rtags = R3_tmp; const Register RtagType = R3_tmp; - if (wide) { + if (is_ldc_wide(type)) { __ get_unsigned_2_byte_index_at_bcp(Rindex, 1); } else { __ ldrb(Rindex, at_bcp(1)); @@ -401,7 +401,7 @@ __ b(fastCase, ne); // slow case - call runtime - __ mov(R1, wide); + __ mov(R1, is_ldc_wide(type) ? 1 : 0); call_VM(R0_tos, CAST_FROM_FN_PTR(address, InterpreterRuntime::ldc), R1); __ push(atos); __ b(Done); @@ -429,9 +429,9 @@ } // Fast path for caching oop constants. -void TemplateTable::fast_aldc(bool wide) { +void TemplateTable::fast_aldc(LdcType type) { transition(vtos, atos); - int index_size = wide ? sizeof(u2) : sizeof(u1); + int index_size = is_ldc_wide(type) ? sizeof(u2) : sizeof(u1); Label resolved; // We are resolved if the resolved reference cache entry contains a diff -Nru openjdk-17-17.0.17+10/src/hotspot/cpu/ppc/frame_ppc.cpp openjdk-17-17.0.18+8/src/hotspot/cpu/ppc/frame_ppc.cpp --- openjdk-17-17.0.17+10/src/hotspot/cpu/ppc/frame_ppc.cpp 2025-10-13 07:48:04.000000000 +0000 +++ openjdk-17-17.0.18+8/src/hotspot/cpu/ppc/frame_ppc.cpp 2026-01-15 15:23:06.000000000 +0000 @@ -114,9 +114,9 @@ return false; } - abi_minframe* sender_abi = (abi_minframe*) fp; + volatile abi_minframe* sender_abi = (abi_minframe*) fp; // May get updated concurrently by deoptimization! intptr_t* sender_sp = (intptr_t*) fp; - address sender_pc = (address) sender_abi->lr;; + address sender_pc = (address) sender_abi->lr; // We must always be able to find a recognizable pc. CodeBlob* sender_blob = CodeCache::find_blob_unsafe(sender_pc); @@ -129,9 +129,20 @@ return false; } + intptr_t* unextended_sender_sp = is_interpreted_frame() ? (intptr_t*)get_ijava_state()->sender_sp : sender_sp; + // It should be safe to construct the sender though it might not be valid. - frame sender(sender_sp, sender_pc); + // JDK-8339386 is different than the upstream version: + // The frame constructor doesn't check sanity of a deopt pc, but determines it. + // Other accessors for reading it are not available in 17u. + frame sender(sender_sp, sender_pc, unextended_sender_sp); + // If the sender is a deoptimized nmethod we need to check if the original pc is valid. + nmethod* sender_nm = sender_blob->as_nmethod_or_null(); + if (sender_nm != nullptr && sender._deopt_state == is_deoptimized) { + address orig_pc = sender.pc(); + if (!sender_nm->insts_contains_inclusive(orig_pc)) return false; + } // Do we have a valid fp? address sender_fp = (address) sender.fp(); diff -Nru openjdk-17-17.0.17+10/src/hotspot/cpu/ppc/interp_masm_ppc.hpp openjdk-17-17.0.18+8/src/hotspot/cpu/ppc/interp_masm_ppc.hpp --- openjdk-17-17.0.17+10/src/hotspot/cpu/ppc/interp_masm_ppc.hpp 2025-10-13 07:48:04.000000000 +0000 +++ openjdk-17-17.0.18+8/src/hotspot/cpu/ppc/interp_masm_ppc.hpp 2026-01-15 15:23:06.000000000 +0000 @@ -126,7 +126,8 @@ void get_cache_index_at_bcp(Register Rdst, int bcp_offset, size_t index_size); - void get_cache_and_index_at_bcp(Register cache, int bcp_offset, size_t index_size = sizeof(u2)); + void get_cache_and_index_at_bcp(Register cache, int bcp_offset, size_t index_size = sizeof(u2), + bool for_fast_bytecode = false); void get_u4(Register Rdst, Register Rsrc, int offset, signedOrNot is_signed); diff -Nru openjdk-17-17.0.17+10/src/hotspot/cpu/ppc/interp_masm_ppc_64.cpp openjdk-17-17.0.18+8/src/hotspot/cpu/ppc/interp_masm_ppc_64.cpp --- openjdk-17-17.0.17+10/src/hotspot/cpu/ppc/interp_masm_ppc_64.cpp 2025-10-13 07:48:04.000000000 +0000 +++ openjdk-17-17.0.18+8/src/hotspot/cpu/ppc/interp_masm_ppc_64.cpp 2026-01-15 15:23:06.000000000 +0000 @@ -450,10 +450,18 @@ } void InterpreterMacroAssembler::get_cache_and_index_at_bcp(Register cache, int bcp_offset, - size_t index_size) { + size_t index_size, bool for_fast_bytecode) { get_cache_index_at_bcp(cache, bcp_offset, index_size); sldi(cache, cache, exact_log2(in_words(ConstantPoolCacheEntry::size()) * BytesPerWord)); add(cache, R27_constPoolCache, cache); + + if (for_fast_bytecode) { + // Prevent speculative loading from ConstantPoolCacheEntry as it can miss the info written by another thread. + // TemplateTable::patch_bytecode uses release-store. + // We reached here via control dependency (Bytecode dispatch has used the rewritten Bytecode). + // So, we can use control-isync based ordering. + isync(); + } } // Load 4-byte signed or unsigned integer in Java format (that is, big-endian format) diff -Nru openjdk-17-17.0.17+10/src/hotspot/cpu/ppc/templateTable_ppc_64.cpp openjdk-17-17.0.18+8/src/hotspot/cpu/ppc/templateTable_ppc_64.cpp --- openjdk-17-17.0.17+10/src/hotspot/cpu/ppc/templateTable_ppc_64.cpp 2025-10-13 07:48:04.000000000 +0000 +++ openjdk-17-17.0.18+8/src/hotspot/cpu/ppc/templateTable_ppc_64.cpp 2026-01-15 15:23:06.000000000 +0000 @@ -146,7 +146,9 @@ __ bind(L_fast_patch); } - // Patch bytecode. + // Patch bytecode with release store to coordinate with ConstantPoolCacheEntry + // loads in fast bytecode codelets. + __ release(); __ stb(Rnew_bc, 0, R14_bcp); __ bind(L_patch_done); @@ -237,7 +239,7 @@ __ get_2_byte_integer_at_bcp(1, R17_tos, InterpreterMacroAssembler::Signed); } -void TemplateTable::ldc(bool wide) { +void TemplateTable::ldc(LdcType type) { Register Rscratch1 = R11_scratch1, Rscratch2 = R12_scratch2, Rcpool = R3_ARG1; @@ -246,7 +248,7 @@ Label notInt, notFloat, notClass, exit; __ get_cpool_and_tags(Rcpool, Rscratch2); // Set Rscratch2 = &tags. - if (wide) { // Read index. + if (is_ldc_wide(type)) { // Read index. __ get_2_byte_integer_at_bcp(1, Rscratch1, InterpreterMacroAssembler::Unsigned); } else { __ lbz(Rscratch1, 1, R14_bcp); @@ -268,7 +270,7 @@ __ crnor(CCR0, Assembler::equal, CCR1, Assembler::equal); // Neither resolved class nor unresolved case from above? __ beq(CCR0, notClass); - __ li(R4, wide ? 1 : 0); + __ li(R4, is_ldc_wide(type) ? 1 : 0); call_VM(R17_tos, CAST_FROM_FN_PTR(address, InterpreterRuntime::ldc), R4); __ push(atos); __ b(exit); @@ -301,15 +303,16 @@ } // Fast path for caching oop constants. -void TemplateTable::fast_aldc(bool wide) { +void TemplateTable::fast_aldc(LdcType type) { transition(vtos, atos); - int index_size = wide ? sizeof(u2) : sizeof(u1); + int index_size = is_ldc_wide(type) ? sizeof(u2) : sizeof(u1); Label is_null; // We are resolved if the resolved reference cache entry contains a // non-null object (CallSite, etc.) __ get_cache_index_at_bcp(R31, 1, index_size); // Load index. + // Only rewritten during link time. So, no need for memory barriers for accessing resolved info. __ load_resolved_reference_at_index(R17_tos, R31, R11_scratch1, R12_scratch2, &is_null); // Convert null sentinel to NULL @@ -2309,7 +2312,7 @@ if (is_invokevfinal) { assert(Ritable_index == noreg, "register not used"); // Already resolved. - __ get_cache_and_index_at_bcp(Rcache, 1); + __ get_cache_and_index_at_bcp(Rcache, 1, sizeof(u2), /* for_fast_bytecode */ true); } else { resolve_cache_and_index(byte_no, Rcache, /* temp */ Rmethod, is_invokedynamic ? sizeof(u4) : sizeof(u2)); } @@ -3016,7 +3019,7 @@ const ConditionRegister CR_is_vol = CCR2; // Non-volatile condition register (survives runtime call in do_oop_store). // Constant pool already resolved => Load flags and offset of field. - __ get_cache_and_index_at_bcp(Rcache, 1); + __ get_cache_and_index_at_bcp(Rcache, 1, sizeof(u2), /* for_fast_bytecode */ true); jvmti_post_field_mod(Rcache, Rscratch, false /* not static */); load_field_cp_cache_entry(noreg, Rcache, noreg, Roffset, Rflags, false); // Uses R11, R12 @@ -3097,7 +3100,7 @@ // R12_scratch2 used by load_field_cp_cache_entry // Constant pool already resolved. Get the field offset. - __ get_cache_and_index_at_bcp(Rcache, 1); + __ get_cache_and_index_at_bcp(Rcache, 1, sizeof(u2), /* for_fast_bytecode */ true); load_field_cp_cache_entry(noreg, Rcache, noreg, Roffset, Rflags, false); // Uses R11, R12 // JVMTI support @@ -3236,7 +3239,7 @@ __ ld(Rclass_or_obj, 0, R18_locals); // Constant pool already resolved. Get the field offset. - __ get_cache_and_index_at_bcp(Rcache, 2); + __ get_cache_and_index_at_bcp(Rcache, 2, sizeof(u2), /* for_fast_bytecode */ true); load_field_cp_cache_entry(noreg, Rcache, noreg, Roffset, Rflags, false); // Uses R11, R12 // JVMTI support not needed, since we switch back to single bytecode as soon as debugger attaches. diff -Nru openjdk-17-17.0.17+10/src/hotspot/cpu/riscv/templateTable_riscv.cpp openjdk-17-17.0.18+8/src/hotspot/cpu/riscv/templateTable_riscv.cpp --- openjdk-17-17.0.17+10/src/hotspot/cpu/riscv/templateTable_riscv.cpp 2025-10-13 07:48:04.000000000 +0000 +++ openjdk-17-17.0.18+8/src/hotspot/cpu/riscv/templateTable_riscv.cpp 2026-01-15 15:23:06.000000000 +0000 @@ -300,12 +300,12 @@ } } -void TemplateTable::ldc(bool wide) +void TemplateTable::ldc(LdcType type) { transition(vtos, vtos); Label call_ldc, notFloat, notClass, notInt, Done; - if (wide) { + if (is_ldc_wide(type)) { __ get_unsigned_2_byte_index_at_bcp(x11, 1); } else { __ load_unsigned_byte(x11, at_bcp(1)); @@ -335,7 +335,7 @@ __ bne(x13, t1, notClass); __ bind(call_ldc); - __ mv(c_rarg1, wide); + __ mv(c_rarg1, is_ldc_wide(type) ? 1 : 0); call_VM(x10, CAST_FROM_FN_PTR(address, InterpreterRuntime::ldc), c_rarg1); __ push_ptr(x10); __ verify_oop(x10); @@ -369,7 +369,7 @@ } // Fast path for caching oop constants. -void TemplateTable::fast_aldc(bool wide) +void TemplateTable::fast_aldc(LdcType type) { transition(vtos, atos); @@ -377,7 +377,7 @@ const Register tmp = x11; const Register rarg = x12; - const int index_size = wide ? sizeof(u2) : sizeof(u1); + const int index_size = is_ldc_wide(type) ? sizeof(u2) : sizeof(u1); Label resolved; diff -Nru openjdk-17-17.0.17+10/src/hotspot/cpu/s390/templateTable_s390.cpp openjdk-17-17.0.18+8/src/hotspot/cpu/s390/templateTable_s390.cpp --- openjdk-17-17.0.17+10/src/hotspot/cpu/s390/templateTable_s390.cpp 2025-10-13 07:48:04.000000000 +0000 +++ openjdk-17-17.0.18+8/src/hotspot/cpu/s390/templateTable_s390.cpp 2026-01-15 15:23:06.000000000 +0000 @@ -377,13 +377,13 @@ } -void TemplateTable::ldc(bool wide) { +void TemplateTable::ldc(LdcType type) { transition(vtos, vtos); Label call_ldc, notFloat, notClass, notInt, Done; const Register RcpIndex = Z_tmp_1; const Register Rtags = Z_ARG2; - if (wide) { + if (is_ldc_wide(type)) { __ get_2_byte_integer_at_bcp(RcpIndex, 1, InterpreterMacroAssembler::Unsigned); } else { __ z_llgc(RcpIndex, at_bcp(1)); @@ -411,7 +411,7 @@ // We deal with a class. Call vm to do the appropriate. __ bind(call_ldc); - __ load_const_optimized(Z_ARG2, wide); + __ load_const_optimized(Z_ARG2, is_ldc_wide(type) ? 1 : 0); call_VM(Z_RET, CAST_FROM_FN_PTR(address, InterpreterRuntime::ldc), Z_ARG2); __ push_ptr(Z_RET); __ z_bru(Done); @@ -447,11 +447,11 @@ // Fast path for caching oop constants. // %%% We should use this to handle Class and String constants also. // %%% It will simplify the ldc/primitive path considerably. -void TemplateTable::fast_aldc(bool wide) { +void TemplateTable::fast_aldc(LdcType type) { transition(vtos, atos); const Register index = Z_tmp_2; - int index_size = wide ? sizeof(u2) : sizeof(u1); + int index_size = is_ldc_wide(type) ? sizeof(u2) : sizeof(u1); Label L_do_resolve, L_resolved; // We are resolved if the resolved reference cache entry contains a diff -Nru openjdk-17-17.0.17+10/src/hotspot/cpu/x86/assembler_x86.cpp openjdk-17-17.0.18+8/src/hotspot/cpu/x86/assembler_x86.cpp --- openjdk-17-17.0.17+10/src/hotspot/cpu/x86/assembler_x86.cpp 2025-10-13 07:48:04.000000000 +0000 +++ openjdk-17-17.0.18+8/src/hotspot/cpu/x86/assembler_x86.cpp 2026-01-15 15:23:06.000000000 +0000 @@ -7546,6 +7546,10 @@ emit_int24(0x72, (0xC0 | encode), shift & 0xFF); } +// Register is a class, but it would be assigned numerical value. +// "0" is assigned for xmm0. Thus we need to ignore -Wnonnull. +PRAGMA_DIAG_PUSH +PRAGMA_NONNULL_IGNORED void Assembler::evprord(XMMRegister dst, XMMRegister src, int shift, int vector_len) { assert(VM_Version::supports_evex(), "requires EVEX support"); assert(vector_len == Assembler::AVX_512bit || VM_Version::supports_avx512vl(), "requires VL support"); @@ -7563,6 +7567,7 @@ int encode = vex_prefix_and_encode(xmm0->encoding(), dst->encoding(), src->encoding(), VEX_SIMD_66, VEX_OPCODE_0F, &attributes); emit_int24(0x72, (0xC0 | encode), shift & 0xFF); } +PRAGMA_DIAG_POP void Assembler::evprolvd(XMMRegister dst, XMMRegister src, XMMRegister shift, int vector_len) { assert(VM_Version::supports_evex(), "requires EVEX support"); diff -Nru openjdk-17-17.0.17+10/src/hotspot/cpu/x86/c1_Runtime1_x86.cpp openjdk-17-17.0.18+8/src/hotspot/cpu/x86/c1_Runtime1_x86.cpp --- openjdk-17-17.0.17+10/src/hotspot/cpu/x86/c1_Runtime1_x86.cpp 2025-10-13 07:48:04.000000000 +0000 +++ openjdk-17-17.0.18+8/src/hotspot/cpu/x86/c1_Runtime1_x86.cpp 2026-01-15 15:23:06.000000000 +0000 @@ -318,7 +318,11 @@ // expensive. The deopt blob is the only thing which needs to // describe FPU registers. In all other cases it should be sufficient // to simply save their current value. - +// +// Register is a class, but it would be assigned numerical value. +// "0" is assigned for rax. Thus we need to ignore -Wnonnull. +PRAGMA_DIAG_PUSH +PRAGMA_NONNULL_IGNORED static OopMap* generate_oop_map(StubAssembler* sasm, int num_rt_args, bool save_fpu_registers = true) { @@ -418,6 +422,7 @@ return map; } +PRAGMA_DIAG_POP #define __ this-> diff -Nru openjdk-17-17.0.17+10/src/hotspot/cpu/x86/frame_x86.inline.hpp openjdk-17-17.0.18+8/src/hotspot/cpu/x86/frame_x86.inline.hpp --- openjdk-17-17.0.17+10/src/hotspot/cpu/x86/frame_x86.inline.hpp 2025-10-13 07:48:04.000000000 +0000 +++ openjdk-17-17.0.18+8/src/hotspot/cpu/x86/frame_x86.inline.hpp 2026-01-15 15:23:06.000000000 +0000 @@ -230,6 +230,10 @@ // Compiled frames +// Register is a class, but it would be assigned numerical value. +// "0" is assigned for rax. Thus we need to ignore -Wnonnull. +PRAGMA_DIAG_PUSH +PRAGMA_NONNULL_IGNORED inline oop frame::saved_oop_result(RegisterMap* map) const { oop* result_adr = (oop *)map->location(rax->as_VMReg()); guarantee(result_adr != NULL, "bad register save location"); @@ -243,5 +247,6 @@ *result_adr = obj; } +PRAGMA_DIAG_POP #endif // CPU_X86_FRAME_X86_INLINE_HPP diff -Nru openjdk-17-17.0.17+10/src/hotspot/cpu/x86/gc/z/zBarrierSetAssembler_x86.cpp openjdk-17-17.0.18+8/src/hotspot/cpu/x86/gc/z/zBarrierSetAssembler_x86.cpp --- openjdk-17-17.0.17+10/src/hotspot/cpu/x86/gc/z/zBarrierSetAssembler_x86.cpp 2025-10-13 07:48:04.000000000 +0000 +++ openjdk-17-17.0.18+8/src/hotspot/cpu/x86/gc/z/zBarrierSetAssembler_x86.cpp 2026-01-15 15:23:06.000000000 +0000 @@ -465,6 +465,10 @@ _spill_offset += 8; } +// Register is a class, but it would be assigned numerical value. +// "0" is assigned for rax. Thus we need to ignore -Wnonnull. +PRAGMA_DIAG_PUSH +PRAGMA_NONNULL_IGNORED void initialize(ZLoadBarrierStubC2* stub) { // Create mask of caller saved registers that need to // be saved/restored if live @@ -540,6 +544,7 @@ // Stack pointer must be 16 bytes aligned for the call _spill_offset = _spill_size = align_up(xmm_spill_size + gp_spill_size + opmask_spill_size + arg_spill_size, 16); } +PRAGMA_DIAG_POP public: ZSaveLiveRegisters(MacroAssembler* masm, ZLoadBarrierStubC2* stub) : diff -Nru openjdk-17-17.0.17+10/src/hotspot/cpu/x86/macroAssembler_x86_exp.cpp openjdk-17-17.0.18+8/src/hotspot/cpu/x86/macroAssembler_x86_exp.cpp --- openjdk-17-17.0.17+10/src/hotspot/cpu/x86/macroAssembler_x86_exp.cpp 2025-10-13 07:48:04.000000000 +0000 +++ openjdk-17-17.0.18+8/src/hotspot/cpu/x86/macroAssembler_x86_exp.cpp 2026-01-15 15:23:06.000000000 +0000 @@ -1,6 +1,6 @@ /* * Copyright (c) 2016, Intel Corporation. -* Copyright (C) 2021 THL A29 Limited, a Tencent company. All rights reserved. +* Copyright (C) 2021, Tencent. All rights reserved. * Intel Math Library (LIBM) Source Code * * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. diff -Nru openjdk-17-17.0.17+10/src/hotspot/cpu/x86/macroAssembler_x86_log.cpp openjdk-17-17.0.18+8/src/hotspot/cpu/x86/macroAssembler_x86_log.cpp --- openjdk-17-17.0.17+10/src/hotspot/cpu/x86/macroAssembler_x86_log.cpp 2025-10-13 07:48:04.000000000 +0000 +++ openjdk-17-17.0.18+8/src/hotspot/cpu/x86/macroAssembler_x86_log.cpp 2026-01-15 15:23:06.000000000 +0000 @@ -1,6 +1,6 @@ /* * Copyright (c) 2016, Intel Corporation. -* Copyright (C) 2021 THL A29 Limited, a Tencent company. All rights reserved. +* Copyright (C) 2021, Tencent. All rights reserved. * Intel Math Library (LIBM) Source Code * * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. diff -Nru openjdk-17-17.0.17+10/src/hotspot/cpu/x86/macroAssembler_x86_pow.cpp openjdk-17-17.0.18+8/src/hotspot/cpu/x86/macroAssembler_x86_pow.cpp --- openjdk-17-17.0.17+10/src/hotspot/cpu/x86/macroAssembler_x86_pow.cpp 2025-10-13 07:48:04.000000000 +0000 +++ openjdk-17-17.0.18+8/src/hotspot/cpu/x86/macroAssembler_x86_pow.cpp 2026-01-15 15:23:06.000000000 +0000 @@ -1,6 +1,6 @@ /* * Copyright (c) 2016, Intel Corporation. -* Copyright (C) 2021 THL A29 Limited, a Tencent company. All rights reserved. +* Copyright (C) 2021, Tencent. All rights reserved. * Intel Math Library (LIBM) Source Code * * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. diff -Nru openjdk-17-17.0.17+10/src/hotspot/cpu/x86/sharedRuntime_x86_64.cpp openjdk-17-17.0.18+8/src/hotspot/cpu/x86/sharedRuntime_x86_64.cpp --- openjdk-17-17.0.17+10/src/hotspot/cpu/x86/sharedRuntime_x86_64.cpp 2025-10-13 07:48:04.000000000 +0000 +++ openjdk-17-17.0.18+8/src/hotspot/cpu/x86/sharedRuntime_x86_64.cpp 2026-01-15 15:23:06.000000000 +0000 @@ -168,6 +168,10 @@ static void restore_result_registers(MacroAssembler* masm); }; +// Register is a class, but it would be assigned numerical value. +// "0" is assigned for rax. Thus we need to ignore -Wnonnull. +PRAGMA_DIAG_PUSH +PRAGMA_NONNULL_IGNORED OopMap* RegisterSaver::save_live_registers(MacroAssembler* masm, int additional_frame_words, int* total_frame_words, bool save_wide_vectors) { int off = 0; int num_xmm_regs = XMMRegisterImpl::number_of_registers; @@ -361,6 +365,7 @@ return map; } +PRAGMA_DIAG_POP void RegisterSaver::restore_live_registers(MacroAssembler* masm, bool restore_wide_vectors) { int num_xmm_regs = XMMRegisterImpl::number_of_registers; diff -Nru openjdk-17-17.0.17+10/src/hotspot/cpu/x86/templateTable_x86.cpp openjdk-17-17.0.18+8/src/hotspot/cpu/x86/templateTable_x86.cpp --- openjdk-17-17.0.17+10/src/hotspot/cpu/x86/templateTable_x86.cpp 2025-10-13 07:48:04.000000000 +0000 +++ openjdk-17-17.0.18+8/src/hotspot/cpu/x86/templateTable_x86.cpp 2026-01-15 15:23:06.000000000 +0000 @@ -350,12 +350,12 @@ __ sarl(rax, 16); } -void TemplateTable::ldc(bool wide) { +void TemplateTable::ldc(LdcType type) { transition(vtos, vtos); Register rarg = NOT_LP64(rcx) LP64_ONLY(c_rarg1); Label call_ldc, notFloat, notClass, notInt, Done; - if (wide) { + if (is_ldc_wide(type)) { __ get_unsigned_2_byte_index_at_bcp(rbx, 1); } else { __ load_unsigned_byte(rbx, at_bcp(1)); @@ -383,7 +383,7 @@ __ bind(call_ldc); - __ movl(rarg, wide); + __ movl(rarg, is_ldc_wide(type) ? 1 : 0); call_VM(rax, CAST_FROM_FN_PTR(address, InterpreterRuntime::ldc), rarg); __ push(atos); @@ -415,13 +415,13 @@ } // Fast path for caching oop constants. -void TemplateTable::fast_aldc(bool wide) { +void TemplateTable::fast_aldc(LdcType type) { transition(vtos, atos); Register result = rax; Register tmp = rdx; Register rarg = NOT_LP64(rcx) LP64_ONLY(c_rarg1); - int index_size = wide ? sizeof(u2) : sizeof(u1); + int index_size = is_ldc_wide(type) ? sizeof(u2) : sizeof(u1); Label resolved; diff -Nru openjdk-17-17.0.17+10/src/hotspot/cpu/x86/universalUpcallHandler_x86_64.cpp openjdk-17-17.0.18+8/src/hotspot/cpu/x86/universalUpcallHandler_x86_64.cpp --- openjdk-17-17.0.17+10/src/hotspot/cpu/x86/universalUpcallHandler_x86_64.cpp 2025-10-13 07:48:04.000000000 +0000 +++ openjdk-17-17.0.18+8/src/hotspot/cpu/x86/universalUpcallHandler_x86_64.cpp 2026-01-15 15:23:06.000000000 +0000 @@ -587,6 +587,10 @@ } } +// Register is a class, but it would be assigned numerical value. +// "0" is assigned for rax and for xmm0. Thus we need to ignore -Wnonnull. +PRAGMA_DIAG_PUSH +PRAGMA_NONNULL_IGNORED address ProgrammableUpcallHandler::generate_optimized_upcall_stub(jobject receiver, Method* entry, jobject jabi, jobject jconv) { ResourceMark rm; const ABIDescriptor abi = ForeignGlobals::parse_abi_descriptor(jabi); @@ -779,6 +783,7 @@ return blob->code_begin(); } +PRAGMA_DIAG_POP bool ProgrammableUpcallHandler::supports_optimized_upcalls() { return true; diff -Nru openjdk-17-17.0.17+10/src/hotspot/os/linux/cgroupSubsystem_linux.cpp openjdk-17-17.0.18+8/src/hotspot/os/linux/cgroupSubsystem_linux.cpp --- openjdk-17-17.0.17+10/src/hotspot/os/linux/cgroupSubsystem_linux.cpp 2025-10-13 07:48:04.000000000 +0000 +++ openjdk-17-17.0.18+8/src/hotspot/os/linux/cgroupSubsystem_linux.cpp 2026-01-15 15:23:06.000000000 +0000 @@ -35,7 +35,7 @@ #include "utilities/globalDefinitions.hpp" // controller names have to match the *_IDX indices -static const char* cg_controller_name[] = { "cpu", "cpuset", "cpuacct", "memory", "pids" }; +static const char* cg_controller_name[] = { "cpuset", "cpu", "cpuacct", "memory", "pids" }; CgroupSubsystem* CgroupSubsystemFactory::create() { CgroupV1MemoryController* memory = NULL; @@ -159,9 +159,10 @@ char buf[MAXPATHLEN+1]; char *p; bool is_cgroupsV2; - // true iff all required controllers, memory, cpu, cpuset, cpuacct are enabled + // true iff all required controllers, memory, cpu, cpuacct are enabled // at the kernel level. // pids might not be enabled on older Linux distros (SLES 12.1, RHEL 7.1) + // cpuset might not be enabled on newer Linux distros (Fedora 41) bool all_required_controllers_enabled; /* @@ -193,6 +194,7 @@ cg_infos[MEMORY_IDX]._hierarchy_id = hierarchy_id; cg_infos[MEMORY_IDX]._enabled = (enabled == 1); } else if (strcmp(name, "cpuset") == 0) { + log_debug(os, container)("Detected optional cpuset controller entry in %s", proc_cgroups); cg_infos[CPUSET_IDX]._name = os::strdup(name); cg_infos[CPUSET_IDX]._hierarchy_id = hierarchy_id; cg_infos[CPUSET_IDX]._enabled = (enabled == 1); @@ -216,8 +218,8 @@ is_cgroupsV2 = true; all_required_controllers_enabled = true; for (int i = 0; i < CG_INFO_LENGTH; i++) { - // pids controller is optional. All other controllers are required - if (i != PIDS_IDX) { + // pids and cpuset controllers are optional. All other controllers are required + if (i != PIDS_IDX && i != CPUSET_IDX) { is_cgroupsV2 = is_cgroupsV2 && cg_infos[i]._hierarchy_id == 0; all_required_controllers_enabled = all_required_controllers_enabled && cg_infos[i]._enabled; } diff -Nru openjdk-17-17.0.17+10/src/hotspot/os/posix/signals_posix.cpp openjdk-17-17.0.18+8/src/hotspot/os/posix/signals_posix.cpp --- openjdk-17-17.0.17+10/src/hotspot/os/posix/signals_posix.cpp 2025-10-13 07:48:04.000000000 +0000 +++ openjdk-17-17.0.18+8/src/hotspot/os/posix/signals_posix.cpp 2026-01-15 15:23:06.000000000 +0000 @@ -770,7 +770,7 @@ typedef int (*os_sigaction_t)(int, const struct sigaction *, struct sigaction *); -static void SR_handler(int sig, siginfo_t* siginfo, ucontext_t* context); +static void SR_handler(int sig, siginfo_t* siginfo, void* ucVoid); // Semantically compare two sigaction structures. Return true if they are referring to // the same handler, using the same flags. @@ -1565,8 +1565,8 @@ osthread->set_siginfo(NULL); } -static void suspend_save_context(OSThread *osthread, siginfo_t* siginfo, ucontext_t* context) { - osthread->set_ucontext(context); +static void suspend_save_context(OSThread *osthread, siginfo_t* siginfo, void* ucVoid) { + osthread->set_ucontext((ucontext_t*)ucVoid); osthread->set_siginfo(siginfo); } @@ -1583,7 +1583,7 @@ // // Currently only ever called on the VMThread and JavaThreads (PC sampling) // -static void SR_handler(int sig, siginfo_t* siginfo, ucontext_t* context) { +static void SR_handler(int sig, siginfo_t* siginfo, void* ucVoid) { // Save and restore errno to avoid confusing native code with EINTR // after sigsuspend. @@ -1611,7 +1611,7 @@ os::SuspendResume::State current = osthread->sr.state(); if (current == os::SuspendResume::SR_SUSPEND_REQUEST) { - suspend_save_context(osthread, siginfo, context); + suspend_save_context(osthread, siginfo, ucVoid); // attempt to switch the state, we assume we had a SUSPEND_REQUEST os::SuspendResume::State state = osthread->sr.suspended(); @@ -1680,7 +1680,7 @@ // Set up signal handler for suspend/resume act.sa_flags = SA_RESTART|SA_SIGINFO; - act.sa_handler = (void (*)(int)) SR_handler; + act.sa_sigaction = SR_handler; // SR_signum is blocked by default. pthread_sigmask(SIG_BLOCK, NULL, &act.sa_mask); diff -Nru openjdk-17-17.0.17+10/src/hotspot/os/windows/os_windows.cpp openjdk-17-17.0.18+8/src/hotspot/os/windows/os_windows.cpp --- openjdk-17-17.0.17+10/src/hotspot/os/windows/os_windows.cpp 2025-10-13 07:48:04.000000000 +0000 +++ openjdk-17-17.0.18+8/src/hotspot/os/windows/os_windows.cpp 2026-01-15 15:23:06.000000000 +0000 @@ -4547,7 +4547,7 @@ return ERROR_SUCCESS; } -static void set_path_prefix(char* buf, LPWSTR* prefix, int* prefix_off, bool* needs_fullpath) { +static void set_path_prefix(char* buf, LPCWSTR* prefix, int* prefix_off, bool* needs_fullpath) { *prefix_off = 0; *needs_fullpath = true; @@ -4583,7 +4583,7 @@ strncpy(buf, path, buf_len); os::native_path(buf); - LPWSTR prefix = NULL; + LPCWSTR prefix = NULL; int prefix_off = 0; bool needs_fullpath = true; set_path_prefix(buf, &prefix, &prefix_off, &needs_fullpath); diff -Nru openjdk-17-17.0.17+10/src/hotspot/os_cpu/aix_ppc/thread_aix_ppc.cpp openjdk-17-17.0.18+8/src/hotspot/os_cpu/aix_ppc/thread_aix_ppc.cpp --- openjdk-17-17.0.17+10/src/hotspot/os_cpu/aix_ppc/thread_aix_ppc.cpp 2025-10-13 07:48:04.000000000 +0000 +++ openjdk-17-17.0.18+8/src/hotspot/os_cpu/aix_ppc/thread_aix_ppc.cpp 2026-01-15 15:23:06.000000000 +0000 @@ -1,6 +1,6 @@ /* - * Copyright (c) 1997, 2022, Oracle and/or its affiliates. All rights reserved. - * Copyright (c) 2012, 2014 SAP SE. All rights reserved. + * Copyright (c) 1997, 2025, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2012, 2025 SAP SE. All rights reserved. * Copyright (c) 2022, IBM Corp. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * @@ -27,6 +27,7 @@ #include "precompiled.hpp" #include "memory/metaspace.hpp" #include "runtime/frame.inline.hpp" +#include "runtime/os.inline.hpp" #include "runtime/thread.hpp" frame JavaThread::pd_last_frame() { @@ -54,9 +55,19 @@ if (has_last_Java_frame() && frame_anchor()->walkable()) { intptr_t* sp = last_Java_sp(); address pc = _anchor.last_Java_pc(); - // pc can be seen as null because not all writers use store pc + release store sp. - // Simply discard the sample in this very rare case. - if (pc == nullptr) return false; + if (pc == nullptr) { + // This is not uncommon. Many c1/c2 runtime stubs do not set the pc in the anchor. + intptr_t* top_sp = os::Aix::ucontext_get_sp((const ucontext_t*)ucontext); + if ((uint64_t)sp <= ((frame::abi_minframe*)top_sp)->callers_sp) { + // The interrupt occurred either in the last java frame or in its direct callee. + // We cannot be sure that the link register LR was already saved to the + // java frame. Therefore we discard this sample. + return false; + } + // The last java pc will be found in the abi part of the last java frame. + *fr_addr = frame(sp); + return true; + } *fr_addr = frame(sp, pc); return true; } diff -Nru openjdk-17-17.0.17+10/src/hotspot/os_cpu/linux_ppc/thread_linux_ppc.cpp openjdk-17-17.0.18+8/src/hotspot/os_cpu/linux_ppc/thread_linux_ppc.cpp --- openjdk-17-17.0.17+10/src/hotspot/os_cpu/linux_ppc/thread_linux_ppc.cpp 2025-10-13 07:48:04.000000000 +0000 +++ openjdk-17-17.0.18+8/src/hotspot/os_cpu/linux_ppc/thread_linux_ppc.cpp 2026-01-15 15:23:06.000000000 +0000 @@ -1,6 +1,6 @@ /* - * Copyright (c) 1997, 2022, Oracle and/or its affiliates. All rights reserved. - * Copyright (c) 2012, 2022 SAP SE. All rights reserved. + * Copyright (c) 1997, 2025, 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. * * This code is free software; you can redistribute it and/or modify it @@ -26,6 +26,7 @@ #include "precompiled.hpp" #include "memory/metaspace.hpp" #include "runtime/frame.inline.hpp" +#include "runtime/os.hpp" #include "runtime/thread.hpp" frame JavaThread::pd_last_frame() { @@ -53,9 +54,19 @@ if (has_last_Java_frame() && frame_anchor()->walkable()) { intptr_t* sp = last_Java_sp(); address pc = _anchor.last_Java_pc(); - // pc can be seen as null because not all writers use store pc + release store sp. - // Simply discard the sample in this very rare case. - if (pc == nullptr) return false; + if (pc == nullptr) { + // This is not uncommon. Many c1/c2 runtime stubs do not set the pc in the anchor. + intptr_t* top_sp = os::Linux::ucontext_get_sp((const ucontext_t*)ucontext); + if ((uint64_t)sp <= ((frame::abi_minframe*)top_sp)->callers_sp) { + // The interrupt occurred either in the last java frame or in its direct callee. + // We cannot be sure that the link register LR was already saved to the + // java frame. Therefore we discard this sample. + return false; + } + // The last java pc will be found in the abi part of the last java frame. + *fr_addr = frame(sp); + return true; + } *fr_addr = frame(sp, pc); return true; } diff -Nru openjdk-17-17.0.17+10/src/hotspot/share/c1/c1_Canonicalizer.hpp openjdk-17-17.0.18+8/src/hotspot/share/c1/c1_Canonicalizer.hpp --- openjdk-17-17.0.17+10/src/hotspot/share/c1/c1_Canonicalizer.hpp 2025-10-13 07:48:04.000000000 +0000 +++ openjdk-17-17.0.18+8/src/hotspot/share/c1/c1_Canonicalizer.hpp 2026-01-15 15:23:06.000000000 +0000 @@ -1,5 +1,5 @@ /* - * Copyright (c) 1999, 2019, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 1999, 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 @@ -40,10 +40,6 @@ void set_constant(jlong x) { set_canonical(new Constant(new LongConstant(x))); } void set_constant(jfloat x) { set_canonical(new Constant(new FloatConstant(x))); } void set_constant(jdouble x) { set_canonical(new Constant(new DoubleConstant(x))); } -#ifdef _WINDOWS - // jint is defined as long in jni_md.h, so convert from int to jint - void set_constant(int x) { set_constant((jint)x); } -#endif void move_const_to_right(Op2* x); void do_Op2(Op2* x); void do_UnsafeRawOp(UnsafeRawOp* x); diff -Nru openjdk-17-17.0.17+10/src/hotspot/share/classfile/classLoaderData.cpp openjdk-17-17.0.18+8/src/hotspot/share/classfile/classLoaderData.cpp --- openjdk-17-17.0.17+10/src/hotspot/share/classfile/classLoaderData.cpp 2025-10-13 07:48:04.000000000 +0000 +++ openjdk-17-17.0.18+8/src/hotspot/share/classfile/classLoaderData.cpp 2026-01-15 15:23:06.000000000 +0000 @@ -985,14 +985,23 @@ } out->print_cr(" - handles %d", _handles.count()); out->print_cr(" - dependency count %d", _dependency_count); - out->print (" - klasses {"); - PrintKlassClosure closure(out); - ((ClassLoaderData*)this)->classes_do(&closure); + out->print (" - klasses { "); + if (Verbose) { + PrintKlassClosure closure(out); + ((ClassLoaderData*)this)->classes_do(&closure); + } else { + out->print("..."); + } out->print_cr(" }"); out->print_cr(" - packages " INTPTR_FORMAT, p2i(_packages)); out->print_cr(" - module " INTPTR_FORMAT, p2i(_modules)); out->print_cr(" - unnamed module " INTPTR_FORMAT, p2i(_unnamed_module)); - out->print_cr(" - dictionary " INTPTR_FORMAT, p2i(_dictionary)); + if (_dictionary != nullptr) { + out->print (" - dictionary " INTPTR_FORMAT " ", p2i(_dictionary)); + _dictionary->print_size(out); + } else { + out->print_cr(" - dictionary " INTPTR_FORMAT, p2i(_dictionary)); + } if (_jmethod_ids != NULL) { out->print (" - jmethod count "); Method::print_jmethod_ids_count(this, out); diff -Nru openjdk-17-17.0.17+10/src/hotspot/share/classfile/dictionary.cpp openjdk-17-17.0.18+8/src/hotspot/share/classfile/dictionary.cpp --- openjdk-17-17.0.17+10/src/hotspot/share/classfile/dictionary.cpp 2025-10-13 07:48:04.000000000 +0000 +++ openjdk-17-17.0.18+8/src/hotspot/share/classfile/dictionary.cpp 2026-01-15 15:23:06.000000000 +0000 @@ -586,13 +586,17 @@ // ---------------------------------------------------------------------------- +void Dictionary::print_size(outputStream* st) const { + st->print_cr("Java dictionary (table_size=%d, classes=%d, resizable=%s)", + table_size(), number_of_entries(), BOOL_TO_STR(_resizable)); +} + void Dictionary::print_on(outputStream* st) const { ResourceMark rm; assert(loader_data() != NULL, "loader data should not be null"); assert(!loader_data()->has_class_mirror_holder(), "cld should have a ClassLoader holder not a Class holder"); - st->print_cr("Java dictionary (table_size=%d, classes=%d, resizable=%s)", - table_size(), number_of_entries(), BOOL_TO_STR(_resizable)); + print_size(st); st->print_cr("^ indicates that initiating loader is different from defining loader"); for (int index = 0; index < table_size(); index++) { diff -Nru openjdk-17-17.0.17+10/src/hotspot/share/classfile/dictionary.hpp openjdk-17-17.0.18+8/src/hotspot/share/classfile/dictionary.hpp --- openjdk-17-17.0.17+10/src/hotspot/share/classfile/dictionary.hpp 2025-10-13 07:48:04.000000000 +0000 +++ openjdk-17-17.0.18+8/src/hotspot/share/classfile/dictionary.hpp 2026-01-15 15:23:06.000000000 +0000 @@ -1,5 +1,5 @@ /* - * Copyright (c) 2003, 2021, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2003, 2022, Oracle and/or its affiliates. All rights reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * * This code is free software; you can redistribute it and/or modify it @@ -79,6 +79,7 @@ TRAPS); void print_on(outputStream* st) const; + void print_size(outputStream* st) const; void verify(); private: diff -Nru openjdk-17-17.0.17+10/src/hotspot/share/classfile/verifier.cpp openjdk-17-17.0.18+8/src/hotspot/share/classfile/verifier.cpp --- openjdk-17-17.0.17+10/src/hotspot/share/classfile/verifier.cpp 2025-10-13 07:48:04.000000000 +0000 +++ openjdk-17-17.0.18+8/src/hotspot/share/classfile/verifier.cpp 2026-01-15 15:23:06.000000000 +0000 @@ -2439,216 +2439,6 @@ } } -// Look at the method's handlers. If the bci is in the handler's try block -// then check if the handler_pc is already on the stack. If not, push it -// unless the handler has already been scanned. -void ClassVerifier::push_handlers(ExceptionTable* exhandlers, - GrowableArray* handler_list, - GrowableArray* handler_stack, - u4 bci) { - int exlength = exhandlers->length(); - for(int x = 0; x < exlength; x++) { - if (bci >= exhandlers->start_pc(x) && bci < exhandlers->end_pc(x)) { - u4 exhandler_pc = exhandlers->handler_pc(x); - if (!handler_list->contains(exhandler_pc)) { - handler_stack->append_if_missing(exhandler_pc); - handler_list->append(exhandler_pc); - } - } - } -} - -// Return TRUE if all code paths starting with start_bc_offset end in -// bytecode athrow or loop. -bool ClassVerifier::ends_in_athrow(u4 start_bc_offset) { - ResourceMark rm; - // Create bytecode stream. - RawBytecodeStream bcs(method()); - u4 code_length = method()->code_size(); - bcs.set_start(start_bc_offset); - u4 target; - // Create stack for storing bytecode start offsets for if* and *switch. - GrowableArray* bci_stack = new GrowableArray(30); - // Create stack for handlers for try blocks containing this handler. - GrowableArray* handler_stack = new GrowableArray(30); - // Create list of handlers that have been pushed onto the handler_stack - // so that handlers embedded inside of their own TRY blocks only get - // scanned once. - GrowableArray* handler_list = new GrowableArray(30); - // Create list of visited branch opcodes (goto* and if*). - GrowableArray* visited_branches = new GrowableArray(30); - ExceptionTable exhandlers(_method()); - - while (true) { - if (bcs.is_last_bytecode()) { - // if no more starting offsets to parse or if at the end of the - // method then return false. - if ((bci_stack->is_empty()) || ((u4)bcs.end_bci() == code_length)) - return false; - // Pop a bytecode starting offset and scan from there. - bcs.set_start(bci_stack->pop()); - } - Bytecodes::Code opcode = bcs.raw_next(); - u4 bci = bcs.bci(); - - // If the bytecode is in a TRY block, push its handlers so they - // will get parsed. - push_handlers(&exhandlers, handler_list, handler_stack, bci); - - switch (opcode) { - case Bytecodes::_if_icmpeq: - case Bytecodes::_if_icmpne: - case Bytecodes::_if_icmplt: - case Bytecodes::_if_icmpge: - case Bytecodes::_if_icmpgt: - case Bytecodes::_if_icmple: - case Bytecodes::_ifeq: - case Bytecodes::_ifne: - case Bytecodes::_iflt: - case Bytecodes::_ifge: - case Bytecodes::_ifgt: - case Bytecodes::_ifle: - case Bytecodes::_if_acmpeq: - case Bytecodes::_if_acmpne: - case Bytecodes::_ifnull: - case Bytecodes::_ifnonnull: - target = bcs.dest(); - if (visited_branches->contains(bci)) { - if (bci_stack->is_empty()) { - if (handler_stack->is_empty()) { - return true; - } else { - // Parse the catch handlers for try blocks containing athrow. - bcs.set_start(handler_stack->pop()); - } - } else { - // Pop a bytecode starting offset and scan from there. - bcs.set_start(bci_stack->pop()); - } - } else { - if (target > bci) { // forward branch - if (target >= code_length) return false; - // Push the branch target onto the stack. - bci_stack->push(target); - // then, scan bytecodes starting with next. - bcs.set_start(bcs.next_bci()); - } else { // backward branch - // Push bytecode offset following backward branch onto the stack. - bci_stack->push(bcs.next_bci()); - // Check bytecodes starting with branch target. - bcs.set_start(target); - } - // Record target so we don't branch here again. - visited_branches->append(bci); - } - break; - - case Bytecodes::_goto: - case Bytecodes::_goto_w: { - int offset = (opcode == Bytecodes::_goto ? bcs.get_offset_s2() : bcs.get_offset_s4()); - int min_offset = -1 * max_method_code_size; - // Check offset for overflow - if (offset < min_offset || offset > max_method_code_size) return false; - - target = bci + offset; - if (visited_branches->contains(bci)) { - if (bci_stack->is_empty()) { - if (handler_stack->is_empty()) { - return true; - } else { - // Parse the catch handlers for try blocks containing athrow. - bcs.set_start(handler_stack->pop()); - } - } else { - // Been here before, pop new starting offset from stack. - bcs.set_start(bci_stack->pop()); - } - } else { - if (target >= code_length) return false; - // Continue scanning from the target onward. - bcs.set_start(target); - // Record target so we don't branch here again. - visited_branches->append(bci); - } - break; - } - - // Check that all switch alternatives end in 'athrow' bytecodes. Since it - // is difficult to determine where each switch alternative ends, parse - // each switch alternative until either hit a 'return', 'athrow', or reach - // the end of the method's bytecodes. This is gross but should be okay - // because: - // 1. tableswitch and lookupswitch byte codes in handlers for ctor explicit - // constructor invocations should be rare. - // 2. if each switch alternative ends in an athrow then the parsing should be - // short. If there is no athrow then it is bogus code, anyway. - case Bytecodes::_lookupswitch: - case Bytecodes::_tableswitch: - { - address aligned_bcp = align_up(bcs.bcp() + 1, jintSize); - u4 default_offset = Bytes::get_Java_u4(aligned_bcp) + bci; - int keys, delta; - if (opcode == Bytecodes::_tableswitch) { - jint low = (jint)Bytes::get_Java_u4(aligned_bcp + jintSize); - jint high = (jint)Bytes::get_Java_u4(aligned_bcp + 2*jintSize); - // This is invalid, but let the regular bytecode verifier - // report this because the user will get a better error message. - if (low > high) return true; - keys = high - low + 1; - delta = 1; - } else { - keys = (int)Bytes::get_Java_u4(aligned_bcp + jintSize); - delta = 2; - } - // Invalid, let the regular bytecode verifier deal with it. - if (keys < 0) return true; - - // Push the offset of the next bytecode onto the stack. - bci_stack->push(bcs.next_bci()); - - // Push the switch alternatives onto the stack. - for (int i = 0; i < keys; i++) { - int min_offset = -1 * max_method_code_size; - int offset = (jint)Bytes::get_Java_u4(aligned_bcp+(3+i*delta)*jintSize); - if (offset < min_offset || offset > max_method_code_size) return false; - u4 target = bci + offset; - if (target > code_length) return false; - bci_stack->push(target); - } - - // Start bytecode parsing for the switch at the default alternative. - if (default_offset > code_length) return false; - bcs.set_start(default_offset); - break; - } - - case Bytecodes::_return: - return false; - - case Bytecodes::_athrow: - { - if (bci_stack->is_empty()) { - if (handler_stack->is_empty()) { - return true; - } else { - // Parse the catch handlers for try blocks containing athrow. - bcs.set_start(handler_stack->pop()); - } - } else { - // Pop a bytecode offset and starting scanning from there. - bcs.set_start(bci_stack->pop()); - } - } - break; - - default: - ; - } // end switch - } // end while loop - - return false; -} - void ClassVerifier::verify_invoke_init( RawBytecodeStream* bcs, u2 ref_class_index, VerificationType ref_class_type, StackMapFrame* current_frame, u4 code_length, bool in_try_block, @@ -2673,25 +2463,6 @@ // sure that all catch clause paths end in a throw. Otherwise, this can // result in returning an incomplete object. if (in_try_block) { - ExceptionTable exhandlers(_method()); - int exlength = exhandlers.length(); - for(int i = 0; i < exlength; i++) { - u2 start_pc = exhandlers.start_pc(i); - u2 end_pc = exhandlers.end_pc(i); - - if (bci >= start_pc && bci < end_pc) { - if (!ends_in_athrow(exhandlers.handler_pc(i))) { - verify_error(ErrorContext::bad_code(bci), - "Bad method call from after the start of a try block"); - return; - } else if (log_is_enabled(Debug, verification)) { - ResourceMark rm(THREAD); - log_debug(verification)("Survived call to ends_in_athrow(): %s", - current_class()->name()->as_C_string()); - } - } - } - // Check the exception handler target stackmaps with the locals from the // incoming stackmap (before initialize_object() changes them to outgoing // state). diff -Nru openjdk-17-17.0.17+10/src/hotspot/share/classfile/verifier.hpp openjdk-17-17.0.18+8/src/hotspot/share/classfile/verifier.hpp --- openjdk-17-17.0.17+10/src/hotspot/share/classfile/verifier.hpp 2025-10-13 07:48:04.000000000 +0000 +++ openjdk-17-17.0.18+8/src/hotspot/share/classfile/verifier.hpp 2026-01-15 15:23:06.000000000 +0000 @@ -1,5 +1,5 @@ /* - * Copyright (c) 1998, 2020, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 1998, 2025, Oracle and/or its affiliates. All rights reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * * This code is free software; you can redistribute it and/or modify it @@ -336,17 +336,6 @@ bool* this_uninit, const constantPoolHandle& cp, StackMapTable* stackmap_table, TRAPS); - // Used by ends_in_athrow() to push all handlers that contain bci onto the - // handler_stack, if the handler has not already been pushed on the stack. - void push_handlers(ExceptionTable* exhandlers, - GrowableArray* handler_list, - GrowableArray* handler_stack, - u4 bci); - - // Returns true if all paths starting with start_bc_offset end in athrow - // bytecode or loop. - bool ends_in_athrow(u4 start_bc_offset); - void verify_invoke_instructions( RawBytecodeStream* bcs, u4 code_length, StackMapFrame* current_frame, bool in_try_block, bool* this_uninit, VerificationType return_type, diff -Nru openjdk-17-17.0.17+10/src/hotspot/share/gc/g1/g1GCPhaseTimes.cpp openjdk-17-17.0.18+8/src/hotspot/share/gc/g1/g1GCPhaseTimes.cpp --- openjdk-17-17.0.17+10/src/hotspot/share/gc/g1/g1GCPhaseTimes.cpp 2025-10-13 07:48:04.000000000 +0000 +++ openjdk-17-17.0.18+8/src/hotspot/share/gc/g1/g1GCPhaseTimes.cpp 2026-01-15 15:23:06.000000000 +0000 @@ -340,7 +340,7 @@ } } -#define TIME_FORMAT "%.1lfms" +#define TIME_FORMAT "%.2lfms" void G1GCPhaseTimes::info_time(const char* name, double value) const { log_info(gc, phases)(" %s: " TIME_FORMAT, name, value); diff -Nru openjdk-17-17.0.17+10/src/hotspot/share/gc/shared/weakProcessorTimes.cpp openjdk-17-17.0.18+8/src/hotspot/share/gc/shared/weakProcessorTimes.cpp --- openjdk-17-17.0.17+10/src/hotspot/share/gc/shared/weakProcessorTimes.cpp 2025-10-13 07:48:04.000000000 +0000 +++ openjdk-17-17.0.18+8/src/hotspot/share/gc/shared/weakProcessorTimes.cpp 2026-01-15 15:23:06.000000000 +0000 @@ -173,7 +173,7 @@ return indents[MIN2(i, max_indents_index)]; } -#define TIME_FORMAT "%.1lfms" +#define TIME_FORMAT "%.2lfms" void WeakProcessorTimes::log_summary(OopStorageSet::WeakId id, uint indent) const { LogTarget(Debug, gc, phases) lt; diff -Nru openjdk-17-17.0.17+10/src/hotspot/share/gc/shared/workerDataArray.cpp openjdk-17-17.0.18+8/src/hotspot/share/gc/shared/workerDataArray.cpp --- openjdk-17-17.0.17+10/src/hotspot/share/gc/shared/workerDataArray.cpp 2025-10-13 07:48:04.000000000 +0000 +++ openjdk-17-17.0.18+8/src/hotspot/share/gc/shared/workerDataArray.cpp 2026-01-15 15:23:06.000000000 +0000 @@ -36,6 +36,8 @@ return -1.0; } +#define WDA_TIME_FORMAT "%4.2lf" + template <> void WorkerDataArray::WDAPrinter::summary(outputStream* out, double time) { out->print_cr(" %.1lfms", time * MILLIUNITS); @@ -48,9 +50,10 @@ template <> void WorkerDataArray::WDAPrinter::summary(outputStream* out, double min, double avg, double max, double diff, double sum, bool print_sum) { - out->print(" Min: %4.1lf, Avg: %4.1lf, Max: %4.1lf, Diff: %4.1lf", min * MILLIUNITS, avg * MILLIUNITS, max * MILLIUNITS, diff* MILLIUNITS); + out->print(" Min: " WDA_TIME_FORMAT ", Avg: " WDA_TIME_FORMAT ", Max: " WDA_TIME_FORMAT ", Diff: " WDA_TIME_FORMAT, + min * MILLIUNITS, avg * MILLIUNITS, max * MILLIUNITS, diff* MILLIUNITS); if (print_sum) { - out->print(", Sum: %4.1lf", sum * MILLIUNITS); + out->print(", Sum: " WDA_TIME_FORMAT, sum * MILLIUNITS); } } @@ -68,7 +71,7 @@ for (uint i = 0; i < phase->_length; ++i) { double value = phase->get(i); if (value != phase->uninitialized()) { - out->print(" %4.1lf", phase->get(i) * 1000.0); + out->print(" " WDA_TIME_FORMAT, phase->get(i) * 1000.0); } else { out->print(" -"); } diff -Nru openjdk-17-17.0.17+10/src/hotspot/share/gc/shenandoah/c2/shenandoahSupport.cpp openjdk-17-17.0.18+8/src/hotspot/share/gc/shenandoah/c2/shenandoahSupport.cpp --- openjdk-17-17.0.17+10/src/hotspot/share/gc/shenandoah/c2/shenandoahSupport.cpp 2025-10-13 07:48:04.000000000 +0000 +++ openjdk-17-17.0.18+8/src/hotspot/share/gc/shenandoah/c2/shenandoahSupport.cpp 2026-01-15 15:23:06.000000000 +0000 @@ -639,6 +639,34 @@ } #endif +bool ShenandoahBarrierC2Support::is_anti_dependent_load_at_control(PhaseIdealLoop* phase, Node* maybe_load, Node* store, + Node* control) { + return maybe_load->is_Load() && phase->C->can_alias(store->adr_type(), phase->C->get_alias_index(maybe_load->adr_type())) && + phase->ctrl_or_self(maybe_load) == control; +} + +void ShenandoahBarrierC2Support::maybe_push_anti_dependent_loads(PhaseIdealLoop* phase, Node* maybe_store, Node* control, Unique_Node_List &wq) { + if (!maybe_store->is_Store() && !maybe_store->is_LoadStore()) { + return; + } + Node* mem = maybe_store->in(MemNode::Memory); + for (DUIterator_Fast imax, i = mem->fast_outs(imax); i < imax; i++) { + Node* u = mem->fast_out(i); + if (is_anti_dependent_load_at_control(phase, u, maybe_store, control)) { + wq.push(u); + } + } +} + +void ShenandoahBarrierC2Support::push_data_inputs_at_control(PhaseIdealLoop* phase, Node* n, Node* ctrl, Unique_Node_List &wq) { + for (uint i = 0; i < n->req(); i++) { + Node* in = n->in(i); + if (in != nullptr && (ShenandoahIUBarrier ? (phase->ctrl_or_self(in) == ctrl) : (phase->has_ctrl(in) && phase->get_ctrl(in) == ctrl))) { + wq.push(in); + } + } +} + bool ShenandoahBarrierC2Support::is_dominator_same_ctrl(Node* c, Node* d, Node* n, PhaseIdealLoop* phase) { // That both nodes have the same control is not sufficient to prove // domination, verify that there's no path from d to n @@ -653,22 +681,9 @@ if (m->is_Phi() && m->in(0)->is_Loop()) { assert(phase->ctrl_or_self(m->in(LoopNode::EntryControl)) != c, "following loop entry should lead to new control"); } else { - if (m->is_Store() || m->is_LoadStore()) { - // Take anti-dependencies into account - Node* mem = m->in(MemNode::Memory); - for (DUIterator_Fast imax, i = mem->fast_outs(imax); i < imax; i++) { - Node* u = mem->fast_out(i); - if (u->is_Load() && phase->C->can_alias(m->adr_type(), phase->C->get_alias_index(u->adr_type())) && - phase->ctrl_or_self(u) == c) { - wq.push(u); - } - } - } - for (uint i = 0; i < m->req(); i++) { - if (m->in(i) != NULL && phase->ctrl_or_self(m->in(i)) == c) { - wq.push(m->in(i)); - } - } + // Take anti-dependencies into account + maybe_push_anti_dependent_loads(phase, m, c, wq); + push_data_inputs_at_control(phase, m, c, wq); } } return true; @@ -1020,7 +1035,20 @@ phase->register_new_node(val, ctrl); } -void ShenandoahBarrierC2Support::fix_ctrl(Node* barrier, Node* region, const MemoryGraphFixer& fixer, Unique_Node_List& uses, Unique_Node_List& uses_to_ignore, uint last, PhaseIdealLoop* phase) { +void ShenandoahBarrierC2Support::collect_nodes_above_barrier(Unique_Node_List &nodes_above_barrier, PhaseIdealLoop* phase, Node* ctrl, Node* init_raw_mem) { + nodes_above_barrier.clear(); + if (phase->has_ctrl(init_raw_mem) && phase->get_ctrl(init_raw_mem) == ctrl && !init_raw_mem->is_Phi()) { + nodes_above_barrier.push(init_raw_mem); + } + for (uint next = 0; next < nodes_above_barrier.size(); next++) { + Node* n = nodes_above_barrier.at(next); + // Take anti-dependencies into account + maybe_push_anti_dependent_loads(phase, n, ctrl, nodes_above_barrier); + push_data_inputs_at_control(phase, n, ctrl, nodes_above_barrier); + } +} + +void ShenandoahBarrierC2Support::fix_ctrl(Node* barrier, Node* region, const MemoryGraphFixer& fixer, Unique_Node_List& uses, Unique_Node_List& nodes_above_barrier, uint last, PhaseIdealLoop* phase) { Node* ctrl = phase->get_ctrl(barrier); Node* init_raw_mem = fixer.find_mem(ctrl, barrier); @@ -1031,30 +1059,17 @@ // control will be after the expanded barrier. The raw memory (if // its memory is control dependent on the barrier's input control) // must stay above the barrier. - uses_to_ignore.clear(); - if (phase->has_ctrl(init_raw_mem) && phase->get_ctrl(init_raw_mem) == ctrl && !init_raw_mem->is_Phi()) { - uses_to_ignore.push(init_raw_mem); - } - for (uint next = 0; next < uses_to_ignore.size(); next++) { - Node *n = uses_to_ignore.at(next); - for (uint i = 0; i < n->req(); i++) { - Node* in = n->in(i); - if (in != NULL && phase->has_ctrl(in) && phase->get_ctrl(in) == ctrl) { - uses_to_ignore.push(in); - } - } - } + collect_nodes_above_barrier(nodes_above_barrier, phase, ctrl, init_raw_mem); for (DUIterator_Fast imax, i = ctrl->fast_outs(imax); i < imax; i++) { Node* u = ctrl->fast_out(i); if (u->_idx < last && u != barrier && !u->depends_only_on_test() && // preserve dependency on test - !uses_to_ignore.member(u) && + !nodes_above_barrier.member(u) && (u->in(0) != ctrl || (!u->is_Region() && !u->is_Phi())) && (ctrl->Opcode() != Op_CatchProj || u->Opcode() != Op_CreateEx)) { Node* old_c = phase->ctrl_or_self(u); - Node* c = old_c; - if (c != ctrl || + if (old_c != ctrl || is_dominator_same_ctrl(old_c, barrier, u, phase) || ShenandoahBarrierSetC2::is_shenandoah_state_load(u)) { phase->igvn().rehash_node_delayed(u); @@ -1326,7 +1341,7 @@ // Expand load-reference-barriers MemoryGraphFixer fixer(Compile::AliasIdxRaw, true, phase); - Unique_Node_List uses_to_ignore; + Unique_Node_List nodes_above_barriers; for (int i = state->load_reference_barriers_count() - 1; i >= 0; i--) { ShenandoahLoadReferenceBarrierNode* lrb = state->load_reference_barrier(i); uint last = phase->C->unique(); @@ -1423,7 +1438,7 @@ Node* out_val = val_phi; phase->register_new_node(val_phi, region); - fix_ctrl(lrb, region, fixer, uses, uses_to_ignore, last, phase); + fix_ctrl(lrb, region, fixer, uses, nodes_above_barriers, last, phase); ctrl = orig_ctrl; @@ -1579,7 +1594,7 @@ phase->register_control(region, loop, heap_stable_ctrl->in(0)); phase->register_new_node(phi, region); - fix_ctrl(barrier, region, fixer, uses, uses_to_ignore, last, phase); + fix_ctrl(barrier, region, fixer, uses, nodes_above_barriers, last, phase); for(uint next = 0; next < uses.size(); next++ ) { Node *n = uses.at(next); assert(phase->get_ctrl(n) == init_ctrl, "bad control"); diff -Nru openjdk-17-17.0.17+10/src/hotspot/share/gc/shenandoah/c2/shenandoahSupport.hpp openjdk-17-17.0.18+8/src/hotspot/share/gc/shenandoah/c2/shenandoahSupport.hpp --- openjdk-17-17.0.17+10/src/hotspot/share/gc/shenandoah/c2/shenandoahSupport.hpp 2025-10-13 07:48:04.000000000 +0000 +++ openjdk-17-17.0.18+8/src/hotspot/share/gc/shenandoah/c2/shenandoahSupport.hpp 2026-01-15 15:23:06.000000000 +0000 @@ -62,12 +62,16 @@ PhaseIdealLoop* phase, int flags); static void call_lrb_stub(Node*& ctrl, Node*& val, Node* load_addr, DecoratorSet decorators, PhaseIdealLoop* phase); + + static void collect_nodes_above_barrier(Unique_Node_List &nodes_above_barrier, PhaseIdealLoop* phase, Node* ctrl, + Node* init_raw_mem); + static void test_in_cset(Node*& ctrl, Node*& not_cset_ctrl, Node* val, Node* raw_mem, PhaseIdealLoop* phase); static void move_gc_state_test_out_of_loop(IfNode* iff, PhaseIdealLoop* phase); static void merge_back_to_back_tests(Node* n, PhaseIdealLoop* phase); static bool merge_point_safe(Node* region); static bool identical_backtoback_ifs(Node *n, PhaseIdealLoop* phase); - static void fix_ctrl(Node* barrier, Node* region, const MemoryGraphFixer& fixer, Unique_Node_List& uses, Unique_Node_List& uses_to_ignore, uint last, PhaseIdealLoop* phase); + static void fix_ctrl(Node* barrier, Node* region, const MemoryGraphFixer& fixer, Unique_Node_List& uses, Unique_Node_List& nodes_above_barrier, uint last, PhaseIdealLoop* phase); static IfNode* find_unswitching_candidate(const IdealLoopTree *loop, PhaseIdealLoop* phase); static Node* get_load_addr(PhaseIdealLoop* phase, VectorSet& visited, Node* lrb); @@ -82,6 +86,11 @@ static void pin_and_expand(PhaseIdealLoop* phase); static void optimize_after_expansion(VectorSet& visited, Node_Stack& nstack, Node_List& old_new, PhaseIdealLoop* phase); + static void push_data_inputs_at_control(PhaseIdealLoop* phase, Node* n, Node* ctrl, + Unique_Node_List &wq); + static bool is_anti_dependent_load_at_control(PhaseIdealLoop* phase, Node* maybe_load, Node* store, Node* control); + + static void maybe_push_anti_dependent_loads(PhaseIdealLoop* phase, Node* maybe_store, Node* control, Unique_Node_List &wq); #ifdef ASSERT static void verify(RootNode* root); #endif diff -Nru openjdk-17-17.0.17+10/src/hotspot/share/gc/shenandoah/shenandoahHeap.cpp openjdk-17-17.0.18+8/src/hotspot/share/gc/shenandoah/shenandoahHeap.cpp --- openjdk-17-17.0.17+10/src/hotspot/share/gc/shenandoah/shenandoahHeap.cpp 2025-10-13 07:48:04.000000000 +0000 +++ openjdk-17-17.0.18+8/src/hotspot/share/gc/shenandoah/shenandoahHeap.cpp 2026-01-15 15:23:06.000000000 +0000 @@ -1039,26 +1039,23 @@ } } -void ShenandoahHeap::trash_humongous_region_at(ShenandoahHeapRegion* start) { +size_t ShenandoahHeap::trash_humongous_region_at(ShenandoahHeapRegion* start) const { assert(start->is_humongous_start(), "reclaim regions starting with the first one"); - - oop humongous_obj = cast_to_oop(start->bottom()); - size_t size = humongous_obj->size(); - size_t required_regions = ShenandoahHeapRegion::required_regions(size * HeapWordSize); - size_t index = start->index() + required_regions - 1; - assert(!start->has_live(), "liveness must be zero"); - for(size_t i = 0; i < required_regions; i++) { - // Reclaim from tail. Otherwise, assertion fails when printing region to trace log, - // as it expects that every region belongs to a humongous region starting with a humongous start region. - ShenandoahHeapRegion* region = get_region(index --); - - assert(region->is_humongous(), "expect correct humongous start or continuation"); + // Do not try to get the size of this humongous object. STW collections will + // have already unloaded classes, so an unmarked object may have a bad klass pointer. + ShenandoahHeapRegion* region = start; + size_t index = region->index(); + do { + assert(region->is_humongous(), "Expect correct humongous start or continuation"); assert(!region->is_cset(), "Humongous region should not be in collection set"); - region->make_trash_immediate(); - } + region = get_region(++index); + } while (region != nullptr && region->is_humongous_continuation()); + + // Return number of regions trashed + return index - start->index(); } class ShenandoahCheckCleanGCLABClosure : public ThreadClosure { diff -Nru openjdk-17-17.0.17+10/src/hotspot/share/gc/shenandoah/shenandoahHeap.hpp openjdk-17-17.0.18+8/src/hotspot/share/gc/shenandoah/shenandoahHeap.hpp --- openjdk-17-17.0.17+10/src/hotspot/share/gc/shenandoah/shenandoahHeap.hpp 2025-10-13 07:48:04.000000000 +0000 +++ openjdk-17-17.0.18+8/src/hotspot/share/gc/shenandoah/shenandoahHeap.hpp 2026-01-15 15:23:06.000000000 +0000 @@ -651,7 +651,7 @@ static inline void atomic_clear_oop(narrowOop* addr, oop compare); static inline void atomic_clear_oop(narrowOop* addr, narrowOop compare); - void trash_humongous_region_at(ShenandoahHeapRegion *r); + size_t trash_humongous_region_at(ShenandoahHeapRegion *r) const; private: void trash_cset_regions(); diff -Nru openjdk-17-17.0.17+10/src/hotspot/share/interpreter/templateTable.cpp openjdk-17-17.0.18+8/src/hotspot/share/interpreter/templateTable.cpp --- openjdk-17-17.0.17+10/src/hotspot/share/interpreter/templateTable.cpp 2025-10-13 07:48:04.000000000 +0000 +++ openjdk-17-17.0.18+8/src/hotspot/share/interpreter/templateTable.cpp 2026-01-15 15:23:06.000000000 +0000 @@ -202,8 +202,8 @@ } -void TemplateTable::def(Bytecodes::Code code, int flags, TosState in, TosState out, void (*gen)(bool arg ), bool arg) { - def(code, flags, in, out, (Template::generator)gen, (int)arg); +void TemplateTable::def(Bytecodes::Code code, int flags, TosState in, TosState out, void (*gen)(LdcType ldct), LdcType ldct) { + def(code, flags, in, out, (Template::generator)gen, (int)ldct); } @@ -250,8 +250,8 @@ def(Bytecodes::_dconst_1 , ____|____|____|____, vtos, dtos, dconst , 1 ); def(Bytecodes::_bipush , ubcp|____|____|____, vtos, itos, bipush , _ ); def(Bytecodes::_sipush , ubcp|____|____|____, vtos, itos, sipush , _ ); - def(Bytecodes::_ldc , ubcp|____|clvm|____, vtos, vtos, ldc , false ); - def(Bytecodes::_ldc_w , ubcp|____|clvm|____, vtos, vtos, ldc , true ); + def(Bytecodes::_ldc , ubcp|____|clvm|____, vtos, vtos, ldc , ldc_normal ); + def(Bytecodes::_ldc_w , ubcp|____|clvm|____, vtos, vtos, ldc , ldc_wide ); def(Bytecodes::_ldc2_w , ubcp|____|clvm|____, vtos, vtos, ldc2_w , _ ); def(Bytecodes::_iload , ubcp|____|clvm|____, vtos, itos, iload , _ ); def(Bytecodes::_lload , ubcp|____|____|____, vtos, ltos, lload , _ ); @@ -484,8 +484,8 @@ def(Bytecodes::_fast_linearswitch , ubcp|disp|____|____, itos, vtos, fast_linearswitch , _ ); def(Bytecodes::_fast_binaryswitch , ubcp|disp|____|____, itos, vtos, fast_binaryswitch , _ ); - def(Bytecodes::_fast_aldc , ubcp|____|clvm|____, vtos, atos, fast_aldc , false ); - def(Bytecodes::_fast_aldc_w , ubcp|____|clvm|____, vtos, atos, fast_aldc , true ); + def(Bytecodes::_fast_aldc , ubcp|____|clvm|____, vtos, atos, fast_aldc , ldc_normal ); + def(Bytecodes::_fast_aldc_w , ubcp|____|clvm|____, vtos, atos, fast_aldc , ldc_wide ); def(Bytecodes::_return_register_finalizer , ____|disp|clvm|____, vtos, vtos, _return , vtos ); diff -Nru openjdk-17-17.0.17+10/src/hotspot/share/interpreter/templateTable.hpp openjdk-17-17.0.18+8/src/hotspot/share/interpreter/templateTable.hpp --- openjdk-17-17.0.17+10/src/hotspot/share/interpreter/templateTable.hpp 2025-10-13 07:48:04.000000000 +0000 +++ openjdk-17-17.0.18+8/src/hotspot/share/interpreter/templateTable.hpp 2026-01-15 15:23:06.000000000 +0000 @@ -83,6 +83,7 @@ enum Operation { add, sub, mul, div, rem, _and, _or, _xor, shl, shr, ushr }; enum Condition { equal, not_equal, less, less_equal, greater, greater_equal }; enum CacheByte { f1_byte = 1, f2_byte = 2 }; // byte_no codes + enum LdcType { ldc_normal = 0, ldc_wide = 1 }; // LDC type enum RewriteControl { may_rewrite, may_not_rewrite }; // control for fast code under CDS private: @@ -105,6 +106,11 @@ static void patch_bytecode(Bytecodes::Code bc, Register bc_reg, Register temp_reg, bool load_bc_into_bc_reg = true, int byte_no = -1); + static bool is_ldc_wide(LdcType type) { + assert(type == ldc_wide || type == ldc_normal, "sanity"); + return (type == ldc_wide); + } + // C calls static void call_VM(Register oop_result, address entry_point); static void call_VM(Register oop_result, address entry_point, Register arg_1); @@ -128,9 +134,9 @@ static void bipush(); static void sipush(); - static void ldc(bool wide); + static void ldc(LdcType type); static void ldc2_w(); - static void fast_aldc(bool wide); + static void fast_aldc(LdcType type); static void locals_index(Register reg, int offset = 1); static void iload(); @@ -327,7 +333,7 @@ // initialization helpers static void def(Bytecodes::Code code, int flags, TosState in, TosState out, void (*gen)( ), char filler ); static void def(Bytecodes::Code code, int flags, TosState in, TosState out, void (*gen)(int arg ), int arg ); - static void def(Bytecodes::Code code, int flags, TosState in, TosState out, void (*gen)(bool arg ), bool arg ); + static void def(Bytecodes::Code code, int flags, TosState in, TosState out, void (*gen)(LdcType ldct), LdcType ldct); static void def(Bytecodes::Code code, int flags, TosState in, TosState out, void (*gen)(TosState tos), TosState tos); static void def(Bytecodes::Code code, int flags, TosState in, TosState out, void (*gen)(Operation op), Operation op); static void def(Bytecodes::Code code, int flags, TosState in, TosState out, void (*gen)(Condition cc), Condition cc); diff -Nru openjdk-17-17.0.17+10/src/hotspot/share/memory/guardedMemory.cpp openjdk-17-17.0.18+8/src/hotspot/share/memory/guardedMemory.cpp --- openjdk-17-17.0.17+10/src/hotspot/share/memory/guardedMemory.cpp 2025-10-13 07:48:04.000000000 +0000 +++ openjdk-17-17.0.18+8/src/hotspot/share/memory/guardedMemory.cpp 2026-01-15 15:23:06.000000000 +0000 @@ -27,11 +27,12 @@ #include "memory/guardedMemory.hpp" #include "runtime/os.hpp" -void* GuardedMemory::wrap_copy(const void* ptr, const size_t len, const void* tag) { +void* GuardedMemory::wrap_copy(const void* ptr, const size_t len, + const void* tag, const void* tag2) { size_t total_sz = GuardedMemory::get_total_size(len); void* outerp = os::malloc(total_sz, mtInternal); if (outerp != NULL) { - GuardedMemory guarded(outerp, len, tag); + GuardedMemory guarded(outerp, len, tag, tag2); void* innerp = guarded.get_user_ptr(); if (ptr != nullptr) { memcpy(innerp, ptr, len); @@ -60,8 +61,8 @@ return; } st->print_cr("GuardedMemory(" PTR_FORMAT ") base_addr=" PTR_FORMAT - " tag=" PTR_FORMAT " user_size=" SIZE_FORMAT " user_data=" PTR_FORMAT, - p2i(this), p2i(_base_addr), p2i(get_tag()), get_user_size(), p2i(get_user_ptr())); + " tag=" PTR_FORMAT "tag2=" PTR_FORMAT " user_size=" SIZE_FORMAT " user_data=" PTR_FORMAT, + p2i(this), p2i(_base_addr), p2i(get_tag()), p2i(get_tag2()), get_user_size(), p2i(get_user_ptr())); Guard* guard = get_head_guard(); st->print_cr(" Header guard @" PTR_FORMAT " is %s", p2i(guard), (guard->verify() ? "OK" : "BROKEN")); diff -Nru openjdk-17-17.0.17+10/src/hotspot/share/memory/guardedMemory.hpp openjdk-17-17.0.18+8/src/hotspot/share/memory/guardedMemory.hpp --- openjdk-17-17.0.17+10/src/hotspot/share/memory/guardedMemory.hpp 2025-10-13 07:48:04.000000000 +0000 +++ openjdk-17-17.0.18+8/src/hotspot/share/memory/guardedMemory.hpp 2026-01-15 15:23:06.000000000 +0000 @@ -1,5 +1,5 @@ /* - * Copyright (c) 2014, 2019, 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 @@ -26,6 +26,7 @@ #define SHARE_MEMORY_GUARDEDMEMORY_HPP #include "memory/allocation.hpp" +#include "runtime/os.hpp" #include "utilities/globalDefinitions.hpp" /** @@ -41,15 +42,19 @@ * |Offset | Content | Description | * |------------------------------------------------------------ * |base_addr | 0xABABABABABABABAB | Head guard | - * |+16 | | User data size | - * |+sizeof(uintptr_t) | | Tag word | + * |+GUARD_SIZE | | User data size | + * |+sizeof(size_t) | | Tag word | + * |+sizeof(void*) | | Tag word | + * |+sizeof(void*) | | Padding | * |+sizeof(void*) | 0xF1 ( | User data | * |+user_size | 0xABABABABABABABAB | Tail guard | * ------------------------------------------------------------- * * Where: * - guard padding uses "badResourceValue" (0xAB) - * - tag word is general purpose + * - tag word and tag2 word are general purpose + * - padding is inserted as-needed by the compiler to ensure + * the user data is aligned on a 16-byte boundary * - user data * -- initially padded with "uninitBlockPad" (0xF1), * -- to "freeBlockPad" (0xBA), when freed @@ -111,6 +116,10 @@ } bool verify() const { + // We may not be able to dereference directly. + if (!os::is_readable_range((const void*) _guard, (const void*) (_guard + GUARD_SIZE))) { + return false; + } u_char* c = (u_char*) _guard; u_char* end = c + GUARD_SIZE; while (c < end) { @@ -126,17 +135,21 @@ /** * Header guard and size + * + * NB: the size and placement of the GuardHeader must be such that the + * user-ptr is maximally aligned i.e. 16-byte alignment for x86 ABI for + * stack alignment and use of vector (xmm) instructions. We use alignas + * to achieve this. */ - class GuardHeader : Guard { + class alignas(16) GuardHeader : Guard { friend class GuardedMemory; protected: - // Take care in modifying fields here, will effect alignment - // e.g. x86 ABI 16 byte stack alignment union { uintptr_t __unused_full_word1; size_t _user_size; }; void* _tag; + void* _tag2; public: void set_user_size(const size_t usz) { _user_size = usz; } size_t get_user_size() const { return _user_size; } @@ -144,6 +157,8 @@ void set_tag(const void* tag) { _tag = (void*) tag; } void* get_tag() const { return _tag; } + void set_tag2(const void* tag2) { _tag2 = (void*) tag2; } + void* get_tag2() const { return _tag2; } }; // GuardedMemory::GuardHeader // Guarded Memory... @@ -162,9 +177,11 @@ * @param base_ptr allocation wishing to be wrapped, must be at least "GuardedMemory::get_total_size()" bytes. * @param user_size the size of the user data to be wrapped. * @param tag optional general purpose tag. + * @param tag2 optional second general purpose tag. */ - GuardedMemory(void* base_ptr, const size_t user_size, const void* tag = NULL) { - wrap_with_guards(base_ptr, user_size, tag); + GuardedMemory(void* base_ptr, const size_t user_size, + const void* tag = nullptr, const void* tag2 = nullptr) { + wrap_with_guards(base_ptr, user_size, tag, tag2); } /** @@ -189,16 +206,19 @@ * @param base_ptr allocation wishing to be wrapped, must be at least "GuardedMemory::get_total_size()" bytes. * @param user_size the size of the user data to be wrapped. * @param tag optional general purpose tag. + * @param tag2 optional second general purpose tag. * * @return user data pointer (inner pointer to supplied "base_ptr"). */ - void* wrap_with_guards(void* base_ptr, size_t user_size, const void* tag = NULL) { + void* wrap_with_guards(void* base_ptr, size_t user_size, + const void* tag = nullptr, const void* tag2 = nullptr) { assert(base_ptr != NULL, "Attempt to wrap NULL with memory guard"); _base_addr = (u_char*)base_ptr; get_head_guard()->build(); get_head_guard()->set_user_size(user_size); get_tail_guard()->build(); set_tag(tag); + set_tag2(tag2); set_user_bytes(uninitBlockPad); assert(verify_guards(), "Expected valid memory guards"); return get_user_ptr(); @@ -231,6 +251,20 @@ void* get_tag() const { return get_head_guard()->get_tag(); } /** + * Set the second general purpose tag. + * + * @param tag general purpose tag. + */ + void set_tag2(const void* tag) { get_head_guard()->set_tag2(tag); } + + /** + * Return the second general purpose tag. + * + * @return the second general purpose tag, defaults to null. + */ + void* get_tag2() const { return get_head_guard()->get_tag2(); } + + /** * Return the size of the user data. * * @return the size of the user data. @@ -302,10 +336,12 @@ * @param ptr the memory to be copied * @param len the length of the copy * @param tag optional general purpose tag (see GuardedMemory::get_tag()) + * @param tag2 optional general purpose tag (see GuardedMemory::get_tag2()) * * @return guarded wrapped memory pointer to the user area, or NULL if OOM. */ - static void* wrap_copy(const void* p, const size_t len, const void* tag = NULL); + static void* wrap_copy(const void* p, const size_t len, + const void* tag = nullptr, const void* tag2 = nullptr); /** * Free wrapped copy. diff -Nru openjdk-17-17.0.17+10/src/hotspot/share/opto/compile.cpp openjdk-17-17.0.18+8/src/hotspot/share/opto/compile.cpp --- openjdk-17-17.0.17+10/src/hotspot/share/opto/compile.cpp 2025-10-13 07:48:04.000000000 +0000 +++ openjdk-17-17.0.18+8/src/hotspot/share/opto/compile.cpp 2026-01-15 15:23:06.000000000 +0000 @@ -775,7 +775,7 @@ // If any phase is randomized for stress testing, seed random number // generation and log the seed for repeatability. if (StressLCM || StressGCM || StressIGVN || StressCCP) { - if (FLAG_IS_DEFAULT(StressSeed) || (FLAG_IS_ERGO(StressSeed) && RepeatCompilation)) { + if (FLAG_IS_DEFAULT(StressSeed) || (FLAG_IS_ERGO(StressSeed) && directive->RepeatCompilationOption)) { _stress_seed = static_cast(Ticks::now().nanoseconds()); FLAG_SET_ERGO(StressSeed, _stress_seed); } else { diff -Nru openjdk-17-17.0.17+10/src/hotspot/share/opto/vector.cpp openjdk-17-17.0.18+8/src/hotspot/share/opto/vector.cpp --- openjdk-17-17.0.17+10/src/hotspot/share/opto/vector.cpp 2025-10-13 07:48:04.000000000 +0000 +++ openjdk-17-17.0.18+8/src/hotspot/share/opto/vector.cpp 2026-01-15 15:23:06.000000000 +0000 @@ -163,6 +163,17 @@ for (uint i = 0; i < size; i++) { map->init_req(i, sfpt->in(i)); } + Node* mem = map->memory(); + if (!mem->is_MergeMem()) { + // Since we are not in parsing, the SafePointNode does not guarantee that the memory + // input is necessarily a MergeMemNode. But we need to ensure that there is that + // MergeMemNode, since the GraphKit assumes the memory input of the map to be a + // MergeMemNode, so that it can directly access the memory slices. + PhaseGVN& gvn = *C->initial_gvn(); + Node* mergemem = MergeMemNode::make(mem); + gvn.set_type_bottom(mergemem); + map->set_memory(mergemem); + } new_jvms->set_map(map); return new_jvms; } diff -Nru openjdk-17-17.0.17+10/src/hotspot/share/prims/jniCheck.cpp openjdk-17-17.0.18+8/src/hotspot/share/prims/jniCheck.cpp --- openjdk-17-17.0.17+10/src/hotspot/share/prims/jniCheck.cpp 2025-10-13 07:48:04.000000000 +0000 +++ openjdk-17-17.0.18+8/src/hotspot/share/prims/jniCheck.cpp 2026-01-15 15:23:06.000000000 +0000 @@ -351,24 +351,33 @@ } } +// Arbitrary (but well-known) tag for GetStringChars +const void* STRING_TAG = (void*)0x47114711; + +// Arbitrary (but well-known) tag for GetStringUTFChars +const void* STRING_UTF_TAG = (void*) 0x48124812; + +// Arbitrary (but well-known) tag for GetPrimitiveArrayCritical +const void* CRITICAL_TAG = (void*)0x49134913; + /* * Copy and wrap array elements for bounds checking. * Remember the original elements (GuardedMemory::get_tag()) */ static void* check_jni_wrap_copy_array(JavaThread* thr, jarray array, - void* orig_elements) { + void* orig_elements, jboolean is_critical = JNI_FALSE) { void* result; IN_VM( oop a = JNIHandles::resolve_non_null(array); size_t len = arrayOop(a)->length() << TypeArrayKlass::cast(a->klass())->log2_element_size(); - result = GuardedMemory::wrap_copy(orig_elements, len, orig_elements); + result = GuardedMemory::wrap_copy(orig_elements, len, orig_elements, is_critical ? CRITICAL_TAG : nullptr); ) return result; } static void* check_wrapped_array(JavaThread* thr, const char* fn_name, - void* obj, void* carray, size_t* rsz) { + void* obj, void* carray, size_t* rsz, jboolean is_critical) { if (carray == NULL) { tty->print_cr("%s: elements vector NULL" PTR_FORMAT, fn_name, p2i(obj)); NativeReportJNIFatalError(thr, "Elements vector NULL"); @@ -387,6 +396,29 @@ DEBUG_ONLY(guarded.print_on(tty);) // This may crash. NativeReportJNIFatalError(thr, err_msg("%s: unrecognized elements", fn_name)); } + if (orig_result == STRING_TAG || orig_result == STRING_UTF_TAG) { + bool was_utf = orig_result == STRING_UTF_TAG; + tty->print_cr("%s: called on something allocated by %s", + fn_name, was_utf ? "GetStringUTFChars" : "GetStringChars"); + DEBUG_ONLY(guarded.print_on(tty);) // This may crash. + NativeReportJNIFatalError(thr, err_msg("%s called on something allocated by %s", + fn_name, was_utf ? "GetStringUTFChars" : "GetStringChars")); + } + + if (is_critical && (guarded.get_tag2() != CRITICAL_TAG)) { + tty->print_cr("%s: called on something not allocated by GetPrimitiveArrayCritical", fn_name); + DEBUG_ONLY(guarded.print_on(tty);) // This may crash. + NativeReportJNIFatalError(thr, err_msg("%s called on something not allocated by GetPrimitiveArrayCritical", + fn_name)); + } + + if (!is_critical && (guarded.get_tag2() == CRITICAL_TAG)) { + tty->print_cr("%s: called on something allocated by GetPrimitiveArrayCritical", fn_name); + DEBUG_ONLY(guarded.print_on(tty);) // This may crash. + NativeReportJNIFatalError(thr, err_msg("%s called on something allocated by GetPrimitiveArrayCritical", + fn_name)); + } + if (rsz != NULL) { *rsz = guarded.get_user_size(); } @@ -396,7 +428,7 @@ static void* check_wrapped_array_release(JavaThread* thr, const char* fn_name, void* obj, void* carray, jint mode, jboolean is_critical) { size_t sz; - void* orig_result = check_wrapped_array(thr, fn_name, obj, carray, &sz); + void* orig_result = check_wrapped_array(thr, fn_name, obj, carray, &sz, is_critical); switch (mode) { case 0: memcpy(orig_result, carray, sz); @@ -1431,9 +1463,6 @@ return result; JNI_END -// Arbitrary (but well-known) tag -const void* STRING_TAG = (void*)0x47114711; - JNI_ENTRY_CHECKED(const jchar *, checked_jni_GetStringChars(JNIEnv *env, jstring str, @@ -1515,9 +1544,6 @@ return result; JNI_END -// Arbitrary (but well-known) tag - different than GetStringChars -const void* STRING_UTF_TAG = (void*) 0x48124812; - JNI_ENTRY_CHECKED(const char *, checked_jni_GetStringUTFChars(JNIEnv *env, jstring str, @@ -1839,7 +1865,7 @@ ) void *result = UNCHECKED()->GetPrimitiveArrayCritical(env, array, isCopy); if (result != NULL) { - result = check_jni_wrap_copy_array(thr, array, result); + result = check_jni_wrap_copy_array(thr, array, result, JNI_TRUE); } functionExit(thr); return result; diff -Nru openjdk-17-17.0.17+10/src/hotspot/share/runtime/abstract_vm_version.cpp openjdk-17-17.0.18+8/src/hotspot/share/runtime/abstract_vm_version.cpp --- openjdk-17-17.0.17+10/src/hotspot/share/runtime/abstract_vm_version.cpp 2025-10-13 07:48:04.000000000 +0000 +++ openjdk-17-17.0.18+8/src/hotspot/share/runtime/abstract_vm_version.cpp 2026-01-15 15:23:06.000000000 +0000 @@ -253,6 +253,18 @@ #define HOTSPOT_BUILD_COMPILER "MS VC++ 17.7 (VS2022)" #elif _MSC_VER == 1938 #define HOTSPOT_BUILD_COMPILER "MS VC++ 17.8 (VS2022)" + #elif _MSC_VER == 1939 + #define HOTSPOT_BUILD_COMPILER "MS VC++ 17.9 (VS2022)" + #elif _MSC_VER == 1940 + #define HOTSPOT_BUILD_COMPILER "MS VC++ 17.10 (VS2022)" + #elif _MSC_VER == 1941 + #define HOTSPOT_BUILD_COMPILER "MS VC++ 17.11 (VS2022)" + #elif _MSC_VER == 1942 + #define HOTSPOT_BUILD_COMPILER "MS VC++ 17.12 (VS2022)" + #elif _MSC_VER == 1943 + #define HOTSPOT_BUILD_COMPILER "MS VC++ 17.13 (VS2022)" + #elif _MSC_VER == 1944 + #define HOTSPOT_BUILD_COMPILER "MS VC++ 17.14 (VS2022)" #else #define HOTSPOT_BUILD_COMPILER "unknown MS VC++:" XSTR(_MSC_VER) #endif diff -Nru openjdk-17-17.0.17+10/src/hotspot/share/runtime/flags/jvmFlagConstraintsRuntime.cpp openjdk-17-17.0.18+8/src/hotspot/share/runtime/flags/jvmFlagConstraintsRuntime.cpp --- openjdk-17-17.0.17+10/src/hotspot/share/runtime/flags/jvmFlagConstraintsRuntime.cpp 2025-10-13 07:48:04.000000000 +0000 +++ openjdk-17-17.0.18+8/src/hotspot/share/runtime/flags/jvmFlagConstraintsRuntime.cpp 2026-01-15 15:23:06.000000000 +0000 @@ -161,3 +161,13 @@ return JVMFlag::SUCCESS; } + +JVMFlag::Error LargePageSizeInBytesConstraintFunc(size_t value, bool verbose) { + if (!is_power_of_2(value)) { + JVMFlag::printError(verbose, "LargePageSizeInBytes ( %zu ) must be " + "a power of 2\n", + value); + return JVMFlag::VIOLATES_CONSTRAINT; + } + return JVMFlag::SUCCESS; +} diff -Nru openjdk-17-17.0.17+10/src/hotspot/share/runtime/flags/jvmFlagConstraintsRuntime.hpp openjdk-17-17.0.18+8/src/hotspot/share/runtime/flags/jvmFlagConstraintsRuntime.hpp --- openjdk-17-17.0.17+10/src/hotspot/share/runtime/flags/jvmFlagConstraintsRuntime.hpp 2025-10-13 07:48:04.000000000 +0000 +++ openjdk-17-17.0.18+8/src/hotspot/share/runtime/flags/jvmFlagConstraintsRuntime.hpp 2026-01-15 15:23:06.000000000 +0000 @@ -42,7 +42,8 @@ f(intx, BiasedLockingDecayTimeFunc) \ f(intx, PerfDataSamplingIntervalFunc) \ f(uintx, VMPageSizeConstraintFunc) \ - f(size_t, NUMAInterleaveGranularityConstraintFunc) + f(size_t, NUMAInterleaveGranularityConstraintFunc) \ + f(size_t, LargePageSizeInBytesConstraintFunc) RUNTIME_CONSTRAINTS(DECLARE_CONSTRAINT) diff -Nru openjdk-17-17.0.17+10/src/hotspot/share/runtime/globals.hpp openjdk-17-17.0.18+8/src/hotspot/share/runtime/globals.hpp --- openjdk-17-17.0.17+10/src/hotspot/share/runtime/globals.hpp 2025-10-13 07:48:04.000000000 +0000 +++ openjdk-17-17.0.18+8/src/hotspot/share/runtime/globals.hpp 2026-01-15 15:23:06.000000000 +0000 @@ -241,8 +241,10 @@ \ product(size_t, LargePageSizeInBytes, 0, \ "Maximum large page size used (0 will use the default large " \ - "page size for the environment as the maximum)") \ + "page size for the environment as the maximum) " \ + "(must be a power of 2)") \ range(0, max_uintx) \ + constraint(LargePageSizeInBytesConstraintFunc, AtParse) \ \ product(size_t, LargePageHeapSizeThreshold, 128*M, \ "Use large pages if maximum heap is at least this big") \ diff -Nru openjdk-17-17.0.17+10/src/hotspot/share/utilities/compilerWarnings.hpp openjdk-17-17.0.18+8/src/hotspot/share/utilities/compilerWarnings.hpp --- openjdk-17-17.0.17+10/src/hotspot/share/utilities/compilerWarnings.hpp 2025-10-13 07:48:04.000000000 +0000 +++ openjdk-17-17.0.18+8/src/hotspot/share/utilities/compilerWarnings.hpp 2026-01-15 15:23:06.000000000 +0000 @@ -74,4 +74,8 @@ #define PRAGMA_INFINITE_RECURSION_IGNORED #endif +#ifndef PRAGMA_NONNULL_IGNORED +#define PRAGMA_NONNULL_IGNORED +#endif + #endif // SHARE_UTILITIES_COMPILERWARNINGS_HPP diff -Nru openjdk-17-17.0.17+10/src/hotspot/share/utilities/compilerWarnings_gcc.hpp openjdk-17-17.0.18+8/src/hotspot/share/utilities/compilerWarnings_gcc.hpp --- openjdk-17-17.0.17+10/src/hotspot/share/utilities/compilerWarnings_gcc.hpp 2025-10-13 07:48:04.000000000 +0000 +++ openjdk-17-17.0.18+8/src/hotspot/share/utilities/compilerWarnings_gcc.hpp 2026-01-15 15:23:06.000000000 +0000 @@ -58,6 +58,9 @@ #define PRAGMA_STRINGOP_TRUNCATION_IGNORED PRAGMA_DISABLE_GCC_WARNING("-Wstringop-truncation") #endif +#define PRAGMA_NONNULL_IGNORED \ + PRAGMA_DISABLE_GCC_WARNING("-Wnonnull") + #if defined(__clang_major__) && \ (__clang_major__ >= 4 || \ (__clang_major__ >= 3 && __clang_minor__ >= 1)) || \ diff -Nru openjdk-17-17.0.17+10/src/hotspot/share/utilities/exceptions.cpp openjdk-17-17.0.18+8/src/hotspot/share/utilities/exceptions.cpp --- openjdk-17-17.0.17+10/src/hotspot/share/utilities/exceptions.cpp 2025-10-13 07:48:04.000000000 +0000 +++ openjdk-17-17.0.18+8/src/hotspot/share/utilities/exceptions.cpp 2026-01-15 15:23:06.000000000 +0000 @@ -1,5 +1,5 @@ /* - * Copyright (c) 1998, 2021, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 1998, 2024, Oracle and/or its affiliates. All rights reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * * This code is free software; you can redistribute it and/or modify it @@ -440,6 +440,7 @@ // Pass through an Error, including BootstrapMethodError, any other form // of linkage error, or say ThreadDeath/OutOfMemoryError if (ls != NULL) { + ResourceMark rm(THREAD); ls->print_cr("bootstrap method invocation wraps BSME around " INTPTR_FORMAT, p2i((void *)exception)); exception->print_on(ls); } @@ -448,6 +449,7 @@ // Otherwise wrap the exception in a BootstrapMethodError if (ls != NULL) { + ResourceMark rm(THREAD); ls->print_cr("%s throws BSME for " INTPTR_FORMAT, is_indy ? "invokedynamic" : "dynamic constant", p2i((void *)exception)); exception->print_on(ls); } diff -Nru openjdk-17-17.0.17+10/src/java.base/share/classes/java/net/InMemoryCookieStore.java openjdk-17-17.0.18+8/src/java.base/share/classes/java/net/InMemoryCookieStore.java --- openjdk-17-17.0.17+10/src/java.base/share/classes/java/net/InMemoryCookieStore.java 2025-10-13 07:48:04.000000000 +0000 +++ openjdk-17-17.0.18+8/src/java.base/share/classes/java/net/InMemoryCookieStore.java 2026-01-15 15:23:06.000000000 +0000 @@ -1,5 +1,5 @@ /* - * Copyright (c) 2005, 2012, 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 @@ -25,10 +25,6 @@ package java.net; -import java.net.URI; -import java.net.CookieStore; -import java.net.HttpCookie; -import java.net.URISyntaxException; import java.util.List; import java.util.Map; import java.util.ArrayList; @@ -72,6 +68,7 @@ /** * Add one cookie into cookie store. */ + @Override public void add(URI uri, HttpCookie cookie) { // pre-condition : argument can't be null if (cookie == null) { @@ -109,6 +106,7 @@ * 3) not expired. * See RFC 2965 sec. 3.3.4 for more detail. */ + @Override public List get(URI uri) { // argument can't be null if (uri == null) { @@ -127,12 +125,13 @@ lock.unlock(); } - return cookies; + return Collections.unmodifiableList(cookies); } /** * Get all cookies in cookie store, except those have expired */ + @Override public List getCookies() { List rt; @@ -156,6 +155,7 @@ * Get all URIs, which are associated with at least one cookie * of this cookie store. */ + @Override public List getURIs() { List uris = new ArrayList<>(); @@ -165,7 +165,7 @@ while (it.hasNext()) { URI uri = it.next(); List cookies = uriIndex.get(uri); - if (cookies == null || cookies.size() == 0) { + if (cookies == null || cookies.isEmpty()) { // no cookies list or an empty list associated with // this uri entry, delete it it.remove(); @@ -176,13 +176,14 @@ lock.unlock(); } - return uris; + return Collections.unmodifiableList(uris); } /** * Remove a cookie from store */ + @Override public boolean remove(URI uri, HttpCookie ck) { // argument can't be null if (ck == null) { @@ -204,6 +205,7 @@ /** * Remove all cookies in this cookie store. */ + @Override public boolean removeAll() { lock.lock(); try { diff -Nru openjdk-17-17.0.17+10/src/java.base/share/classes/java/text/Collator.java openjdk-17-17.0.18+8/src/java.base/share/classes/java/text/Collator.java --- openjdk-17-17.0.17+10/src/java.base/share/classes/java/text/Collator.java 2025-10-13 07:48:04.000000000 +0000 +++ openjdk-17-17.0.18+8/src/java.base/share/classes/java/text/Collator.java 2026-01-15 15:23:06.000000000 +0000 @@ -115,8 +115,13 @@ *
* Note: {@code CollationKey}s from different * {@code Collator}s can not be compared. See the class description - * for {@link CollationKey} - * for an example using {@code CollationKey}s. + * for {@link CollationKey} for an example using {@code CollationKey}s. + * + * @implNote Significant thread contention may occur during concurrent usage + * of the JDK Reference Implementation's {@link RuleBasedCollator}, which is the + * subtype returned by the default provider of the {@link #getInstance()} factory + * methods. As such, users should consider retrieving a separate instance for + * each thread when used in multithreaded environments. * * @see RuleBasedCollator * @see CollationKey diff -Nru openjdk-17-17.0.17+10/src/java.base/share/classes/java/text/RuleBasedCollator.java openjdk-17-17.0.18+8/src/java.base/share/classes/java/text/RuleBasedCollator.java --- openjdk-17-17.0.17+10/src/java.base/share/classes/java/text/RuleBasedCollator.java 2025-10-13 07:48:04.000000000 +0000 +++ openjdk-17-17.0.18+8/src/java.base/share/classes/java/text/RuleBasedCollator.java 2026-01-15 15:23:06.000000000 +0000 @@ -1,5 +1,5 @@ /* - * Copyright (c) 1997, 2020, 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 @@ -38,10 +38,6 @@ package java.text; -import java.text.Normalizer; -import java.util.Vector; -import java.util.Locale; - /** * The {@code RuleBasedCollator} class is a concrete subclass of * {@code Collator} that provides a simple, data-driven, table @@ -239,6 +235,11 @@ * * * + * @implNote For this implementation, concurrent usage of this class may + * lead to significant thread contention since {@code synchronized} is employed + * to ensure thread-safety. As such, users of this class should consider creating + * a separate instance for each thread when used in multithreaded environments. + * * @see Collator * @see CollationElementIterator * @author Helena Shih, Laura Werner, Richard Gillam diff -Nru openjdk-17-17.0.17+10/src/java.base/share/classes/java/util/SimpleTimeZone.java openjdk-17-17.0.18+8/src/java.base/share/classes/java/util/SimpleTimeZone.java --- openjdk-17-17.0.17+10/src/java.base/share/classes/java/util/SimpleTimeZone.java 2025-10-13 07:48:04.000000000 +0000 +++ openjdk-17-17.0.18+8/src/java.base/share/classes/java/util/SimpleTimeZone.java 2026-01-15 15:23:06.000000000 +0000 @@ -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 @@ -112,15 +112,15 @@ *

  *      // Base GMT offset: -8:00
  *      // DST starts:      at 2:00am in standard time
- *      //                  on the first Sunday in April
+ *      //                  on the second Sunday in March
  *      // DST ends:        at 2:00am in daylight time
- *      //                  on the last Sunday in October
+ *      //                  on the first Sunday in November
  *      // Save:            1 hour
  *      SimpleTimeZone(-28800000,
  *                     "America/Los_Angeles",
- *                     Calendar.APRIL, 1, -Calendar.SUNDAY,
+ *                     Calendar.MARCH, 8, -Calendar.SUNDAY,
  *                     7200000,
- *                     Calendar.OCTOBER, -1, Calendar.SUNDAY,
+ *                     Calendar.NOVEMBER, 1, -Calendar.SUNDAY,
  *                     7200000,
  *                     3600000)
  *
@@ -857,13 +857,24 @@
     }
 
     /**
-     * Generates the hash code for the SimpleDateFormat object.
+     * Generates the hash code for the SimpleTimeZone object.
      * @return the hash code for this object
      */
     public int hashCode()
     {
-        return startMonth ^ startDay ^ startDayOfWeek ^ startTime ^
-            endMonth ^ endDay ^ endDayOfWeek ^ endTime ^ rawOffset;
+        int hash = 31 * getID().hashCode() + rawOffset;
+        hash = 31 * hash + Boolean.hashCode(useDaylight);
+        if (useDaylight) {
+            hash = 31 * hash + startMonth;
+            hash = 31 * hash + startDay;
+            hash = 31 * hash + startDayOfWeek;
+            hash = 31 * hash + startTime;
+            hash = 31 * hash + endMonth;
+            hash = 31 * hash + endDay;
+            hash = 31 * hash + endDayOfWeek;
+            hash = 31 * hash + endTime;
+        }
+        return hash;
     }
 
     /**
diff -Nru openjdk-17-17.0.17+10/src/java.base/share/classes/java/util/concurrent/CopyOnWriteArraySet.java openjdk-17-17.0.18+8/src/java.base/share/classes/java/util/concurrent/CopyOnWriteArraySet.java
--- openjdk-17-17.0.17+10/src/java.base/share/classes/java/util/concurrent/CopyOnWriteArraySet.java	2025-10-13 07:48:04.000000000 +0000
+++ openjdk-17-17.0.18+8/src/java.base/share/classes/java/util/concurrent/CopyOnWriteArraySet.java	2026-01-15 15:23:06.000000000 +0000
@@ -35,6 +35,13 @@
 
 package java.util.concurrent;
 
+import jdk.internal.misc.Unsafe;
+
+import java.io.IOException;
+import java.io.ObjectInputStream;
+import java.io.ObjectStreamException;
+import java.io.Serial;
+import java.io.StreamCorruptedException;
 import java.util.AbstractSet;
 import java.util.Collection;
 import java.util.Iterator;
@@ -444,4 +451,38 @@
         return Spliterators.spliterator
             (al.getArray(), Spliterator.IMMUTABLE | Spliterator.DISTINCT);
     }
+
+    /**
+     * De-serialization without data not supported for this class.
+     */
+    @Serial
+    private void readObjectNoData() throws ObjectStreamException {
+        throw new StreamCorruptedException("Deserialized CopyOnWriteArraySet requires data");
+    }
+
+    /**
+     * Reconstitutes the {@code CopyOnWriteArraySet} instance from a stream
+     * (that is, deserializes it).
+     * @throws StreamCorruptedException if the object read from the stream is invalid.
+     */
+    @Serial
+    private void readObject(ObjectInputStream in) throws IOException, ClassNotFoundException {
+        CopyOnWriteArrayList newAl; // Set during the duplicate check
+
+        @SuppressWarnings("unchecked")
+        CopyOnWriteArrayList inAl = (CopyOnWriteArrayList) in.readFields().get("al", null);
+
+        if (inAl == null
+                || inAl.getClass() != CopyOnWriteArrayList.class
+                || (newAl = new CopyOnWriteArrayList<>()).addAllAbsent(inAl) != inAl.size()) {
+            throw new StreamCorruptedException("Content is invalid");
+        }
+
+        final Unsafe U = Unsafe.getUnsafe();
+        U.putReference(
+                this,
+                U.objectFieldOffset(CopyOnWriteArraySet.class, "al"),
+                newAl
+        );
+    }
 }
diff -Nru openjdk-17-17.0.17+10/src/java.base/share/classes/java/util/regex/Pattern.java openjdk-17-17.0.18+8/src/java.base/share/classes/java/util/regex/Pattern.java
--- openjdk-17-17.0.17+10/src/java.base/share/classes/java/util/regex/Pattern.java	2025-10-13 07:48:04.000000000 +0000
+++ openjdk-17-17.0.18+8/src/java.base/share/classes/java/util/regex/Pattern.java	2026-01-15 15:23:06.000000000 +0000
@@ -5364,10 +5364,10 @@
      * they are ignored for purposes of finding word boundaries.
      */
     static final class Bound extends Node {
-        static int LEFT = 0x1;
-        static int RIGHT= 0x2;
-        static int BOTH = 0x3;
-        static int NONE = 0x4;
+        static final int LEFT = 0x1;
+        static final int RIGHT= 0x2;
+        static final int BOTH = 0x3;
+        static final int NONE = 0x4;
         int type;
         boolean useUWORD;
         Bound(int n, boolean useUWORD) {
diff -Nru openjdk-17-17.0.17+10/src/java.base/share/classes/jdk/internal/module/ModuleInfoWriter.java openjdk-17-17.0.18+8/src/java.base/share/classes/jdk/internal/module/ModuleInfoWriter.java
--- openjdk-17-17.0.17+10/src/java.base/share/classes/jdk/internal/module/ModuleInfoWriter.java	2025-10-13 07:48:04.000000000 +0000
+++ openjdk-17-17.0.18+8/src/java.base/share/classes/jdk/internal/module/ModuleInfoWriter.java	1970-01-01 00:00:00.000000000 +0000
@@ -1,231 +0,0 @@
-/*
- * Copyright (c) 2015, 2020, Oracle and/or its affiliates. All rights reserved.
- * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
- *
- * This code is free software; you can redistribute it and/or modify it
- * under the terms of the GNU General Public License version 2 only, as
- * published by the Free Software Foundation.  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.module;
-
-import java.io.IOException;
-import java.io.OutputStream;
-import java.lang.module.ModuleDescriptor;
-import java.nio.ByteBuffer;
-import java.util.Map;
-import java.util.stream.Stream;
-
-import jdk.internal.org.objectweb.asm.ClassWriter;
-import jdk.internal.org.objectweb.asm.ModuleVisitor;
-import jdk.internal.org.objectweb.asm.Opcodes;
-import jdk.internal.org.objectweb.asm.commons.ModuleResolutionAttribute;
-import jdk.internal.org.objectweb.asm.commons.ModuleTargetAttribute;
-import static jdk.internal.org.objectweb.asm.Opcodes.*;
-
-/**
- * Utility class to write a ModuleDescriptor as a module-info.class.
- */
-
-public final class ModuleInfoWriter {
-
-    private static final Map
-        MODULE_MODS_TO_FLAGS = Map.of(
-            ModuleDescriptor.Modifier.OPEN, ACC_OPEN,
-            ModuleDescriptor.Modifier.SYNTHETIC, ACC_SYNTHETIC,
-            ModuleDescriptor.Modifier.MANDATED, ACC_MANDATED
-        );
-
-    private static final Map
-        REQUIRES_MODS_TO_FLAGS = Map.of(
-            ModuleDescriptor.Requires.Modifier.TRANSITIVE, ACC_TRANSITIVE,
-            ModuleDescriptor.Requires.Modifier.STATIC, ACC_STATIC_PHASE,
-            ModuleDescriptor.Requires.Modifier.SYNTHETIC, ACC_SYNTHETIC,
-            ModuleDescriptor.Requires.Modifier.MANDATED, ACC_MANDATED
-        );
-
-    private static final Map
-        EXPORTS_MODS_TO_FLAGS = Map.of(
-            ModuleDescriptor.Exports.Modifier.SYNTHETIC, ACC_SYNTHETIC,
-            ModuleDescriptor.Exports.Modifier.MANDATED, ACC_MANDATED
-        );
-
-    private static final Map
-        OPENS_MODS_TO_FLAGS = Map.of(
-            ModuleDescriptor.Opens.Modifier.SYNTHETIC, ACC_SYNTHETIC,
-            ModuleDescriptor.Opens.Modifier.MANDATED, ACC_MANDATED
-        );
-
-    private static final String[] EMPTY_STRING_ARRAY = new String[0];
-
-    private ModuleInfoWriter() { }
-
-    /**
-     * Writes the given module descriptor to a module-info.class file,
-     * returning it in a byte array.
-     */
-    private static byte[] toModuleInfo(ModuleDescriptor md,
-                                       ModuleResolution mres,
-                                       ModuleTarget target) {
-        ClassWriter cw = new ClassWriter(0);
-        cw.visit(Opcodes.V10, ACC_MODULE, "module-info", null, null, null);
-
-        int moduleFlags = md.modifiers().stream()
-                .map(MODULE_MODS_TO_FLAGS::get)
-                .reduce(0, (x, y) -> (x | y));
-        String vs = md.rawVersion().orElse(null);
-        ModuleVisitor mv = cw.visitModule(md.name(), moduleFlags, vs);
-
-        // requires
-        for (ModuleDescriptor.Requires r : md.requires()) {
-            int flags = r.modifiers().stream()
-                    .map(REQUIRES_MODS_TO_FLAGS::get)
-                    .reduce(0, (x, y) -> (x | y));
-            vs = r.rawCompiledVersion().orElse(null);
-            mv.visitRequire(r.name(), flags, vs);
-        }
-
-        // exports
-        for (ModuleDescriptor.Exports e : md.exports()) {
-            int flags = e.modifiers().stream()
-                    .map(EXPORTS_MODS_TO_FLAGS::get)
-                    .reduce(0, (x, y) -> (x | y));
-            String[] targets = e.targets().toArray(EMPTY_STRING_ARRAY);
-            mv.visitExport(e.source().replace('.', '/'), flags, targets);
-        }
-
-        // opens
-        for (ModuleDescriptor.Opens opens : md.opens()) {
-            int flags = opens.modifiers().stream()
-                    .map(OPENS_MODS_TO_FLAGS::get)
-                    .reduce(0, (x, y) -> (x | y));
-            String[] targets = opens.targets().toArray(EMPTY_STRING_ARRAY);
-            mv.visitOpen(opens.source().replace('.', '/'), flags, targets);
-        }
-
-        // uses
-        md.uses().stream().map(sn -> sn.replace('.', '/')).forEach(mv::visitUse);
-
-        // provides
-        for (ModuleDescriptor.Provides p : md.provides()) {
-            mv.visitProvide(p.service().replace('.', '/'),
-                            p.providers()
-                                .stream()
-                                .map(pn -> pn.replace('.', '/'))
-                                .toArray(String[]::new));
-        }
-
-        // add the ModulePackages attribute when there are packages that aren't
-        // exported or open
-        Stream exported = md.exports().stream()
-                .map(ModuleDescriptor.Exports::source);
-        Stream open = md.opens().stream()
-                .map(ModuleDescriptor.Opens::source);
-        long exportedOrOpen = Stream.concat(exported, open).distinct().count();
-        if (md.packages().size() > exportedOrOpen) {
-            md.packages().stream()
-                    .map(pn -> pn.replace('.', '/'))
-                    .forEach(mv::visitPackage);
-        }
-
-        // ModuleMainClass attribute
-        md.mainClass()
-            .map(mc -> mc.replace('.', '/'))
-            .ifPresent(mv::visitMainClass);
-
-        mv.visitEnd();
-
-        // write ModuleResolution attribute if specified
-        if (mres != null) {
-            cw.visitAttribute(new ModuleResolutionAttribute(mres.value()));
-        }
-
-        // write ModuleTarget attribute if there is a target platform
-        if (target != null && target.targetPlatform().length() > 0) {
-            cw.visitAttribute(new ModuleTargetAttribute(target.targetPlatform()));
-        }
-
-        cw.visitEnd();
-        return cw.toByteArray();
-    }
-
-    /**
-     * Writes a module descriptor to the given output stream as a
-     * module-info.class.
-     */
-    public static void write(ModuleDescriptor descriptor,
-                             ModuleResolution mres,
-                             ModuleTarget target,
-                             OutputStream out)
-        throws IOException
-    {
-        byte[] bytes = toModuleInfo(descriptor, mres, target);
-        out.write(bytes);
-    }
-
-    /**
-     * Writes a module descriptor to the given output stream as a
-     * module-info.class.
-     */
-    public static void write(ModuleDescriptor descriptor,
-                             ModuleResolution mres,
-                             OutputStream out)
-        throws IOException
-    {
-        write(descriptor, mres, null, out);
-    }
-
-    /**
-     * Writes a module descriptor to the given output stream as a
-     * module-info.class.
-     */
-    public static void write(ModuleDescriptor descriptor,
-                             ModuleTarget target,
-                             OutputStream out)
-        throws IOException
-    {
-        write(descriptor, null, target, out);
-    }
-
-    /**
-     * Writes a module descriptor to the given output stream as a
-     * module-info.class.
-     */
-    public static void write(ModuleDescriptor descriptor, OutputStream out)
-        throws IOException
-    {
-        write(descriptor, null, null, out);
-    }
-
-    /**
-     * Returns a byte array containing the given module descriptor in
-     * module-info.class format.
-     */
-    public static byte[] toBytes(ModuleDescriptor descriptor) {
-        return toModuleInfo(descriptor, null, null);
-    }
-
-    /**
-     * Returns a {@code ByteBuffer} containing the given module descriptor
-     * in module-info.class format.
-     */
-    public static ByteBuffer toByteBuffer(ModuleDescriptor descriptor) {
-        byte[] bytes = toModuleInfo(descriptor, null, null);
-        return ByteBuffer.wrap(bytes);
-    }
-}
diff -Nru openjdk-17-17.0.17+10/src/java.base/share/classes/sun/nio/ch/Net.java openjdk-17-17.0.18+8/src/java.base/share/classes/sun/nio/ch/Net.java
--- openjdk-17-17.0.17+10/src/java.base/share/classes/sun/nio/ch/Net.java	2025-10-13 07:48:04.000000000 +0000
+++ openjdk-17-17.0.18+8/src/java.base/share/classes/sun/nio/ch/Net.java	2026-01-15 15:23:06.000000000 +0000
@@ -70,6 +70,9 @@
     // set to true if the fast tcp loopback should be enabled on Windows
     private static final boolean fastLoopback;
 
+    // set to true if shut down before close should be enabled on Windows
+    private static final boolean SHUTDOWN_WRITE_BEFORE_CLOSE;
+
     // -- Miscellaneous utilities --
 
     private static volatile boolean checkedIPv6;
@@ -107,6 +110,13 @@
     }
 
     /**
+     * Tells whether a TCP connection should be shutdown for writing before closing.
+     */
+    static boolean shouldShutdownWriteBeforeClose() {
+        return SHUTDOWN_WRITE_BEFORE_CLOSE;
+    }
+
+    /**
      * Tells whether both IPV6_XXX and IP_XXX socket options should be set on
      * IPv6 sockets. On some kernels, both IPV6_XXX and IP_XXX socket options
      * need to be set so that the settings are effective for IPv4 multicast
@@ -506,6 +516,8 @@
      */
     private static native int isExclusiveBindAvailable();
 
+    private static native boolean shouldShutdownWriteBeforeClose0();
+
     private static native boolean shouldSetBothIPv4AndIPv6Options0();
 
     private static native boolean canIPv6SocketJoinIPv4Group0();
@@ -832,5 +844,6 @@
         }
 
         fastLoopback = isFastTcpLoopbackRequested();
+        SHUTDOWN_WRITE_BEFORE_CLOSE = shouldShutdownWriteBeforeClose0();
     }
 }
diff -Nru openjdk-17-17.0.17+10/src/java.base/share/classes/sun/nio/ch/SocketChannelImpl.java openjdk-17-17.0.18+8/src/java.base/share/classes/sun/nio/ch/SocketChannelImpl.java
--- openjdk-17-17.0.17+10/src/java.base/share/classes/sun/nio/ch/SocketChannelImpl.java	2025-10-13 07:48:04.000000000 +0000
+++ openjdk-17-17.0.18+8/src/java.base/share/classes/sun/nio/ch/SocketChannelImpl.java	2026-01-15 15:23:06.000000000 +0000
@@ -743,7 +743,7 @@
     /**
      * Marks the beginning of a connect operation that might block.
      * @param blocking true if configured blocking
-     * @param isa the remote address
+     * @param sa the remote socket address
      * @throws ClosedChannelException if the channel is closed
      * @throws AlreadyConnectedException if already connected
      * @throws ConnectionPendingException is a connection is pending
@@ -970,8 +970,8 @@
     }
 
     /**
-     * Closes the socket if there are no I/O operations in progress and the
-     * channel is not registered with a Selector.
+     * Closes the socket if there are no I/O operations in progress (or no I/O
+     * operations tracked), and the channel is not registered with a Selector.
      */
     private boolean tryClose() throws IOException {
         assert Thread.holdsLock(stateLock) && state == ST_CLOSING;
@@ -996,11 +996,16 @@
     }
 
     /**
-     * Closes this channel when configured in blocking mode.
+     * Closes this channel when configured in blocking mode. If there are no I/O
+     * operations in progress (or tracked), then the channel's socket is closed. If
+     * there are I/O operations in progress then the behavior is platform specific.
      *
-     * If there is an I/O operation in progress then the socket is pre-closed
-     * and the I/O threads signalled, in which case the final close is deferred
-     * until all I/O operations complete.
+     * On Unix systems, the channel's socket is pre-closed. The socket is dup'ed
+     * and the threads signalled. The final close is deferred until all I/O
+     * operations complete.
+     *
+     * On Windows, the channel's socket is pre-closed. The channel's
+     * socket is closed.
      *
      * Note that a channel configured blocking may be registered with a Selector
      * This arises when a key is canceled and the channel configured to blocking
@@ -1009,7 +1014,19 @@
     private void implCloseBlockingMode() throws IOException {
         synchronized (stateLock) {
             assert state < ST_CLOSING;
+            boolean connected = (state == ST_CONNECTED);
             state = ST_CLOSING;
+
+            if (connected && Net.shouldShutdownWriteBeforeClose()) {
+                // shutdown output when linger interval not set to 0
+                try {
+                    var SO_LINGER = StandardSocketOptions.SO_LINGER;
+                    if ((int) Net.getSocketOption(fd, SO_LINGER) != 0) {
+                        Net.shutdown(fd, Net.SHUT_WR);
+                    }
+                } catch (IOException ignore) { }
+            }
+
             if (!tryClose()) {
                 long reader = readerThread;
                 long writer = writerThread;
diff -Nru openjdk-17-17.0.17+10/src/java.base/share/classes/sun/nio/cs/StreamDecoder.java openjdk-17-17.0.18+8/src/java.base/share/classes/sun/nio/cs/StreamDecoder.java
--- openjdk-17-17.0.17+10/src/java.base/share/classes/sun/nio/cs/StreamDecoder.java	2025-10-13 07:48:04.000000000 +0000
+++ openjdk-17-17.0.18+8/src/java.base/share/classes/sun/nio/cs/StreamDecoder.java	2026-01-15 15:23:06.000000000 +0000
@@ -332,7 +332,6 @@
                     eof = true;
                     if ((cb.position() == 0) && (!bb.hasRemaining()))
                         break;
-                    decoder.reset();
                 }
                 continue;
             }
diff -Nru openjdk-17-17.0.17+10/src/java.base/share/classes/sun/security/provider/certpath/URICertStore.java openjdk-17-17.0.18+8/src/java.base/share/classes/sun/security/provider/certpath/URICertStore.java
--- openjdk-17-17.0.17+10/src/java.base/share/classes/sun/security/provider/certpath/URICertStore.java	2025-10-13 07:48:04.000000000 +0000
+++ openjdk-17-17.0.18+8/src/java.base/share/classes/sun/security/provider/certpath/URICertStore.java	2026-01-15 15:23:06.000000000 +0000
@@ -1,5 +1,5 @@
 /*
- * Copyright (c) 2006, 2023, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 2006, 2025, Oracle and/or its affiliates. All rights reserved.
  * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
  *
  * This code is free software; you can redistribute it and/or modify it
@@ -29,6 +29,7 @@
 import java.io.IOException;
 import java.net.HttpURLConnection;
 import java.net.URI;
+import java.net.URISyntaxException;
 import java.net.URLConnection;
 import java.security.InvalidAlgorithmParameterException;
 import java.security.NoSuchAlgorithmException;
@@ -48,8 +49,11 @@
 import java.util.ArrayList;
 import java.util.Collection;
 import java.util.Collections;
+import java.util.LinkedHashSet;
 import java.util.List;
 import java.util.Locale;
+import java.util.Optional;
+import java.util.Set;
 
 import sun.security.action.GetPropertyAction;
 import sun.security.x509.AccessDescription;
@@ -57,6 +61,9 @@
 import sun.security.x509.URIName;
 import sun.security.util.Cache;
 import sun.security.util.Debug;
+import sun.security.util.SecurityProperties;
+
+import javax.security.auth.x500.X500Principal;
 
 /**
  * A CertStore that retrieves Certificates or
@@ -183,6 +190,165 @@
     }
 
     /**
+     * Enumeration for the allowed schemes we support when following a
+     * URI from an authorityInfoAccess extension on a certificate.
+     */
+    private enum AllowedScheme {
+        HTTP(HttpFtpRuleMatcher.HTTP),
+        HTTPS(HttpFtpRuleMatcher.HTTPS),
+        LDAP(LdapRuleMatcher.LDAP),
+        LDAPS(LdapRuleMatcher.LDAPS),
+        FTP(HttpFtpRuleMatcher.FTP);
+
+        final URIRuleMatcher ruleMatcher;
+
+        AllowedScheme(URIRuleMatcher matcher) {
+            ruleMatcher = matcher;
+        }
+
+        /**
+         * Return an {@code AllowedScheme} based on a case-insensitive match
+         * @param name the scheme name to be matched
+         * @return the {@code AllowedScheme} that corresponds to the
+         *      {@code name} provided, or null if there is no match.
+         */
+        static AllowedScheme nameOf(String name) {
+            if (name == null) {
+                return null;
+            }
+
+            try {
+                return AllowedScheme.valueOf(name.toUpperCase(Locale.ROOT));
+            } catch (IllegalArgumentException iaEx) {
+                return null;
+            }
+        }
+    }
+
+    private static Set CA_ISS_URI_FILTERS = null;
+    private static final boolean CA_ISS_ALLOW_ANY;
+
+    static {
+        boolean allowAny = false;
+        try {
+            if (Builder.USE_AIA) {
+                CA_ISS_URI_FILTERS = new LinkedHashSet<>();
+                String aiaPropVal = SecurityProperties.privilegedGetOverridable(
+                        "com.sun.security.allowedAIALocations");
+                aiaPropVal = (aiaPropVal != null)?aiaPropVal.trim():"";
+                if (aiaPropVal.equalsIgnoreCase("any")) {
+                    allowAny = true;
+                    if (debug != null)     {
+                        debug.println("allowedAIALocations: Warning: " +
+                                "Allow-All URI filtering enabled!");
+                    }
+                } else {
+                    // Load all the valid rules from the Security property
+                    if (!aiaPropVal.isEmpty()) {
+                        String[] aiaUriStrs = aiaPropVal.trim().split("\\s+");
+                        addCaIssUriFilters(aiaUriStrs);
+                    }
+
+                    if (CA_ISS_URI_FILTERS.isEmpty()) {
+                        if (debug != null) {
+                            debug.println("allowedAIALocations: Warning: " +
+                                    "No valid filters found. Deny-all URI " +
+                                    "filtering is active.");
+                        }
+                    }
+                }
+            }
+        } finally {
+            CA_ISS_ALLOW_ANY = allowAny;
+        }
+    }
+
+    /**
+     * Populate the filter collection from the list of AIA CA issuer URIs
+     * found in the {@code com.sun.security.allowedAIALocations} security
+     * or system property.
+     *
+     * @param aiaUriStrs array containing String URI filters
+     */
+    private static void addCaIssUriFilters(String[] aiaUriStrs) {
+        for (String aiaStr : aiaUriStrs) {
+            if (aiaStr != null && !aiaStr.isEmpty()) {
+                try {
+                    AllowedScheme scheme;
+                    URI aiaUri = new URI(aiaStr).normalize();
+                    // It must be absolute and non-opaque
+                    if (!aiaUri.isAbsolute() || aiaUri.isOpaque()) {
+                        if (debug != null) {
+                            debug.println("allowedAIALocations: Skipping " +
+                                    "non-absolute or opaque URI " + aiaUri);
+                        }
+                    } else if (aiaUri.getHost() == null) {
+                        // We do not allow rules with URIs that omit a hostname
+                        // or address.
+                        if (debug != null) {
+                            debug.println("allowedAIALocations: Skipping " +
+                                    "URI rule with no hostname or address: " +
+                                    aiaUri);
+                        }
+                    } else if ((scheme = AllowedScheme.nameOf(
+                            aiaUri.getScheme())) != null) {
+                        // When it is an LDAP type, we can check the path
+                        // portion (the DN) for proper structure and reject
+                        // the rule early if it isn't correct.
+                        if (scheme == AllowedScheme.LDAP ||
+                                scheme == AllowedScheme.LDAPS) {
+                            try {
+                                new X500Principal(aiaUri.getPath().
+                                        replaceFirst("^/+", ""));
+                            } catch (IllegalArgumentException iae) {
+                                if (debug != null) {
+                                    debug.println("allowedAIALocations: " +
+                                            "Skipping LDAP rule: " + iae);
+                                }
+                                continue;
+                            }
+                        }
+
+                        // When a URI has a non-null query or fragment
+                        // warn the user upon adding the rule that those
+                        // components will be ignored
+                        if (aiaUri.getQuery() != null) {
+                            if (debug != null) {
+                                debug.println("allowedAIALocations: " +
+                                        "Rule will ignore non-null query");
+                            }
+                        }
+                        if (aiaUri.getFragment() != null) {
+                            if (debug != null) {
+                                debug.println("allowedAIALocations: " +
+                                        "Rule will ignore non-null fragment");
+                            }
+                        }
+
+                        CA_ISS_URI_FILTERS.add(aiaUri);
+                        if (debug != null) {
+                            debug.println("allowedAIALocations: Added " +
+                                    aiaUri + " to URI filters");
+                        }
+                    } else {
+                        if (debug != null) {
+                            debug.println("allowedAIALocations: Disallowed " +
+                                    "filter URI scheme: " +
+                                    aiaUri.getScheme());
+                        }
+                    }
+                } catch (URISyntaxException urise) {
+                    if (debug != null) {
+                        debug.println("allowedAIALocations: Skipping " +
+                                "filter URI entry " + aiaStr +
+                                ": parse failure at index " + urise.getIndex());
+                    }
+                }
+            }
+        }
+    }
+
+    /**
      * Creates a URICertStore.
      *
      * @param params specifying the URI
@@ -244,6 +410,39 @@
             return null;
         }
         URI uri = ((URIName) gn).getURI();
+
+        // Before performing any instantiation make sure that
+        // the URI passes any filtering rules.  This processing should
+        // only occur if the com.sun.security.enableAIAcaIssuers is true
+        // and the "any" rule has not been specified.
+        if (Builder.USE_AIA && !CA_ISS_ALLOW_ANY) {
+            URI normAIAUri = uri.normalize();
+            AllowedScheme scheme = AllowedScheme.nameOf(normAIAUri.getScheme());
+
+            if (scheme == null) {
+                if (debug != null) {
+                    debug.println("allowedAIALocations: No matching ruleset " +
+                            "for scheme " + normAIAUri.getScheme());
+                }
+                return null;
+            }
+
+            // Go through each of the filter rules and see if any will
+            // make a positive match against the caIssuer URI.  If nothing
+            // matches then we won't instantiate a URICertStore.
+            if (CA_ISS_URI_FILTERS.stream().noneMatch(rule ->
+                    scheme.ruleMatcher.matchRule(rule, normAIAUri))) {
+                if (debug != null) {
+                    debug.println("allowedAIALocations: Warning - " +
+                        "The caIssuer URI " + normAIAUri +
+                        " in the AuthorityInfoAccess extension is denied " +
+                        "access. Use the com.sun.security.allowedAIALocations" +
+                        " security/system property to allow access.");
+                }
+                return null;
+            }
+        }
+
         try {
             return URICertStore.getInstance(new URICertStoreParameters(uri));
         } catch (Exception ex) {
@@ -270,7 +469,7 @@
     @Override
     @SuppressWarnings("unchecked")
     public synchronized Collection engineGetCertificates
-        (CertSelector selector) throws CertStoreException {
+            (CertSelector selector) throws CertStoreException {
 
         if (ldap) {
             // caching mechanism, see the class description for more info.
@@ -464,4 +663,159 @@
             super(spi, p, type, params);
         }
     }
+
+    /**
+     * URIRuleMatcher - abstract base class for the rule sets used for
+     * various URI schemes.
+     */
+    static abstract class URIRuleMatcher {
+        protected final int wellKnownPort;
+
+        protected URIRuleMatcher(int port) {
+            wellKnownPort = port;
+        }
+
+        /**
+         * Attempt to match the scheme, host and port between a filter
+         * rule URI and a URI coming from an AIA extension.
+         *
+         * @param filterRule the filter rule to match against
+         * @param caIssuer the AIA URI being compared
+         * @return true if the scheme, host and port numbers match, false if
+         * any of the components do not match. If a port number is omitted in
+         * either the filter rule or AIA URI, the well-known port for that
+         * scheme is used in the comparison.
+         */
+        boolean schemeHostPortCheck(URI filterRule, URI caIssuer) {
+            if (!filterRule.getScheme().equalsIgnoreCase(
+                    caIssuer.getScheme())) {
+                return false;
+            } else if (!filterRule.getHost().equalsIgnoreCase(
+                    caIssuer.getHost())) {
+                return false;
+            } else {
+                try {
+                    // Check for port matching, taking into consideration
+                    // default ports
+                    int fPort = (filterRule.getPort() == -1) ? wellKnownPort :
+                            filterRule.getPort();
+                    int caiPort = (caIssuer.getPort() == -1) ? wellKnownPort :
+                            caIssuer.getPort();
+                    if (fPort != caiPort) {
+                        return false;
+                    }
+                } catch (IllegalArgumentException iae) {
+                    return false;
+                }
+            }
+            return true;
+        }
+
+        /**
+         * Attempt to match an AIA URI against a specific filter rule.  The
+         * specific rules to apply are implementation dependent.
+         *
+         * @param filterRule the filter rule to match against
+         * @param caIssuer the AIA URI being compared
+         * @return true if all matching rules pass, false if any fail.
+         */
+        abstract boolean matchRule(URI filterRule, URI caIssuer);
+    }
+
+    static class HttpFtpRuleMatcher extends URIRuleMatcher {
+        static final HttpFtpRuleMatcher HTTP = new HttpFtpRuleMatcher(80);
+        static final HttpFtpRuleMatcher HTTPS = new HttpFtpRuleMatcher(443);
+        static final HttpFtpRuleMatcher FTP = new HttpFtpRuleMatcher(21);
+
+        private HttpFtpRuleMatcher(int port) {
+            super(port);
+        }
+
+        @Override
+        boolean matchRule(URI filterRule, URI caIssuer) {
+            // Check for scheme/host/port matching
+            if (!schemeHostPortCheck(filterRule, caIssuer)) {
+                return false;
+            }
+
+            // Check the path component to make sure the filter is at
+            // least a root of the AIA caIssuer URI's path.  It must be
+            // a case-sensitive match for all platforms.
+            if (!isRootOf(filterRule, caIssuer)) {
+                if (debug != null) {
+                    debug.println("allowedAIALocations: Match failed: " +
+                            "AIA URI is not within the rule's path hierarchy.");
+                }
+                return false;
+            }
+            return true;
+        }
+
+        /**
+         * Performs a hierarchical containment check, ensuring that the
+         * base URI's path is a root component of the candidate path.  The
+         * path comparison is case-sensitive.  If the base path ends in a
+         * slash (/) then all candidate paths that begin with the base
+         * path are allowed.  If it does not end in a slash, then it is
+         * assumed that the leaf node in the base path is a file component
+         * and both paths must match exactly.
+         *
+         * @param base the URI that contains the root path
+         * @param candidate the URI that contains the path being evaluated
+         * @return true if {@code candidate} is a child path of {@code base},
+         *         false otherwise.
+         */
+        private static boolean isRootOf(URI base, URI candidate) {
+            // Note: The URIs have already been normalized at this point and
+            // HTTP URIs cannot have null paths.  If it's an empty path
+            // then consider the path to be "/".
+            String basePath = Optional.of(base.getPath()).
+                    filter(p -> !p.isEmpty()).orElse("/");
+            String candPath = Optional.of(candidate.getPath()).
+                    filter(p -> !p.isEmpty()).orElse("/");
+            return (basePath.endsWith("/")) ? candPath.startsWith(basePath) :
+                    candPath.equals(basePath);
+        }
+    }
+
+    static class LdapRuleMatcher extends URIRuleMatcher {
+        static final LdapRuleMatcher LDAP = new LdapRuleMatcher(389);
+        static final LdapRuleMatcher LDAPS = new LdapRuleMatcher(636);
+
+        private LdapRuleMatcher(int port) {
+            super(port);
+        }
+
+        @Override
+        boolean matchRule(URI filterRule, URI caIssuer) {
+            // Check for scheme/host/port matching
+            if (!schemeHostPortCheck(filterRule, caIssuer)) {
+                return false;
+            }
+
+            // Obtain the base DN component and compare
+            try {
+                X500Principal filterBaseDn = new X500Principal(
+                        filterRule.getPath().replaceFirst("^/+", ""));
+                X500Principal caIssBaseDn = new X500Principal(
+                        caIssuer.getPath().replaceFirst("^/+", ""));
+                if (!filterBaseDn.equals(caIssBaseDn)) {
+                    if (debug != null) {
+                        debug.println("allowedAIALocations: Match failed: " +
+                                "Base DN mismatch (" + filterBaseDn + " vs " +
+                                caIssBaseDn + ")");
+                    }
+                    return false;
+                }
+            } catch (IllegalArgumentException iae) {
+                if (debug != null) {
+                    debug.println("allowedAIALocations: Match failed on DN: " +
+                            iae);
+                }
+                return false;
+            }
+
+            return true;
+        }
+    }
 }
diff -Nru openjdk-17-17.0.17+10/src/java.base/share/classes/sun/security/ssl/DTLSInputRecord.java openjdk-17-17.0.18+8/src/java.base/share/classes/sun/security/ssl/DTLSInputRecord.java
--- openjdk-17-17.0.17+10/src/java.base/share/classes/sun/security/ssl/DTLSInputRecord.java	2025-10-13 07:48:04.000000000 +0000
+++ openjdk-17-17.0.18+8/src/java.base/share/classes/sun/security/ssl/DTLSInputRecord.java	2026-01-15 15:23:06.000000000 +0000
@@ -1,5 +1,5 @@
 /*
- * Copyright (c) 2015, 2024, 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
@@ -809,8 +809,11 @@
 
             // buffer this fragment
             if (hsf.handshakeType == SSLHandshake.FINISHED.id) {
-                // Need no status update.
-                bufferedFragments.add(hsf);
+                // Make sure it's not a retransmitted message
+                if (hsf.recordEpoch > handshakeEpoch) {
+                    bufferedFragments.add(hsf);
+                    flightIsReady = holes.isEmpty();
+                }
             } else {
                 bufferFragment(hsf);
             }
diff -Nru openjdk-17-17.0.17+10/src/java.base/share/classes/sun/security/ssl/SignatureScheme.java openjdk-17-17.0.18+8/src/java.base/share/classes/sun/security/ssl/SignatureScheme.java
--- openjdk-17-17.0.17+10/src/java.base/share/classes/sun/security/ssl/SignatureScheme.java	2025-10-13 07:48:04.000000000 +0000
+++ openjdk-17-17.0.18+8/src/java.base/share/classes/sun/security/ssl/SignatureScheme.java	2026-01-15 15:23:06.000000000 +0000
@@ -133,8 +133,9 @@
                                     "DSA",
                                     ProtocolVersion.PROTOCOLS_TO_12),
     ECDSA_SHA1              (0x0203, "ecdsa_sha1", "SHA1withECDSA",
-                                    "EC",
-                                    ProtocolVersion.PROTOCOLS_TO_13),
+                                    "EC", null, null, -1,
+                                    ProtocolVersion.PROTOCOLS_TO_13,
+                                    ProtocolVersion.PROTOCOLS_TO_12),
     RSA_PKCS1_SHA1          (0x0201, "rsa_pkcs1_sha1", "SHA1withRSA",
                                     "RSA", null, null, 511,
                                     ProtocolVersion.PROTOCOLS_TO_13,
diff -Nru openjdk-17-17.0.17+10/src/java.base/share/classes/sun/util/calendar/ZoneInfo.java openjdk-17-17.0.18+8/src/java.base/share/classes/sun/util/calendar/ZoneInfo.java
--- openjdk-17-17.0.17+10/src/java.base/share/classes/sun/util/calendar/ZoneInfo.java	2025-10-13 07:48:04.000000000 +0000
+++ openjdk-17-17.0.18+8/src/java.base/share/classes/sun/util/calendar/ZoneInfo.java	2026-01-15 15:23:06.000000000 +0000
@@ -1,5 +1,5 @@
 /*
- * Copyright (c) 2000, 2021, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 2000, 2024, Oracle and/or its affiliates. All rights reserved.
  * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
  *
  * This code is free software; you can redistribute it and/or modify it
@@ -45,14 +45,14 @@
  * for the {@link #getOffset(int,int,int,int,int,int) getOffset}
  * method that takes Gregorian calendar date fields.
  * 

- * This table covers transitions from 1900 until 2037 (as of version - * 1.4), Before 1900, it assumes that there was no daylight saving + * This table covers transitions from 1900 until 2100 (as of version + * 23), Before 1900, it assumes that there was no daylight saving * time and the getOffset methods always return the * {@link #getRawOffset} value. No Local Mean Time is supported. If a * specified date is beyond the transition table and this time zone is - * supposed to observe daylight saving time in 2037, it delegates + * supposed to observe daylight saving time in 2100, it delegates * operations to a {@link java.util.SimpleTimeZone SimpleTimeZone} - * object created using the daylight saving time schedule as of 2037. + * object created using the daylight saving time schedule as of 2100. *

* The date items, transitions, GMT offset(s), etc. are read from a database * file. See {@link ZoneInfoFile} for details. diff -Nru openjdk-17-17.0.17+10/src/java.base/share/classes/sun/util/calendar/ZoneInfoFile.java openjdk-17-17.0.18+8/src/java.base/share/classes/sun/util/calendar/ZoneInfoFile.java --- openjdk-17-17.0.17+10/src/java.base/share/classes/sun/util/calendar/ZoneInfoFile.java 2025-10-13 07:48:04.000000000 +0000 +++ openjdk-17-17.0.18+8/src/java.base/share/classes/sun/util/calendar/ZoneInfoFile.java 2026-01-15 15:23:06.000000000 +0000 @@ -1,5 +1,5 @@ /* - * Copyright (c) 2012, 2021, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2012, 2024, Oracle and/or its affiliates. All rights reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * * This code is free software; you can redistribute it and/or modify it @@ -398,16 +398,16 @@ // ZoneInfo starts with UTC1900 private static final long UTC1900 = -2208988800L; - // ZoneInfo ends with UTC2037 - // LocalDateTime.of(2038, 1, 1, 0, 0, 0).toEpochSecond(ZoneOffset.UTC) - 1; - private static final long UTC2037 = 2145916799L; + // ZoneInfo ends with UTC2100 + // LocalDateTime.of(2101, 1, 1, 0, 0, 0).toEpochSecond(ZoneOffset.UTC) - 1; + private static final long UTC2100 = 4133980799L; - // ZoneInfo has an ending entry for 2037, this need to be offset by + // ZoneInfo has an ending entry for 2100, this need to be offset by // a "rawOffset" - // LocalDateTime.of(2037, 1, 1, 0, 0, 0).toEpochSecond(ZoneOffset.UTC)); - private static final long LDT2037 = 2114380800L; + // LocalDateTime.of(2100, 1, 1, 0, 0, 0).toEpochSecond(ZoneOffset.UTC); + private static final long LDT2100 = 4102444800L; - //Current time. Used to determine future GMToffset transitions + //Current time. Used to determine future GMT offset transitions private static final long CURRT = System.currentTimeMillis()/1000; /* Get a ZoneInfo instance. @@ -474,7 +474,7 @@ for (; i < savingsInstantTransitions.length; i++) { long trans = savingsInstantTransitions[i]; - if (trans > UTC2037) { + if (trans > UTC2100) { // no trans beyond LASTYEAR lastyear = LASTYEAR; break; @@ -621,11 +621,11 @@ } } else if (nTrans > 0) { // only do this if there is something in table already if (lastyear < LASTYEAR) { - // ZoneInfo has an ending entry for 2037 + // ZoneInfo has an ending entry for 2100 //long trans = OffsetDateTime.of(LASTYEAR, 1, 1, 0, 0, 0, 0, // ZoneOffset.ofTotalSeconds(rawOffset/1000)) // .toEpochSecond(); - long trans = LDT2037 - rawOffset/1000; + long trans = LDT2100 - rawOffset/1000; int offsetIndex = indexOf(offsets, 0, nOffsets, rawOffset/1000); if (offsetIndex == nOffsets) @@ -810,7 +810,9 @@ private static final long DST_MASK = 0xf0L; private static final int DST_NSHIFT = 4; private static final int TRANSITION_NSHIFT = 12; - private static final int LASTYEAR = 2037; + // The `last` year that transitions are accounted for. If there are + // rules that go beyond this LASTYEAR, the value needs to be expanded. + private static final int LASTYEAR = 2100; // from: 0 for offset lookup, 1 for dstsvings lookup private static int indexOf(int[] offsets, int from, int nOffsets, int offset) { diff -Nru openjdk-17-17.0.17+10/src/java.base/share/conf/security/java.security openjdk-17-17.0.18+8/src/java.base/share/conf/security/java.security --- openjdk-17-17.0.17+10/src/java.base/share/conf/security/java.security 2025-10-13 07:48:04.000000000 +0000 +++ openjdk-17-17.0.18+8/src/java.base/share/conf/security/java.security 2026-01-15 15:23:06.000000000 +0000 @@ -761,7 +761,8 @@ # rsa_pkcs1_sha1, secp224r1, TLS_RSA_* jdk.tls.disabledAlgorithms=SSLv3, TLSv1, TLSv1.1, DTLSv1.0, RC4, DES, \ MD5withRSA, DH keySize < 1024, EC keySize < 224, 3DES_EDE_CBC, anon, NULL, \ - ECDH + ECDH, TLS_RSA_*, rsa_pkcs1_sha1 usage HandshakeSignature, \ + ecdsa_sha1 usage HandshakeSignature, dsa_sha1 usage HandshakeSignature # # Legacy algorithms for Secure Socket Layer/Transport Layer Security (SSL/TLS) @@ -1469,3 +1470,48 @@ # The default pattern value allows any object factory class defined in the jdk.naming.rmi module # to be specified by the reference instance, but rejects any other. #jdk.jndi.rmi.object.factoriesFilter=jdk.naming.rmi/com.sun.jndi.rmi.**;!* + +# +# X.509 AuthorityInfoAccess caIssuer URI Filtering +# +# This property defines a whitespace-separated list of filters that +# are applied to URIs found in the authorityInfoAccess extension in +# X.509 certificates. Any caIssuers URIs in X.509 certificates are only +# followed when the com.sun.security.enableAIAcaIssuers System property is +# enabled and the filter allows the URI. By default this property imposes a +# deny-all ruleset. This property may be overridden by a System property +# of the same name. +# +# The filters must take the form of absolute, hierarchical URIs as defined by +# the java.net.URI class. Additionally, only the following protocols are +# allowed as filters: http, https, ldap and ftp. +# See RFC 5280, section 4.2.2.1 for details about the types of URIs allowed for +# the extension and their specific requirements. +# The filter matching rules are applied to each CA issuer URI as follows: +# 1. The scheme must match (case-insensitive). +# 2. A hostname or address must be specified in the filter URI. It must match +# the host or address in the caIssuers URI (case-insensitive). No name +# resolution is performed on hostnames to match IP addresses. +# 3. The port number must match. For filter and caIssuer URIs, when a port +# number is omitted, the well-known port for that scheme will be used in the +# comparison. +# 4. For hierarchical filesystem schemes (e.g. http[s], ftp): +# a. The normalized path portion of the filter URI is matched in a +# case-sensitive manner. If the final component of the path does not end +# in a slash (/), it is considered to be a file path component and must +# be an exact match of the caIssuer's URI file path component. If the +# final filter component ends in a slash, then it must either match or be +# a prefix of the caIssuer's URI path component (e.g. a filter path of +# /ab/cd/ will match a caIssuer path of /ab/cd/, /ab/cd/ef and +# /ab/cd/ef/ghi). +# b. Query strings will be ignored in filter rules and caIssuer URIs. +# c. Fragments will be ignored in filter rules and caIssuer URIs. +# 5. For ldap URIs: +# a. The base DN must be an exact match (case-insensitive). +# b. Any query string in the rule, if specified, is ignored. +# 6. A single value "any" (case-insensitive) will create an allow-all rule. +# +# As an example, here is a valid filter policy consisting of two rules: +# com.sun.security.allowedAIALocations=http://some.company.com/cacert \ +# ldap://ldap.company.com/dc=company,dc=com?caCertificate;binary +com.sun.security.allowedAIALocations= diff -Nru openjdk-17-17.0.17+10/src/java.base/unix/native/libjava/TimeZone_md.c openjdk-17-17.0.18+8/src/java.base/unix/native/libjava/TimeZone_md.c --- openjdk-17-17.0.17+10/src/java.base/unix/native/libjava/TimeZone_md.c 2025-10-13 07:48:04.000000000 +0000 +++ openjdk-17-17.0.18+8/src/java.base/unix/native/libjava/TimeZone_md.c 2026-01-15 15:23:06.000000000 +0000 @@ -1,5 +1,5 @@ /* - * Copyright (c) 1999, 2023, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 1999, 2025, Oracle and/or its affiliates. All rights reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * * This code is free software; you can redistribute it and/or modify it @@ -60,7 +60,6 @@ #endif #if defined(__linux__) || defined(_ALLBSD_SOURCE) -static const char *ETC_TIMEZONE_FILE = "/etc/timezone"; static const char *ZONEINFO_DIR = "/usr/share/zoneinfo"; static const char *DEFAULT_ZONEINFO_FILE = "/etc/localtime"; #else @@ -239,40 +238,13 @@ { struct stat64 statbuf; char *tz = NULL; - FILE *fp; int fd; char *buf; size_t size; int res; -#if defined(__linux__) /* - * Try reading the /etc/timezone file for Debian distros. There's - * no spec of the file format available. This parsing assumes that - * there's one line of an Olson tzid followed by a '\n', no - * leading or trailing spaces, no comments. - */ - if ((fp = fopen(ETC_TIMEZONE_FILE, "r")) != NULL) { - char line[256]; - - if (fgets(line, sizeof(line), fp) != NULL) { - char *p = strchr(line, '\n'); - if (p != NULL) { - *p = '\0'; - } - if (strlen(line) > 0) { - tz = strdup(line); - } - } - (void) fclose(fp); - if (tz != NULL) { - return tz; - } - } -#endif /* defined(__linux__) */ - - /* - * Next, try /etc/localtime to find the zone ID. + * Try /etc/localtime to find the zone ID. */ RESTARTABLE(lstat64(DEFAULT_ZONEINFO_FILE, &statbuf), res); if (res == -1) { diff -Nru openjdk-17-17.0.17+10/src/java.base/unix/native/libnio/ch/Net.c openjdk-17-17.0.18+8/src/java.base/unix/native/libnio/ch/Net.c --- openjdk-17-17.0.17+10/src/java.base/unix/native/libnio/ch/Net.c 2025-10-13 07:48:04.000000000 +0000 +++ openjdk-17-17.0.18+8/src/java.base/unix/native/libnio/ch/Net.c 2026-01-15 15:23:06.000000000 +0000 @@ -201,6 +201,11 @@ } JNIEXPORT jboolean JNICALL +Java_sun_nio_ch_Net_shouldShutdownWriteBeforeClose0(JNIEnv *env, jclass clazz) { + return JNI_FALSE; +} + +JNIEXPORT jboolean JNICALL Java_sun_nio_ch_Net_shouldSetBothIPv4AndIPv6Options0(JNIEnv* env, jclass cl) { #if defined(__linux__) diff -Nru openjdk-17-17.0.17+10/src/java.base/windows/native/include/jni_md.h openjdk-17-17.0.18+8/src/java.base/windows/native/include/jni_md.h --- openjdk-17-17.0.17+10/src/java.base/windows/native/include/jni_md.h 2025-10-13 07:48:04.000000000 +0000 +++ openjdk-17-17.0.18+8/src/java.base/windows/native/include/jni_md.h 2026-01-15 15:23:06.000000000 +0000 @@ -1,5 +1,5 @@ /* - * Copyright (c) 1996, 2020, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 1996, 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,9 +32,8 @@ #define JNIIMPORT __declspec(dllimport) #define JNICALL __stdcall -// 'long' is always 32 bit on windows so this matches what jdk expects -typedef long jint; -typedef __int64 jlong; +typedef int jint; +typedef long long jlong; typedef signed char jbyte; #endif /* !_JAVASOFT_JNI_MD_H_ */ diff -Nru openjdk-17-17.0.17+10/src/java.base/windows/native/libnio/ch/Net.c openjdk-17-17.0.18+8/src/java.base/windows/native/libnio/ch/Net.c --- openjdk-17-17.0.17+10/src/java.base/windows/native/libnio/ch/Net.c 2025-10-13 07:48:04.000000000 +0000 +++ openjdk-17-17.0.18+8/src/java.base/windows/native/libnio/ch/Net.c 2026-01-15 15:23:06.000000000 +0000 @@ -1,5 +1,5 @@ /* - * Copyright (c) 2001, 2021, 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 @@ -118,6 +118,11 @@ } JNIEXPORT jboolean JNICALL +Java_sun_nio_ch_Net_shouldShutdownWriteBeforeClose0(JNIEnv *env, jclass clazz) { + return JNI_TRUE; +} + +JNIEXPORT jboolean JNICALL Java_sun_nio_ch_Net_shouldSetBothIPv4AndIPv6Options0(JNIEnv* env, jclass cl) { /* Set both IPv4 and IPv6 socket options when setting multicast options */ diff -Nru openjdk-17-17.0.17+10/src/java.desktop/macosx/classes/com/apple/laf/AquaFileChooserUI.java openjdk-17-17.0.18+8/src/java.desktop/macosx/classes/com/apple/laf/AquaFileChooserUI.java --- openjdk-17-17.0.17+10/src/java.desktop/macosx/classes/com/apple/laf/AquaFileChooserUI.java 2025-10-13 07:48:04.000000000 +0000 +++ openjdk-17-17.0.18+8/src/java.desktop/macosx/classes/com/apple/laf/AquaFileChooserUI.java 2026-01-15 15:23:06.000000000 +0000 @@ -1181,6 +1181,9 @@ setText(fc.getName(file)); setIcon(fc.getIcon(file)); setEnabled(isSelectableInList(file)); + + putClientProperty("html.disable", getFileChooser().getClientProperty("html.disable")); + return this; } } @@ -1246,6 +1249,9 @@ final JFileChooser chooser = getFileChooser(); setText(chooser.getName(directory)); setIcon(chooser.getIcon(directory)); + + putClientProperty("html.disable", getFileChooser().getClientProperty("html.disable")); + return this; } }; diff -Nru openjdk-17-17.0.17+10/src/java.desktop/macosx/classes/com/apple/laf/AquaKeyBindings.java openjdk-17-17.0.18+8/src/java.desktop/macosx/classes/com/apple/laf/AquaKeyBindings.java --- openjdk-17-17.0.17+10/src/java.desktop/macosx/classes/com/apple/laf/AquaKeyBindings.java 2025-10-13 07:48:04.000000000 +0000 +++ openjdk-17-17.0.18+8/src/java.desktop/macosx/classes/com/apple/laf/AquaKeyBindings.java 2026-01-15 15:23:06.000000000 +0000 @@ -155,6 +155,9 @@ "shift alt KP_LEFT", null, "shift alt RIGHT", null, "shift alt KP_RIGHT", null, + "alt BACK_SPACE", null, + "ctrl W", null, + "alt DELETE", null, })); } @@ -383,7 +386,8 @@ "ENTER", "selectNextRowCell", "shift ENTER", "selectPreviousRowCell", "alt TAB", "focusHeader", - "alt shift TAB", "focusHeader" + "alt shift TAB", "focusHeader", + "F8", "focusHeader" })); } diff -Nru openjdk-17-17.0.17+10/src/java.desktop/macosx/classes/sun/lwawt/macosx/CDesktopPeer.java openjdk-17-17.0.18+8/src/java.desktop/macosx/classes/sun/lwawt/macosx/CDesktopPeer.java --- openjdk-17-17.0.17+10/src/java.desktop/macosx/classes/sun/lwawt/macosx/CDesktopPeer.java 2025-10-13 07:48:04.000000000 +0000 +++ openjdk-17-17.0.18+8/src/java.desktop/macosx/classes/sun/lwawt/macosx/CDesktopPeer.java 2026-01-15 15:23:06.000000000 +0000 @@ -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 @@ -34,7 +34,10 @@ import java.io.File; import java.io.FileNotFoundException; import java.io.IOException; +import java.lang.annotation.Native; import java.net.URI; +import java.nio.file.Files; +import java.nio.file.Path; /** @@ -44,6 +47,12 @@ */ public final class CDesktopPeer implements DesktopPeer { + @Native private static final int OPEN = 0; + @Native private static final int BROWSE = 1; + @Native private static final int EDIT = 2; + @Native private static final int PRINT = 3; + @Native private static final int MAIL = 4; + @Override public boolean isSupported(Action action) { return true; @@ -51,27 +60,27 @@ @Override public void open(File file) throws IOException { - this.lsOpenFile(file, false); + this.lsOpenFile(file, OPEN); } @Override public void edit(File file) throws IOException { - this.lsOpenFile(file, false); + this.lsOpenFile(file, EDIT); } @Override public void print(File file) throws IOException { - this.lsOpenFile(file, true); + this.lsOpenFile(file, PRINT); } @Override public void mail(URI uri) throws IOException { - this.lsOpen(uri); + this.lsOpen(uri, MAIL); } @Override public void browse(URI uri) throws IOException { - this.lsOpen(uri); + this.lsOpen(uri, BROWSE); } @Override @@ -162,24 +171,44 @@ } } - private void lsOpen(URI uri) throws IOException { - int status = _lsOpenURI(uri.toString()); + private void lsOpen(URI uri, int action) throws IOException { + int status = _lsOpenURI(uri.toString(), action); if (status != 0 /* noErr */) { - throw new IOException("Failed to mail or browse " + uri + ". Error code: " + status); + String actionString = (action == MAIL) ? "mail" : "browse"; + throw new IOException("Failed to " + actionString + " " + uri + + ". Error code: " + status); } } - private void lsOpenFile(File file, boolean print) throws IOException { - int status = _lsOpenFile(file.getCanonicalPath(), print); + private void lsOpenFile(File file, int action) throws IOException { + int status = -1; + Path tmpFile = null; + String tmpTxtPath = null; + try { + if (action == EDIT) { + tmpFile = Files.createTempFile("TmpFile", ".txt"); + tmpTxtPath = tmpFile.toAbsolutePath().toString(); + } + status = _lsOpenFile(file.getCanonicalPath(), action, tmpTxtPath); + } catch (Exception e) { + throw new IOException("Failed to create tmp file: ", e); + } finally { + if (tmpFile != null) { + Files.deleteIfExists(tmpFile); + } + } if (status != 0 /* noErr */) { - throw new IOException("Failed to open, edit or print " + file + ". Error code: " + status); + String actionString = (action == OPEN) ? "open" + : (action == EDIT) ? "edit" : "print"; + throw new IOException("Failed to " + actionString + " " + file + + ". Error code: " + status); } } - private static native int _lsOpenURI(String uri); + private static native int _lsOpenURI(String uri, int action); - private static native int _lsOpenFile(String path, boolean print); + private static native int _lsOpenFile(String path, int action, String tmpTxtPath); } diff -Nru openjdk-17-17.0.17+10/src/java.desktop/macosx/native/libawt_lwawt/awt/CDesktopPeer.m openjdk-17-17.0.18+8/src/java.desktop/macosx/native/libawt_lwawt/awt/CDesktopPeer.m --- openjdk-17-17.0.17+10/src/java.desktop/macosx/native/libawt_lwawt/awt/CDesktopPeer.m 2025-10-13 07:48:04.000000000 +0000 +++ openjdk-17-17.0.18+8/src/java.desktop/macosx/native/libawt_lwawt/awt/CDesktopPeer.m 2026-01-15 15:23:06.000000000 +0000 @@ -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 @@ -27,27 +27,60 @@ #import "JNIUtilities.h" #import #import +#import "sun_lwawt_macosx_CDesktopPeer.h" /* * Class: sun_lwawt_macosx_CDesktopPeer * Method: _lsOpenURI - * Signature: (Ljava/lang/String;)I; + * Signature: (Ljava/lang/String;I)I */ JNIEXPORT jint JNICALL Java_sun_lwawt_macosx_CDesktopPeer__1lsOpenURI -(JNIEnv *env, jclass clz, jstring uri) +(JNIEnv *env, jclass clz, jstring uri, jint action) { - OSStatus status = noErr; + __block OSStatus status = noErr; JNI_COCOA_ENTER(env); - // I would love to use NSWorkspace here, but it's not thread safe. Why? I don't know. - // So we use LaunchServices directly. + NSURL *urlToOpen = [NSURL URLWithString:JavaStringToNSString(env, uri)]; + NSURL *appURI = nil; - NSURL *url = [NSURL URLWithString:JavaStringToNSString(env, uri)]; + if (action == sun_lwawt_macosx_CDesktopPeer_BROWSE) { + // To get the defaultBrowser + NSURL *httpsURL = [NSURL URLWithString:@"https://"]; + NSWorkspace *workspace = [NSWorkspace sharedWorkspace]; + appURI = [workspace URLForApplicationToOpenURL:httpsURL]; + } else if (action == sun_lwawt_macosx_CDesktopPeer_MAIL) { + // To get the default mailer + NSURL *mailtoURL = [NSURL URLWithString:@"mailto://"]; + NSWorkspace *workspace = [NSWorkspace sharedWorkspace]; + appURI = [workspace URLForApplicationToOpenURL:mailtoURL]; + } + + if (appURI == nil) { + return -1; + } + + // Prepare NSOpenConfig object + NSArray *urls = @[urlToOpen]; + NSWorkspaceOpenConfiguration *configuration = [NSWorkspaceOpenConfiguration configuration]; + configuration.activates = YES; // To bring app to foreground + configuration.promptsUserIfNeeded = YES; // To allow macOS desktop prompts + + // dispatch semaphores used to wait for the completion handler to update and return status + dispatch_semaphore_t semaphore = dispatch_semaphore_create(0); + dispatch_time_t timeout = dispatch_time(DISPATCH_TIME_NOW, (int64_t)(NSEC_PER_SEC)); // 1 second timeout + + // Asynchronous call to openURL + [[NSWorkspace sharedWorkspace] openURLs:urls + withApplicationAtURL:appURI + configuration:configuration + completionHandler:^(NSRunningApplication *app, NSError *error) { + if (error) { + status = (OSStatus) error.code; + } + dispatch_semaphore_signal(semaphore); + }]; - LSLaunchFlags flags = kLSLaunchDefaults; - - LSApplicationParameters params = {0, flags, NULL, NULL, NULL, NULL, NULL}; - status = LSOpenURLsWithRole((CFArrayRef)[NSArray arrayWithObject:url], kLSRolesAll, NULL, ¶ms, NULL, 0); + dispatch_semaphore_wait(semaphore, timeout); JNI_COCOA_EXIT(env); return status; @@ -56,32 +89,73 @@ /* * Class: sun_lwawt_macosx_CDesktopPeer * Method: _lsOpenFile - * Signature: (Ljava/lang/String;Z)I; + * Signature: (Ljava/lang/String;I;Ljava/lang/String;)I; */ JNIEXPORT jint JNICALL Java_sun_lwawt_macosx_CDesktopPeer__1lsOpenFile -(JNIEnv *env, jclass clz, jstring jpath, jboolean print) +(JNIEnv *env, jclass clz, jstring jpath, jint action, jstring jtmpTxtPath) { - OSStatus status = noErr; + __block OSStatus status = noErr; JNI_COCOA_ENTER(env); - // I would love to use NSWorkspace here, but it's not thread safe. Why? I don't know. - // So we use LaunchServices directly. - NSString *path = NormalizedPathNSStringFromJavaString(env, jpath); - - NSURL *url = [NSURL fileURLWithPath:(NSString *)path]; + NSURL *urlToOpen = [NSURL fileURLWithPath:(NSString *)path]; // This byzantine workaround is necesary, or else directories won't open in Finder - url = (NSURL *)CFURLCreateWithFileSystemPath(NULL, (CFStringRef)[url path], kCFURLPOSIXPathStyle, false); + urlToOpen = (NSURL *)CFURLCreateWithFileSystemPath(NULL, (CFStringRef)[urlToOpen path], + kCFURLPOSIXPathStyle, false); - LSLaunchFlags flags = kLSLaunchDefaults; - if (print) flags |= kLSLaunchAndPrint; + NSWorkspace *workspace = [NSWorkspace sharedWorkspace]; + NSURL *appURI = [workspace URLForApplicationToOpenURL:urlToOpen]; + NSURL *defaultTerminalApp = [workspace URLForApplicationToOpenURL:[NSURL URLWithString:@"file:///bin/sh"]]; + + // Prepare NSOpenConfig object + NSArray *urls = @[urlToOpen]; + NSWorkspaceOpenConfiguration *configuration = [NSWorkspaceOpenConfiguration configuration]; + configuration.activates = YES; // To bring app to foreground + configuration.promptsUserIfNeeded = YES; // To allow macOS desktop prompts + + // pre-checks for open/print/edit before calling openURLs API + if (action == sun_lwawt_macosx_CDesktopPeer_OPEN + || action == sun_lwawt_macosx_CDesktopPeer_PRINT) { + if (appURI == nil + || [[urlToOpen absoluteString] containsString:[appURI absoluteString]] + || [[defaultTerminalApp absoluteString] containsString:[appURI absoluteString]]) { + return -1; + } + // Additionally set forPrinting=TRUE for print + if (action == sun_lwawt_macosx_CDesktopPeer_PRINT) { + configuration.forPrinting = YES; + } + } else if (action == sun_lwawt_macosx_CDesktopPeer_EDIT) { + if (appURI == nil + || [[urlToOpen absoluteString] containsString:[appURI absoluteString]]) { + return -1; + } + // for EDIT: if (defaultApp = TerminalApp) then set appURI = DefaultTextEditor + if ([[defaultTerminalApp absoluteString] containsString:[appURI absoluteString]]) { + NSString *path = NormalizedPathNSStringFromJavaString(env, jtmpTxtPath); + NSURL *tempFilePath = [NSURL fileURLWithPath:(NSString *)path]; + appURI = [workspace URLForApplicationToOpenURL:tempFilePath]; + } + } + + // dispatch semaphores used to wait for the completion handler to update and return status + dispatch_semaphore_t semaphore = dispatch_semaphore_create(0); + dispatch_time_t timeout = dispatch_time(DISPATCH_TIME_NOW, (int64_t)(NSEC_PER_SEC)); // 1 second timeout + + // Asynchronous call - openURLs:withApplicationAtURL + [[NSWorkspace sharedWorkspace] openURLs:urls + withApplicationAtURL:appURI + configuration:configuration + completionHandler:^(NSRunningApplication *app, NSError *error) { + if (error) { + status = (OSStatus) error.code; + } + dispatch_semaphore_signal(semaphore); + }]; - LSApplicationParameters params = {0, flags, NULL, NULL, NULL, NULL, NULL}; - status = LSOpenURLsWithRole((CFArrayRef)[NSArray arrayWithObject:url], kLSRolesAll, NULL, ¶ms, NULL, 0); - [url release]; + dispatch_semaphore_wait(semaphore, timeout); JNI_COCOA_EXIT(env); return status; } - diff -Nru openjdk-17-17.0.17+10/src/java.desktop/macosx/native/libjsound/PLATFORM_API_MacOSX_Ports.cpp openjdk-17-17.0.18+8/src/java.desktop/macosx/native/libjsound/PLATFORM_API_MacOSX_Ports.cpp --- openjdk-17-17.0.17+10/src/java.desktop/macosx/native/libjsound/PLATFORM_API_MacOSX_Ports.cpp 2025-10-13 07:48:04.000000000 +0000 +++ openjdk-17-17.0.18+8/src/java.desktop/macosx/native/libjsound/PLATFORM_API_MacOSX_Ports.cpp 2026-01-15 15:23:06.000000000 +0000 @@ -1,5 +1,5 @@ /* - * Copyright (c) 2003, 2018, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2003, 2025, Oracle and/or its affiliates. All rights reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * * This code is free software; you can redistribute it and/or modify it @@ -124,9 +124,12 @@ kAudioHardwarePropertyDevices, &size); if (err == noErr) { int count = size/sizeof(AudioDeviceID); - AudioDeviceID devices[count]; + AudioDeviceID *devices = (AudioDeviceID *) malloc(size); + if (!devices) { + break; + } err = GetAudioObjectProperty(kAudioObjectSystemObject, kAudioObjectPropertyScopeGlobal, - kAudioHardwarePropertyDevices, count*sizeof(AudioDeviceID), devices, 1); + kAudioHardwarePropertyDevices, size, devices, 1); if (err == noErr) { bool found = false; for (int j = 0; j < count; j++) { @@ -139,6 +142,7 @@ invalid = true; } } + free(devices); } break; case kAudioObjectPropertyOwnedObjects: @@ -148,9 +152,12 @@ kAudioObjectPropertyOwnedObjects, &size); if (err == noErr) { int count = size / sizeof(AudioObjectID); - AudioObjectID controlIDs[count]; + AudioObjectID *controlIDs = (AudioObjectID *) malloc(size); + if (!controlIDs) { + break; + } err = GetAudioObjectProperty(mixer->deviceID, kAudioObjectPropertyScopeGlobal, - kAudioObjectPropertyOwnedObjects, count * sizeof(AudioObjectID), &controlIDs, 1); + kAudioObjectPropertyOwnedObjects, size, controlIDs, 1); if (err == noErr) { for (PortControl *ctrl = mixer->portControls; ctrl != NULL; ctrl = ctrl->next) { for (int i = 0; i < ctrl->controlCount; i++) { @@ -168,6 +175,7 @@ } } } + free(controlIDs); } } } @@ -229,6 +237,9 @@ void* PORT_Open(INT32 mixerIndex) { TRACE1("\n>>PORT_Open (mixerIndex=%d)\n", (int)mixerIndex); PortMixer *mixer = (PortMixer *)calloc(1, sizeof(PortMixer)); + if (!mixer) { + return nullptr; + } mixer->deviceID = deviceCache.GetDeviceID(mixerIndex); if (mixer->deviceID != 0) { @@ -480,16 +491,20 @@ mixer->deviceControlCount = size / sizeof(AudioObjectID); TRACE1(" PORT_GetControls: detected %d owned objects\n", mixer->deviceControlCount); - AudioObjectID controlIDs[mixer->deviceControlCount]; + AudioObjectID *controlIDs = (AudioObjectID *) malloc(size); + if (!controlIDs) { + return; + } err = GetAudioObjectProperty(mixer->deviceID, kAudioObjectPropertyScopeGlobal, - kAudioObjectPropertyOwnedObjects, sizeof(controlIDs), controlIDs, 1); + kAudioObjectPropertyOwnedObjects, size, controlIDs, 1); if (err) { OS_ERROR1(err, "PORT_GetControls (portIndex = %d) get OwnedObject values", portIndex); } else { mixer->deviceControls = (AudioControl *)calloc(mixer->deviceControlCount, sizeof(AudioControl)); if (mixer->deviceControls == NULL) { + free(controlIDs); return; } @@ -513,6 +528,7 @@ control->controlID, FourCC2Str(control->classID), FourCC2Str(control->scope), control->channel); } } + free(controlIDs); } } @@ -524,10 +540,14 @@ int totalChannels = GetChannelCount(mixer->deviceID, port->scope == kAudioDevicePropertyScopeOutput ? 1 : 0); // collect volume and mute controls - AudioControl* volumeControls[totalChannels+1]; // 0 - for master channel - memset(&volumeControls, 0, sizeof(AudioControl *) * (totalChannels+1)); - AudioControl* muteControls[totalChannels+1]; // 0 - for master channel - memset(&muteControls, 0, sizeof(AudioControl *) * (totalChannels+1)); + size_t totalAndMaster = totalChannels + 1; // 0 - for master channel + AudioControl **volumeControls = (AudioControl **) calloc(totalAndMaster, sizeof(AudioControl *)); + AudioControl **muteControls = (AudioControl **) calloc(totalAndMaster, sizeof(AudioControl *)); + if (!volumeControls || !muteControls) { + free(muteControls); + free(volumeControls); + return; + } for (int i=0; ideviceControlCount; i++) { AudioControl *control = &mixer->deviceControls[i]; @@ -626,6 +646,8 @@ CFIndex length = CFStringGetLength(cfname) + 1; channelName = (char *)malloc(length); if (channelName == NULL) { + free(muteControls); + free(volumeControls); return; } CFStringGetCString(cfname, channelName, length, kCFStringEncodingUTF8); @@ -633,6 +655,8 @@ } else { channelName = (char *)malloc(16); if (channelName == NULL) { + free(muteControls); + free(volumeControls); return; } snprintf(channelName, 16, "Ch %d", ch); @@ -657,7 +681,8 @@ } AddChangeListeners(mixer); - + free(muteControls); + free(volumeControls); TRACE1("<controlCount]; + Float32 *subVolumes = (Float32 *) malloc(control->controlCount * sizeof(Float32)); + if (!subVolumes) { + return DEFAULT_VOLUME_VALUE; + } Float32 maxVolume; switch (control->type) { case PortControl::Volume: if (!TestPortControlValidity(control)) { - return DEFAULT_VOLUME_VALUE; + result = DEFAULT_VOLUME_VALUE; + break; } if (!GetPortControlVolumes(control, subVolumes, &maxVolume)) { - return DEFAULT_VOLUME_VALUE; + result = DEFAULT_VOLUME_VALUE; + break; } result = maxVolume; break; case PortControl::Balance: if (!TestPortControlValidity(control)) { - return DEFAULT_BALANCE_VALUE; + result = DEFAULT_BALANCE_VALUE; + break; } // balance control always has 2 volume controls if (!GetPortControlVolumes(control, subVolumes, &maxVolume)) { - return DEFAULT_VOLUME_VALUE; + result = DEFAULT_VOLUME_VALUE; + break; } // calculate balance value if (subVolumes[0] > subVolumes[1]) { @@ -806,9 +838,10 @@ break; default: ERROR1("GetFloatValue requested for non-Float control (control-type == %d)\n", control->type); - return 0; + result = 0; + break; } - + free(subVolumes); TRACE1("<controlCount]; + Float32 *subVolumes = (Float32 *) malloc(sizeof(Float32) * control->controlCount); + if (!subVolumes) { + return; + } Float32 maxVolume; switch (control->type) { case PortControl::Volume: if (!GetPortControlVolumes(control, subVolumes, &maxVolume)) { - return; + break; } // update the values if (maxVolume > 0.001) { @@ -845,7 +881,7 @@ case PortControl::Balance: // balance control always has 2 volume controls if (!GetPortControlVolumes(control, subVolumes, &maxVolume)) { - return; + break; } // calculate new values if (value < 0.0f) { @@ -861,8 +897,9 @@ break; default: ERROR1("PORT_SetFloatValue requested for non-Float control (control-type == %d)\n", control->type); - return; + break; } + free(subVolumes); } #endif // USE_PORTS diff -Nru openjdk-17-17.0.17+10/src/java.desktop/share/classes/com/sun/beans/introspect/MethodInfo.java openjdk-17-17.0.18+8/src/java.desktop/share/classes/com/sun/beans/introspect/MethodInfo.java --- openjdk-17-17.0.17+10/src/java.desktop/share/classes/com/sun/beans/introspect/MethodInfo.java 2025-10-13 07:48:04.000000000 +0000 +++ openjdk-17-17.0.18+8/src/java.desktop/share/classes/com/sun/beans/introspect/MethodInfo.java 2026-01-15 15:23:06.000000000 +0000 @@ -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 @@ -31,10 +31,11 @@ import java.lang.reflect.Method; import java.lang.reflect.Modifier; import java.lang.reflect.Type; +import java.util.ArrayDeque; import java.util.ArrayList; -import java.util.Arrays; import java.util.Collections; import java.util.Comparator; +import java.util.Deque; import java.util.List; import java.util.Set; @@ -105,13 +106,16 @@ } } - // Add default methods inherited from interfaces - for (Class iface : type.getInterfaces()) { + // Add methods inherited from interfaces + Deque> ifaceDeque = new ArrayDeque<>(List.of(type.getInterfaces())); + while (!ifaceDeque.isEmpty()) { + Class iface = ifaceDeque.removeLast(); if (IGNORABLE_INTERFACES.contains(iface)) { continue; } + ifaceDeque.addAll(List.of(iface.getInterfaces())); for (Method method : iface.getMethods()) { - if (!Modifier.isAbstract(method.getModifiers())) { + if (!Modifier.isAbstract(method.getModifiers()) && !method.isBridge()) { (list = createIfNeeded(list)).add(method); } } diff -Nru openjdk-17-17.0.17+10/src/java.desktop/share/classes/com/sun/beans/introspect/PropertyInfo.java openjdk-17-17.0.18+8/src/java.desktop/share/classes/com/sun/beans/introspect/PropertyInfo.java --- openjdk-17-17.0.17+10/src/java.desktop/share/classes/com/sun/beans/introspect/PropertyInfo.java 2025-10-13 07:48:04.000000000 +0000 +++ openjdk-17-17.0.18+8/src/java.desktop/share/classes/com/sun/beans/introspect/PropertyInfo.java 2026-01-15 15:23:06.000000000 +0000 @@ -1,5 +1,5 @@ /* - * Copyright (c) 2014, 2018, 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 @@ -79,7 +79,8 @@ } if (!isInitedToIsGetter && this.readList != null) { for (MethodInfo info : this.readList) { - if ((this.read == null) || this.read.type.isAssignableFrom(info.type)) { + if ((this.read == null) || (!info.method.isDefault() + && this.read.type.isAssignableFrom(info.type))) { this.read = info; this.type = info.type; } @@ -92,6 +93,9 @@ if (writeType == null) { this.write = info; writeType = info.type; + } else if (isParentOfIncoming(this.write, info)) { + this.write = info; + writeType = info.type; } else if (writeType.isAssignableFrom(info.type)) { if ((this.write == null) || this.write.type.isAssignableFrom(info.type)) { this.write = info; @@ -313,4 +317,16 @@ ? Collections.unmodifiableMap(map) : Collections.emptyMap(); } + + private static boolean isParentOfIncoming(MethodInfo current, MethodInfo incoming) { + if (null == current) { + return false; + } + Class currentClass = current.method.getDeclaringClass(); + Class incomingClass = incoming.method.getDeclaringClass(); + if (currentClass == incomingClass) { + return false; + } + return currentClass.isAssignableFrom(incomingClass); + } } diff -Nru openjdk-17-17.0.17+10/src/java.desktop/share/classes/com/sun/java/swing/SwingUtilities3.java openjdk-17-17.0.18+8/src/java.desktop/share/classes/com/sun/java/swing/SwingUtilities3.java --- openjdk-17-17.0.17+10/src/java.desktop/share/classes/com/sun/java/swing/SwingUtilities3.java 2025-10-13 07:48:04.000000000 +0000 +++ openjdk-17-17.0.18+8/src/java.desktop/share/classes/com/sun/java/swing/SwingUtilities3.java 2026-01-15 15:23:06.000000000 +0000 @@ -25,28 +25,34 @@ package com.sun.java.swing; -import sun.awt.AppContext; -import sun.awt.SunToolkit; - -import java.util.Collections; -import java.util.Map; -import java.util.WeakHashMap; import java.applet.Applet; import java.awt.Color; import java.awt.Component; import java.awt.Container; import java.awt.Graphics; +import java.awt.Graphics2D; import java.awt.Insets; import java.awt.Rectangle; +import java.awt.Stroke; import java.awt.Window; +import java.awt.geom.AffineTransform; +import java.util.Collections; +import java.util.Map; +import java.util.WeakHashMap; + import javax.swing.ButtonModel; import javax.swing.Icon; import javax.swing.JComponent; import javax.swing.JMenu; import javax.swing.RepaintManager; + +import sun.awt.AppContext; +import sun.awt.SunToolkit; import sun.swing.MenuItemLayoutHelper; import sun.swing.SwingUtilities2; +import static sun.java2d.pipe.Region.clipRound; + /** * A collection of utility methods for Swing. *

@@ -120,6 +126,31 @@ return Boolean.TRUE == vsyncedMap.get(rootContainer); } + /** + * Returns delegate {@code RepaintManager} for {@code component} hierarchy. + */ + public static RepaintManager getDelegateRepaintManager(Component + component) { + RepaintManager delegate = null; + if (Boolean.TRUE == SunToolkit.targetToAppContext(component) + .get(DELEGATE_REPAINT_MANAGER_KEY)) { + while (delegate == null && component != null) { + while (component != null + && ! (component instanceof JComponent)) { + component = component.getParent(); + } + if (component != null) { + delegate = (RepaintManager) + ((JComponent) component) + .getClientProperty(DELEGATE_REPAINT_MANAGER_KEY); + component = component.getParent(); + } + + } + } + return delegate; + } + public static void applyInsets(Rectangle rect, Insets insets) { if (insets != null) { rect.x += insets.left; @@ -234,27 +265,112 @@ } /** - * Returns delegate {@code RepaintManager} for {@code component} hierarchy. + * A task which paints an unscaled border after {@code Graphics} + * transforms are removed. It's used with the + * {@link #paintBorder(Component, Graphics, int, int, int, int, UnscaledBorderPainter) + * SwingUtilities3.paintBorder} which manages changing the transforms and calculating + * the coordinates and size of the border. */ - public static RepaintManager getDelegateRepaintManager(Component - component) { - RepaintManager delegate = null; - if (Boolean.TRUE == SunToolkit.targetToAppContext(component) - .get(DELEGATE_REPAINT_MANAGER_KEY)) { - while (delegate == null && component != null) { - while (component != null - && ! (component instanceof JComponent)) { - component = component.getParent(); - } - if (component != null) { - delegate = (RepaintManager) - ((JComponent) component) - .getClientProperty(DELEGATE_REPAINT_MANAGER_KEY); - component = component.getParent(); - } + @FunctionalInterface + public interface UnscaledBorderPainter { + /** + * Paints the border for the specified component after the + * {@code Graphics} transforms are removed. + * + *

+ * The x and y of the painted border are zero. + * + * @param c the component for which this border is being painted + * @param g the paint graphics + * @param w the width of the painted border, in physical pixels + * @param h the height of the painted border, in physical pixels + * @param scaleFactor the scale that was in the {@code Graphics} + * + * @see #paintBorder(Component, Graphics, int, int, int, int, UnscaledBorderPainter) + * SwingUtilities3.paintBorder + * @see javax.swing.border.Border#paintBorder(Component, Graphics, int, int, int, int) + * Border.paintBorder + */ + void paintUnscaledBorder(Component c, Graphics g, + int w, int h, + double scaleFactor); + } + + /** + * Paints the border for a component ensuring its sides have consistent + * thickness at different scales. + *

+ * It performs the following steps: + *

    + *
  1. Reset the scale transform on the {@code Graphics},
  2. + *
  3. Call {@code painter} to paint the border,
  4. + *
  5. Restores the transform.
  6. + *
+ * + * @param c the component for which this border is being painted + * @param g the paint graphics + * @param x the x position of the painted border + * @param y the y position of the painted border + * @param w the width of the painted border + * @param h the height of the painted border + * @param painter the painter object which paints the border after + * the transform on the {@code Graphics} is reset + */ + public static void paintBorder(Component c, Graphics g, + int x, int y, + int w, int h, + UnscaledBorderPainter painter) { + + // Step 1: Reset Transform + AffineTransform at = null; + Stroke oldStroke = null; + boolean resetTransform = false; + double scaleFactor = 1; + + int xtranslation = x; + int ytranslation = y; + int width = w; + int height = h; + + if (g instanceof Graphics2D) { + Graphics2D g2d = (Graphics2D) g; + at = g2d.getTransform(); + oldStroke = g2d.getStroke(); + scaleFactor = Math.min(at.getScaleX(), at.getScaleY()); + + // if m01 or m10 is non-zero, then there is a rotation or shear, + // or if scale=1, skip resetting the transform in these cases. + resetTransform = ((at.getShearX() == 0) && (at.getShearY() == 0)) + && ((at.getScaleX() > 1) || (at.getScaleY() > 1)); + + if (resetTransform) { + /* Deactivate the HiDPI scaling transform, + * so we can do paint operations in the device + * pixel coordinate system instead of the logical coordinate system. + */ + g2d.setTransform(new AffineTransform()); + double xx = at.getScaleX() * x + at.getTranslateX(); + double yy = at.getScaleY() * y + at.getTranslateY(); + xtranslation = clipRound(xx); + ytranslation = clipRound(yy); + width = clipRound(at.getScaleX() * w + xx) - xtranslation; + height = clipRound(at.getScaleY() * h + yy) - ytranslation; + } + } + + g.translate(xtranslation, ytranslation); + // Step 2: Call respective paintBorder with transformed values + painter.paintUnscaledBorder(c, g, width, height, scaleFactor); + + // Step 3: Restore previous stroke & transform + g.translate(-xtranslation, -ytranslation); + if (g instanceof Graphics2D) { + Graphics2D g2d = (Graphics2D) g; + g2d.setStroke(oldStroke); + if (resetTransform) { + g2d.setTransform(at); } } - return delegate; } } diff -Nru openjdk-17-17.0.17+10/src/java.desktop/share/classes/com/sun/java/swing/plaf/gtk/GTKFileChooserUI.java openjdk-17-17.0.18+8/src/java.desktop/share/classes/com/sun/java/swing/plaf/gtk/GTKFileChooserUI.java --- openjdk-17-17.0.17+10/src/java.desktop/share/classes/com/sun/java/swing/plaf/gtk/GTKFileChooserUI.java 2025-10-13 07:48:04.000000000 +0000 +++ openjdk-17-17.0.18+8/src/java.desktop/share/classes/com/sun/java/swing/plaf/gtk/GTKFileChooserUI.java 2026-01-15 15:23:06.000000000 +0000 @@ -1082,6 +1082,9 @@ if (showFileIcons) { setIcon(getFileChooser().getIcon((File)value)); } + + putClientProperty("html.disable", getFileChooser().getClientProperty("html.disable")); + return this; } } @@ -1099,6 +1102,9 @@ } else { setText(getFileChooser().getName((File)value) + "/"); } + + putClientProperty("html.disable", getFileChooser().getClientProperty("html.disable")); + return this; } } diff -Nru openjdk-17-17.0.17+10/src/java.desktop/share/classes/com/sun/java/swing/plaf/motif/MotifFileChooserUI.java openjdk-17-17.0.18+8/src/java.desktop/share/classes/com/sun/java/swing/plaf/motif/MotifFileChooserUI.java --- openjdk-17-17.0.17+10/src/java.desktop/share/classes/com/sun/java/swing/plaf/motif/MotifFileChooserUI.java 2025-10-13 07:48:04.000000000 +0000 +++ openjdk-17-17.0.18+8/src/java.desktop/share/classes/com/sun/java/swing/plaf/motif/MotifFileChooserUI.java 2026-01-15 15:23:06.000000000 +0000 @@ -664,6 +664,9 @@ super.getListCellRendererComponent(list, value, index, isSelected, cellHasFocus); setText(getFileChooser().getName((File) value)); setInheritsPopupMenu(true); + + putClientProperty("html.disable", getFileChooser().getClientProperty("html.disable")); + return this; } } @@ -676,6 +679,9 @@ super.getListCellRendererComponent(list, value, index, isSelected, cellHasFocus); setText(getFileChooser().getName((File) value)); setInheritsPopupMenu(true); + + putClientProperty("html.disable", getFileChooser().getClientProperty("html.disable")); + return this; } } diff -Nru openjdk-17-17.0.17+10/src/java.desktop/share/classes/com/sun/media/sound/AudioFileSoundbankReader.java openjdk-17-17.0.18+8/src/java.desktop/share/classes/com/sun/media/sound/AudioFileSoundbankReader.java --- openjdk-17-17.0.17+10/src/java.desktop/share/classes/com/sun/media/sound/AudioFileSoundbankReader.java 2025-10-13 07:48:04.000000000 +0000 +++ openjdk-17-17.0.18+8/src/java.desktop/share/classes/com/sun/media/sound/AudioFileSoundbankReader.java 2026-01-15 15:23:06.000000000 +0000 @@ -1,5 +1,5 @@ /* - * Copyright (c) 2007, 2021, 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 @@ -93,6 +93,13 @@ "Can not allocate enough memory to read audio data."); } + long maximumHeapSize = (long) ((Runtime.getRuntime().maxMemory() - + (Runtime.getRuntime().totalMemory() - Runtime.getRuntime().freeMemory())) * 0.9); + if (totalSize > maximumHeapSize) { + throw new InvalidMidiDataException( + "Insufficient heap size to render audio data."); + } + if (ais.getFrameLength() == -1 || totalSize > MEGABYTE) { ByteArrayOutputStream baos = new ByteArrayOutputStream(); byte[] buff = new byte[DEFAULT_BUFFER_SIZE - (DEFAULT_BUFFER_SIZE % frameSize)]; diff -Nru openjdk-17-17.0.17+10/src/java.desktop/share/classes/java/awt/AWTEventMulticaster.java openjdk-17-17.0.18+8/src/java.desktop/share/classes/java/awt/AWTEventMulticaster.java --- openjdk-17-17.0.17+10/src/java.desktop/share/classes/java/awt/AWTEventMulticaster.java 2025-10-13 07:48:04.000000000 +0000 +++ openjdk-17-17.0.18+8/src/java.desktop/share/classes/java/awt/AWTEventMulticaster.java 2026-01-15 15:23:06.000000000 +0000 @@ -110,6 +110,8 @@ TextListener, InputMethodListener, HierarchyListener, HierarchyBoundsListener, MouseWheelListener { + private static final int MAX_UNBALANCED_TOP_NODES = 100; + /** * A variable in the event chain (listener-a) */ @@ -954,6 +956,7 @@ * If listener-b is null, it returns listener-a * If neither are null, then it creates and returns * a new AWTEventMulticaster instance which chains a with b. + * * @param a event listener-a * @param b event listener-b * @return the resulting listener @@ -961,7 +964,64 @@ protected static EventListener addInternal(EventListener a, EventListener b) { if (a == null) return b; if (b == null) return a; - return new AWTEventMulticaster(a, b); + AWTEventMulticaster n = new AWTEventMulticaster(a, b); + if (!needsRebalance(n)) { + return n; + } + + EventListener[] array = getListeners(n, EventListener.class); + return rebalance(array, 0, array.length - 1); + } + + /** + * Return true if the argument represents a binary tree that needs to be rebalanced. + */ + private static boolean needsRebalance(AWTEventMulticaster l) { + int level = 0; + while (true) { + // The criteria for when we need a rebalance is subjective. This method checks + // up to a given threshold of the topmost nodes of a AWTEventMulticaster. If + // they all include one leaf node, then this method returns true. This criteria + // will be met after several consecutive iterations of `addInternal(a, b)` + if (++level > MAX_UNBALANCED_TOP_NODES) { + return true; + } + if (l.a instanceof AWTEventMulticaster aMulti) { + if (l.b instanceof AWTEventMulticaster) { + // we reached a node where both children are AWTEventMulticaster: let's assume + // the current node marks the start of a well-balanced subtree + return false; + } + l = aMulti; + } else if (l.b instanceof AWTEventMulticaster bMulti) { + l = bMulti; + } else { + return false; + } + } + } + + /** + * Recursively create a balanced tree that includes a given range of EventListeners. + * + * @param array the array of the EventListeners to consult + * @param index0 the lowest index (inclusive) that the return value must include + * @param index1 the highest index (inclusive) that the return value must include. + * + * @return a balanced tree. If index0 equals index1 then this returns an EventListener from + * the array provided. Otherwise this returns an AWTEventMulticaster. + */ + private static EventListener rebalance(EventListener[] array, int index0, int index1) { + if (index0 == index1) { + return array[index0]; + } + if (index0 == index1 - 1) { + return new AWTEventMulticaster(array[index0], array[index1]); + } + int mid = (index0 + index1) / 2; + return new AWTEventMulticaster( + rebalance(array, index0, mid), + rebalance(array, mid + 1, index1)); } /** diff -Nru openjdk-17-17.0.17+10/src/java.desktop/share/classes/java/awt/color/ICC_ColorSpace.java openjdk-17-17.0.18+8/src/java.desktop/share/classes/java/awt/color/ICC_ColorSpace.java --- openjdk-17-17.0.17+10/src/java.desktop/share/classes/java/awt/color/ICC_ColorSpace.java 2025-10-13 07:48:04.000000000 +0000 +++ openjdk-17-17.0.18+8/src/java.desktop/share/classes/java/awt/color/ICC_ColorSpace.java 2026-01-15 15:23:06.000000000 +0000 @@ -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 @@ -140,10 +140,11 @@ if (profileClass != ICC_Profile.CLASS_INPUT && profileClass != ICC_Profile.CLASS_DISPLAY && profileClass != ICC_Profile.CLASS_OUTPUT + && profileClass != ICC_Profile.CLASS_DEVICELINK && profileClass != ICC_Profile.CLASS_COLORSPACECONVERSION && profileClass != ICC_Profile.CLASS_NAMEDCOLOR && profileClass != ICC_Profile.CLASS_ABSTRACT) { - throw new IllegalArgumentException("Invalid profile type"); + throw new IllegalArgumentException("Invalid profile class"); } thisProfile = profile; diff -Nru openjdk-17-17.0.17+10/src/java.desktop/share/classes/java/awt/color/ICC_Profile.java openjdk-17-17.0.18+8/src/java.desktop/share/classes/java/awt/color/ICC_Profile.java --- openjdk-17-17.0.17+10/src/java.desktop/share/classes/java/awt/color/ICC_Profile.java 2025-10-13 07:48:04.000000000 +0000 +++ openjdk-17-17.0.18+8/src/java.desktop/share/classes/java/awt/color/ICC_Profile.java 2026-01-15 15:23:06.000000000 +0000 @@ -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 @@ -751,6 +751,7 @@ */ public static final int icXYZNumberX = 8; + private static final int HEADER_SIZE = 128; /** * Constructs an {@code ICC_Profile} object with a given ID. @@ -799,10 +800,15 @@ ProfileDataVerifier.verify(data); Profile p; try { + byte[] theHeader = new byte[HEADER_SIZE]; + System.arraycopy(data, 0, theHeader, 0, HEADER_SIZE); + verifyHeader(theHeader); + p = CMSManager.getModule().loadProfile(data); } catch (CMMException c) { throw new IllegalArgumentException("Invalid ICC Profile Data"); } + try { if (getColorSpaceType(p) == ColorSpace.TYPE_GRAY && getData(p, icSigMediaWhitePointTag) != null @@ -991,6 +997,10 @@ return info.profileClass; } byte[] theHeader = getData(icSigHead); + return getProfileClass(theHeader); + } + + private static int getProfileClass(byte[] theHeader) { int theClassSig = intFromBigEndian(theHeader, icHdrDeviceClass); return switch (theClassSig) { case icSigInputClass -> CLASS_INPUT; @@ -1032,6 +1042,11 @@ return iccCStoJCS(theColorSpaceSig); } + private static int getColorSpaceType(byte[] theHeader) { + int theColorSpaceSig = intFromBigEndian(theHeader, icHdrColorSpace); + return iccCStoJCS(theColorSpaceSig); + } + /** * Returns the color space type of the Profile Connection Space (PCS). * Returns one of the color space type constants defined by the ColorSpace @@ -1051,6 +1066,21 @@ return iccCStoJCS(thePCSSig); } + private static int getPCSType(byte[] theHeader) { + int thePCSSig = intFromBigEndian(theHeader, icHdrPcs); + int theDeviceClass = intFromBigEndian(theHeader, icHdrDeviceClass); + + if (theDeviceClass == icSigLinkClass) { + return iccCStoJCS(thePCSSig); + } else { + return switch (thePCSSig) { + case icSigXYZData -> ColorSpace.TYPE_XYZ; + case icSigLabData -> ColorSpace.TYPE_Lab; + default -> throw new IllegalArgumentException("Unexpected PCS type"); + }; + } + } + /** * Write this {@code ICC_Profile} to a file. * @@ -1129,9 +1159,42 @@ * @see #getData */ public void setData(int tagSignature, byte[] tagData) { + if (tagSignature == ICC_Profile.icSigHead) { + verifyHeader(tagData); + } CMSManager.getModule().setTagData(cmmProfile(), tagSignature, tagData); } + private static void verifyHeader(byte[] data) { + if (data == null || data.length < HEADER_SIZE) { + throw new IllegalArgumentException("Invalid header data"); + } + getProfileClass(data); + getColorSpaceType(data); + getPCSType(data); + checkRenderingIntent(data); + } + + private static boolean checkRenderingIntent(byte[] header) { + int index = ICC_Profile.icHdrRenderingIntent; + + /* According to ICC spec, only the least-significant 16 bits shall be + * used to encode the rendering intent. The most significant 16 bits + * shall be set to zero. Thus, we are ignoring two most significant + * bytes here. Please refer ICC Spec Document for more details. + */ + int renderingIntent = ((header[index+2] & 0xff) << 8) | + (header[index+3] & 0xff); + + switch (renderingIntent) { + case icPerceptual, icMediaRelativeColorimetric, + icSaturation, icAbsoluteColorimetric -> { + return true; + } + default -> throw new IllegalArgumentException("Unknown Rendering Intent"); + } + } + /** * Returns the number of color components in the "input" color space of this * profile. For example if the color space type of this profile is diff -Nru openjdk-17-17.0.17+10/src/java.desktop/share/classes/java/beans/Introspector.java openjdk-17-17.0.18+8/src/java.desktop/share/classes/java/beans/Introspector.java --- openjdk-17-17.0.17+10/src/java.desktop/share/classes/java/beans/Introspector.java 2025-10-13 07:48:04.000000000 +0000 +++ openjdk-17-17.0.18+8/src/java.desktop/share/classes/java/beans/Introspector.java 2026-01-15 15:23:06.000000000 +0000 @@ -1,5 +1,5 @@ /* - * Copyright (c) 1996, 2023, 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 @@ -1068,8 +1068,12 @@ } } if (match) { - MethodDescriptor composite = new MethodDescriptor(old, md); - methods.put(name, composite); + Class oldClass = old.getMethod().getDeclaringClass(); + Class mdClass = md.getMethod().getDeclaringClass(); + if (oldClass == mdClass || oldClass.isAssignableFrom(mdClass) || !mdClass.isAssignableFrom(oldClass)) { + MethodDescriptor composite = new MethodDescriptor(old, md); + methods.put(name, composite); + } return; } diff -Nru openjdk-17-17.0.17+10/src/java.desktop/share/classes/javax/swing/JFileChooser.java openjdk-17-17.0.18+8/src/java.desktop/share/classes/javax/swing/JFileChooser.java --- openjdk-17-17.0.17+10/src/java.desktop/share/classes/javax/swing/JFileChooser.java 2025-10-13 07:48:04.000000000 +0000 +++ openjdk-17-17.0.18+8/src/java.desktop/share/classes/javax/swing/JFileChooser.java 2026-01-15 15:23:06.000000000 +0000 @@ -398,6 +398,7 @@ setFileFilter(getAcceptAllFileFilter()); } enableEvents(AWTEvent.MOUSE_EVENT_MASK); + putClientProperty("html.disable", true); } private void installHierarchyListener() { diff -Nru openjdk-17-17.0.17+10/src/java.desktop/share/classes/javax/swing/JViewport.java openjdk-17-17.0.18+8/src/java.desktop/share/classes/javax/swing/JViewport.java --- openjdk-17-17.0.17+10/src/java.desktop/share/classes/javax/swing/JViewport.java 2025-10-13 07:48:04.000000000 +0000 +++ openjdk-17-17.0.18+8/src/java.desktop/share/classes/javax/swing/JViewport.java 2026-01-15 15:23:06.000000000 +0000 @@ -1,5 +1,5 @@ /* - * Copyright (c) 1997, 2020, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 1997, 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 diff -Nru openjdk-17-17.0.17+10/src/java.desktop/share/classes/javax/swing/TablePrintable.java openjdk-17-17.0.18+8/src/java.desktop/share/classes/javax/swing/TablePrintable.java --- openjdk-17-17.0.17+10/src/java.desktop/share/classes/javax/swing/TablePrintable.java 2025-10-13 07:48:04.000000000 +0000 +++ openjdk-17-17.0.18+8/src/java.desktop/share/classes/javax/swing/TablePrintable.java 2026-01-15 15:23:06.000000000 +0000 @@ -282,6 +282,9 @@ // dictated by the previous two assertions assert sf > 0; + Rectangle bounds = table.getBounds(); + bounds.x = bounds.y = 0; + // This is in a loop for two reasons: // First, it allows us to catch up in case we're called starting // with a non-zero pageIndex. Second, we know that we can be called @@ -303,9 +306,10 @@ // calculate the area of the table to be printed for this page findNextClip(scaledWidth, scaledHeight); - if (!((table.getBounds()).intersects(clip))) { + if (!(bounds.intersects(clip))) { return NO_SUCH_PAGE; } + last++; } @@ -395,11 +399,12 @@ // draw a box around the table g2d.setColor(Color.BLACK); + // compute the visible portion of table and draw the rect around it - Rectangle visibleBounds = clip.intersection(table.getBounds()); + Rectangle visibleBounds = clip.intersection(bounds); Point upperLeft = visibleBounds.getLocation(); - Point lowerRight = new Point(visibleBounds.x + visibleBounds.width, - visibleBounds.y + visibleBounds.height); + Point lowerRight = new Point(visibleBounds.x + visibleBounds.width - 1, + visibleBounds.y + visibleBounds.height - 1); int rMin = table.rowAtPoint(upperLeft); int rMax = table.rowAtPoint(lowerRight); @@ -410,7 +415,7 @@ rMax = table.getRowCount(); } int rowHeight = 0; - for(int visrow = rMin; visrow < rMax; visrow++) { + for(int visrow = rMin; visrow <= rMax; visrow++) { rowHeight += table.getRowHeight(visrow); } // If PrintMode is FIT_WIDTH, then draw rect for entire column width while diff -Nru openjdk-17-17.0.17+10/src/java.desktop/share/classes/javax/swing/border/EtchedBorder.java openjdk-17-17.0.18+8/src/java.desktop/share/classes/javax/swing/border/EtchedBorder.java --- openjdk-17-17.0.17+10/src/java.desktop/share/classes/javax/swing/border/EtchedBorder.java 2025-10-13 07:48:04.000000000 +0000 +++ openjdk-17-17.0.18+8/src/java.desktop/share/classes/javax/swing/border/EtchedBorder.java 2026-01-15 15:23:06.000000000 +0000 @@ -1,5 +1,5 @@ /* - * Copyright (c) 1997, 2022, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 1997, 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 @@ -30,10 +30,10 @@ import java.awt.Insets; import java.awt.Color; import java.awt.Component; -import java.awt.Stroke; -import java.awt.geom.AffineTransform; import java.beans.ConstructorProperties; +import com.sun.java.swing.SwingUtilities3; + /** * A class which implements a simple etched border which can * either be etched-in or etched-out. If no highlight/shadow @@ -150,59 +150,26 @@ * @param height the height of the painted border */ public void paintBorder(Component c, Graphics g, int x, int y, int width, int height) { - // We remove any initial transforms to prevent rounding errors - // when drawing in non-integer scales - AffineTransform at = null; - Stroke oldStk = null; - int stkWidth = 1; - boolean resetTransform = false; - if (g instanceof Graphics2D) { - Graphics2D g2d = (Graphics2D) g; - at = g2d.getTransform(); - oldStk = g2d.getStroke(); - // if m01 or m10 is non-zero, then there is a rotation or shear - // skip resetting the transform - resetTransform = (at.getShearX() == 0) && (at.getShearY() == 0); - if (resetTransform) { - g2d.setTransform(new AffineTransform()); - stkWidth = (int) Math.floor(Math.min(at.getScaleX(), at.getScaleY())); - g2d.setStroke(new BasicStroke((float) stkWidth)); - } - } + SwingUtilities3.paintBorder(c, g, + x, y, + width, height, + this::paintUnscaledBorder); + } - int w; - int h; - int xtranslation; - int ytranslation; - if (resetTransform) { - w = (int) Math.floor(at.getScaleX() * width - 1); - h = (int) Math.floor(at.getScaleY() * height - 1); - xtranslation = (int) Math.ceil(at.getScaleX()*x+at.getTranslateX()); - ytranslation = (int) Math.ceil(at.getScaleY()*y+at.getTranslateY()); - } else { - w = width; - h = height; - xtranslation = x; - ytranslation = y; + private void paintUnscaledBorder(Component c, Graphics g, + int w, int h, + double scaleFactor) { + int stkWidth = (int) Math.floor(scaleFactor); + if (g instanceof Graphics2D) { + ((Graphics2D) g).setStroke(new BasicStroke((float) stkWidth)); } - g.translate(xtranslation, ytranslation); - paintBorderShadow(g, (etchType == LOWERED) ? getHighlightColor(c) : getShadowColor(c), w, h, stkWidth); paintBorderHighlight(g, (etchType == LOWERED) ? getShadowColor(c) : getHighlightColor(c), w, h, stkWidth); - - g.translate(-xtranslation, -ytranslation); - - // Set the transform we removed earlier - if (resetTransform) { - Graphics2D g2d = (Graphics2D) g; - g2d.setTransform(at); - g2d.setStroke(oldStk); - } } /** diff -Nru openjdk-17-17.0.17+10/src/java.desktop/share/classes/javax/swing/border/LineBorder.java openjdk-17-17.0.18+8/src/java.desktop/share/classes/javax/swing/border/LineBorder.java --- openjdk-17-17.0.17+10/src/java.desktop/share/classes/javax/swing/border/LineBorder.java 2025-10-13 07:48:04.000000000 +0000 +++ openjdk-17-17.0.18+8/src/java.desktop/share/classes/javax/swing/border/LineBorder.java 2026-01-15 15:23:06.000000000 +0000 @@ -1,5 +1,5 @@ /* - * Copyright (c) 1997, 2022, 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 @@ -34,7 +34,8 @@ import java.awt.geom.Rectangle2D; import java.awt.geom.RoundRectangle2D; import java.beans.ConstructorProperties; -import java.awt.geom.AffineTransform; + +import com.sun.java.swing.SwingUtilities3; import static sun.java2d.pipe.Region.clipRound; @@ -144,73 +145,41 @@ * @param height the height of the painted border */ public void paintBorder(Component c, Graphics g, int x, int y, int width, int height) { + SwingUtilities3.paintBorder(c, g, + x, y, + width, height, + this::paintUnscaledBorder); + } + + private void paintUnscaledBorder(Component c, Graphics g, + int w, int h, + double scaleFactor) { if ((this.thickness > 0) && (g instanceof Graphics2D)) { Graphics2D g2d = (Graphics2D) g; - AffineTransform at = g2d.getTransform(); - - // if m01 or m10 is non-zero, then there is a rotation or shear - // or if no Scaling enabled, - // skip resetting the transform - boolean resetTransform = ((at.getShearX() == 0) && (at.getShearY() == 0)) && - ((at.getScaleX() > 1) || (at.getScaleY() > 1)); - - int xtranslation; - int ytranslation; - int w; - int h; - int offs; - - if (resetTransform) { - /* Deactivate the HiDPI scaling transform, - * so we can do paint operations in the device - * pixel coordinate system instead of the logical coordinate system. - */ - g2d.setTransform(new AffineTransform()); - double xx = at.getScaleX() * x + at.getTranslateX(); - double yy = at.getScaleY() * y + at.getTranslateY(); - xtranslation = clipRound(xx); - ytranslation = clipRound(yy); - w = clipRound(at.getScaleX() * width + xx) - xtranslation; - h = clipRound(at.getScaleY() * height + yy) - ytranslation; - offs = this.thickness * (int) at.getScaleX(); - } else { - w = width; - h = height; - xtranslation = x; - ytranslation = y; - offs = this.thickness; - } - - g2d.translate(xtranslation, ytranslation); - Color oldColor = g2d.getColor(); g2d.setColor(this.lineColor); Shape outer; Shape inner; + int offs = clipRound(this.thickness * scaleFactor); int size = offs + offs; if (this.roundedCorners) { float arc = .2f * offs; outer = new RoundRectangle2D.Float(0, 0, w, h, offs, offs); inner = new RoundRectangle2D.Float(offs, offs, w - size, h - size, arc, arc); - } - else { + } else { outer = new Rectangle2D.Float(0, 0, w, h); inner = new Rectangle2D.Float(offs, offs, w - size, h - size); } + Path2D path = new Path2D.Float(Path2D.WIND_EVEN_ODD); path.append(outer, false); path.append(inner, false); g2d.fill(path); - g2d.setColor(oldColor); - g2d.translate(-xtranslation, -ytranslation); - - if (resetTransform) { - g2d.setTransform(at); - } + g2d.setColor(oldColor); } } diff -Nru openjdk-17-17.0.17+10/src/java.desktop/share/classes/javax/swing/plaf/basic/BasicOptionPaneUI.java openjdk-17-17.0.18+8/src/java.desktop/share/classes/javax/swing/plaf/basic/BasicOptionPaneUI.java --- openjdk-17-17.0.17+10/src/java.desktop/share/classes/javax/swing/plaf/basic/BasicOptionPaneUI.java 2025-10-13 07:48:04.000000000 +0000 +++ openjdk-17-17.0.18+8/src/java.desktop/share/classes/javax/swing/plaf/basic/BasicOptionPaneUI.java 2026-01-15 15:23:06.000000000 +0000 @@ -456,79 +456,54 @@ } else if ((nl = s.indexOf('\n')) >= 0) { nll = 1; } - if (s.contains("")) { - /* line break in html text is done by
tag - * and not by /n so it's incorrect to address newline - * same as non-html text. - * Text between tags are extracted - * and rendered as JLabel text - */ - int index1 = s.indexOf(""); - int index2 = s.indexOf(""); - String str = ""; - if (index2 >= 0) { - str = s.substring(index2 + "".length()); - s = s.substring(index1, index2 + + "".length()); + if (nl >= 0) { + // break up newlines + if (nl == 0) { + JPanel breakPanel = new JPanel() { + public Dimension getPreferredSize() { + Font f = getFont(); + + if (f != null) { + return new Dimension(1, f.getSize() + 2); + } + return new Dimension(0, 0); + } + }; + breakPanel.setName("OptionPane.break"); + addMessageComponents(container, cons, breakPanel, maxll, + true); + } else { + addMessageComponents(container, cons, s.substring(0, nl), + maxll, false); + } + // Prevent recursion of more than + // 200 successive newlines in a message + // and indicate message is truncated via ellipsis + if (recursionCount++ > 200) { + recursionCount = 0; + addMessageComponents(container, cons, new String("..."), + maxll, false); + return; } - JLabel label; - label = new JLabel(s, JLabel.LEADING); + addMessageComponents(container, cons, s.substring(nl + nll), maxll, + false); + + } else if (len > maxll) { + Container c = Box.createVerticalBox(); + c.setName("OptionPane.verticalBox"); + burstStringInto(c, s, maxll); + addMessageComponents(container, cons, c, maxll, true); + + } else { + JLabel label = new JLabel(); if (Boolean.TRUE.equals( - this.optionPane.getClientProperty("html.disable"))) { + optionPane.getClientProperty("html.disable"))) { label.putClientProperty("html.disable", true); } + label.setText(s); label.setName("OptionPane.label"); configureMessageLabel(label); addMessageComponents(container, cons, label, maxll, true); - if (!str.isEmpty()) { - addMessageComponents(container, cons, str, maxll, false); - } - } else { - if (nl >= 0) { - // break up newlines - if (nl == 0) { - @SuppressWarnings("serial") // anonymous class - JPanel breakPanel = new JPanel() { - public Dimension getPreferredSize() { - Font f = getFont(); - - if (f != null) { - return new Dimension(1, f.getSize() + 2); - } - return new Dimension(0, 0); - } - }; - breakPanel.setName("OptionPane.break"); - addMessageComponents(container, cons, breakPanel, maxll, - true); - } else { - addMessageComponents(container, cons, s.substring(0, nl), - maxll, false); - } - // Prevent recursion of more than - // 200 successive newlines in a message - // and indicate message is truncated via ellipsis - if (recursionCount++ > 200) { - recursionCount = 0; - addMessageComponents(container, cons, new String("..."), - maxll, false); - return; - } - addMessageComponents(container, cons, s.substring(nl + nll), maxll, - false); - - } else if (len > maxll) { - Container c = Box.createVerticalBox(); - c.setName("OptionPane.verticalBox"); - burstStringInto(c, s, maxll); - addMessageComponents(container, cons, c, maxll, true); - - } else { - JLabel label; - label = new JLabel(s, JLabel.LEADING); - label.setName("OptionPane.label"); - configureMessageLabel(label); - addMessageComponents(container, cons, label, maxll, true); - } } } } diff -Nru openjdk-17-17.0.17+10/src/java.desktop/share/classes/javax/swing/plaf/basic/BasicPasswordFieldUI.java openjdk-17-17.0.18+8/src/java.desktop/share/classes/javax/swing/plaf/basic/BasicPasswordFieldUI.java --- openjdk-17-17.0.17+10/src/java.desktop/share/classes/javax/swing/plaf/basic/BasicPasswordFieldUI.java 2025-10-13 07:48:04.000000000 +0000 +++ openjdk-17-17.0.18+8/src/java.desktop/share/classes/javax/swing/plaf/basic/BasicPasswordFieldUI.java 2026-01-15 15:23:06.000000000 +0000 @@ -1,5 +1,5 @@ /* - * Copyright (c) 1997, 2006, 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 @@ -91,23 +91,4 @@ public View create(Element elem) { return new PasswordView(elem); } - - /** - * Create the action map for Password Field. This map provides - * same actions for double mouse click and - * and for triple mouse click (see bug 4231444). - */ - - ActionMap createActionMap() { - ActionMap map = super.createActionMap(); - if (map.get(DefaultEditorKit.selectWordAction) != null) { - Action a = map.get(DefaultEditorKit.selectLineAction); - if (a != null) { - map.remove(DefaultEditorKit.selectWordAction); - map.put(DefaultEditorKit.selectWordAction, a); - } - } - return map; - } - } diff -Nru openjdk-17-17.0.17+10/src/java.desktop/share/classes/javax/swing/plaf/basic/BasicTableUI.java openjdk-17-17.0.18+8/src/java.desktop/share/classes/javax/swing/plaf/basic/BasicTableUI.java --- openjdk-17-17.0.17+10/src/java.desktop/share/classes/javax/swing/plaf/basic/BasicTableUI.java 2025-10-13 07:48:04.000000000 +0000 +++ openjdk-17-17.0.18+8/src/java.desktop/share/classes/javax/swing/plaf/basic/BasicTableUI.java 2026-01-15 15:23:06.000000000 +0000 @@ -1884,23 +1884,6 @@ comp = comp.getParent(); } - if (comp != null && !(comp instanceof JViewport) && !(comp instanceof JScrollPane)) { - // We did rMax-1 to paint the same number of rows that are drawn on console - // otherwise 1 extra row is printed per page than that are displayed - // when there is no scrollPane and we do printing of table - // but not when rmax is already pointing to index of last row - // and if there is any selected rows - if (rMax != (table.getRowCount() - 1) && - (table.getSelectedRow() == -1)) { - // Do not decrement rMax if rMax becomes - // less than or equal to rMin - // else cells will not be painted - if (rMax - rMin > 1) { - rMax = rMax - 1; - } - } - } - // Paint the grid. paintGrid(g, rMin, rMax, cMin, cMax); diff -Nru openjdk-17-17.0.17+10/src/java.desktop/share/classes/javax/swing/plaf/basic/BasicTextUI.java openjdk-17-17.0.18+8/src/java.desktop/share/classes/javax/swing/plaf/basic/BasicTextUI.java --- openjdk-17-17.0.17+10/src/java.desktop/share/classes/javax/swing/plaf/basic/BasicTextUI.java 2025-10-13 07:48:04.000000000 +0000 +++ openjdk-17-17.0.18+8/src/java.desktop/share/classes/javax/swing/plaf/basic/BasicTextUI.java 2026-01-15 15:23:06.000000000 +0000 @@ -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 @@ -650,6 +650,22 @@ TransferHandler.getCopyAction()); map.put(TransferHandler.getPasteAction().getValue(Action.NAME), TransferHandler.getPasteAction()); + + if (getComponent() instanceof JPasswordField) { + // Edit the action map for Password Field. This map provides + // same actions for double mouse click and + // and for triple mouse click (see bugs 4231444, 8354646). + + if (map.get(DefaultEditorKit.selectWordAction) != null) { + map.remove(DefaultEditorKit.selectWordAction); + + Action a = map.get(DefaultEditorKit.selectLineAction); + if (a != null) { + map.put(DefaultEditorKit.selectWordAction, a); + } + } + } + return map; } diff -Nru openjdk-17-17.0.17+10/src/java.desktop/share/classes/javax/swing/plaf/metal/MetalBorders.java openjdk-17-17.0.18+8/src/java.desktop/share/classes/javax/swing/plaf/metal/MetalBorders.java --- openjdk-17-17.0.17+10/src/java.desktop/share/classes/javax/swing/plaf/metal/MetalBorders.java 2025-10-13 07:48:04.000000000 +0000 +++ openjdk-17-17.0.18+8/src/java.desktop/share/classes/javax/swing/plaf/metal/MetalBorders.java 2026-01-15 15:23:06.000000000 +0000 @@ -1,5 +1,5 @@ /* - * Copyright (c) 1998, 2022, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 1998, 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 @@ -33,9 +33,7 @@ import java.awt.Graphics; import java.awt.Graphics2D; import java.awt.Insets; -import java.awt.Stroke; import java.awt.Window; -import java.awt.geom.AffineTransform; import javax.swing.AbstractButton; import javax.swing.ButtonModel; @@ -62,6 +60,7 @@ import javax.swing.plaf.basic.BasicBorders; import javax.swing.text.JTextComponent; +import com.sun.java.swing.SwingUtilities3; import sun.swing.StringUIClientPropertyKey; import sun.swing.SwingUtilities2; @@ -251,6 +250,14 @@ public void paintBorder(Component c, Graphics g, int x, int y, int w, int h) { + SwingUtilities3.paintBorder(c, g, + x, y, w, h, + this::paintUnscaledBorder); + } + + private void paintUnscaledBorder(Component c, Graphics g, + int width, int height, + double scaleFactor) { Color background; Color highlight; Color shadow; @@ -265,48 +272,6 @@ shadow = MetalLookAndFeel.getControlInfo(); } - AffineTransform at = null; - Stroke oldStk = null; - boolean resetTransform = false; - int stkWidth = 1; - double scaleFactor = 1; - - if (g instanceof Graphics2D g2d) { - at = g2d.getTransform(); - scaleFactor = at.getScaleX(); - oldStk = g2d.getStroke(); - - // if m01 or m10 is non-zero, then there is a rotation or shear - // skip resetting the transform - resetTransform = ((at.getShearX() == 0) && (at.getShearY() == 0)); - - if (resetTransform) { - g2d.setTransform(new AffineTransform()); - stkWidth = clipRound(Math.min(at.getScaleX(), at.getScaleY())); - g2d.setStroke(new BasicStroke((float) stkWidth)); - } - } - - int xtranslation; - int ytranslation; - int width; - int height; - - if (resetTransform) { - double xx = at.getScaleX() * x + at.getTranslateX(); - double yy = at.getScaleY() * y + at.getTranslateY(); - xtranslation = clipRound(xx); - ytranslation = clipRound(yy); - width = clipRound(at.getScaleX() * w + xx) - xtranslation; - height = clipRound(at.getScaleY() * h + yy) - ytranslation; - } else { - xtranslation = x; - ytranslation = y; - width = w; - height = h; - } - g.translate(xtranslation, ytranslation); - // scaled border int thickness = (int) Math.ceil(4 * scaleFactor); @@ -320,12 +285,17 @@ // midpoint at which highlight & shadow lines // are positioned on the border int midPoint = thickness / 2; + int stkWidth = clipRound(scaleFactor); int offset = (((scaleFactor - stkWidth) >= 0) && ((stkWidth % 2) != 0)) ? 1 : 0; int loc1 = thickness % 2 == 0 ? midPoint + stkWidth / 2 - stkWidth : midPoint; int loc2 = thickness % 2 == 0 ? midPoint + stkWidth / 2 : midPoint + stkWidth; // scaled corner int corner = (int) Math.round(CORNER * scaleFactor); + if (g instanceof Graphics2D) { + ((Graphics2D) g).setStroke(new BasicStroke((float) stkWidth)); + } + // Draw the Long highlight lines g.setColor(highlight); g.drawLine(corner + 1, loc2, width - corner, loc2); //top @@ -344,14 +314,6 @@ g.drawLine(corner, (height - offset) - loc2, width - corner - 1, (height - offset) - loc2); } - - // restore previous transform - g.translate(-xtranslation, -ytranslation); - if (resetTransform) { - Graphics2D g2d = (Graphics2D) g; - g2d.setTransform(at); - g2d.setStroke(oldStk); - } } public Insets getBorderInsets(Component c, Insets newInsets) { diff -Nru openjdk-17-17.0.17+10/src/java.desktop/share/classes/javax/swing/plaf/metal/MetalFileChooserUI.java openjdk-17-17.0.18+8/src/java.desktop/share/classes/javax/swing/plaf/metal/MetalFileChooserUI.java --- openjdk-17-17.0.17+10/src/java.desktop/share/classes/javax/swing/plaf/metal/MetalFileChooserUI.java 2025-10-13 07:48:04.000000000 +0000 +++ openjdk-17-17.0.18+8/src/java.desktop/share/classes/javax/swing/plaf/metal/MetalFileChooserUI.java 2026-01-15 15:23:06.000000000 +0000 @@ -953,6 +953,8 @@ ii.depth = directoryComboBoxModel.getDepth(index); setIcon(ii); + putClientProperty("html.disable", getFileChooser().getClientProperty("html.disable")); + return this; } } diff -Nru openjdk-17-17.0.17+10/src/java.desktop/share/classes/javax/swing/plaf/synth/SynthPasswordFieldUI.java openjdk-17-17.0.18+8/src/java.desktop/share/classes/javax/swing/plaf/synth/SynthPasswordFieldUI.java --- openjdk-17-17.0.17+10/src/java.desktop/share/classes/javax/swing/plaf/synth/SynthPasswordFieldUI.java 2025-10-13 07:48:04.000000000 +0000 +++ openjdk-17-17.0.18+8/src/java.desktop/share/classes/javax/swing/plaf/synth/SynthPasswordFieldUI.java 2026-01-15 15:23:06.000000000 +0000 @@ -1,5 +1,5 @@ /* - * Copyright (c) 2002, 2013, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2002, 2025, Oracle and/or its affiliates. All rights reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * * This code is free software; you can redistribute it and/or modify it @@ -95,19 +95,4 @@ int y, int w, int h) { context.getPainter().paintPasswordFieldBorder(context, g, x, y, w, h); } - - /** - * {@inheritDoc} - */ - @Override - protected void installKeyboardActions() { - super.installKeyboardActions(); - ActionMap map = SwingUtilities.getUIActionMap(getComponent()); - if (map != null && map.get(DefaultEditorKit.selectWordAction) != null) { - Action a = map.get(DefaultEditorKit.selectLineAction); - if (a != null) { - map.put(DefaultEditorKit.selectWordAction, a); - } - } - } } diff -Nru openjdk-17-17.0.17+10/src/java.desktop/share/classes/sun/awt/datatransfer/SunClipboard.java openjdk-17-17.0.18+8/src/java.desktop/share/classes/sun/awt/datatransfer/SunClipboard.java --- openjdk-17-17.0.17+10/src/java.desktop/share/classes/sun/awt/datatransfer/SunClipboard.java 2025-10-13 07:48:04.000000000 +0000 +++ openjdk-17-17.0.18+8/src/java.desktop/share/classes/sun/awt/datatransfer/SunClipboard.java 2026-01-15 15:23:06.000000000 +0000 @@ -1,5 +1,5 @@ /* - * Copyright (c) 1999, 2015, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 1999, 2025, Oracle and/or its affiliates. All rights reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * * This code is free software; you can redistribute it and/or modify it @@ -204,8 +204,9 @@ byte[] data = null; Transferable localeTransferable = null; + openClipboard(null); + try { - openClipboard(null); long[] formats = getClipboardFormats(); Long lFormat = DataTransferer.getInstance(). @@ -318,12 +319,7 @@ * @since 1.5 */ protected long[] getClipboardFormatsOpenClose() { - try { - openClipboard(null); - return getClipboardFormats(); - } finally { - closeClipboard(); - } + return getClipboardFormats(); } /** @@ -356,15 +352,7 @@ flavorListeners.add(listener); if (numberOfFlavorListeners++ == 0) { - long[] currentFormats = null; - try { - openClipboard(null); - currentFormats = getClipboardFormats(); - } catch (final IllegalStateException ignored) { - } finally { - closeClipboard(); - } - this.currentFormats = currentFormats; + this.currentFormats = getClipboardFormats(); registerClipboardViewerChecked(); } diff -Nru openjdk-17-17.0.17+10/src/java.desktop/share/classes/sun/java2d/SunGraphics2D.java openjdk-17-17.0.18+8/src/java.desktop/share/classes/sun/java2d/SunGraphics2D.java --- openjdk-17-17.0.17+10/src/java.desktop/share/classes/sun/java2d/SunGraphics2D.java 2025-10-13 07:48:04.000000000 +0000 +++ openjdk-17-17.0.18+8/src/java.desktop/share/classes/sun/java2d/SunGraphics2D.java 2026-01-15 15:23:06.000000000 +0000 @@ -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 @@ -1903,9 +1903,9 @@ if (usrClip == null) { clipState = CLIP_DEVICE; clipRegion = devClip; - } else if (usrClip instanceof Rectangle2D) { + } else if (usrClip instanceof Rectangle2D clip) { clipState = CLIP_RECTANGULAR; - clipRegion = devClip.getIntersection((Rectangle2D) usrClip); + clipRegion = devClip.getIntersection(clip); } else { PathIterator cpi = usrClip.getPathIterator(null); int[] box = new int[4]; diff -Nru openjdk-17-17.0.17+10/src/java.desktop/share/classes/sun/java2d/pipe/SpanClipRenderer.java openjdk-17-17.0.18+8/src/java.desktop/share/classes/sun/java2d/pipe/SpanClipRenderer.java --- openjdk-17-17.0.17+10/src/java.desktop/share/classes/sun/java2d/pipe/SpanClipRenderer.java 2025-10-13 07:48:04.000000000 +0000 +++ openjdk-17-17.0.18+8/src/java.desktop/share/classes/sun/java2d/pipe/SpanClipRenderer.java 2026-01-15 15:23:06.000000000 +0000 @@ -1,5 +1,5 @@ /* - * Copyright (c) 1998, 2018, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 1998, 2025, Oracle and/or its affiliates. All rights reserved. * 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,8 @@ import java.awt.Rectangle; import java.awt.Shape; + +import sun.java2d.InvalidPipeException; import sun.java2d.SunGraphics2D; /** @@ -67,7 +69,9 @@ public Object startSequence(SunGraphics2D sg, Shape s, Rectangle devR, int[] abox) { RegionIterator ri = sg.clipRegion.getIterator(); - + if (ri.region.isRectangular()) { + throw new InvalidPipeException("Invalid clip data"); + } return new SCRcontext(ri, outpipe.startSequence(sg, s, devR, abox)); } diff -Nru openjdk-17-17.0.17+10/src/java.desktop/share/classes/sun/print/PathGraphics.java openjdk-17-17.0.18+8/src/java.desktop/share/classes/sun/print/PathGraphics.java --- openjdk-17-17.0.17+10/src/java.desktop/share/classes/sun/print/PathGraphics.java 2025-10-13 07:48:04.000000000 +0000 +++ openjdk-17-17.0.18+8/src/java.desktop/share/classes/sun/print/PathGraphics.java 2026-01-15 15:23:06.000000000 +0000 @@ -1,5 +1,5 @@ /* - * Copyright (c) 1998, 2018, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 1998, 2024, Oracle and/or its affiliates. All rights reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * * This code is free software; you can redistribute it and/or modify it @@ -69,6 +69,7 @@ import java.awt.image.DataBufferInt; import java.awt.image.ImageObserver; import java.awt.image.IndexColorModel; +import java.awt.image.MultiResolutionImage; import java.awt.image.Raster; import java.awt.image.RenderedImage; import java.awt.image.SampleModel; @@ -1138,6 +1139,9 @@ // VI needs to make a new BI: this is unavoidable but // I don't expect VI's to be "huge" in any case. return ((VolatileImage)img).getSnapshot(); + } else if (img instanceof MultiResolutionImage) { + return convertToBufferedImage((MultiResolutionImage) img, + img.getWidth(null), img.getHeight(null)); } else { // may be null or may be some non-standard Image which // shouldn't happen as Image is implemented by the platform @@ -1148,6 +1152,18 @@ } } + protected BufferedImage convertToBufferedImage(MultiResolutionImage multiResolutionImage, + double width, double height ) { + Image resolutionImage = multiResolutionImage.getResolutionVariant(width, height); + BufferedImage bufferedImage = new BufferedImage(resolutionImage.getWidth(null), + resolutionImage.getHeight(null), + BufferedImage.TYPE_INT_ARGB); + Graphics2D g2d = bufferedImage.createGraphics(); + g2d.drawImage(resolutionImage, 0, 0, (int) width, (int) height, null); + g2d.dispose(); + return bufferedImage; + } + /** * Return true if the BufferedImage argument has non-opaque * bits in it and therefore can not be directly rendered by diff -Nru openjdk-17-17.0.17+10/src/java.desktop/share/classes/sun/swing/FilePane.java openjdk-17-17.0.18+8/src/java.desktop/share/classes/sun/swing/FilePane.java --- openjdk-17-17.0.17+10/src/java.desktop/share/classes/sun/swing/FilePane.java 2025-10-13 07:48:04.000000000 +0000 +++ openjdk-17-17.0.18+8/src/java.desktop/share/classes/sun/swing/FilePane.java 2026-01-15 15:23:06.000000000 +0000 @@ -1214,6 +1214,8 @@ setText(text); + putClientProperty("html.disable", getFileChooser().getClientProperty("html.disable")); + return this; } } @@ -1602,6 +1604,8 @@ } } + putClientProperty("html.disable", getFileChooser().getClientProperty("html.disable")); + return this; } } diff -Nru openjdk-17-17.0.17+10/src/java.desktop/share/classes/sun/swing/SwingUtilities2.java openjdk-17-17.0.18+8/src/java.desktop/share/classes/sun/swing/SwingUtilities2.java --- openjdk-17-17.0.17+10/src/java.desktop/share/classes/sun/swing/SwingUtilities2.java 2025-10-13 07:48:04.000000000 +0000 +++ openjdk-17-17.0.18+8/src/java.desktop/share/classes/sun/swing/SwingUtilities2.java 2026-01-15 15:23:06.000000000 +0000 @@ -1,5 +1,5 @@ /* - * Copyright (c) 2002, 2021, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2002, 2024, Oracle and/or its affiliates. All rights reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * * This code is free software; you can redistribute it and/or modify it diff -Nru openjdk-17-17.0.17+10/src/java.desktop/share/classes/sun/swing/plaf/synth/SynthFileChooserUIImpl.java openjdk-17-17.0.18+8/src/java.desktop/share/classes/sun/swing/plaf/synth/SynthFileChooserUIImpl.java --- openjdk-17-17.0.17+10/src/java.desktop/share/classes/sun/swing/plaf/synth/SynthFileChooserUIImpl.java 2025-10-13 07:48:04.000000000 +0000 +++ openjdk-17-17.0.18+8/src/java.desktop/share/classes/sun/swing/plaf/synth/SynthFileChooserUIImpl.java 2026-01-15 15:23:06.000000000 +0000 @@ -692,6 +692,8 @@ ii.depth = directoryComboBoxModel.getDepth(index); label.setIcon(ii); + label.putClientProperty("html.disable", getFileChooser().getClientProperty("html.disable")); + return label; } } diff -Nru openjdk-17-17.0.17+10/src/java.desktop/share/legal/libpng.md openjdk-17-17.0.18+8/src/java.desktop/share/legal/libpng.md --- openjdk-17-17.0.17+10/src/java.desktop/share/legal/libpng.md 2025-10-13 07:48:04.000000000 +0000 +++ openjdk-17-17.0.18+8/src/java.desktop/share/legal/libpng.md 2026-01-15 15:23:06.000000000 +0000 @@ -1,4 +1,4 @@ -## libpng v1.6.47 +## libpng v1.6.51 ### libpng License
@@ -9,7 +9,7 @@
 PNG Reference Library License version 2
 ---------------------------------------
 
-Copyright (c) 1995-2025 The PNG Reference Library Authors.
+Copyright (C) 1995-2025 The PNG Reference Library Authors.
 Copyright (C) 2018-2025 Cosmin Truta
 Copyright (C) 1998-2018 Glenn Randers-Pehrson
 Copyright (C) 1996-1997 Andreas Dilger
@@ -173,6 +173,7 @@
  * Lucas Chollet
  * Magnus Holmgren
  * Mandar Sahastrabuddhe
+ * Manfred Schlaegl
  * Mans Rullgard
  * Matt Sarett
  * Mike Klein
@@ -184,6 +185,7 @@
  * Samuel Williams
  * Simon-Pierre Cadieux
  * Tim Wegner
+ * Tobias Stoeckmann
  * Tom Lane
  * Tom Tanner
  * Vadim Barkov
@@ -193,8 +195,9 @@
     - Zixu Wang (王子旭)
  * Arm Holdings
     - Richard Townsend
- * Google Inc.
+ * Google LLC
     - Dan Field
+    - Dragoș Tiselice
     - Leon Scroggins III
     - Matt Sarett
     - Mike Klein
@@ -204,6 +207,8 @@
     - GuXiWei (顾希伟)
     - JinBo (金波)
     - ZhangLixia (张利霞)
+ * Samsung Group
+    - Filip Wasil
 
 The build projects, the build scripts, the test scripts, and other
 files in the "projects", "scripts" and "tests" directories, have
@@ -214,3 +219,4 @@
 other copyright owners, and are released under other open source
 licenses.
 ```
+
diff -Nru openjdk-17-17.0.17+10/src/java.desktop/share/native/common/java2d/opengl/OGLContext.c openjdk-17-17.0.18+8/src/java.desktop/share/native/common/java2d/opengl/OGLContext.c
--- openjdk-17-17.0.17+10/src/java.desktop/share/native/common/java2d/opengl/OGLContext.c	2025-10-13 07:48:04.000000000 +0000
+++ openjdk-17-17.0.18+8/src/java.desktop/share/native/common/java2d/opengl/OGLContext.c	2026-01-15 15:23:06.000000000 +0000
@@ -484,6 +484,7 @@
     if (oglc->xformMatrix == NULL) {
         size_t arrsize = 16 * sizeof(GLdouble);
         oglc->xformMatrix = (GLdouble *)malloc(arrsize);
+        RETURN_IF_NULL(oglc->xformMatrix);
         memset(oglc->xformMatrix, 0, arrsize);
         oglc->xformMatrix[10] = 1.0;
         oglc->xformMatrix[15] = 1.0;
diff -Nru openjdk-17-17.0.17+10/src/java.desktop/share/native/libmlib_image/mlib_ImageConvMxN_Fp.c openjdk-17-17.0.18+8/src/java.desktop/share/native/libmlib_image/mlib_ImageConvMxN_Fp.c
--- openjdk-17-17.0.17+10/src/java.desktop/share/native/libmlib_image/mlib_ImageConvMxN_Fp.c	2025-10-13 07:48:04.000000000 +0000
+++ openjdk-17-17.0.18+8/src/java.desktop/share/native/libmlib_image/mlib_ImageConvMxN_Fp.c	2026-01-15 15:23:06.000000000 +0000
@@ -1,5 +1,5 @@
 /*
- * Copyright (c) 2003, 2020, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 2003, 2025, Oracle and/or its affiliates. All rights reserved.
  * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
  *
  * This code is free software; you can redistribute it and/or modify it
@@ -76,6 +76,7 @@
 #include "mlib_ImageCheck.h"
 #include "mlib_SysMath.h"
 #include "mlib_ImageConv.h"
+#include "safe_math.h"
 
 /***************************************************************/
 static void mlib_ImageConvMxNMulAdd_F32(mlib_f32       *dst,
@@ -272,6 +273,9 @@
   mlib_s32 nch = mlib_ImageGetChannels(dst);
   mlib_s32 i, j, j1, k;
 
+  if (!SAFE_TO_MULT(3, wid_e) || !SAFE_TO_ADD(3 * wid_e, m)) {
+    return MLIB_FAILURE;
+  }
   if (3 * wid_e + m > 1024) {
     dsa = mlib_malloc((3 * wid_e + m) * sizeof(mlib_d64));
 
@@ -629,6 +633,9 @@
   mlib_s32 nch = mlib_ImageGetChannels(dst);
   mlib_s32 i, j, j1, k;
 
+  if (!SAFE_TO_MULT(3, wid_e) || !SAFE_TO_ADD(3 * wid_e, m)) {
+    return MLIB_FAILURE;
+  }
   if (3 * wid_e + m > 1024) {
     dsa = mlib_malloc((3 * wid_e + m) * sizeof(mlib_d64));
 
diff -Nru openjdk-17-17.0.17+10/src/java.desktop/share/native/libmlib_image/mlib_ImageConvMxN_ext.c openjdk-17-17.0.18+8/src/java.desktop/share/native/libmlib_image/mlib_ImageConvMxN_ext.c
--- openjdk-17-17.0.17+10/src/java.desktop/share/native/libmlib_image/mlib_ImageConvMxN_ext.c	2025-10-13 07:48:04.000000000 +0000
+++ openjdk-17-17.0.18+8/src/java.desktop/share/native/libmlib_image/mlib_ImageConvMxN_ext.c	2026-01-15 15:23:06.000000000 +0000
@@ -1,5 +1,5 @@
 /*
- * Copyright (c) 2003, 2020, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 2003, 2025, Oracle and/or its affiliates. All rights reserved.
  * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
  *
  * This code is free software; you can redistribute it and/or modify it
@@ -82,6 +82,7 @@
 
 #include "mlib_image.h"
 #include "mlib_ImageConv.h"
+#include "safe_math.h"
 
 /***************************************************************/
 static void mlib_ImageConvMxNMulAdd_S32(mlib_d64       *dst,
@@ -229,6 +230,9 @@
 
   /* internal buffer */
 
+  if (!SAFE_TO_MULT(3, wid_e) || !SAFE_TO_ADD(3 * wid_e, m)) {
+    return MLIB_FAILURE;
+  }
   if (3 * wid_e + m > 1024) {
     dsa = mlib_malloc((3 * wid_e + m) * sizeof(mlib_d64));
 
diff -Nru openjdk-17-17.0.17+10/src/java.desktop/share/native/libmlib_image/mlib_ImageConv_16ext.c openjdk-17-17.0.18+8/src/java.desktop/share/native/libmlib_image/mlib_ImageConv_16ext.c
--- openjdk-17-17.0.17+10/src/java.desktop/share/native/libmlib_image/mlib_ImageConv_16ext.c	2025-10-13 07:48:04.000000000 +0000
+++ openjdk-17-17.0.18+8/src/java.desktop/share/native/libmlib_image/mlib_ImageConv_16ext.c	2026-01-15 15:23:06.000000000 +0000
@@ -1,5 +1,5 @@
 /*
- * Copyright (c) 2003, 2020, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 2003, 2025, Oracle and/or its affiliates. All rights reserved.
  * 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 "mlib_image.h"
 #include "mlib_ImageConv.h"
 #include "mlib_c_ImageConv.h"
+#include "safe_math.h"
 
 /*
  * This define switches between functions of different data types
@@ -260,8 +261,14 @@
   if (max_hsize > hgt) max_hsize = hgt;
 
   shgt = hgt + (n - 1);
+  if (!SAFE_TO_ADD(max_hsize, (n - 1))) {
+    return MLIB_FAILURE;
+  }
   smax_hsize = max_hsize + (n - 1);
 
+  if (!SAFE_TO_ADD(smax_hsize, 1) || !SAFE_TO_MULT(2, (smax_hsize + 1))) {
+    return MLIB_FAILURE;
+  }
   bsize = 2 * (smax_hsize + 1);
 
   if (bsize > BUFF_SIZE) {
@@ -509,8 +516,16 @@
     FREE_AND_RETURN_STATUS;
   }
 
+  if (!SAFE_TO_ADD(wid, (m - 1))) {
+    status = MLIB_FAILURE;
+    FREE_AND_RETURN_STATUS;
+  }
   swid = wid + (m - 1);
 
+  if (!SAFE_TO_MULT((n + 3), swid)) {
+    status = MLIB_FAILURE;
+    FREE_AND_RETURN_STATUS;
+  }
   bsize = (n + 3)*swid;
 
   if ((bsize > BUFF_SIZE) || (n > MAX_N)) {
@@ -919,8 +934,14 @@
   chan1 = nchannel;
   chan2 = chan1 + chan1;
 
+  if (!SAFE_TO_ADD(wid, (m - 1))) {
+    return MLIB_FAILURE;
+  }
   swid = wid + (m - 1);
 
+  if (!SAFE_TO_MULT((n + 2), swid)) {
+    return MLIB_FAILURE;
+  }
   bsize = (n + 2)*swid;
 
   if ((bsize > BUFF_SIZE) || (n > MAX_N)) {
diff -Nru openjdk-17-17.0.17+10/src/java.desktop/share/native/libmlib_image/mlib_ImageConv_16nw.c openjdk-17-17.0.18+8/src/java.desktop/share/native/libmlib_image/mlib_ImageConv_16nw.c
--- openjdk-17-17.0.17+10/src/java.desktop/share/native/libmlib_image/mlib_ImageConv_16nw.c	2025-10-13 07:48:04.000000000 +0000
+++ openjdk-17-17.0.18+8/src/java.desktop/share/native/libmlib_image/mlib_ImageConv_16nw.c	2026-01-15 15:23:06.000000000 +0000
@@ -1,5 +1,5 @@
 /*
- * Copyright (c) 2000, 2020, 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
@@ -32,6 +32,7 @@
 
 #include "mlib_image.h"
 #include "mlib_c_ImageConv.h"
+#include "safe_math.h"
 
 /*
   This define switches between functions of different data types
@@ -466,6 +467,10 @@
     FREE_AND_RETURN_STATUS;
   }
 
+  if (!SAFE_TO_MULT((n + 3), wid)) {
+    status = MLIB_FAILURE;
+    FREE_AND_RETURN_STATUS;
+  }
   bsize = (n + 3)*wid;
 
   if ((bsize > BUFF_SIZE) || (n > MAX_N)) {
diff -Nru openjdk-17-17.0.17+10/src/java.desktop/share/native/libmlib_image/mlib_ImageConv_32nw.c openjdk-17-17.0.18+8/src/java.desktop/share/native/libmlib_image/mlib_ImageConv_32nw.c
--- openjdk-17-17.0.17+10/src/java.desktop/share/native/libmlib_image/mlib_ImageConv_32nw.c	2025-10-13 07:48:04.000000000 +0000
+++ openjdk-17-17.0.18+8/src/java.desktop/share/native/libmlib_image/mlib_ImageConv_32nw.c	2026-01-15 15:23:06.000000000 +0000
@@ -1,5 +1,5 @@
 /*
- * Copyright (c) 2000, 2020, 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
@@ -33,6 +33,7 @@
 
 #include "mlib_image.h"
 #include "mlib_ImageConv.h"
+#include "safe_math.h"
 
 /***************************************************************/
 #define CACHE_SIZE (64*1024)
@@ -335,6 +336,10 @@
     FREE_AND_RETURN_STATUS;
   }
 
+  if (!SAFE_TO_MULT((n + 2), wid)) {
+    status = MLIB_FAILURE;
+    FREE_AND_RETURN_STATUS;
+  }
   bsize = (n + 2)*wid;
 
   if ((bsize > BUFF_SIZE) || (n > MAX_N)) {
diff -Nru openjdk-17-17.0.17+10/src/java.desktop/share/native/libmlib_image/mlib_ImageConv_8ext.c openjdk-17-17.0.18+8/src/java.desktop/share/native/libmlib_image/mlib_ImageConv_8ext.c
--- openjdk-17-17.0.17+10/src/java.desktop/share/native/libmlib_image/mlib_ImageConv_8ext.c	2025-10-13 07:48:04.000000000 +0000
+++ openjdk-17-17.0.18+8/src/java.desktop/share/native/libmlib_image/mlib_ImageConv_8ext.c	2026-01-15 15:23:06.000000000 +0000
@@ -1,5 +1,5 @@
 /*
- * Copyright (c) 2003, 2020, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 2003, 2025, Oracle and/or its affiliates. All rights reserved.
  * 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 "mlib_image.h"
 #include "mlib_ImageConv.h"
 #include "mlib_c_ImageConv.h"
+#include "safe_math.h"
 
 /*
  * This define switches between functions of different data types
@@ -245,8 +246,14 @@
   if (max_hsize > hgt) max_hsize = hgt;
 
   shgt = hgt + (n - 1);
+  if (!SAFE_TO_ADD(max_hsize, (n - 1))) {
+    return MLIB_FAILURE;
+  }
   smax_hsize = max_hsize + (n - 1);
 
+  if (!SAFE_TO_ADD(smax_hsize, 1) || !SAFE_TO_MULT(2, (smax_hsize + 1))) {
+    return MLIB_FAILURE;
+  }
   bsize = 2 * (smax_hsize + 1);
 
   if (bsize > BUFF_SIZE) {
@@ -494,8 +501,16 @@
     FREE_AND_RETURN_STATUS;
   }
 
+  if (!SAFE_TO_ADD(wid, (m - 1))) {
+    status = MLIB_FAILURE;
+    FREE_AND_RETURN_STATUS;
+  }
   swid = wid + (m - 1);
 
+  if (!SAFE_TO_MULT((n + 3), swid)) {
+    status = MLIB_FAILURE;
+    FREE_AND_RETURN_STATUS;
+  }
   bsize = (n + 3)*swid;
 
   if ((bsize > BUFF_SIZE) || (n > MAX_N)) {
@@ -904,8 +919,14 @@
   chan1 = nchannel;
   chan2 = chan1 + chan1;
 
+  if (!SAFE_TO_ADD(wid, (m - 1))) {
+    return MLIB_FAILURE;
+  }
   swid = wid + (m - 1);
 
+  if (!SAFE_TO_MULT((n + 2), swid)) {
+    return MLIB_FAILURE;
+  }
   bsize = (n + 2)*swid;
 
   if ((bsize > BUFF_SIZE) || (n > MAX_N)) {
diff -Nru openjdk-17-17.0.17+10/src/java.desktop/share/native/libmlib_image/mlib_ImageConv_8nw.c openjdk-17-17.0.18+8/src/java.desktop/share/native/libmlib_image/mlib_ImageConv_8nw.c
--- openjdk-17-17.0.17+10/src/java.desktop/share/native/libmlib_image/mlib_ImageConv_8nw.c	2025-10-13 07:48:04.000000000 +0000
+++ openjdk-17-17.0.18+8/src/java.desktop/share/native/libmlib_image/mlib_ImageConv_8nw.c	2026-01-15 15:23:06.000000000 +0000
@@ -1,5 +1,5 @@
 /*
- * Copyright (c) 2003, 2020, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 2003, 2025, Oracle and/or its affiliates. All rights reserved.
  * 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 "mlib_image.h"
 #include "mlib_ImageConv.h"
 #include "mlib_c_ImageConv.h"
+#include "safe_math.h"
 
 /*
   This define switches between functions of different data types
@@ -467,6 +468,10 @@
     FREE_AND_RETURN_STATUS;
   }
 
+  if (!SAFE_TO_MULT((n + 3), wid)) {
+    status = MLIB_FAILURE;
+    FREE_AND_RETURN_STATUS;
+  }
   bsize = (n + 3)*wid;
 
   if ((bsize > BUFF_SIZE) || (n > MAX_N)) {
diff -Nru openjdk-17-17.0.17+10/src/java.desktop/share/native/libmlib_image/mlib_ImageConv_u16ext.c openjdk-17-17.0.18+8/src/java.desktop/share/native/libmlib_image/mlib_ImageConv_u16ext.c
--- openjdk-17-17.0.17+10/src/java.desktop/share/native/libmlib_image/mlib_ImageConv_u16ext.c	2025-10-13 07:48:04.000000000 +0000
+++ openjdk-17-17.0.18+8/src/java.desktop/share/native/libmlib_image/mlib_ImageConv_u16ext.c	2026-01-15 15:23:06.000000000 +0000
@@ -1,5 +1,5 @@
 /*
- * Copyright (c) 2003, 2020, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 2003, 2025, Oracle and/or its affiliates. All rights reserved.
  * 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 "mlib_image.h"
 #include "mlib_ImageConv.h"
 #include "mlib_c_ImageConv.h"
+#include "safe_math.h"
 
 /*
  * This define switches between functions of different data types
@@ -270,8 +271,14 @@
   if (max_hsize > hgt) max_hsize = hgt;
 
   shgt = hgt + (n - 1);
+  if (!SAFE_TO_ADD(max_hsize, (n - 1))) {
+    return MLIB_FAILURE;
+  }
   smax_hsize = max_hsize + (n - 1);
 
+  if (!SAFE_TO_ADD(smax_hsize, 1) || !SAFE_TO_MULT(2, (smax_hsize + 1))) {
+    return MLIB_FAILURE;
+  }
   bsize = 2 * (smax_hsize + 1);
 
   if (bsize > BUFF_SIZE) {
@@ -519,8 +526,16 @@
     FREE_AND_RETURN_STATUS;
   }
 
+  if (!SAFE_TO_ADD(wid, (m - 1))) {
+    status = MLIB_FAILURE;
+    FREE_AND_RETURN_STATUS;
+  }
   swid = wid + (m - 1);
 
+  if (!SAFE_TO_MULT((n + 3), swid)) {
+    status = MLIB_FAILURE;
+    FREE_AND_RETURN_STATUS;
+  }
   bsize = (n + 3)*swid;
 
   if ((bsize > BUFF_SIZE) || (n > MAX_N)) {
@@ -927,8 +942,14 @@
   chan1 = nchannel;
   chan2 = chan1 + chan1;
 
+  if (!SAFE_TO_ADD(wid, (m - 1))) {
+    return MLIB_FAILURE;
+  }
   swid = wid + (m - 1);
 
+  if (!SAFE_TO_MULT((n + 2), swid)) {
+    return MLIB_FAILURE;
+  }
   bsize = (n + 2)*swid;
 
   if ((bsize > BUFF_SIZE) || (n > MAX_N)) {
diff -Nru openjdk-17-17.0.17+10/src/java.desktop/share/native/libmlib_image/mlib_ImageConv_u16nw.c openjdk-17-17.0.18+8/src/java.desktop/share/native/libmlib_image/mlib_ImageConv_u16nw.c
--- openjdk-17-17.0.17+10/src/java.desktop/share/native/libmlib_image/mlib_ImageConv_u16nw.c	2025-10-13 07:48:04.000000000 +0000
+++ openjdk-17-17.0.18+8/src/java.desktop/share/native/libmlib_image/mlib_ImageConv_u16nw.c	2026-01-15 15:23:06.000000000 +0000
@@ -1,5 +1,5 @@
 /*
- * Copyright (c) 2003, 2020, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 2003, 2025, Oracle and/or its affiliates. All rights reserved.
  * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
  *
  * This code is free software; you can redistribute it and/or modify it
@@ -32,6 +32,7 @@
 
 #include "mlib_image.h"
 #include "mlib_c_ImageConv.h"
+#include "safe_math.h"
 
 /*
   This define switches between functions of different data types
@@ -466,6 +467,10 @@
     FREE_AND_RETURN_STATUS;
   }
 
+  if (!SAFE_TO_MULT((n + 3), wid)) {
+    status = MLIB_FAILURE;
+    FREE_AND_RETURN_STATUS;
+  }
   bsize = (n + 3)*wid;
 
   if ((bsize > BUFF_SIZE) || (n > MAX_N)) {
diff -Nru openjdk-17-17.0.17+10/src/java.desktop/share/native/libmlib_image/mlib_ImageLookUp_Bit.c openjdk-17-17.0.18+8/src/java.desktop/share/native/libmlib_image/mlib_ImageLookUp_Bit.c
--- openjdk-17-17.0.17+10/src/java.desktop/share/native/libmlib_image/mlib_ImageLookUp_Bit.c	2025-10-13 07:48:04.000000000 +0000
+++ openjdk-17-17.0.18+8/src/java.desktop/share/native/libmlib_image/mlib_ImageLookUp_Bit.c	2026-01-15 15:23:06.000000000 +0000
@@ -1,5 +1,5 @@
 /*
- * Copyright (c) 2003, 2020, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 2003, 2025, Oracle and/or its affiliates. All rights reserved.
  * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
  *
  * This code is free software; you can redistribute it and/or modify it
@@ -50,6 +50,7 @@
 
 #include "mlib_image.h"
 #include "mlib_ImageLookUp.h"
+#include "safe_math.h"
 
 /***************************************************************/
 #define MAX_WIDTH  512
@@ -302,6 +303,9 @@
   mlib_u8  *buff = (mlib_u8*)buff_lcl, *buffs;
   mlib_u32 val0, val1;
 
+  if (!SAFE_TO_MULT(xsize, 2)) {
+    return MLIB_FAILURE;
+  }
   size = xsize * 2;
 
   if (size > MAX_WIDTH) {
@@ -440,6 +444,9 @@
   mlib_u8  *buff = (mlib_u8*)buff_lcl, *buffs;
   mlib_u32 l0, h0, v0, l1, h1, v1, l2, h2, v2;
 
+  if (!SAFE_TO_MULT(3, xsize)) {
+    return MLIB_FAILURE;
+  }
   size = 3 * xsize;
 
   if (size > MAX_WIDTH) {
@@ -583,6 +590,9 @@
   mlib_u8  *buff = (mlib_u8*)buff_lcl, *buffs;
   mlib_u32 l, h;
 
+  if (!SAFE_TO_MULT(xsize, 4)) {
+    return MLIB_FAILURE;
+  }
   size = xsize * 4;
 
   if (size > MAX_WIDTH) {
diff -Nru openjdk-17-17.0.17+10/src/java.desktop/share/native/libmlib_image/mlib_ImageScanPoly.c openjdk-17-17.0.18+8/src/java.desktop/share/native/libmlib_image/mlib_ImageScanPoly.c
--- openjdk-17-17.0.17+10/src/java.desktop/share/native/libmlib_image/mlib_ImageScanPoly.c	2025-10-13 07:48:04.000000000 +0000
+++ openjdk-17-17.0.18+8/src/java.desktop/share/native/libmlib_image/mlib_ImageScanPoly.c	2026-01-15 15:23:06.000000000 +0000
@@ -1,5 +1,5 @@
 /*
- * Copyright (c) 1997, 2020, 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
@@ -101,6 +101,11 @@
     return MLIB_FAILURE;
   }
 
+  int intSize = sizeof(mlib_s32);
+  if (!SAFE_TO_MULT(dstHeight, intSize) ||
+      !SAFE_TO_ADD(dstHeight * intSize, 7)) {
+    return MLIB_FAILURE;
+  }
   bsize0 = (dstHeight * sizeof(mlib_s32) + 7) & ~7;
 
   if (lineAddr == NULL) {
@@ -109,6 +114,10 @@
 
   param->buff_malloc = NULL;
 
+  if (!SAFE_TO_MULT(4, bsize0) || !SAFE_TO_ADD(4 * bsize0, bsize1)) {
+    return MLIB_FAILURE;
+  }
+
   if ((4 * bsize0 + bsize1) > buff_size) {
     buff = param->buff_malloc = mlib_malloc(4 * bsize0 + bsize1);
 
diff -Nru openjdk-17-17.0.17+10/src/java.desktop/share/native/libsplashscreen/splashscreen_gif.c openjdk-17-17.0.18+8/src/java.desktop/share/native/libsplashscreen/splashscreen_gif.c
--- openjdk-17-17.0.17+10/src/java.desktop/share/native/libsplashscreen/splashscreen_gif.c	2025-10-13 07:48:04.000000000 +0000
+++ openjdk-17-17.0.18+8/src/java.desktop/share/native/libsplashscreen/splashscreen_gif.c	2026-01-15 15:23:06.000000000 +0000
@@ -1,5 +1,5 @@
 /*
- * Copyright (c) 2005, 2013, 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
@@ -48,7 +48,7 @@
                                 // restore the area overwritten by the graphic with
                                 // what was there prior to rendering the graphic.
 
-static const char szNetscape20ext[11] = "NETSCAPE2.0";
+static const char szNetscape20ext[] = "NETSCAPE2.0";
 
 #define NSEXT_LOOP      0x01    // Loop Count field code
 
@@ -181,7 +181,7 @@
                 }
             case APPLICATION_EXT_FUNC_CODE:
                 {
-                    if (size == sizeof(szNetscape20ext)
+                    if (size == strlen(szNetscape20ext)
                         && memcmp(pExtension, szNetscape20ext, size) == 0) {
                         int iSubCode;
 
diff -Nru openjdk-17-17.0.17+10/src/java.desktop/unix/classes/sun/awt/PlatformGraphicsInfo.java openjdk-17-17.0.18+8/src/java.desktop/unix/classes/sun/awt/PlatformGraphicsInfo.java
--- openjdk-17-17.0.17+10/src/java.desktop/unix/classes/sun/awt/PlatformGraphicsInfo.java	2025-10-13 07:48:04.000000000 +0000
+++ openjdk-17-17.0.18+8/src/java.desktop/unix/classes/sun/awt/PlatformGraphicsInfo.java	2026-01-15 15:23:06.000000000 +0000
@@ -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
@@ -25,6 +25,7 @@
 
 package sun.awt;
 
+import java.io.File;
 import java.awt.GraphicsEnvironment;
 import java.awt.Toolkit;
 import java.security.AccessController;
@@ -43,17 +44,42 @@
     /**
       * Called from java.awt.GraphicsEnvironment when
       * to check if on this platform, the JDK should default to
-      * headless mode, in the case the application did specify
+      * headless mode, in the case the application did not specify
       * a value for the java.awt.headless system property.
       */
     @SuppressWarnings("removal")
     public static boolean getDefaultHeadlessProperty() {
-        return
+        boolean noDisplay =
             AccessController.doPrivileged((PrivilegedAction) () -> {
 
                final String display = System.getenv("DISPLAY");
-               return  display == null || display.trim().isEmpty();
+               return display == null || display.trim().isEmpty();
+            });
+        if (noDisplay) {
+            return true;
+        }
+        /*
+         * If we positively identify a separate headless library support being present
+         * but no corresponding headful library, then we can support headless but
+         * not headful, so report that back to the caller.
+         * This does require duplication of knowing the name of the libraries
+         * also in libawt's OnLoad() but we need to make sure that the Java
+         * code is also set up as headless from the start - it is not so easy
+         * to try headful and then unwind that and then retry as headless.
+         */
+        boolean headless =
+            AccessController.doPrivileged((PrivilegedAction) () -> {
+                String[] libDirs = System.getProperty("sun.boot.library.path", "").split(":");
+                for (String libDir : libDirs) {
+                    File headlessLib = new File(libDir, "libawt_headless.so");
+                    File xawtLib = new File(libDir, "libawt_xawt.so");
+                    if (headlessLib.exists() && !xawtLib.exists()) {
+                        return true;
+                    }
+                }
+                return false;
             });
+        return headless;
     }
 
     /**
@@ -63,7 +89,10 @@
       */
     public static String getDefaultHeadlessMessage() {
         return
-            "\nNo X11 DISPLAY variable was set,\n" +
-            "but this program performed an operation which requires it.";
+            """
+
+            No X11 DISPLAY variable was set,
+            or no headful library support was found,
+            but this program performed an operation which requires it.""";
     }
 }
diff -Nru openjdk-17-17.0.17+10/src/java.desktop/unix/native/libawt_xawt/awt/awt_GraphicsEnv.c openjdk-17-17.0.18+8/src/java.desktop/unix/native/libawt_xawt/awt/awt_GraphicsEnv.c
--- openjdk-17-17.0.17+10/src/java.desktop/unix/native/libawt_xawt/awt/awt_GraphicsEnv.c	2025-10-13 07:48:04.000000000 +0000
+++ openjdk-17-17.0.18+8/src/java.desktop/unix/native/libawt_xawt/awt/awt_GraphicsEnv.c	2026-01-15 15:23:06.000000000 +0000
@@ -298,6 +298,7 @@
     // NB: should be invoked only while holding the AWT lock
     DASSERT(screen >= 0 && screen < awt_numScreens);
 
+    jboolean success = JNI_FALSE;
     int i;
     int n8p=0, n12p=0, n8s=0, n8gs=0, n8sg=0, n1sg=0, nTrue=0;
     int nConfig;
@@ -385,7 +386,7 @@
          */
         screenDataPtr->defaultConfig = makeDefaultConfig(env, screen);
         if (screenDataPtr->defaultConfig == NULL) {
-            return;
+            goto cleanup;
         }
     }
 
@@ -568,10 +569,17 @@
                 sizeof (XVisualInfo));
     }
 
+    success = JNI_TRUE;
     screenDataPtr->numConfigs = nConfig;
     screenDataPtr->configs = graphicsConfigs;
 
 cleanup:
+    if (success != JNI_TRUE) {
+        for (i = 0; i < nConfig; i++) {
+            free(graphicsConfigs[i]);
+        }
+        free(graphicsConfigs);
+    }
     if (n8p != 0)
        XFree (pVI8p);
     if (n12p != 0)
diff -Nru openjdk-17-17.0.17+10/src/java.desktop/windows/classes/com/sun/java/swing/plaf/windows/WindowsFileChooserUI.java openjdk-17-17.0.18+8/src/java.desktop/windows/classes/com/sun/java/swing/plaf/windows/WindowsFileChooserUI.java
--- openjdk-17-17.0.17+10/src/java.desktop/windows/classes/com/sun/java/swing/plaf/windows/WindowsFileChooserUI.java	2025-10-13 07:48:04.000000000 +0000
+++ openjdk-17-17.0.18+8/src/java.desktop/windows/classes/com/sun/java/swing/plaf/windows/WindowsFileChooserUI.java	2026-01-15 15:23:06.000000000 +0000
@@ -1048,6 +1048,8 @@
             ii.depth = directoryComboBoxModel.getDepth(index);
             setIcon(ii);
 
+            putClientProperty("html.disable", getFileChooser().getClientProperty("html.disable"));
+
             return this;
         }
     }
diff -Nru openjdk-17-17.0.17+10/src/java.desktop/windows/classes/com/sun/java/swing/plaf/windows/WindowsIconFactory.java openjdk-17-17.0.18+8/src/java.desktop/windows/classes/com/sun/java/swing/plaf/windows/WindowsIconFactory.java
--- openjdk-17-17.0.17+10/src/java.desktop/windows/classes/com/sun/java/swing/plaf/windows/WindowsIconFactory.java	2025-10-13 07:48:04.000000000 +0000
+++ openjdk-17-17.0.18+8/src/java.desktop/windows/classes/com/sun/java/swing/plaf/windows/WindowsIconFactory.java	2026-01-15 15:23:06.000000000 +0000
@@ -28,7 +28,6 @@
 import java.awt.BasicStroke;
 import java.awt.Color;
 import java.awt.Component;
-import java.awt.Dimension;
 import java.awt.Graphics;
 import java.awt.Graphics2D;
 import java.awt.RenderingHints;
@@ -175,7 +174,7 @@
 
     @SuppressWarnings("serial") // Same-version serialization only
     private static class FrameButtonIcon implements Icon, Serializable {
-        private Part part;
+        private final Part part;
 
         private FrameButtonIcon(Part part) {
             this.part = part;
@@ -286,18 +285,10 @@
             int width;
             if (XPStyle.getXP() != null) {
                 // Fix for XP bug where sometimes these sizes aren't updated properly
-                // Assume for now that height is correct and derive width using the
-                // ratio from the uxtheme part
-                width = UIManager.getInt("InternalFrame.titleButtonHeight") -2;
-                Dimension d = XPStyle.getPartSize(Part.WP_CLOSEBUTTON, State.NORMAL);
-                if (d != null && d.width != 0 && d.height != 0) {
-                    width = (int) ((float) width * d.width / d.height);
-                }
+                // Assume for now that height is correct and derive width from height
+                width = UIManager.getInt("InternalFrame.titleButtonHeight") + 10;
             } else {
-                width = UIManager.getInt("InternalFrame.titleButtonWidth") -2;
-            }
-            if (XPStyle.getXP() != null) {
-                width -= 2;
+                width = UIManager.getInt("InternalFrame.titleButtonHeight") - 2;
             }
             return width;
         }
@@ -891,8 +882,15 @@
                     }
                 }
                 if (icon != null) {
-                    icon.paintIcon(c, g, x + VistaMenuItemCheckIconFactory.getIconWidth(),
-                                   y + OFFSET);
+                    if (WindowsGraphicsUtils.isLeftToRight(c)) {
+                        icon.paintIcon(c, g,
+                                       x + VistaMenuItemCheckIconFactory.getIconWidth(),
+                                       y + OFFSET);
+                    } else {
+                        icon.paintIcon(c, g,
+                                       x - VistaMenuItemCheckIconFactory.getIconWidth() + 2 * OFFSET,
+                                       y + OFFSET);
+                    }
                 }
             }
             private static WindowsMenuItemUIAccessor getAccessor(
diff -Nru openjdk-17-17.0.17+10/src/java.desktop/windows/classes/com/sun/java/swing/plaf/windows/WindowsInternalFrameTitlePane.java openjdk-17-17.0.18+8/src/java.desktop/windows/classes/com/sun/java/swing/plaf/windows/WindowsInternalFrameTitlePane.java
--- openjdk-17-17.0.17+10/src/java.desktop/windows/classes/com/sun/java/swing/plaf/windows/WindowsInternalFrameTitlePane.java	2025-10-13 07:48:04.000000000 +0000
+++ openjdk-17-17.0.18+8/src/java.desktop/windows/classes/com/sun/java/swing/plaf/windows/WindowsInternalFrameTitlePane.java	2026-01-15 15:23:06.000000000 +0000
@@ -1,5 +1,5 @@
 /*
- * Copyright (c) 2001, 2014, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 2001, 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
@@ -25,20 +25,46 @@
 
 package com.sun.java.swing.plaf.windows;
 
-import sun.swing.SwingUtilities2;
-
-import javax.swing.*;
-import javax.swing.border.*;
-import javax.swing.UIManager;
-import javax.swing.plaf.*;
-import javax.swing.plaf.basic.BasicInternalFrameTitlePane;
-import java.awt.*;
-import java.awt.event.*;
+import java.awt.Color;
+import java.awt.Component;
+import java.awt.Container;
+import java.awt.Dimension;
+import java.awt.Font;
+import java.awt.FontMetrics;
+import java.awt.GradientPaint;
+import java.awt.Graphics;
+import java.awt.Graphics2D;
+import java.awt.Insets;
+import java.awt.LayoutManager;
+import java.awt.Paint;
+import java.awt.Point;
+import java.awt.Rectangle;
+import java.awt.event.MouseAdapter;
+import java.awt.event.MouseEvent;
 import java.beans.PropertyChangeEvent;
 import java.beans.PropertyChangeListener;
 import java.beans.PropertyVetoException;
 
-import static com.sun.java.swing.plaf.windows.TMSchema.*;
+import javax.swing.BorderFactory;
+import javax.swing.Icon;
+import javax.swing.JComponent;
+import javax.swing.JInternalFrame;
+import javax.swing.JLabel;
+import javax.swing.JMenuItem;
+import javax.swing.JPopupMenu;
+import javax.swing.JSeparator;
+import javax.swing.LookAndFeel;
+import javax.swing.UIDefaults;
+import javax.swing.UIManager;
+import javax.swing.border.Border;
+import javax.swing.plaf.UIResource;
+import javax.swing.plaf.basic.BasicInternalFrameTitlePane;
+
+import sun.swing.SwingUtilities2;
+
+import static com.sun.java.swing.plaf.windows.TMSchema.Part;
+import static com.sun.java.swing.plaf.windows.TMSchema.Prop;
+import static com.sun.java.swing.plaf.windows.TMSchema.State;
 import static com.sun.java.swing.plaf.windows.XPStyle.Skin;
 
 @SuppressWarnings("serial") // Superclass is not serializable across versions
@@ -68,7 +94,6 @@
         super.installDefaults();
 
         titlePaneHeight = UIManager.getInt("InternalFrame.titlePaneHeight");
-        buttonWidth     = UIManager.getInt("InternalFrame.titleButtonWidth")  - 4;
         buttonHeight    = UIManager.getInt("InternalFrame.titleButtonHeight") - 4;
 
         Object obj      = UIManager.get("InternalFrame.titleButtonToolTipsOn");
@@ -77,15 +102,10 @@
 
         if (XPStyle.getXP() != null) {
             // Fix for XP bug where sometimes these sizes aren't updated properly
-            // Assume for now that height is correct and derive width using the
-            // ratio from the uxtheme part
-            buttonWidth = buttonHeight;
-            Dimension d = XPStyle.getPartSize(Part.WP_CLOSEBUTTON, State.NORMAL);
-            if (d != null && d.width != 0 && d.height != 0) {
-                buttonWidth = (int) ((float) buttonWidth * d.width / d.height);
-            }
+            // Assume for now that height is correct and derive width from height
+            buttonWidth = buttonHeight + 14;
         } else {
-            buttonWidth += 2;
+            buttonWidth = buttonHeight + 2;
             Color activeBorderColor =
                     UIManager.getColor("InternalFrame.activeBorderColor");
             setBorder(BorderFactory.createLineBorder(activeBorderColor, 1));
diff -Nru openjdk-17-17.0.17+10/src/java.desktop/windows/classes/com/sun/java/swing/plaf/windows/WindowsMenuItemUI.java openjdk-17-17.0.18+8/src/java.desktop/windows/classes/com/sun/java/swing/plaf/windows/WindowsMenuItemUI.java
--- openjdk-17-17.0.17+10/src/java.desktop/windows/classes/com/sun/java/swing/plaf/windows/WindowsMenuItemUI.java	2025-10-13 07:48:04.000000000 +0000
+++ openjdk-17-17.0.18+8/src/java.desktop/windows/classes/com/sun/java/swing/plaf/windows/WindowsMenuItemUI.java	2026-01-15 15:23:06.000000000 +0000
@@ -43,6 +43,7 @@
 import javax.swing.JComponent;
 import javax.swing.JMenu;
 import javax.swing.JMenuItem;
+import javax.swing.SwingConstants;
 import javax.swing.UIManager;
 import javax.swing.plaf.ComponentUI;
 import javax.swing.plaf.UIResource;
@@ -215,8 +216,17 @@
 
         if (lh.getCheckIcon() != null && lh.useCheckAndArrow()) {
             Rectangle rect = lr.getTextRect();
-
-            rect.x += lh.getAfterCheckIconGap();
+            if (menuItem.getComponentOrientation().isLeftToRight()) {
+                if (menuItem.getHorizontalTextPosition() != SwingConstants.LEADING
+                    && menuItem.getHorizontalTextPosition() != SwingConstants.LEFT) {
+                    rect.x += lh.getAfterCheckIconGap();
+                }
+            } else {
+                if (menuItem.getHorizontalTextPosition() != SwingConstants.LEADING
+                    && menuItem.getHorizontalTextPosition() != SwingConstants.RIGHT) {
+                    rect.x -= lh.getAfterCheckIconGap();
+                }
+            }
 
             lr.setTextRect(rect);
         }
@@ -232,7 +242,11 @@
         }
         if (lh.getCheckIcon() != null && lh.useCheckAndArrow()) {
             Rectangle rect = lr.getAccRect();
-            rect.x += lh.getAfterCheckIconGap();
+            if (menuItem.getComponentOrientation().isLeftToRight()) {
+                rect.x += lh.getAfterCheckIconGap();
+            } else {
+                rect.x -= lh.getAfterCheckIconGap();
+            }
             lr.setAccRect(rect);
         }
         SwingUtilities3.paintAccText(g, lh, lr, disabledForeground,
diff -Nru openjdk-17-17.0.17+10/src/java.desktop/windows/classes/sun/awt/windows/ThemeReader.java openjdk-17-17.0.18+8/src/java.desktop/windows/classes/sun/awt/windows/ThemeReader.java
--- openjdk-17-17.0.17+10/src/java.desktop/windows/classes/sun/awt/windows/ThemeReader.java	2025-10-13 07:48:04.000000000 +0000
+++ openjdk-17-17.0.18+8/src/java.desktop/windows/classes/sun/awt/windows/ThemeReader.java	2026-01-15 15:23:06.000000000 +0000
@@ -1,5 +1,5 @@
 /*
- * Copyright (c) 2004, 2023, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 2004, 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
@@ -100,21 +100,30 @@
         return xpStyleEnabled;
     }
 
-    private static Long openThemeImpl(String widget, int dpi) {
-       Long theme;
+    private static long openThemeImpl(String widget, int dpi) {
+       long theme;
        int i = widget.indexOf("::");
        if (i > 0) {
            // We're using the syntax "subAppName::controlName" here, as used by msstyles.
            // See documentation for SetWindowTheme on MSDN.
            setWindowTheme(widget.substring(0, i));
-           theme = openTheme(widget.substring(i + 2), dpi);
+           theme = getOpenThemeValue(widget.substring(i + 2), dpi);
            setWindowTheme(null);
        } else {
-           theme = openTheme(widget, dpi);
+           theme = getOpenThemeValue(widget, dpi);
        }
        return theme;
     }
 
+    private static long getOpenThemeValue(String widget, int dpi) {
+        long theme;
+        theme = openTheme(widget, dpi);
+        if (theme == 0) {
+            theme = openTheme(widget, defaultDPI);
+        }
+        return theme;
+    }
+
     // this should be called only with writeLock held
     private static Long getThemeImpl(String widget, int dpi) {
        return dpiAwareWidgetToTheme.computeIfAbsent(dpi, key -> new HashMap<>())
diff -Nru openjdk-17-17.0.17+10/src/java.desktop/windows/classes/sun/awt/windows/WClipboard.java openjdk-17-17.0.18+8/src/java.desktop/windows/classes/sun/awt/windows/WClipboard.java
--- openjdk-17-17.0.17+10/src/java.desktop/windows/classes/sun/awt/windows/WClipboard.java	2025-10-13 07:48:04.000000000 +0000
+++ openjdk-17-17.0.18+8/src/java.desktop/windows/classes/sun/awt/windows/WClipboard.java	2026-01-15 15:23:06.000000000 +0000
@@ -1,5 +1,5 @@
 /*
- * Copyright (c) 1996, 2014, 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
@@ -29,7 +29,9 @@
 import java.awt.datatransfer.Transferable;
 import java.awt.datatransfer.UnsupportedFlavorException;
 import java.io.IOException;
+import java.lang.System.Logger.Level;
 import java.util.Map;
+import java.util.concurrent.locks.ReentrantLock;
 
 import sun.awt.datatransfer.DataTransferer;
 import sun.awt.datatransfer.SunClipboard;
@@ -51,8 +53,12 @@
 
     private boolean isClipboardViewerRegistered;
 
+    private final ReentrantLock clipboardLocked = new ReentrantLock();
+
     WClipboard() {
         super("System");
+        // Register java side of the clipboard with the native side
+        registerClipboard();
     }
 
     @Override
@@ -104,18 +110,42 @@
 
     /**
      * Call the Win32 OpenClipboard function. If newOwner is non-null,
-     * we also call EmptyClipboard and take ownership.
+     * we also call EmptyClipboard and take ownership. If this method call
+     * succeeds, it must be followed by a call to {@link #closeClipboard()}.
      *
      * @throws IllegalStateException if the clipboard has not been opened
      */
     @Override
-    public native void openClipboard(SunClipboard newOwner) throws IllegalStateException;
+    public void openClipboard(SunClipboard newOwner) throws IllegalStateException {
+        if (!clipboardLocked.tryLock()) {
+            throw new IllegalStateException("Failed to acquire clipboard lock");
+        }
+        try {
+            openClipboard0(newOwner);
+        } catch (IllegalStateException ex) {
+            clipboardLocked.unlock();
+            throw ex;
+        }
+    }
+
     /**
      * Call the Win32 CloseClipboard function if we have clipboard ownership,
      * does nothing if we have not ownership.
      */
     @Override
-    public native void closeClipboard();
+    public void closeClipboard() {
+        if (clipboardLocked.isLocked()) {
+            try {
+                closeClipboard0();
+            } finally {
+                clipboardLocked.unlock();
+            }
+        }
+    }
+
+    private native void openClipboard0(SunClipboard newOwner) throws IllegalStateException;
+    private native void closeClipboard0();
+
     /**
      * Call the Win32 SetClipboardData function.
      */
@@ -157,16 +187,12 @@
             return;
         }
 
-        long[] formats = null;
         try {
-            openClipboard(null);
-            formats = getClipboardFormats();
-        } catch (IllegalStateException exc) {
-            // do nothing to handle the exception, call checkChange(null)
-        } finally {
-            closeClipboard();
+            long[] formats = getClipboardFormats();
+            checkChange(formats);
+        } catch (Throwable ex) {
+            System.getLogger(WClipboard.class.getName()).log(Level.DEBUG, "Failed to process handleContentsChanged", ex);
         }
-        checkChange(formats);
     }
 
     /**
@@ -214,4 +240,6 @@
                 }
             };
     }
+
+    private native void registerClipboard();
 }
diff -Nru openjdk-17-17.0.17+10/src/java.desktop/windows/classes/sun/awt/windows/WDesktopPeer.java openjdk-17-17.0.18+8/src/java.desktop/windows/classes/sun/awt/windows/WDesktopPeer.java
--- openjdk-17-17.0.17+10/src/java.desktop/windows/classes/sun/awt/windows/WDesktopPeer.java	2025-10-13 07:48:04.000000000 +0000
+++ openjdk-17-17.0.18+8/src/java.desktop/windows/classes/sun/awt/windows/WDesktopPeer.java	2026-01-15 15:23:06.000000000 +0000
@@ -1,5 +1,5 @@
 /*
- * Copyright (c) 2005, 2018, 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
@@ -38,6 +38,9 @@
 import java.io.IOException;
 import java.net.URI;
 
+import java.util.ArrayList;
+import java.util.Arrays;
+import java.util.List;
 import javax.swing.event.EventListenerList;
 
 /**
@@ -48,9 +51,11 @@
  */
 final class WDesktopPeer implements DesktopPeer {
     /* Constants for the operation verbs */
-    private static String ACTION_OPEN_VERB = "open";
-    private static String ACTION_EDIT_VERB = "edit";
-    private static String ACTION_PRINT_VERB = "print";
+    private static final String ACTION_OPEN_VERB = "open";
+    private static final String ACTION_EDIT_VERB = "edit";
+    private static final String ACTION_PRINT_VERB = "print";
+    private static final String ACTION_BROWSE_VERB = "browse";
+    private static final String ACTION_MAIL_VERB = "mail";
 
     private static native void init();
 
@@ -93,12 +98,12 @@
 
     @Override
     public void mail(URI uri) throws IOException {
-        this.ShellExecute(uri, ACTION_OPEN_VERB);
+        this.ShellExecute(uri, ACTION_MAIL_VERB);
     }
 
     @Override
     public void browse(URI uri) throws IOException {
-        this.ShellExecute(uri, ACTION_OPEN_VERB);
+        this.launchUriInBrowser(uri);
     }
 
     private void ShellExecute(File file, String verb) throws IOException {
@@ -117,6 +122,42 @@
         }
     }
 
+    private void launchUriInBrowser(URI uri) throws IOException {
+        String defaultBrowser = getDefaultBrowser();
+        if (defaultBrowser == null) {
+            throw new IOException("Failed to get default browser");
+        }
+
+        List cmdLineTokens = getCmdLineTokens(uri, defaultBrowser);
+        try {
+            ProcessBuilder pb = new ProcessBuilder(cmdLineTokens);
+            pb.start();
+        }  catch (Exception e) {
+            throw new IOException("Error launching Browser: ", e);
+        }
+    }
+
+    private static List getCmdLineTokens(URI uri, String defaultBrowser) {
+        if (defaultBrowser.contains("%1")) {
+            defaultBrowser = defaultBrowser.replace("%1", uri.toString());
+        } else {
+            defaultBrowser = defaultBrowser + " " + uri.toString();
+        }
+
+        List cmdLineTokens = new ArrayList<>();
+        int firstIndex = defaultBrowser.indexOf("\"");
+        int secondIndex = defaultBrowser.indexOf("\"", firstIndex + 1);
+
+        if (firstIndex == 0 && secondIndex != firstIndex) {
+            cmdLineTokens.add(defaultBrowser.substring(firstIndex, secondIndex + 1));
+            defaultBrowser = defaultBrowser.substring(secondIndex + 1).trim();
+        }
+        cmdLineTokens.addAll(Arrays.asList(defaultBrowser.split(" ")));
+        return cmdLineTokens;
+    }
+
+    private static native String getDefaultBrowser();
+
     private static native String ShellExecute(String fileOrUri, String verb);
 
     private static final EventListenerList listenerList = new EventListenerList();
diff -Nru openjdk-17-17.0.17+10/src/java.desktop/windows/classes/sun/awt/windows/WInputMethod.java openjdk-17-17.0.18+8/src/java.desktop/windows/classes/sun/awt/windows/WInputMethod.java
--- openjdk-17-17.0.17+10/src/java.desktop/windows/classes/sun/awt/windows/WInputMethod.java	2025-10-13 07:48:04.000000000 +0000
+++ openjdk-17-17.0.18+8/src/java.desktop/windows/classes/sun/awt/windows/WInputMethod.java	2026-01-15 15:23:06.000000000 +0000
@@ -1,5 +1,5 @@
 /*
- * Copyright (c) 1997, 2021, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 1997, 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
@@ -319,6 +319,10 @@
             isLastFocussedActiveClient = isAc;
         }
         isActive = true;
+
+        // Sync currentLocale with the Windows keyboard layout which could be changed
+        // while the component was inactive.
+        getLocale();
         if (currentLocale != null) {
             setLocale(currentLocale, true);
         }
diff -Nru openjdk-17-17.0.17+10/src/java.desktop/windows/native/libawt/java2d/windows/GDIRenderer.cpp openjdk-17-17.0.18+8/src/java.desktop/windows/native/libawt/java2d/windows/GDIRenderer.cpp
--- openjdk-17-17.0.17+10/src/java.desktop/windows/native/libawt/java2d/windows/GDIRenderer.cpp	2025-10-13 07:48:04.000000000 +0000
+++ openjdk-17-17.0.18+8/src/java.desktop/windows/native/libawt/java2d/windows/GDIRenderer.cpp	2026-01-15 15:23:06.000000000 +0000
@@ -1,5 +1,5 @@
 /*
- * Copyright (c) 1999, 2018, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 1999, 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
@@ -49,7 +49,7 @@
 
 #define POLYTEMPSIZE    (512 / sizeof(POINT))
 
-static void AngleToCoord(jint angle, jint w, jint h, jint *x, jint *y)
+static void AngleToCoord(int angle, int w, int h, int *x, int *y)
 {
     const double pi = 3.1415926535;
     const double toRadians = 2 * pi / 360;
@@ -322,7 +322,7 @@
         return;
     }
 
-    long sx, sy, ex, ey;
+    int sx, sy, ex, ey;
     if (angleExtent >= 360 || angleExtent <= -360) {
         sx = ex = x + w;
         sy = ey = y + h/2;
@@ -602,7 +602,7 @@
     if (wsdo == NULL) {
         return;
     }
-    long sx, sy, ex, ey;
+    int sx, sy, ex, ey;
     int angleEnd;
     if (angleExtent < 0) {
         angleEnd = angleStart;
diff -Nru openjdk-17-17.0.17+10/src/java.desktop/windows/native/libawt/java2d/windows/GDIWindowSurfaceData.cpp openjdk-17-17.0.18+8/src/java.desktop/windows/native/libawt/java2d/windows/GDIWindowSurfaceData.cpp
--- openjdk-17-17.0.17+10/src/java.desktop/windows/native/libawt/java2d/windows/GDIWindowSurfaceData.cpp	2025-10-13 07:48:04.000000000 +0000
+++ openjdk-17-17.0.18+8/src/java.desktop/windows/native/libawt/java2d/windows/GDIWindowSurfaceData.cpp	2026-01-15 15:23:06.000000000 +0000
@@ -1,5 +1,5 @@
 /*
- * Copyright (c) 1999, 2020, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 1999, 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
@@ -897,7 +897,7 @@
     }
     if (wsdo->lockFlags & SD_LOCK_LUT) {
         pRasInfo->lutBase =
-            (long *) wsdo->device->GetSystemPaletteEntries();
+            (jint *) wsdo->device->GetSystemPaletteEntries();
         pRasInfo->lutSize = 256;
     } else {
         pRasInfo->lutBase = NULL;
diff -Nru openjdk-17-17.0.17+10/src/java.desktop/windows/native/libawt/windows/ShellFolder2.cpp openjdk-17-17.0.18+8/src/java.desktop/windows/native/libawt/windows/ShellFolder2.cpp
--- openjdk-17-17.0.17+10/src/java.desktop/windows/native/libawt/windows/ShellFolder2.cpp	2025-10-13 07:48:04.000000000 +0000
+++ openjdk-17-17.0.18+8/src/java.desktop/windows/native/libawt/windows/ShellFolder2.cpp	2026-01-15 15:23:06.000000000 +0000
@@ -1080,12 +1080,12 @@
             // Extract the color bitmap
             int nBits = iconSize * iconSize;
 
-            long *colorBits = NULL;
-            long *maskBits = NULL;
+            jint *colorBits = NULL;
+            int *maskBits = NULL;
 
             try {
                 entry_point();
-                colorBits = (long*)safe_Malloc(MAX_ICON_SIZE * MAX_ICON_SIZE * sizeof(long));
+                colorBits = (jint*)safe_Malloc(MAX_ICON_SIZE * MAX_ICON_SIZE * sizeof(jint));
                 GetDIBits(dc, iconInfo.hbmColor, 0, iconSize, colorBits, &bmi, DIB_RGB_COLORS);
                 // XP supports alpha in some icons, and depending on device.
                 // This should take precedence over the icon mask bits.
@@ -1100,7 +1100,7 @@
                 }
                 if (!hasAlpha) {
                     // Extract the mask bitmap
-                    maskBits = (long*)safe_Malloc(MAX_ICON_SIZE * MAX_ICON_SIZE * sizeof(long));
+                    maskBits = (int*)safe_Malloc(MAX_ICON_SIZE * MAX_ICON_SIZE * sizeof(int));
                     GetDIBits(dc, iconInfo.hbmMask, 0, iconSize, maskBits, &bmi, DIB_RGB_COLORS);
                     // Copy the mask alphas into the color bits
                     for (int i = 0; i < nBits; i++) {
diff -Nru openjdk-17-17.0.17+10/src/java.desktop/windows/native/libawt/windows/WPrinterJob.cpp openjdk-17-17.0.18+8/src/java.desktop/windows/native/libawt/windows/WPrinterJob.cpp
--- openjdk-17-17.0.17+10/src/java.desktop/windows/native/libawt/windows/WPrinterJob.cpp	2025-10-13 07:48:04.000000000 +0000
+++ openjdk-17-17.0.18+8/src/java.desktop/windows/native/libawt/windows/WPrinterJob.cpp	2026-01-15 15:23:06.000000000 +0000
@@ -729,7 +729,7 @@
   }
 
   jstring jPort;
-  LPTSTR printerName = NULL, printerPort = TEXT("LPT1");
+  LPTSTR printerName = NULL, printerPort = (LPTSTR)TEXT("LPT1");
   LPBYTE buffer = NULL;
   DWORD cbBuf = 0;
 
@@ -745,7 +745,7 @@
   }
 
   if (printerPort == NULL) {
-    printerPort = TEXT("LPT1");
+    printerPort = (LPTSTR)TEXT("LPT1");
   }
   jPort = JNU_NewStringPlatform(env, printerPort);
   delete [] buffer;
@@ -1110,7 +1110,7 @@
   // Fill in the structure with info about this "document."
   DocInfo.pDocName = jname;
   DocInfo.pOutputFile = NULL;
-  DocInfo.pDatatype = TEXT("RAW");
+  DocInfo.pDatatype = (LPTSTR)TEXT("RAW");
 
   // Inform the spooler the document is beginning.
   if( (::StartDocPrinter(hPrinter, 1, (LPBYTE)&DocInfo)) == 0 ) {
diff -Nru openjdk-17-17.0.17+10/src/java.desktop/windows/native/libawt/windows/awt_Clipboard.cpp openjdk-17-17.0.18+8/src/java.desktop/windows/native/libawt/windows/awt_Clipboard.cpp
--- openjdk-17-17.0.17+10/src/java.desktop/windows/native/libawt/windows/awt_Clipboard.cpp	2025-10-13 07:48:04.000000000 +0000
+++ openjdk-17-17.0.18+8/src/java.desktop/windows/native/libawt/windows/awt_Clipboard.cpp	2026-01-15 15:23:06.000000000 +0000
@@ -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
@@ -69,9 +69,8 @@
         return;
     }
 
-    if (theCurrentClipboard == NULL) {
-        theCurrentClipboard = env->NewGlobalRef(jclipboard);
-    }
+    DASSERT(AwtClipboard::theCurrentClipboard != NULL);
+    DASSERT(env->IsSameObject(AwtClipboard::theCurrentClipboard, jclipboard));
 
     jclass cls = env->GetObjectClass(jclipboard);
     AwtClipboard::handleContentsChangedMID =
@@ -128,11 +127,13 @@
  * Signature: (Lsun/awt/windows/WClipboard;)V
  */
 JNIEXPORT void JNICALL
-Java_sun_awt_windows_WClipboard_openClipboard(JNIEnv *env, jobject self,
+Java_sun_awt_windows_WClipboard_openClipboard0(JNIEnv *env, jobject self,
                                               jobject newOwner)
 {
     TRY;
 
+    DASSERT(AwtClipboard::theCurrentClipboard != NULL);
+    DASSERT(newOwner == NULL || env->IsSameObject(AwtClipboard::theCurrentClipboard, newOwner));
     DASSERT(::GetOpenClipboardWindow() != AwtToolkit::GetInstance().GetHWnd());
 
     if (!::OpenClipboard(AwtToolkit::GetInstance().GetHWnd())) {
@@ -142,10 +143,6 @@
     }
     if (newOwner != NULL) {
         AwtClipboard::GetOwnership();
-        if (AwtClipboard::theCurrentClipboard != NULL) {
-            env->DeleteGlobalRef(AwtClipboard::theCurrentClipboard);
-        }
-        AwtClipboard::theCurrentClipboard = env->NewGlobalRef(newOwner);
     }
 
     CATCH_BAD_ALLOC;
@@ -157,7 +154,7 @@
  * Signature: ()V
  */
 JNIEXPORT void JNICALL
-Java_sun_awt_windows_WClipboard_closeClipboard(JNIEnv *env, jobject self)
+Java_sun_awt_windows_WClipboard_closeClipboard0(JNIEnv *env, jobject self)
 {
     TRY;
 
@@ -297,23 +294,25 @@
 {
     TRY;
 
-    DASSERT(::GetOpenClipboardWindow() == AwtToolkit::GetInstance().GetHWnd());
+    unsigned int cFormats = 128; // Allocate enough space to hold all
+    unsigned int pcFormatsOut = 0;
+    unsigned int lpuiFormats[128] = { 0 };
 
-    jsize nFormats = ::CountClipboardFormats();
-    jlongArray formats = env->NewLongArray(nFormats);
+    VERIFY(::GetUpdatedClipboardFormats(lpuiFormats, 128, &pcFormatsOut));
+
+    jlongArray formats = env->NewLongArray(pcFormatsOut);
     if (formats == NULL) {
         throw std::bad_alloc();
     }
-    if (nFormats == 0) {
+    if (pcFormatsOut == 0) {
         return formats;
     }
     jboolean isCopy;
     jlong *lFormats = env->GetLongArrayElements(formats, &isCopy),
         *saveFormats = lFormats;
-    UINT num = 0;
 
-    for (jsize i = 0; i < nFormats; i++, lFormats++) {
-        *lFormats = num = ::EnumClipboardFormats(num);
+    for (unsigned int i = 0; i < pcFormatsOut; i++, lFormats++) {
+        *lFormats = lpuiFormats[i];
     }
 
     env->ReleaseLongArrayElements(formats, saveFormats, 0);
@@ -478,4 +477,16 @@
     CATCH_BAD_ALLOC_RET(NULL);
 }
 
+/*
+ * Class:     sun_awt_windows_WClipboard
+ * Method:    registerClipboard
+ * Signature: ()V
+ */
+JNIEXPORT void JNICALL
+Java_sun_awt_windows_WClipboard_registerClipboard(JNIEnv *env, jobject self)
+{
+    DASSERT(AwtClipboard::theCurrentClipboard == NULL);
+    AwtClipboard::theCurrentClipboard = env->NewGlobalRef(self);
+}
+
 } /* extern "C" */
diff -Nru openjdk-17-17.0.17+10/src/java.desktop/windows/native/libawt/windows/awt_Debug.cpp openjdk-17-17.0.18+8/src/java.desktop/windows/native/libawt/windows/awt_Debug.cpp
--- openjdk-17-17.0.17+10/src/java.desktop/windows/native/libawt/windows/awt_Debug.cpp	2025-10-13 07:48:04.000000000 +0000
+++ openjdk-17-17.0.18+8/src/java.desktop/windows/native/libawt/windows/awt_Debug.cpp	2026-01-15 15:23:06.000000000 +0000
@@ -193,7 +193,7 @@
                   NULL);
 
     if (msgBuffer == NULL) {
-        msgBuffer = "";
+        msgBuffer = (LPSTR)"";
     }
     // format the assertion message
     _snprintf(assertMsg, ASSERT_MSG_SIZE, AssertFmt, expr, file, line, lastError, msgBuffer);
diff -Nru openjdk-17-17.0.17+10/src/java.desktop/windows/native/libawt/windows/awt_Desktop.cpp openjdk-17-17.0.18+8/src/java.desktop/windows/native/libawt/windows/awt_Desktop.cpp
--- openjdk-17-17.0.17+10/src/java.desktop/windows/native/libawt/windows/awt_Desktop.cpp	2025-10-13 07:48:04.000000000 +0000
+++ openjdk-17-17.0.18+8/src/java.desktop/windows/native/libawt/windows/awt_Desktop.cpp	2026-01-15 15:23:06.000000000 +0000
@@ -1,5 +1,5 @@
 /*
- * Copyright (c) 2005, 2020, 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
@@ -30,6 +30,12 @@
 #include 
 #include 
 #include "awt_Toolkit.h"
+#include 
+#include   // for AssocQueryStringW
+#include 
+#include 
+#include 
+#include  // for SaferiIsExecutableFileType
 
 #define BUFFER_LIMIT   MAX_PATH+1
 
@@ -78,10 +84,19 @@
     LPCWSTR fileOrUri_c = JNU_GetStringPlatformChars(env, fileOrUri_j, JNI_FALSE);
     CHECK_NULL_RETURN(fileOrUri_c, NULL);
     LPCWSTR verb_c = JNU_GetStringPlatformChars(env, verb_j, JNI_FALSE);
+
     if (verb_c == NULL) {
         JNU_ReleaseStringPlatformChars(env, fileOrUri_j, fileOrUri_c);
         return NULL;
     }
+    if (wcscmp(verb_c, L"open") == 0) {
+        BOOL isExecutable = SaferiIsExecutableFileType(fileOrUri_c, FALSE);
+        if (isExecutable) {
+            return env->NewStringUTF("Unsupported URI content");
+        }
+    }
+    // set action verb for mail() to open before calling ShellExecute
+    LPCWSTR actionVerb = wcscmp(verb_c, L"mail") == 0 ? L"open" : verb_c;
 
     // 6457572: ShellExecute possibly changes FPU control word - saving it here
     unsigned oldcontrol87 = _control87(0, 0);
@@ -90,7 +105,7 @@
     HINSTANCE retval;
     DWORD error;
     if (SUCCEEDED(hr)) {
-        retval = ::ShellExecute(NULL, verb_c, fileOrUri_c, NULL, NULL,
+        retval = ::ShellExecute(NULL, actionVerb, fileOrUri_c, NULL, NULL,
                                 SW_SHOWNORMAL);
         error = ::GetLastError();
         ::CoUninitialize();
@@ -123,11 +138,39 @@
             return errmsg;
         }
     }
-
     return NULL;
 }
 
 /*
+ * Class:     sun_awt_windows_WDesktopPeer
+ * Method:    getDefaultBrowser
+ * Signature: ()Ljava/lang/String;
+ */
+JNIEXPORT jstring JNICALL Java_sun_awt_windows_WDesktopPeer_getDefaultBrowser
+(JNIEnv *env, jclass cls)
+{
+    LPCWSTR fileExtension = L"https";
+    WCHAR defaultBrowser_c [MAX_PATH];
+    DWORD cchBuffer = MAX_PATH;
+
+    // Use AssocQueryString to get the default browser
+    HRESULT hr = AssocQueryStringW(
+        ASSOCF_NONE,            // No special flags
+        ASSOCSTR_COMMAND,       // Request the command string
+        fileExtension,          // File extension
+        NULL,                   // pszExtra (optional)
+        defaultBrowser_c,       // Output buffer - result
+        &cchBuffer              // Size of the output buffer
+    );
+
+    if (FAILED(hr)) {
+        return NULL;
+    }
+
+    return JNU_NewStringPlatform(env, defaultBrowser_c);
+}
+
+/*
  * Class:     sun_awt_windows_WDesktopPeer
  * Method:    moveToTrash
  * Signature: (Ljava/lang/String;)Z
diff -Nru openjdk-17-17.0.17+10/src/java.desktop/windows/native/libawt/windows/awt_DesktopProperties.cpp openjdk-17-17.0.18+8/src/java.desktop/windows/native/libawt/windows/awt_DesktopProperties.cpp
--- openjdk-17-17.0.17+10/src/java.desktop/windows/native/libawt/windows/awt_DesktopProperties.cpp	2025-10-13 07:48:04.000000000 +0000
+++ openjdk-17-17.0.18+8/src/java.desktop/windows/native/libawt/windows/awt_DesktopProperties.cpp	2026-01-15 15:23:06.000000000 +0000
@@ -138,7 +138,7 @@
 // Note that it uses malloc() and returns the pointer to allocated
 // memory, so remember to use free() when you are done with its
 // result.
-static LPTSTR resolveShellDialogFont(LPTSTR fontName, HKEY handle) {
+static LPTSTR resolveShellDialogFont(LPCTSTR fontName, HKEY handle) {
     DWORD valueType, valueSize;
     if (RegQueryValueEx((HKEY)handle, fontName, NULL,
                         &valueType, NULL, &valueSize) != 0) {
@@ -164,7 +164,7 @@
 // memory, so remember to use free() when you are done with its
 // result.
 static LPTSTR resolveShellDialogFont() {
-    LPTSTR subKey = TEXT("Software\\Microsoft\\Windows NT\\CurrentVersion\\FontSubstitutes");
+    LPCTSTR subKey = TEXT("Software\\Microsoft\\Windows NT\\CurrentVersion\\FontSubstitutes");
 
     HKEY handle;
     if (RegOpenKeyEx(HKEY_LOCAL_MACHINE, subKey, 0, KEY_READ, &handle) != 0) {
@@ -183,7 +183,7 @@
 // Note that it uses malloc() and returns the pointer to allocated
 // memory, so remember to use free() when you are done with its
 // result.
-static LPTSTR getWindowsPropFromReg(LPTSTR subKey, LPTSTR valueName, DWORD *valueType) {
+static LPTSTR getWindowsPropFromReg(LPCTSTR subKey, LPCTSTR valueName, DWORD *valueType) {
     HKEY handle;
     if (RegOpenKeyEx(HKEY_CURRENT_USER, subKey, 0, KEY_READ, &handle) != 0) {
         return NULL;
@@ -221,7 +221,7 @@
     }
 }
 
-static LPTSTR getXPStylePropFromReg(LPTSTR valueName) {
+static LPTSTR getXPStylePropFromReg(LPCTSTR valueName) {
     DWORD valueType;
     return getWindowsPropFromReg(TEXT("Software\\Microsoft\\Windows\\CurrentVersion\\ThemeManager"),
                                  valueName, &valueType);
@@ -651,11 +651,11 @@
         throw;
     }
 
-    LPTSTR valueName = TEXT("PlaceN");
+    LPCTSTR valueName = TEXT("PlaceN");
     LPTSTR valueNameBuf = (LPTSTR)SAFE_SIZE_ARRAY_ALLOC(safe_Malloc, (lstrlen(valueName) + 1), sizeof(TCHAR));
     lstrcpy(valueNameBuf, valueName);
 
-    LPTSTR propKey = TEXT("win.comdlg.placesBarPlaceN");
+    LPCTSTR propKey = TEXT("win.comdlg.placesBarPlaceN");
 
     LPTSTR propKeyBuf;
     try {
@@ -672,7 +672,7 @@
         valueNameBuf[5] = _T('0' + i++);
         propKeyBuf[25] = valueNameBuf[5];
 
-        LPTSTR key = TEXT("Software\\Microsoft\\Windows\\CurrentVersion\\Policies\\comdlg32\\PlacesBar");
+        LPCTSTR key = TEXT("Software\\Microsoft\\Windows\\CurrentVersion\\Policies\\comdlg32\\PlacesBar");
         try {
             value = NULL;
             if ((value = getWindowsPropFromReg(key, valueNameBuf, &valueType)) != NULL) {
diff -Nru openjdk-17-17.0.17+10/src/java.desktop/windows/native/libawt/windows/awt_DrawingSurface.cpp openjdk-17-17.0.18+8/src/java.desktop/windows/native/libawt/windows/awt_DrawingSurface.cpp
--- openjdk-17-17.0.17+10/src/java.desktop/windows/native/libawt/windows/awt_DrawingSurface.cpp	2025-10-13 07:48:04.000000000 +0000
+++ openjdk-17-17.0.18+8/src/java.desktop/windows/native/libawt/windows/awt_DrawingSurface.cpp	2026-01-15 15:23:06.000000000 +0000
@@ -275,7 +275,7 @@
 
 // EmbeddedFrame support
 
-static char *const embeddedClassName = "sun/awt/windows/WEmbeddedFrame";
+static const char *const embeddedClassName = "sun/awt/windows/WEmbeddedFrame";
 
 JNIEXPORT jobject JNICALL awt_CreateEmbeddedFrame
 (JNIEnv* env, void* platformInfo)
diff -Nru openjdk-17-17.0.17+10/src/java.desktop/windows/native/libawt/windows/awt_Font.cpp openjdk-17-17.0.18+8/src/java.desktop/windows/native/libawt/windows/awt_Font.cpp
--- openjdk-17-17.0.17+10/src/java.desktop/windows/native/libawt/windows/awt_Font.cpp	2025-10-13 07:48:04.000000000 +0000
+++ openjdk-17-17.0.18+8/src/java.desktop/windows/native/libawt/windows/awt_Font.cpp	2026-01-15 15:23:06.000000000 +0000
@@ -345,7 +345,7 @@
                 wName = L"Arial";
             }
 
-            WCHAR* wEName;
+            LPCWSTR wEName;
             if (!wcscmp(wName, L"Helvetica") || !wcscmp(wName, L"SansSerif")) {
                 wEName = L"Arial";
             } else if (!wcscmp(wName, L"TimesRoman") ||
@@ -388,7 +388,7 @@
     return awtFont;
 }
 
-static void strip_tail(wchar_t* text, wchar_t* tail) { // strips tail and any possible whitespace before it from the end of text
+static void strip_tail(wchar_t* text, const wchar_t* tail) { // strips tail and any possible whitespace before it from the end of text
     if (wcslen(text)<=wcslen(tail)) {
         return;
     }
@@ -495,7 +495,7 @@
     return hFont;
 }
 
-HFONT AwtFont::CreateHFont(WCHAR* name, int style, int height,
+HFONT AwtFont::CreateHFont(LPCWSTR name, int style, int height,
                            int angle, float awScale)
 {
     WCHAR longName[80];
diff -Nru openjdk-17-17.0.17+10/src/java.desktop/windows/native/libawt/windows/awt_Font.h openjdk-17-17.0.18+8/src/java.desktop/windows/native/libawt/windows/awt_Font.h
--- openjdk-17-17.0.17+10/src/java.desktop/windows/native/libawt/windows/awt_Font.h	2025-10-13 07:48:04.000000000 +0000
+++ openjdk-17-17.0.18+8/src/java.desktop/windows/native/libawt/windows/awt_Font.h	2026-01-15 15:23:06.000000000 +0000
@@ -155,7 +155,7 @@
      */
     static AwtFont* Create(JNIEnv *env, jobject font,
                            jint angle = 0, jfloat awScale=1.0f);
-    static HFONT CreateHFont(WCHAR* name, int style, int height,
+    static HFONT CreateHFont(LPCWSTR name, int style, int height,
                              int angle = 0, float awScale=1.0f);
 
     static void Cleanup();
diff -Nru openjdk-17-17.0.17+10/src/java.desktop/windows/native/libawt/windows/awt_Menu.h openjdk-17-17.0.18+8/src/java.desktop/windows/native/libawt/windows/awt_Menu.h
--- openjdk-17-17.0.17+10/src/java.desktop/windows/native/libawt/windows/awt_Menu.h	2025-10-13 07:48:04.000000000 +0000
+++ openjdk-17-17.0.18+8/src/java.desktop/windows/native/libawt/windows/awt_Menu.h	2026-01-15 15:23:06.000000000 +0000
@@ -1,5 +1,5 @@
 /*
- * Copyright (c) 1996, 2019, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 1996, 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
@@ -73,7 +73,7 @@
 
     /*for multifont menu */
     BOOL IsTopMenu();
-    virtual AwtMenuItem* GetItem(jobject target, long index);
+    virtual AwtMenuItem* GetItem(jobject target, jint index);
 
     virtual int CountItem(jobject target);
 
diff -Nru openjdk-17-17.0.17+10/src/java.desktop/windows/native/libawt/windows/awt_MenuBar.cpp openjdk-17-17.0.18+8/src/java.desktop/windows/native/libawt/windows/awt_MenuBar.cpp
--- openjdk-17-17.0.17+10/src/java.desktop/windows/native/libawt/windows/awt_MenuBar.cpp	2025-10-13 07:48:04.000000000 +0000
+++ openjdk-17-17.0.18+8/src/java.desktop/windows/native/libawt/windows/awt_MenuBar.cpp	2026-01-15 15:23:06.000000000 +0000
@@ -1,5 +1,5 @@
 /*
- * Copyright (c) 1996, 2018, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 1996, 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
@@ -145,7 +145,7 @@
     return nCount;
 }
 
-AwtMenuItem* AwtMenuBar::GetItem(jobject target, long index)
+AwtMenuItem* AwtMenuBar::GetItem(jobject target, jint index)
 {
     JNIEnv *env = (JNIEnv *)JNU_GetEnv(jvm, JNI_VERSION_1_2);
     if (env->EnsureLocalCapacity(2) < 0) {
diff -Nru openjdk-17-17.0.17+10/src/java.desktop/windows/native/libawt/windows/awt_MenuBar.h openjdk-17-17.0.18+8/src/java.desktop/windows/native/libawt/windows/awt_MenuBar.h
--- openjdk-17-17.0.17+10/src/java.desktop/windows/native/libawt/windows/awt_MenuBar.h	2025-10-13 07:48:04.000000000 +0000
+++ openjdk-17-17.0.18+8/src/java.desktop/windows/native/libawt/windows/awt_MenuBar.h	2026-01-15 15:23:06.000000000 +0000
@@ -1,5 +1,5 @@
 /*
- * Copyright (c) 1996, 2016, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 1996, 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
@@ -66,7 +66,7 @@
     virtual HWND GetOwnerHWnd();
     virtual void RedrawMenuBar();
 
-    AwtMenuItem* GetItem(jobject target, long index);
+    AwtMenuItem* GetItem(jobject target, jint index);
     int CountItem(jobject menuBar);
 
     void DrawItem(DRAWITEMSTRUCT& drawInfo);
diff -Nru openjdk-17-17.0.17+10/src/java.desktop/windows/native/libawt/windows/awt_PrintControl.cpp openjdk-17-17.0.18+8/src/java.desktop/windows/native/libawt/windows/awt_PrintControl.cpp
--- openjdk-17-17.0.17+10/src/java.desktop/windows/native/libawt/windows/awt_PrintControl.cpp	2025-10-13 07:48:04.000000000 +0000
+++ openjdk-17-17.0.18+8/src/java.desktop/windows/native/libawt/windows/awt_PrintControl.cpp	2026-01-15 15:23:06.000000000 +0000
@@ -1045,7 +1045,7 @@
         DEVNAMES *devnames = (DEVNAMES*)::GlobalLock(pd.hDevNames);
         DASSERT(!IsBadReadPtr(devnames, sizeof(DEVNAMES)));
         LPTSTR lpcNames = (LPTSTR)devnames;
-        LPTSTR pbuf = (_tcslen(lpcNames + devnames->wDeviceOffset) == 0 ?
+        LPCTSTR pbuf = (_tcslen(lpcNames + devnames->wDeviceOffset) == 0 ?
                       TEXT("") : lpcNames + devnames->wDeviceOffset);
         if (pbuf != NULL) {
             jstring jstr = JNU_NewStringPlatform(env, pbuf);
diff -Nru openjdk-17-17.0.17+10/src/java.desktop/windows/native/libawt/windows/awt_PrintJob.cpp openjdk-17-17.0.18+8/src/java.desktop/windows/native/libawt/windows/awt_PrintJob.cpp
--- openjdk-17-17.0.17+10/src/java.desktop/windows/native/libawt/windows/awt_PrintJob.cpp	2025-10-13 07:48:04.000000000 +0000
+++ openjdk-17-17.0.18+8/src/java.desktop/windows/native/libawt/windows/awt_PrintJob.cpp	2026-01-15 15:23:06.000000000 +0000
@@ -65,8 +65,8 @@
 
 /*** Private Constants ***/
 
-static char *kJavaIntStr = "I";
-static char *kJavaLongStr = "J";
+static const char *kJavaIntStr = "I";
+static const char *kJavaLongStr = "J";
 
 /* 2D printing uses 3 byte BGR pixels in Raster printing */
 static int J2DRasterBPP = 3;
@@ -1354,7 +1354,7 @@
     } else {
         destination = VerifyDestination(env, self);
     }
-    LPTSTR docname = NULL;
+    LPCTSTR docname = NULL;
     if (jobname != NULL) {
         LPTSTR tmp = (LPTSTR)JNU_GetStringPlatformChars(env, jobname, NULL);
         if (tmp == NULL) {
diff -Nru openjdk-17-17.0.17+10/src/java.desktop/windows/native/libawt/windows/awt_Toolkit.cpp openjdk-17-17.0.18+8/src/java.desktop/windows/native/libawt/windows/awt_Toolkit.cpp
--- openjdk-17-17.0.17+10/src/java.desktop/windows/native/libawt/windows/awt_Toolkit.cpp	2025-10-13 07:48:04.000000000 +0000
+++ openjdk-17-17.0.18+8/src/java.desktop/windows/native/libawt/windows/awt_Toolkit.cpp	2026-01-15 15:23:06.000000000 +0000
@@ -530,7 +530,7 @@
     JNIEnv *env;
     JavaVMAttachArgs attachArgs;
     attachArgs.version  = JNI_VERSION_1_2;
-    attachArgs.name     = "AWT-Windows";
+    attachArgs.name     = (char*)"AWT-Windows";
     attachArgs.group    = data->threadGroup;
 
     jint res = jvm->AttachCurrentThreadAsDaemon((void **)&env, &attachArgs);
diff -Nru openjdk-17-17.0.17+10/src/java.desktop/windows/native/libawt/windows/awt_Win32GraphicsEnv.cpp openjdk-17-17.0.18+8/src/java.desktop/windows/native/libawt/windows/awt_Win32GraphicsEnv.cpp
--- openjdk-17-17.0.17+10/src/java.desktop/windows/native/libawt/windows/awt_Win32GraphicsEnv.cpp	2025-10-13 07:48:04.000000000 +0000
+++ openjdk-17-17.0.18+8/src/java.desktop/windows/native/libawt/windows/awt_Win32GraphicsEnv.cpp	2026-01-15 15:23:06.000000000 +0000
@@ -232,7 +232,7 @@
     unsigned long fontPathLen = MAX_PATH + 1;
     WCHAR  tmpPath[MAX_PATH + 1];
     LPWSTR fontPath = fontPathBuf;
-    LPWSTR eudcKey = NULL;
+    LPCWSTR eudcKey = NULL;
 
     LANGID langID = GetSystemDefaultLangID();
     //lookup for encoding ID, EUDC only supported in
diff -Nru openjdk-17-17.0.17+10/src/java.management/share/classes/javax/management/remote/package.html openjdk-17-17.0.18+8/src/java.management/share/classes/javax/management/remote/package.html
--- openjdk-17-17.0.17+10/src/java.management/share/classes/javax/management/remote/package.html	2025-10-13 07:48:04.000000000 +0000
+++ openjdk-17-17.0.18+8/src/java.management/share/classes/javax/management/remote/package.html	2026-01-15 15:23:06.000000000 +0000
@@ -2,7 +2,7 @@
 
     JMX Remote API.
 
-
-
-    
-        High resolution custom cursor test, bug ID 8028212
-    
-    
-    
-    

See the dialog box (usually in upper left corner) for instructions

- - diff -Nru openjdk-17-17.0.17+10/test/jdk/java/awt/Cursor/MultiResolutionCursorTest/MultiResolutionCursorTest.java openjdk-17-17.0.18+8/test/jdk/java/awt/Cursor/MultiResolutionCursorTest/MultiResolutionCursorTest.java --- openjdk-17-17.0.17+10/test/jdk/java/awt/Cursor/MultiResolutionCursorTest/MultiResolutionCursorTest.java 2025-10-13 07:48:04.000000000 +0000 +++ openjdk-17-17.0.18+8/test/jdk/java/awt/Cursor/MultiResolutionCursorTest/MultiResolutionCursorTest.java 1970-01-01 00:00:00.000000000 +0000 @@ -1,233 +0,0 @@ -/* - * Copyright (c) 2013, 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. - */ -import java.awt.BorderLayout; -import java.awt.Color; -import java.awt.Cursor; -import java.awt.Dialog; -import java.awt.Frame; -import java.awt.Graphics2D; -import java.awt.Image; -import java.awt.Label; -import java.awt.Point; -import java.awt.TextArea; -import java.awt.Toolkit; -import java.awt.image.BaseMultiResolutionImage; -import java.awt.image.BufferedImage; -import javax.swing.JApplet; - -import jdk.test.lib.Platform; - -/** - * @test - * @bug 8028212 - * @summary [macosx] Custom Cursor HiDPI support - * @author Alexander Scherbatiy - * @library /test/lib - * @modules java.desktop/sun.awt.image - * @build jdk.test.lib.Platform - * @run applet/manual=yesno MultiResolutionCursorTest.html - */ -public class MultiResolutionCursorTest extends JApplet { - //Declare things used in the test, like buttons and labels here - - static final int sizes[] = {8, 16, 32, 128}; - static final Color colors[] = {Color.WHITE, Color.RED, Color.GREEN, Color.BLUE}; - - public void init() { - //Create instructions for the user here, as well as set up - // the environment -- set the layout manager, add buttons, - // etc. - this.setLayout(new BorderLayout()); - - if (Platform.isOSX()) { - String[] instructions = { - "Verify that high resolution custom cursor is used" - + " on HiDPI displays.", - "1) Run the test on Retina display or enable the Quartz Debug" - + " and select the screen resolution with (HiDPI) label", - "2) Move the cursor to the Test Frame", - "3) Check that cursor has red, green or blue color", - "If so, press PASS, else press FAIL." - }; - Sysout.createDialogWithInstructions(instructions); - - } else { - String[] instructions = { - "This test is not applicable to the current platform. Press PASS." - }; - Sysout.createDialogWithInstructions(instructions); - } - }//End init() - - public void start() { - //Get things going. Request focus, set size, et cetera - setSize(200, 200); - setVisible(true); - validate(); - - final Image image = new BaseMultiResolutionImage( - createResolutionVariant(0), - createResolutionVariant(1), - createResolutionVariant(2), - createResolutionVariant(3) - ); - - int center = sizes[0] / 2; - Cursor cursor = Toolkit.getDefaultToolkit().createCustomCursor( - image, new Point(center, center), "multi-resolution cursor"); - - Frame frame = new Frame("Test Frame"); - frame.setSize(300, 300); - frame.setLocation(300, 50); - frame.add(new Label("Move cursor here")); - frame.setCursor(cursor); - frame.setVisible(true); - }// start() - - static BufferedImage createResolutionVariant(int i) { - BufferedImage resolutionVariant = new BufferedImage(sizes[i], sizes[i], - BufferedImage.TYPE_INT_RGB); - Graphics2D g2 = resolutionVariant.createGraphics(); - g2.setColor(colors[i]); - g2.fillRect(0, 0, sizes[i], sizes[i]); - g2.dispose(); - return resolutionVariant; - } -}// class BlockedWindowTest - -/* Place other classes related to the test after this line */ -/** - * ************************************************** - * Standard Test Machinery DO NOT modify anything below -- it's a standard chunk - * of code whose purpose is to make user interaction uniform, and thereby make - * it simpler to read and understand someone else's test. - * ************************************************** - */ -/** - * This is part of the standard test machinery. It creates a dialog (with the - * instructions), and is the interface for sending text messages to the user. To - * print the instructions, send an array of strings to Sysout.createDialog - * WithInstructions method. Put one line of instructions per array entry. To - * display a message for the tester to see, simply call Sysout.println with the - * string to be displayed. This mimics System.out.println but works within the - * test harness as well as standalone. - */ -class Sysout { - - private static TestDialog dialog; - - public static void createDialogWithInstructions(String[] instructions) { - dialog = new TestDialog(new Frame(), "Instructions"); - dialog.printInstructions(instructions); - dialog.setVisible(true); - println("Any messages for the tester will display here."); - } - - public static void createDialog() { - dialog = new TestDialog(new Frame(), "Instructions"); - String[] defInstr = {"Instructions will appear here. ", ""}; - dialog.printInstructions(defInstr); - dialog.setVisible(true); - println("Any messages for the tester will display here."); - } - - public static void printInstructions(String[] instructions) { - dialog.printInstructions(instructions); - } - - public static void println(String messageIn) { - dialog.displayMessage(messageIn); - } -}// Sysout class - -/** - * This is part of the standard test machinery. It provides a place for the test - * instructions to be displayed, and a place for interactive messages to the - * user to be displayed. To have the test instructions displayed, see Sysout. To - * have a message to the user be displayed, see Sysout. Do not call anything in - * this dialog directly. - */ -class TestDialog extends Dialog { - - TextArea instructionsText; - TextArea messageText; - int maxStringLength = 80; - - //DO NOT call this directly, go through Sysout - public TestDialog(Frame frame, String name) { - super(frame, name); - int scrollBoth = TextArea.SCROLLBARS_BOTH; - instructionsText = new TextArea("", 15, maxStringLength, scrollBoth); - add("North", instructionsText); - - messageText = new TextArea("", 5, maxStringLength, scrollBoth); - add("Center", messageText); - - pack(); - - setVisible(true); - }// TestDialog() - - //DO NOT call this directly, go through Sysout - public void printInstructions(String[] instructions) { - //Clear out any current instructions - instructionsText.setText(""); - - //Go down array of instruction strings - - String printStr, remainingStr; - for (int i = 0; i < instructions.length; i++) { - //chop up each into pieces maxSringLength long - remainingStr = instructions[ i]; - while (remainingStr.length() > 0) { - //if longer than max then chop off first max chars to print - if (remainingStr.length() >= maxStringLength) { - //Try to chop on a word boundary - int posOfSpace = remainingStr.lastIndexOf(' ', maxStringLength - 1); - - if (posOfSpace <= 0) { - posOfSpace = maxStringLength - 1; - } - - printStr = remainingStr.substring(0, posOfSpace + 1); - remainingStr = remainingStr.substring(posOfSpace + 1); - } //else just print - else { - printStr = remainingStr; - remainingStr = ""; - } - - instructionsText.append(printStr + "\n"); - - }// while - - }// for - - }//printInstructions() - - //DO NOT call this directly, go through Sysout - public void displayMessage(String messageIn) { - messageText.append(messageIn + "\n"); - System.out.println(messageIn); - } -}// Te diff -Nru openjdk-17-17.0.17+10/test/jdk/java/awt/Cursor/MultiResolutionCursorTest.java openjdk-17-17.0.18+8/test/jdk/java/awt/Cursor/MultiResolutionCursorTest.java --- openjdk-17-17.0.17+10/test/jdk/java/awt/Cursor/MultiResolutionCursorTest.java 1970-01-01 00:00:00.000000000 +0000 +++ openjdk-17-17.0.18+8/test/jdk/java/awt/Cursor/MultiResolutionCursorTest.java 2026-01-15 15:23:06.000000000 +0000 @@ -0,0 +1,99 @@ +/* + * Copyright (c) 2013, 2024, Oracle and/or its affiliates. All rights reserved. + * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. + * + * This code is free software; you can redistribute it and/or modify it + * under the terms of the GNU General Public License version 2 only, as + * published by the Free Software Foundation. + * + * This code is distributed in the hope that it will be useful, but WITHOUT + * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or + * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License + * version 2 for more details (a copy is included in the LICENSE file that + * accompanied this code). + * + * You should have received a copy of the GNU General Public License version + * 2 along with this work; if not, write to the Free Software Foundation, + * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. + * + * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA + * or visit www.oracle.com if you need additional information or have any + * questions. + */ + +import java.awt.Color; +import java.awt.Cursor; +import java.awt.Graphics2D; +import java.awt.Image; +import java.awt.Label; +import java.awt.Point; +import java.awt.Toolkit; +import java.awt.image.BaseMultiResolutionImage; +import java.awt.image.BufferedImage; +import java.lang.reflect.InvocationTargetException; +import javax.swing.JFrame; + +/* + * @test + * @bug 8028212 + * @summary [macosx] Custom Cursor HiDPI support + * @requires (os.family == "mac") + * @library /java/awt/regtesthelpers + * @build PassFailJFrame + * @run main/manual MultiResolutionCursorTest + */ +public class MultiResolutionCursorTest { + static final int sizes[] = {8, 16, 32, 128}; + + private static JFrame initialize() { + final Image image = new BaseMultiResolutionImage( + createResolutionVariant(0), + createResolutionVariant(1), + createResolutionVariant(2), + createResolutionVariant(3) + ); + + int center = sizes[0] / 2; + Cursor cursor = Toolkit.getDefaultToolkit().createCustomCursor( + image, new Point(center, center), "multi-resolution cursor"); + + JFrame frame = new JFrame("Multi-resolution Cursor Test Frame"); + frame.setSize(300, 300); + frame.add(new Label("Move cursor here")); + frame.setCursor(cursor); + return frame; + } + + private static BufferedImage createResolutionVariant(int i) { + BufferedImage resolutionVariant = new BufferedImage(sizes[i], sizes[i], + BufferedImage.TYPE_INT_RGB); + Graphics2D g2 = resolutionVariant.createGraphics(); + Color colors[] = {Color.WHITE, Color.RED, Color.GREEN, Color.BLUE}; + g2.setColor(colors[i]); + g2.fillRect(0, 0, sizes[i], sizes[i]); + g2.dispose(); + return resolutionVariant; + } + + public static void main(String[] args) throws InterruptedException, + InvocationTargetException { + String instructions = """ + Verify that high resolution custom cursor is used + on HiDPI displays. + 1) Run the test on Retina display or enable the Quartz Debug + and select the screen resolution with (HiDPI) label + 2) Move the cursor to the Test Frame + 3) Check that cursor has red, green or blue color + If so, press Pass, else press Fail. + """; + + PassFailJFrame.builder() + .title("Multi-resolution Cursor Test Instructions") + .instructions(instructions) + .rows((int) instructions.lines().count() + 1) + .columns(40) + .testUI(MultiResolutionCursorTest::initialize) + .build() + .awaitAndCheck(); + } +} diff -Nru openjdk-17-17.0.17+10/test/jdk/java/awt/Desktop/BrowseTest.java openjdk-17-17.0.18+8/test/jdk/java/awt/Desktop/BrowseTest.java --- openjdk-17-17.0.17+10/test/jdk/java/awt/Desktop/BrowseTest.java 2025-10-13 07:48:04.000000000 +0000 +++ openjdk-17-17.0.18+8/test/jdk/java/awt/Desktop/BrowseTest.java 2026-01-15 15:23:06.000000000 +0000 @@ -40,10 +40,27 @@ public class BrowseTest extends JPanel { static final String INSTRUCTIONS = """ - This test could launch default file manager to open user's home - directory, and default web browser to show the URL of java vendor. - After test execution close the native file manager and web browser + Set your default browser as per the test platform. + macOS - Safari + windows - MS Edge + linux - Firefox + + This test checks 2 cases: + + 1) Directory URI: + On macOS and windows, verify that a browser window opens and + EITHER the browser OR native file manager shows the user's + home directory. + + On Linux verify that the user's home directory is shown by the + default file manager. + + 2) Web URI: + Verify that the Web URI (URL of java vendor) opens in the browser. + + After test execution close the native file manager and any web browser windows if they were launched by test. + Also check output for any unexpected EXCEPTIONS, if you see any failure messages press Fail otherwise press Pass. """; @@ -53,7 +70,7 @@ URI dirURI = new File(System.getProperty("user.home")).toURI(); URI webURI = URI.create(System.getProperty("java.vendor.url", "http://www.java.com")); - boolean failed = false; + PassFailJFrame.log("Testing 1st case: Directory URI ..."); try { PassFailJFrame.log("Try to browse " + dirURI + " ..."); desktop.browse(dirURI); @@ -62,6 +79,7 @@ PassFailJFrame.log("EXCEPTION: " + e.getMessage()); } + PassFailJFrame.log("Testing 2nd case: Web URI ..."); try { PassFailJFrame.log("Try to browse " + webURI + " ..."); desktop.browse(webURI); diff -Nru openjdk-17-17.0.17+10/test/jdk/java/awt/Desktop/EditAndPrintTest/EditAndPrintTest.java openjdk-17-17.0.18+8/test/jdk/java/awt/Desktop/EditAndPrintTest/EditAndPrintTest.java --- openjdk-17-17.0.17+10/test/jdk/java/awt/Desktop/EditAndPrintTest/EditAndPrintTest.java 2025-10-13 07:48:04.000000000 +0000 +++ openjdk-17-17.0.18+8/test/jdk/java/awt/Desktop/EditAndPrintTest/EditAndPrintTest.java 2026-01-15 15:23:06.000000000 +0000 @@ -48,7 +48,7 @@ This test tries to edit and print a directory, which will expectedly raise IOException. Then this test would edit and print a .txt file, which should be successful. After test execution close the editor if it was launched by test. - If you see any EXCEPTION messages in the output press FAIL. + If you see any EXCEPTION messages in case of .txt file in the output press FAIL. """; static Desktop desktop; diff -Nru openjdk-17-17.0.17+10/test/jdk/java/awt/DesktopProperties/FontSmoothing.java openjdk-17-17.0.18+8/test/jdk/java/awt/DesktopProperties/FontSmoothing.java --- openjdk-17-17.0.17+10/test/jdk/java/awt/DesktopProperties/FontSmoothing.java 1970-01-01 00:00:00.000000000 +0000 +++ openjdk-17-17.0.18+8/test/jdk/java/awt/DesktopProperties/FontSmoothing.java 2026-01-15 15:23:06.000000000 +0000 @@ -0,0 +1,93 @@ +/* + * Copyright (c) 2003, 2024, Oracle and/or its affiliates. All rights reserved. + * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. + * + * This code is free software; you can redistribute it and/or modify it + * under the terms of the GNU General Public License version 2 only, as + * published by the Free Software Foundation. + * + * This code is distributed in the hope that it will be useful, but WITHOUT + * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or + * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License + * version 2 for more details (a copy is included in the LICENSE file that + * accompanied this code). + * + * You should have received a copy of the GNU General Public License version + * 2 along with this work; if not, write to the Free Software Foundation, + * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. + * + * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA + * or visit www.oracle.com if you need additional information or have any + * questions. + */ + +import java.awt.Frame; +import java.awt.Toolkit; +import java.beans.PropertyChangeEvent; +import java.beans.PropertyChangeListener; + +/* + * @test + * @bug 4808569 + * @requires (os.family == "windows") + * @library /java/awt/regtesthelpers + * @build PassFailJFrame + * @summary add desktop property for the Windows XP or later font smoothing settings + * @run main/manual FontSmoothing + */ + +public class FontSmoothing { + + private static final String PROP_NAME = "win.text.fontSmoothingType"; + + public static void main(String[] args) throws Exception { + String INSTRUCTIONS = """ + This test should be run on Windows XP or later. + + On Windows 11: + 1. Open Run dialog by typing 'run' in search bar. + 2. Type 'cttune' and press Ok. + 3. Uncheck the "Turn On ClearType" checkbox and follow next instructions on screen. + 4. Repeat Step 1-2. + 5. Check the "Turn On ClearType" checkbox and follow next instructions on screen. + 6. Take a look at the output window to determine if the test passed or failed. + """; + + PassFailJFrame.builder() + .title("FontSmoothing Test Instructions") + .instructions(INSTRUCTIONS) + .rows((int) INSTRUCTIONS.lines().count() + 2) + .columns(40) + .testTimeOut(5) + .testUI(FontSmoothing::createUI) + .logArea(8) + .build() + .awaitAndCheck(); + } + + private static Frame createUI() { + Frame f = new Frame("FontSmoothing Test"); + f.setSize(50, 50); + + Object value = Toolkit.getDefaultToolkit().getDesktopProperty(PROP_NAME); + PassFailJFrame.log("toolkit.getDesktopProperty: " + PROP_NAME + " = " + value + "\n"); + + Toolkit.getDefaultToolkit().addPropertyChangeListener(PROP_NAME, new PropertyChangeListener() { + public void propertyChange(PropertyChangeEvent e) { + PassFailJFrame.log("PropertyChangeEvent: " + e.getPropertyName() + + "\n old value=" + e.getOldValue() + + "\n new value=" + e.getNewValue()); + + Integer value = (Integer) Toolkit.getDefaultToolkit().getDesktopProperty(PROP_NAME); + PassFailJFrame.log("toolkit.getDesktopProperty:" + PROP_NAME + "=" + value); + + if (value.equals((Integer) e.getNewValue())) { + PassFailJFrame.log("test PASSED"); + } else { + PassFailJFrame.log("test FAILED"); + } + } + }); + return f; + } +} diff -Nru openjdk-17-17.0.17+10/test/jdk/java/awt/DesktopProperties/ThreeDBackgroundColor.java openjdk-17-17.0.18+8/test/jdk/java/awt/DesktopProperties/ThreeDBackgroundColor.java --- openjdk-17-17.0.17+10/test/jdk/java/awt/DesktopProperties/ThreeDBackgroundColor.java 1970-01-01 00:00:00.000000000 +0000 +++ openjdk-17-17.0.18+8/test/jdk/java/awt/DesktopProperties/ThreeDBackgroundColor.java 2026-01-15 15:23:06.000000000 +0000 @@ -0,0 +1,100 @@ +/* + * Copyright (c) 2000, 2024, Oracle and/or its affiliates. All rights reserved. + * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. + * + * This code is free software; you can redistribute it and/or modify it + * under the terms of the GNU General Public License version 2 only, as + * published by the Free Software Foundation. + * + * This code is distributed in the hope that it will be useful, but WITHOUT + * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or + * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License + * version 2 for more details (a copy is included in the LICENSE file that + * accompanied this code). + * + * You should have received a copy of the GNU General Public License version + * 2 along with this work; if not, write to the Free Software Foundation, + * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. + * + * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA + * or visit www.oracle.com if you need additional information or have any + * questions. + */ + +import java.awt.Color; +import java.awt.Frame; +import java.awt.Toolkit; +import java.beans.PropertyChangeEvent; +import java.beans.PropertyChangeListener; + +/* + * @test + * @bug 4368193 + * @library /java/awt/regtesthelpers + * @build PassFailJFrame + * @requires (os.family == "windows") + * @summary Toolkit's getDesktopProperty returns stale values on Microsoft Windows + * @run main/manual ThreeDBackgroundColor + */ + +public class ThreeDBackgroundColor { + + private static final String PROP_NAME = "win.3d.backgroundColor"; + + public static void main(String[] args) throws Exception { + String INSTRUCTIONS = """ + On Windows 10: + 1. Open Windows Settings, in the search bar type + 'high contrast', in the list of suggestions choose option + 'Turn high contrast on or off' + 2. In the High contrast control panel click on the on/off switch + to initialize High contrast mode + 3. Wait for the High contrast mode to finish initialization + 4. Click on the same switch again to turn off High contrast mode + + On Windows 11: + 1. Open Windows settings, in the search bar type + 'Contrast Theme'. + 2. Select any value from 'Contrast themes' dropdown menu and press 'Apply'. + 3. Wait for the High contrast mode to finish initialization + 4. Select 'None' from 'Contrast themes' dropdown menu to revert the changes. + + Take a look at the output window to determine if the test passed or failed."""; + + PassFailJFrame.builder() + .title("ThreeDBackgroundColor Test Instructions") + .instructions(INSTRUCTIONS) + .rows((int) INSTRUCTIONS.lines().count() + 2) + .columns(40) + .testTimeOut(5) + .testUI(ThreeDBackgroundColor::createUI) + .logArea(8) + .build() + .awaitAndCheck(); + } + + private static Frame createUI() { + Frame f = new Frame("ThreeDBackgroundColor Test"); + f.setSize(50, 50); + + Object value = Toolkit.getDefaultToolkit().getDesktopProperty(PROP_NAME); + PassFailJFrame.log("toolkit.getDesktopProperty:" + PROP_NAME + "=" + value); + + Toolkit.getDefaultToolkit().addPropertyChangeListener(PROP_NAME, new PropertyChangeListener() { + public void propertyChange(PropertyChangeEvent e) { + PassFailJFrame.log("PropertyChangeEvent: " + e.getPropertyName() + + "\n old value=" + e.getOldValue() + + "\n new value=" + e.getNewValue()); + + Color value = (Color) Toolkit.getDefaultToolkit().getDesktopProperty(PROP_NAME); + PassFailJFrame.log("toolkit.getDesktopProperty:" + PROP_NAME + "=" + value); + if (value.equals((Color) e.getNewValue())) { + PassFailJFrame.log("test PASSED"); + } else { + PassFailJFrame.log("test FAILED"); + } + } + }); + return f; + } +} diff -Nru openjdk-17-17.0.17+10/test/jdk/java/awt/FileDialog/DoubleActionESC.java openjdk-17-17.0.18+8/test/jdk/java/awt/FileDialog/DoubleActionESC.java --- openjdk-17-17.0.17+10/test/jdk/java/awt/FileDialog/DoubleActionESC.java 2025-10-13 07:48:04.000000000 +0000 +++ openjdk-17-17.0.18+8/test/jdk/java/awt/FileDialog/DoubleActionESC.java 2026-01-15 15:23:06.000000000 +0000 @@ -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 @@ -34,12 +34,15 @@ import java.awt.event.KeyEvent; import java.util.concurrent.CountDownLatch; +import static java.util.concurrent.TimeUnit.SECONDS; + /* * @test * @bug 5097243 * @summary Tests that FileDialog can be closed by ESC any time * @key headful * @run main DoubleActionESC + * @run main/othervm -Dsun.awt.disableGtkFileDialogs=true DoubleActionESC */ public class DoubleActionESC { @@ -49,47 +52,48 @@ private static Robot robot; private static volatile Point p; private static volatile Dimension d; - private static volatile CountDownLatch latch; private static final int REPEAT_COUNT = 2; + private static final long LATCH_TIMEOUT = 10; - public static void main(String[] args) throws Exception { - latch = new CountDownLatch(1); + private static final CountDownLatch latch = new CountDownLatch(REPEAT_COUNT); + public static void main(String[] args) throws Exception { robot = new Robot(); - robot.setAutoDelay(100); + robot.setAutoDelay(50); try { EventQueue.invokeAndWait(() -> { createAndShowUI(); }); + robot.waitForIdle(); robot.delay(1000); + EventQueue.invokeAndWait(() -> { p = showBtn.getLocationOnScreen(); d = showBtn.getSize(); }); for (int i = 0; i < REPEAT_COUNT; ++i) { - Thread thread = new Thread(() -> { - robot.mouseMove(p.x + d.width / 2, p.y + d.height / 2); - robot.mousePress(InputEvent.BUTTON1_DOWN_MASK); - robot.mouseRelease(InputEvent.BUTTON1_DOWN_MASK); - }); - thread.start(); - robot.delay(3000); - - Thread thread1 = new Thread(() -> { - robot.keyPress(KeyEvent.VK_ESCAPE); - robot.keyRelease(KeyEvent.VK_ESCAPE); - robot.waitForIdle(); - }); - thread1.start(); - robot.delay(3000); + robot.mouseMove(p.x + d.width / 2, p.y + d.height / 2); + robot.mousePress(InputEvent.BUTTON1_DOWN_MASK); + robot.mouseRelease(InputEvent.BUTTON1_DOWN_MASK); + robot.waitForIdle(); + robot.delay(1000); + + robot.keyPress(KeyEvent.VK_ESCAPE); + robot.keyRelease(KeyEvent.VK_ESCAPE); + robot.waitForIdle(); + robot.delay(1000); } - latch.await(); - if (fd.isVisible()) { - throw new RuntimeException("File Dialog is not closed"); + if (!latch.await(LATCH_TIMEOUT, SECONDS)) { + throw new RuntimeException("Test failed: Latch timeout reached"); } + EventQueue.invokeAndWait(() -> { + if (fd.isVisible()) { + throw new RuntimeException("File Dialog is not closed"); + } + }); } finally { EventQueue.invokeAndWait(() -> { if (f != null) { diff -Nru openjdk-17-17.0.17+10/test/jdk/java/awt/Focus/ComponentLostFocusTest.java openjdk-17-17.0.18+8/test/jdk/java/awt/Focus/ComponentLostFocusTest.java --- openjdk-17-17.0.17+10/test/jdk/java/awt/Focus/ComponentLostFocusTest.java 2025-10-13 07:48:04.000000000 +0000 +++ openjdk-17-17.0.18+8/test/jdk/java/awt/Focus/ComponentLostFocusTest.java 2026-01-15 15:23:06.000000000 +0000 @@ -1,5 +1,5 @@ /* - * Copyright (c) 2004, 2024, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2004, 2025, Oracle and/or its affiliates. All rights reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * * This code is free software; you can redistribute it and/or modify it @@ -35,13 +35,20 @@ import java.awt.Frame; import java.awt.KeyboardFocusManager; import java.awt.Point; +import java.awt.Rectangle; import java.awt.Robot; import java.awt.TextField; +import java.awt.Toolkit; import java.awt.event.FocusAdapter; import java.awt.event.FocusEvent; import java.awt.event.InputEvent; import java.awt.event.WindowAdapter; import java.awt.event.WindowEvent; +import java.io.File; +import java.util.concurrent.CountDownLatch; +import java.util.concurrent.TimeUnit; + +import javax.imageio.ImageIO; public class ComponentLostFocusTest { @@ -49,10 +56,10 @@ static TextField tf; static Robot r; static Dialog dialog = null; - static volatile boolean passed; static volatile Point loc; static volatile int width; static volatile int top; + static final CountDownLatch focusGainedLatch = new CountDownLatch(1); private static void createTestUI() { @@ -75,11 +82,7 @@ public static void doTest() { System.out.println("dialog.setVisible.... "); - new Thread(new Runnable() { - public void run() { - dialog.setVisible(true); - } - }).start(); + new Thread(() -> dialog.setVisible(true)).start(); // The bug is that this construction leads to the redundant xRequestFocus // By the way, the requestFocusInWindow() works fine before the fix @@ -98,7 +101,7 @@ tf.addFocusListener(new FocusAdapter() { public void focusGained(FocusEvent e) { System.out.println("TextField gained focus: " + e); - passed = true; + focusGainedLatch.countDown(); } }); @@ -116,6 +119,17 @@ tf.requestFocus(); } + private static void captureScreen() { + try { + final Rectangle screenBounds = new Rectangle( + Toolkit.getDefaultToolkit().getScreenSize()); + ImageIO.write(r.createScreenCapture(screenBounds), + "png", new File("ComponentLostFocusTest.png")); + } catch (Exception e) { + e.printStackTrace(); + } + } + public static final void main(String args[]) throws Exception { r = new Robot(); r.setAutoDelay(100); @@ -138,9 +152,10 @@ System.out.println("Focus owner: " + KeyboardFocusManager.getCurrentKeyboardFocusManager(). getFocusOwner()); - - if (!passed) { - throw new RuntimeException("TextField got no focus! Test failed."); + if (!focusGainedLatch.await(5, TimeUnit.SECONDS)) { + captureScreen(); + throw new RuntimeException("Waited too long, " + + "TextField got no focus! Test failed."); } } finally { EventQueue.invokeAndWait(() -> { @@ -151,4 +166,3 @@ } } } - diff -Nru openjdk-17-17.0.17+10/test/jdk/java/awt/Focus/MinimizeNonfocusableWindowTest.java openjdk-17-17.0.18+8/test/jdk/java/awt/Focus/MinimizeNonfocusableWindowTest.java --- openjdk-17-17.0.17+10/test/jdk/java/awt/Focus/MinimizeNonfocusableWindowTest.java 1970-01-01 00:00:00.000000000 +0000 +++ openjdk-17-17.0.18+8/test/jdk/java/awt/Focus/MinimizeNonfocusableWindowTest.java 2026-01-15 15:23:06.000000000 +0000 @@ -0,0 +1,76 @@ +/* + * Copyright (c) 2011, 2024, Oracle and/or its affiliates. All rights reserved. + * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. + * + * This code is free software; you can redistribute it and/or modify it + * 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 6399659 + * @summary When minimizing non-focusable window focus shouldn't jump out of the focused window. + * @library /java/awt/regtesthelpers + * @build PassFailJFrame + * @run main/manual MinimizeNonfocusableWindowTest +*/ + +import java.awt.Frame; +import java.awt.Window; +import java.util.List; + +public class MinimizeNonfocusableWindowTest { + + private static final String INSTRUCTIONS = """ + + You should see three frames: Frame-1, Frame-2 and Unfocusable. + + 1. Click Frame-1 to make it focused window, then click Frame-2. + Minimize Unfocusable frame with the mouse. If Frame-2 is still + the focused window continue testing, otherwise press FAIL. + + 2. Restore Unfocusable frame to normal state. Try to resize by dragging + its edge with left mouse button. It should be resizable. If not press + FAIL. Try the same with right mouse button. It shouldn't resize. + If it does, press FAIL, otherwise press PASS."""; + + public static void main(String[] args) throws Exception { + PassFailJFrame.builder() + .title("MinimizeNonfocusableWindowTest Instructions") + .instructions(INSTRUCTIONS) + .rows((int) INSTRUCTIONS.lines().count() + 1) + .columns(40) + .testUI(MinimizeNonfocusableWindowTest::createTestUI) + .build() + .awaitAndCheck(); + } + + private static List createTestUI() { + Frame frame1 = new Frame("Frame-1"); + Frame frame2 = new Frame("Frame-2"); + Frame frame3 = new Frame("Unfocusable"); + frame1.setBounds(100, 0, 200, 100); + frame2.setBounds(100, 150, 200, 100); + frame3.setBounds(100, 300, 200, 100); + + frame3.setFocusableWindowState(false); + + return List.of(frame1, frame2, frame3); + } +} + diff -Nru openjdk-17-17.0.17+10/test/jdk/java/awt/Focus/WindowDisposeFocusTest.java openjdk-17-17.0.18+8/test/jdk/java/awt/Focus/WindowDisposeFocusTest.java --- openjdk-17-17.0.17+10/test/jdk/java/awt/Focus/WindowDisposeFocusTest.java 1970-01-01 00:00:00.000000000 +0000 +++ openjdk-17-17.0.18+8/test/jdk/java/awt/Focus/WindowDisposeFocusTest.java 2026-01-15 15:23:06.000000000 +0000 @@ -0,0 +1,98 @@ +/* + * Copyright (c) 1999, 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 4257071 4228379 + * @summary Ensures that focus lost is delivered to a lightweight component + in a disposed window + * @library /java/awt/regtesthelpers + * @build PassFailJFrame + * @run main/manual WindowDisposeFocusTest +*/ + +import java.awt.Window; +import java.awt.event.WindowAdapter; +import java.awt.event.WindowEvent; +import javax.swing.JButton; +import javax.swing.JDialog; +import javax.swing.JFrame; +import javax.swing.JPanel; + +public class WindowDisposeFocusTest { + + private static final String INSTRUCTIONS = """ + Click on "Second" + Click on close box + When dialog pops up, "Second" should no longer have focus."""; + + public static void main(String[] args) throws Exception { + PassFailJFrame.builder() + .title("WindowDisposeFocusTest Instructions") + .instructions(INSTRUCTIONS) + .rows((int) INSTRUCTIONS.lines().count() + 2) + .columns(35) + .testUI(WindowDisposeFocusTest::createTestUI) + .build() + .awaitAndCheck(); + } + + private static Window createTestUI() { + return JFCFocusBug2.test(new String[]{}); + } +} + +class JFCFocusBug2 extends JPanel { + + static public Window test(String[] args) { + final JFrame frame = new JFrame("WindowDisposeFrame"); + frame.setSize(100, 100); + frame.setVisible(true); + + final JFCFocusBug2 bug = new JFCFocusBug2(); + final JDialog dialog = new JDialog(frame, false); + dialog.addWindowListener(new WindowAdapter() { + public void windowClosing(WindowEvent e) { + dialog.dispose(); + JDialog dialog2 = new JDialog(frame, false); + dialog2.setContentPane(bug); + dialog2.pack(); + dialog2.setVisible(true); + } + }); + dialog.setContentPane(bug); + dialog.pack(); + dialog.setVisible(true); + return frame; + } + + public JFCFocusBug2() { + _first = new JButton("First"); + _second = new JButton("Second"); + add(_first); + add(_second); + } + + private JButton _first; + private JButton _second; +} diff -Nru openjdk-17-17.0.17+10/test/jdk/java/awt/Focus/bug6435715.java openjdk-17-17.0.18+8/test/jdk/java/awt/Focus/bug6435715.java --- openjdk-17-17.0.17+10/test/jdk/java/awt/Focus/bug6435715.java 1970-01-01 00:00:00.000000000 +0000 +++ openjdk-17-17.0.18+8/test/jdk/java/awt/Focus/bug6435715.java 2026-01-15 15:23:06.000000000 +0000 @@ -0,0 +1,91 @@ +/* + * Copyright (c) 2006, 2024, Oracle and/or its affiliates. All rights reserved. + * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. + * + * This code is free software; you can redistribute it and/or modify it + * 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 6435715 + * @summary JButton stops receiving the focusGained event and eventually focus is lost altogether + * @modules java.desktop/sun.awt + * @library /java/awt/regtesthelpers + * @build PassFailJFrame + * @run main/manual bug6435715 + */ + +import java.awt.event.FocusAdapter; +import java.awt.event.FocusEvent; +import javax.swing.JButton; +import javax.swing.JFrame; +import javax.swing.JPanel; + +public class bug6435715 { + + private static final String INSTRUCTIONS = """ + 1. after test started you will see frame with three buttons. Notice that focus is on Button2. + 2. Click on Button 3. Focus goes to Button3. + 3. Click on Button1 and quickly switch to another window. Via either alt/tab or + clicking another window with the mouse. + 4. After a few seconds, come back to the frame. Notice that focus is around Button2 + 5. Click at Button3. If focus remains at Button2 test failed, if focus is on Button3 - test passed."""; + + public static void main(String[] args) throws Exception { + PassFailJFrame.builder() + .title("bug6435715 Instructions") + .instructions(INSTRUCTIONS) + .rows((int) INSTRUCTIONS.lines().count() + 5) + .columns(35) + .testUI(bug6435715::createTestUI) + .build() + .awaitAndCheck(); + } + + private static JFrame createTestUI() { + JFrame fr = new JFrame("FocusIssue"); + sun.awt.SunToolkit.setLWRequestStatus(fr, true); + + JPanel panel = new JPanel(); + final JButton b1 = new JButton("Button 1"); + final JButton b2 = new JButton("Button 2"); + final JButton b3 = new JButton("Button 3"); + + panel.add(b1); + panel.add(b2); + panel.add(b3); + + b1.addFocusListener(new FocusAdapter() { + public void focusGained(FocusEvent event) { + synchronized (this) { + try { + wait(1000); + } catch (Exception ex) { + ex.printStackTrace(); + } + b2.requestFocus(); + } + } + }); + fr.getContentPane().add(panel); + fr.pack(); + return fr; + } + +} diff -Nru openjdk-17-17.0.17+10/test/jdk/java/awt/FontClass/FontTransformAttributeTest.java openjdk-17-17.0.18+8/test/jdk/java/awt/FontClass/FontTransformAttributeTest.java --- openjdk-17-17.0.17+10/test/jdk/java/awt/FontClass/FontTransformAttributeTest.java 1970-01-01 00:00:00.000000000 +0000 +++ openjdk-17-17.0.18+8/test/jdk/java/awt/FontClass/FontTransformAttributeTest.java 2026-01-15 15:23:06.000000000 +0000 @@ -0,0 +1,84 @@ +/* + * Copyright (c) 2002, 2025, Oracle and/or its affiliates. All rights reserved. + * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. + * + * This code is free software; you can redistribute it and/or modify it + * under the terms of the GNU General Public License version 2 only, as + * published by the Free Software Foundation. + * + * This code is distributed in the hope that it will be useful, but WITHOUT + * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or + * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License + * version 2 for more details (a copy is included in the LICENSE file that + * accompanied this code). + * + * You should have received a copy of the GNU General Public License version + * 2 along with this work; if not, write to the Free Software Foundation, + * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. + * + * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA + * or visit www.oracle.com if you need additional information or have any + * questions. + */ + +import java.awt.Color; +import java.awt.Dimension; +import java.awt.Graphics; +import java.awt.Graphics2D; +import java.awt.font.TextAttribute; +import java.awt.font.TransformAttribute; +import java.awt.geom.AffineTransform; +import java.text.AttributedCharacterIterator; +import java.text.AttributedString; + +import javax.swing.JPanel; + +/* + * @test + * @bug 4650042 + * @summary Draw text using a transform to simulate superscript, it should look like a superscript + * @library /java/awt/regtesthelpers + * @build PassFailJFrame + * @run main/manual FontTransformAttributeTest + */ + +public class FontTransformAttributeTest extends JPanel { + AttributedCharacterIterator iter; + + public static void main(String[] args) throws Exception { + final String INSTRUCTIONS = """ + This test should display a string ending with the superscripted number '11'. + Pass the test if you see the superscript."""; + + PassFailJFrame.builder() + .title("FontTransformAttributeTest Instruction") + .instructions(INSTRUCTIONS) + .columns(35) + .splitUI(FontTransformAttributeTest::new) + .build() + .awaitAndCheck(); + } + + FontTransformAttributeTest() { + AffineTransform superTransform = AffineTransform.getScaleInstance(0.65, 0.65); + superTransform.translate(0, -7); + TransformAttribute superAttribute = new TransformAttribute(superTransform); + String s = "a big number 7 11"; + AttributedString as = new AttributedString(s); + as.addAttribute(TextAttribute.TRANSFORM, superAttribute, 15, 17); + iter = as.getIterator(); + setBackground(Color.WHITE); + } + + @Override + public Dimension getPreferredSize() { + return new Dimension(200, 100); + } + + @Override + public void paint(Graphics g) { + Graphics2D g2 = (Graphics2D) g; + Dimension d = getSize(); + g2.drawString(iter, 20, d.height / 2 + 8); + } +} diff -Nru openjdk-17-17.0.17+10/test/jdk/java/awt/FontClass/FontUnderscoreTest.java openjdk-17-17.0.18+8/test/jdk/java/awt/FontClass/FontUnderscoreTest.java --- openjdk-17-17.0.17+10/test/jdk/java/awt/FontClass/FontUnderscoreTest.java 1970-01-01 00:00:00.000000000 +0000 +++ openjdk-17-17.0.18+8/test/jdk/java/awt/FontClass/FontUnderscoreTest.java 2026-01-15 15:23:06.000000000 +0000 @@ -0,0 +1,77 @@ +/* + * Copyright (c) 1999, 2025, Oracle and/or its affiliates. All rights reserved. + * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. + * + * This code is free software; you can redistribute it and/or modify it + * under the terms of the GNU General Public License version 2 only, as + * published by the Free Software Foundation. + * + * This code is distributed in the hope that it will be useful, but WITHOUT + * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or + * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License + * version 2 for more details (a copy is included in the LICENSE file that + * accompanied this code). + * + * You should have received a copy of the GNU General Public License version + * 2 along with this work; if not, write to the Free Software Foundation, + * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. + * + * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA + * or visit www.oracle.com if you need additional information or have any + * questions. + */ + +import java.awt.Dimension; +import java.awt.Font; +import java.awt.Graphics; + +import javax.swing.JPanel; + +/* + * @test + * @bug 4248579 + * @summary Make sure the underscore glyph appears in the different strings + * @library /java/awt/regtesthelpers + * @build PassFailJFrame + * @run main/manual FontUnderscoreTest + */ + +public class FontUnderscoreTest extends JPanel { + public static void main(String[] args) throws Exception { + final String INSTRUCTIONS = """ + Make sure all 8 underscore characters appear in each + of the 3 strings. + + Press PASS if all 8 are there, else FAIL."""; + + PassFailJFrame.builder() + .title("FontUnderscoreTest Instruction") + .instructions(INSTRUCTIONS) + .columns(35) + .splitUI(FontUnderscoreTest::new) + .build() + .awaitAndCheck(); + } + + @Override + public Dimension getPreferredSize() { + return new Dimension(550, 230); + } + + @Override + public void paint(Graphics g) { + Font f = new Font(Font.SANS_SERIF, Font.PLAIN, 24); + g.setFont(f); + g.drawString ("8 underscore characters appear in each string", 5, 200); + + g.drawString("J_A_V_A_2_j_a_v_a", 25, 50); + + f = new Font(Font.SERIF, Font.PLAIN, 24); + g.setFont(f); + g.drawString("J_A_V_A_2_j_a_v_a", 25, 100); + + f = new Font(Font.MONOSPACED, Font.PLAIN, 24); + g.setFont(f); + g.drawString("J_A_V_A_2_j_a_v_a", 25, 150); + } +} diff -Nru openjdk-17-17.0.17+10/test/jdk/java/awt/Frame/ShownOnPack/ShownOnPack.html openjdk-17-17.0.18+8/test/jdk/java/awt/Frame/ShownOnPack/ShownOnPack.html --- openjdk-17-17.0.17+10/test/jdk/java/awt/Frame/ShownOnPack/ShownOnPack.html 2025-10-13 07:48:04.000000000 +0000 +++ openjdk-17-17.0.18+8/test/jdk/java/awt/Frame/ShownOnPack/ShownOnPack.html 1970-01-01 00:00:00.000000000 +0000 @@ -1,43 +0,0 @@ - - - - - - ShownOnPack - - - -

ShownOnPack
Bug ID: 6525850

- -

See the dialog box (usually in upper left corner) for instructions

- - - - diff -Nru openjdk-17-17.0.17+10/test/jdk/java/awt/Frame/ShownOnPack/ShownOnPack.java openjdk-17-17.0.18+8/test/jdk/java/awt/Frame/ShownOnPack/ShownOnPack.java --- openjdk-17-17.0.17+10/test/jdk/java/awt/Frame/ShownOnPack/ShownOnPack.java 2025-10-13 07:48:04.000000000 +0000 +++ openjdk-17-17.0.18+8/test/jdk/java/awt/Frame/ShownOnPack/ShownOnPack.java 2026-01-15 15:23:06.000000000 +0000 @@ -1,5 +1,5 @@ /* - * Copyright (c) 2007, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2007, 2024, Oracle and/or its affiliates. All rights reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * * This code is free software; you can redistribute it and/or modify it @@ -21,208 +21,48 @@ * questions. */ +import java.awt.EventQueue; +import java.awt.Frame; + /* - test - @bug 6525850 - @summary Iconified frame gets shown after pack() - @author anthony.petrov@...: area=awt.toplevel - @run applet/manual=yesno ShownOnPack.html + * @test + * @bug 6525850 + * @summary Iconified frame gets shown after pack() + * @library /java/awt/regtesthelpers + * @build PassFailJFrame + * @run main/manual ShownOnPack */ +public class ShownOnPack { -/** - * ShownOnPack.java - * - * summary: - */ - -import java.applet.Applet; -import java.awt.*; - -public class ShownOnPack extends Applet -{ - //Declare things used in the test, like buttons and labels here - Frame f; - - public void init() - { - //Create instructions for the user here, as well as set up - // the environment -- set the layout manager, add buttons, - // etc. - this.setLayout (new BorderLayout ()); - - String[] instructions = - { - "This test creates an invisible and iconified frame that should not become visible.", - "If you observe the window titled 'Should NOT BE SHOWN' in the taskbar, press FAIL,", - "else press PASS" - }; - Sysout.createDialogWithInstructions( instructions ); - - }//End init() - - public void start () - { - //Get things going. Request focus, set size, et cetera - setSize (200,200); - setVisible(true); - validate(); - - //What would normally go into main() will probably go here. - //Use System.out.println for diagnostic messages that you want - // to read after the test is done. - //Use Sysout.println for messages you want the tester to read. - f = new Frame("Should NOT BE SHOWN"); - f.setExtendedState(Frame.ICONIFIED); - f.pack(); - }// start() - - //The rest of this class is the actions which perform the test... - - //Use Sysout.println to communicate with the user NOT System.out!! - //Sysout.println ("Something Happened!"); - -}// class ShownOnPack - -/* Place other classes related to the test after this line */ - + private static final String INSTRUCTIONS = """ + This test creates an invisible and iconified frame that should not become visible. - - - -/**************************************************** - Standard Test Machinery - DO NOT modify anything below -- it's a standard - chunk of code whose purpose is to make user - interaction uniform, and thereby make it simpler - to read and understand someone else's test. - ****************************************************/ - -/** - This is part of the standard test machinery. - It creates a dialog (with the instructions), and is the interface - for sending text messages to the user. - To print the instructions, send an array of strings to Sysout.createDialog - WithInstructions method. Put one line of instructions per array entry. - To display a message for the tester to see, simply call Sysout.println - with the string to be displayed. - This mimics System.out.println but works within the test harness as well - as standalone. - */ - -class Sysout -{ - private static TestDialog dialog; - - public static void createDialogWithInstructions( String[] instructions ) - { - dialog = new TestDialog( new Frame(), "Instructions" ); - dialog.printInstructions( instructions ); - dialog.setVisible(true); - println( "Any messages for the tester will display here." ); + If you observe the window titled 'Should NOT BE SHOWN' in the taskbar, + press FAIL, otherwise press PASS + """; + + static Frame frame; + + public static void main(String[] args) throws Exception { + PassFailJFrame shownOnPackInstructions = PassFailJFrame + .builder() + .title("ShownOnPack Instructions") + .instructions(INSTRUCTIONS) + .rows(5) + .columns(50) + .build(); + + EventQueue.invokeAndWait(() -> { + frame = new Frame("Should NOT BE SHOWN"); + frame.setExtendedState(Frame.ICONIFIED); + frame.pack(); + }); + + try { + shownOnPackInstructions.awaitAndCheck(); + } finally { + EventQueue.invokeAndWait(() -> frame.dispose()); + } } - - public static void createDialog( ) - { - dialog = new TestDialog( new Frame(), "Instructions" ); - String[] defInstr = { "Instructions will appear here. ", "" } ; - dialog.printInstructions( defInstr ); - dialog.setVisible(true); - println( "Any messages for the tester will display here." ); - } - - - public static void printInstructions( String[] instructions ) - { - dialog.printInstructions( instructions ); - } - - - public static void println( String messageIn ) - { - dialog.displayMessage( messageIn ); - } - -}// Sysout class - -/** - This is part of the standard test machinery. It provides a place for the - test instructions to be displayed, and a place for interactive messages - to the user to be displayed. - To have the test instructions displayed, see Sysout. - To have a message to the user be displayed, see Sysout. - Do not call anything in this dialog directly. - */ -class TestDialog extends Dialog -{ - - TextArea instructionsText; - TextArea messageText; - int maxStringLength = 80; - - //DO NOT call this directly, go through Sysout - public TestDialog( Frame frame, String name ) - { - super( frame, name ); - int scrollBoth = TextArea.SCROLLBARS_BOTH; - instructionsText = new TextArea( "", 15, maxStringLength, scrollBoth ); - add( "North", instructionsText ); - - messageText = new TextArea( "", 5, maxStringLength, scrollBoth ); - add("Center", messageText); - - pack(); - - setVisible(true); - }// TestDialog() - - //DO NOT call this directly, go through Sysout - public void printInstructions( String[] instructions ) - { - //Clear out any current instructions - instructionsText.setText( "" ); - - //Go down array of instruction strings - - String printStr, remainingStr; - for( int i=0; i < instructions.length; i++ ) - { - //chop up each into pieces maxSringLength long - remainingStr = instructions[ i ]; - while( remainingStr.length() > 0 ) - { - //if longer than max then chop off first max chars to print - if( remainingStr.length() >= maxStringLength ) - { - //Try to chop on a word boundary - int posOfSpace = remainingStr. - lastIndexOf( ' ', maxStringLength - 1 ); - - if( posOfSpace <= 0 ) posOfSpace = maxStringLength - 1; - - printStr = remainingStr.substring( 0, posOfSpace + 1 ); - remainingStr = remainingStr.substring( posOfSpace + 1 ); - } - //else just print - else - { - printStr = remainingStr; - remainingStr = ""; - } - - instructionsText.append( printStr + "\n" ); - - }// while - - }// for - - }//printInstructions() - - //DO NOT call this directly, go through Sysout - public void displayMessage( String messageIn ) - { - messageText.append( messageIn + "\n" ); - System.out.println(messageIn); - } - -}// TestDialog class +} diff -Nru openjdk-17-17.0.17+10/test/jdk/java/awt/FullScreen/NonfocusableFrameFullScreenTest.java openjdk-17-17.0.18+8/test/jdk/java/awt/FullScreen/NonfocusableFrameFullScreenTest.java --- openjdk-17-17.0.17+10/test/jdk/java/awt/FullScreen/NonfocusableFrameFullScreenTest.java 1970-01-01 00:00:00.000000000 +0000 +++ openjdk-17-17.0.18+8/test/jdk/java/awt/FullScreen/NonfocusableFrameFullScreenTest.java 2026-01-15 15:23:06.000000000 +0000 @@ -0,0 +1,139 @@ +/* + * 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 + * under the terms of the GNU General Public License version 2 only, as + * published by the Free Software Foundation. + * + * This code is distributed in the hope that it will be useful, but WITHOUT + * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or + * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License + * version 2 for more details (a copy is included in the LICENSE file that + * accompanied this code). + * + * You should have received a copy of the GNU General Public License version + * 2 along with this work; if not, write to the Free Software Foundation, + * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. + * + * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA + * or visit www.oracle.com if you need additional information or have any + * questions. + */ + +import java.awt.BorderLayout; +import java.awt.Button; +import java.awt.Dimension; +import java.awt.Frame; +import java.awt.GraphicsEnvironment; + +import java.awt.event.ActionEvent; +import java.awt.event.ActionListener; + +import javax.swing.JPanel; + +/* + * @test + * @bug 6225472 6682536 + * @requires (os.family != "linux") + * @summary Tests that non-focusable Frame in full-screen mode overlaps the task bar. + * @library /java/awt/regtesthelpers + * @build PassFailJFrame + * @run main/manual NonfocusableFrameFullScreenTest + */ + +public class NonfocusableFrameFullScreenTest extends JPanel { + boolean fullscreen = false; + + public static void main(String[] args) throws Exception { + final String INSTRUCTIONS = """ + 1. Press "Show Frame" button to show a Frame with two buttons. + + 2. Press the button "To Full Screen" to bring the frame to + full-screen mode: + + The frame should overlap the taskbar + + 3. Press "To Windowed" button: + The frame should return to its original size. + The frame shouldn't be alwaysOnTop. + + 4. Press "Set Always On Top" button and make sure the frame + is alwaysOnTop, then press "To Full Screen" button + and then "To Windowed" button: + + The frame should return to its original size keeping alwaysOnTop + state on. + + Press Pass if everything is as expected."""; + + PassFailJFrame.builder() + .instructions(INSTRUCTIONS) + .columns(45) + .testUI(NonfocusableFrameFullScreenTest::new) + .build() + .awaitAndCheck(); + } + + private NonfocusableFrameFullScreenTest() { + Button b = new Button("Show Frame"); + b.addActionListener(new ActionListener() { + @Override + public void actionPerformed(ActionEvent e) { + showFrame(); + } + }); + setLayout(new BorderLayout()); + add(b, BorderLayout.CENTER); + } + + @Override + public Dimension getPreferredSize() { + return new Dimension(200, 100); + } + + public void showFrame() { + Frame frame = new Frame("Test Frame"); + + Button button = new Button("To Full Screen"); + button.addActionListener(new ActionListener() { + @Override + public void actionPerformed(ActionEvent e) { + if (fullscreen) { + GraphicsEnvironment.getLocalGraphicsEnvironment().getDefaultScreenDevice(). + setFullScreenWindow(null); + button.setLabel("To Full Screen"); + fullscreen = false; + } else { + GraphicsEnvironment.getLocalGraphicsEnvironment().getDefaultScreenDevice(). + setFullScreenWindow(frame); + button.setLabel("To Windowed"); + fullscreen = true; + } + frame.validate(); + } + }); + + Button button2 = new Button("Set Always On Top"); + button2.addActionListener(new ActionListener() { + @Override + public void actionPerformed(ActionEvent e) { + if (frame.isAlwaysOnTop()) { + button2.setLabel("Set Always On Top"); + frame.setAlwaysOnTop(false); + } else { + button2.setLabel("Set Not Always On Top"); + frame.setAlwaysOnTop(true); + } + frame.validate(); + } + }); + + frame.setLayout(new BorderLayout()); + frame.add(button, BorderLayout.WEST); + frame.add(button2, BorderLayout.EAST); + frame.setBounds(400, 200, 350, 100); + frame.setFocusableWindowState(false); + frame.setVisible(true); + } +} diff -Nru openjdk-17-17.0.17+10/test/jdk/java/awt/Graphics/GDIResourceExhaustionTest.java openjdk-17-17.0.18+8/test/jdk/java/awt/Graphics/GDIResourceExhaustionTest.java --- openjdk-17-17.0.17+10/test/jdk/java/awt/Graphics/GDIResourceExhaustionTest.java 1970-01-01 00:00:00.000000000 +0000 +++ openjdk-17-17.0.18+8/test/jdk/java/awt/Graphics/GDIResourceExhaustionTest.java 2026-01-15 15:23:06.000000000 +0000 @@ -0,0 +1,121 @@ +/* + * Copyright (c) 1999, 2025, Oracle and/or its affiliates. All rights reserved. + * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. + * + * This code is free software; you can redistribute 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.imageio.ImageIO; +import java.awt.AWTException; +import java.awt.Color; +import java.awt.Dimension; +import java.awt.EventQueue; +import java.awt.Frame; +import java.awt.Graphics; +import java.awt.Insets; +import java.awt.Label; +import java.awt.Panel; +import java.awt.Point; +import java.awt.Rectangle; +import java.awt.Robot; +import java.awt.image.BufferedImage; +import java.io.File; +import java.io.IOException; +import java.lang.reflect.InvocationTargetException; + +/* + * @test + * @bug 4191297 + * @summary Tests that unreferenced GDI resources are correctly + * destroyed when no longer needed. + * @key headful + * @run main GDIResourceExhaustionTest + */ + +public class GDIResourceExhaustionTest extends Frame { + public void initUI() { + setSize(200, 200); + setUndecorated(true); + setLocationRelativeTo(null); + Panel labelPanel = new Panel(); + Label label = new Label("Red label"); + label.setBackground(Color.red); + labelPanel.add(label); + labelPanel.setLocation(20, 50); + add(labelPanel); + setVisible(true); + } + + public void paint(Graphics graphics) { + super.paint(graphics); + for (int rgb = 0; rgb <= 0xfff; rgb++) { + graphics.setColor(new Color(rgb)); + graphics.fillRect(0, 0, 5, 5); + } + } + + public void requestCoordinates(Rectangle r) { + Insets insets = getInsets(); + Point location = getLocationOnScreen(); + Dimension size = getSize(); + r.x = location.x + insets.left; + r.y = location.y + insets.top; + r.width = size.width - (insets.left + insets.right); + r.height = size.height - (insets.top + insets.bottom); + } + + public static void main(String[] args) throws InterruptedException, + InvocationTargetException, AWTException, IOException { + GDIResourceExhaustionTest test = new GDIResourceExhaustionTest(); + try { + EventQueue.invokeAndWait(test::initUI); + Robot robot = new Robot(); + robot.delay(2000); + Rectangle coords = new Rectangle(); + EventQueue.invokeAndWait(() -> { + test.requestCoordinates(coords); + }); + robot.mouseMove(coords.x - 50, coords.y - 50); + robot.waitForIdle(); + robot.delay(5000); + BufferedImage capture = robot.createScreenCapture(coords); + robot.delay(500); + boolean redFound = false; + int redRGB = Color.red.getRGB(); + for (int y = 0; y < capture.getHeight(); y++) { + for (int x = 0; x < capture.getWidth(); x++) { + if (capture.getRGB(x, y) == redRGB) { + redFound = true; + break; + } + if (redFound) { + break; + } + } + } + if (!redFound) { + File errorImage = new File("screenshot.png"); + ImageIO.write(capture, "png", errorImage); + throw new RuntimeException("Red label is not detected, possibly GDI resources exhausted"); + } + } finally { + EventQueue.invokeAndWait(test::dispose); + } + } +} diff -Nru openjdk-17-17.0.17+10/test/jdk/java/awt/Graphics/RepeatedRepaintTest.java openjdk-17-17.0.18+8/test/jdk/java/awt/Graphics/RepeatedRepaintTest.java --- openjdk-17-17.0.17+10/test/jdk/java/awt/Graphics/RepeatedRepaintTest.java 1970-01-01 00:00:00.000000000 +0000 +++ openjdk-17-17.0.18+8/test/jdk/java/awt/Graphics/RepeatedRepaintTest.java 2026-01-15 15:23:06.000000000 +0000 @@ -0,0 +1,137 @@ +/* + * Copyright (c) 1998, 2025, Oracle and/or its affiliates. All rights reserved. + * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. + * + * This code is free software; you can redistribute it and/or modify it + * under the terms of the GNU General Public License version 2 only, as + * published by the Free Software Foundation. + * + * This code is distributed in the hope that it will be useful, but WITHOUT + * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or + * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License + * version 2 for more details (a copy is included in the LICENSE file that + * accompanied this code). + * + * You should have received a copy of the GNU General Public License version + * 2 along with this work; if not, write to the Free Software Foundation, + * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. + * + * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA + * or visit www.oracle.com if you need additional information or have any + * questions. + */ + +import java.awt.Color; +import java.awt.Dimension; +import java.awt.Font; +import java.awt.FontMetrics; +import java.awt.Frame; +import java.awt.Graphics; +import java.awt.Image; +import java.awt.image.BufferedImage; +import java.lang.reflect.InvocationTargetException; + +/* + * @test + * @bug 4081126 4129709 + * @summary Test for proper repainting on multiprocessor systems. + * @library /java/awt/regtesthelpers + * @build PassFailJFrame + * @run main/manual RepeatedRepaintTest + */ +public class RepeatedRepaintTest extends Frame { + private Font font = null; + private Image background; + + static String INSTRUCTIONS = """ + The frame next to this window called "AWT Draw Test" has + some elements drawn on it. Move this window partially outside of the + screen bounds and then drag it back. Repeat it couple of times. + Drag the instructions window over the frame partially obscuring it. + If after number of attempts the frame content stops repainting + press "Fail", otherwise press "Pass". + """; + + public RepeatedRepaintTest() { + setTitle("AWT Draw Test"); + setSize(300, 300); + background = new BufferedImage(300, 300, BufferedImage.TYPE_INT_ARGB); + Graphics g = background.getGraphics(); + g.setColor(Color.black); + g.fillRect(0, 0, 300, 300); + g.dispose(); + } + + public void paint(Graphics g) { + Dimension dim = this.getSize(); + super.paint(g); + g.drawImage(background, 0, 0, dim.width, dim.height, null); + g.setColor(Color.white); + if (font == null) { + font = new Font("SansSerif", Font.PLAIN, 24); + } + g.setFont(font); + FontMetrics metrics = g.getFontMetrics(); + String message = "Draw Test"; + g.drawString(message, (dim.width / 2) - (metrics.stringWidth(message) / 2), + (dim.height / 2) + (metrics.getHeight() / 2)); + + int counter = 50; + for (int i = 0; i < 50; i++) { + counter += 4; + g.drawOval(counter, 50, i, i); + } + + counter = 20; + for (int i = 0; i < 100; i++) { + counter += 4; + g.drawOval(counter, 150, i, i); + } + g.setColor(Color.black); + g.drawLine(0, dim.height - 25, dim.width, dim.height - 25); + g.setColor(Color.gray); + g.drawLine(0, dim.height - 24, dim.width, dim.height - 24); + g.setColor(Color.lightGray); + g.drawLine(0, dim.height - 23, dim.width, dim.height - 23); + g.fillRect(0, dim.height - 22, dim.width, dim.height); + + + g.setXORMode(Color.blue); + g.fillRect(0, 0, 25, dim.height - 26); + g.setColor(Color.red); + g.fillRect(0, 0, 25, dim.height - 26); + g.setColor(Color.green); + g.fillRect(0, 0, 25, dim.height - 26); + g.setPaintMode(); + + Image img = createImage(50, 50); + Graphics imgGraphics = img.getGraphics(); + imgGraphics.setColor(Color.magenta); + imgGraphics.fillRect(0, 0, 50, 50); + imgGraphics.setColor(Color.yellow); + imgGraphics.drawString("offscreen", 0, 20); + imgGraphics.drawString("image", 0, 30); + + g.drawImage(img, dim.width - 100, dim.height - 100, Color.blue, null); + + g.setXORMode(Color.white); + drawAt(g, 100, 100, 50, 50); + drawAt(g, 105, 105, 50, 50); + drawAt(g, 110, 110, 50, 50); + } + + public void drawAt(Graphics g, int x, int y, int width, int height) { + g.setColor(Color.magenta); + g.fillRect(x, y, width, height); + } + + public static void main(String[] args) throws InterruptedException, + InvocationTargetException { + PassFailJFrame.builder() + .title("Repeated Repaint Test Instructions") + .instructions(INSTRUCTIONS) + .testUI(RepeatedRepaintTest::new) + .build() + .awaitAndCheck(); + } +} diff -Nru openjdk-17-17.0.17+10/test/jdk/java/awt/Graphics/SmallPrimitives.java openjdk-17-17.0.18+8/test/jdk/java/awt/Graphics/SmallPrimitives.java --- openjdk-17-17.0.17+10/test/jdk/java/awt/Graphics/SmallPrimitives.java 1970-01-01 00:00:00.000000000 +0000 +++ openjdk-17-17.0.18+8/test/jdk/java/awt/Graphics/SmallPrimitives.java 2026-01-15 15:23:06.000000000 +0000 @@ -0,0 +1,224 @@ +/* + * Copyright (c) 2002, 2025, Oracle and/or its affiliates. All rights reserved. + * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. + * + * This code is free software; you can redistribute it and/or modify it + * under the terms of the GNU General Public License version 2 only, as + * published by the Free Software Foundation. + * + * This code is distributed in the hope that it will be useful, but WITHOUT + * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or + * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License + * version 2 for more details (a copy is included in the LICENSE file that + * accompanied this code). + * + * You should have received a copy of the GNU General Public License version + * 2 along with this work; if not, write to the Free Software Foundation, + * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. + * + * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA + * or visit www.oracle.com if you need additional information or have any + * questions. + */ + +import java.awt.Color; +import java.awt.Dimension; +import java.awt.Frame; +import java.awt.Graphics; +import java.awt.Graphics2D; +import java.awt.Panel; +import java.awt.Polygon; +import java.awt.geom.GeneralPath; +import java.awt.geom.Line2D; +import java.lang.reflect.InvocationTargetException; + +/* + * @test + * @bug 4411814 4298688 4205762 4524760 4067534 + * @summary Check that Graphics rendering primitives function + * correctly when fed small and degenerate shapes + * @library /java/awt/regtesthelpers + * @build PassFailJFrame + * @run main/manual SmallPrimitives + */ + + +public class SmallPrimitives extends Panel { + + static String INSTRUCTIONS = """ + In the borderless frame next to this window there should be a + set of tiny narrow blue polygons painted next to the green rectangles. + If rectangle is vertical the corresponding polygon is painted to the right of it, + if rectangle is horizontal the polygon is painted below it. + The length of the polygon should be roughly the same as the length of the + green rectangle next to it. If size is significantly different or any of the + polygons is not painted press "Fail" otherwise press "Pass". + Note: one may consider using screen magnifier to compare sizes. + """; + + public void paint(Graphics g) { + Dimension d = getSize(); + Polygon p; + GeneralPath gp; + + g.setColor(Color.white); + g.fillRect(0, 0, d.width, d.height); + + // Reposition for horizontal tests (below) + g.translate(0, 20); + + // Reference shapes + g.setColor(Color.green); + g.fillRect(10, 7, 11, 1); + g.fillRect(10, 17, 11, 2); + g.fillRect(10, 27, 11, 1); + g.fillRect(10, 37, 11, 1); + g.fillRect(10, 47, 11, 2); + g.fillRect(10, 57, 11, 2); + g.fillRect(10, 67, 11, 1); + g.fillRect(10, 77, 11, 2); + g.fillRect(10, 87, 11, 1); + g.fillRect(10, 97, 11, 1); + g.fillRect(10, 107, 11, 1); + g.fillRect(10, 117, 6, 1); g.fillRect(20, 117, 6, 1); + + // Potentially problematic test shapes + g.setColor(Color.blue); + g.drawRect(10, 10, 10, 0); + g.drawRect(10, 20, 10, 1); + g.drawRoundRect(10, 30, 10, 0, 0, 0); + g.drawRoundRect(10, 40, 10, 0, 4, 4); + g.drawRoundRect(10, 50, 10, 1, 0, 0); + g.drawRoundRect(10, 60, 10, 1, 4, 4); + g.drawOval(10, 70, 10, 0); + g.drawOval(10, 80, 10, 1); + p = new Polygon(); + p.addPoint(10, 90); + p.addPoint(20, 90); + g.drawPolyline(p.xpoints, p.ypoints, p.npoints); + p = new Polygon(); + p.addPoint(10, 100); + p.addPoint(20, 100); + g.drawPolygon(p.xpoints, p.ypoints, p.npoints); + ((Graphics2D) g).draw(new Line2D.Double(10, 110, 20, 110)); + gp = new GeneralPath(); + gp.moveTo(10, 120); + gp.lineTo(15, 120); + gp.moveTo(20, 120); + gp.lineTo(25, 120); + ((Graphics2D) g).draw(gp); + + // Polygon limit tests + p = new Polygon(); + trypoly(g, p); + p.addPoint(10, 120); + trypoly(g, p); + + // Reposition for vertical tests (below) + g.translate(20, -20); + + // Reference shapes + g.setColor(Color.green); + g.fillRect(7, 10, 1, 11); + g.fillRect(17, 10, 2, 11); + g.fillRect(27, 10, 1, 11); + g.fillRect(37, 10, 1, 11); + g.fillRect(47, 10, 2, 11); + g.fillRect(57, 10, 2, 11); + g.fillRect(67, 10, 1, 11); + g.fillRect(77, 10, 2, 11); + g.fillRect(87, 10, 1, 11); + g.fillRect(97, 10, 1, 11); + g.fillRect(107, 10, 1, 11); + g.fillRect(117, 10, 1, 6); g.fillRect(117, 20, 1, 6); + + // Potentially problematic test shapes + g.setColor(Color.blue); + g.drawRect(10, 10, 0, 10); + g.drawRect(20, 10, 1, 10); + g.drawRoundRect(30, 10, 0, 10, 0, 0); + g.drawRoundRect(40, 10, 0, 10, 4, 4); + g.drawRoundRect(50, 10, 1, 10, 0, 0); + g.drawRoundRect(60, 10, 1, 10, 4, 4); + g.drawOval(70, 10, 0, 10); + g.drawOval(80, 10, 1, 10); + p = new Polygon(); + p.addPoint(90, 10); + p.addPoint(90, 20); + g.drawPolyline(p.xpoints, p.ypoints, p.npoints); + p = new Polygon(); + p.addPoint(100, 10); + p.addPoint(100, 20); + g.drawPolygon(p.xpoints, p.ypoints, p.npoints); + ((Graphics2D) g).draw(new Line2D.Double(110, 10, 110, 20)); + gp = new GeneralPath(); + gp.moveTo(120, 10); + gp.lineTo(120, 15); + gp.moveTo(120, 20); + gp.lineTo(120, 25); + ((Graphics2D) g).draw(gp); + + // Polygon limit tests + p = new Polygon(); + trypoly(g, p); + p.addPoint(110, 10); + trypoly(g, p); + + // Reposition for oval tests + g.translate(0, 20); + + for (int i = 0, xy = 8; i < 11; i++) { + g.setColor(Color.green); + g.fillRect(xy, 5, i, 1); + g.fillRect(5, xy, 1, i); + g.setColor(Color.blue); + g.fillOval(xy, 8, i, 1); + g.fillOval(8, xy, 1, i); + xy += i + 2; + } + + g.translate(10, 10); + for (int i = 0, xy = 9; i < 6; i++) { + g.setColor(Color.green); + g.fillRect(xy, 5, i, 2); + g.fillRect(5, xy, 2, i); + g.setColor(Color.blue); + g.fillOval(xy, 8, i, 2); + g.fillOval(8, xy, 2, i); + xy += i + 2; + } + } + + public static void trypoly(Graphics g, Polygon p) { + g.drawPolygon(p); + g.drawPolygon(p.xpoints, p.ypoints, p.npoints); + g.drawPolyline(p.xpoints, p.ypoints, p.npoints); + g.fillPolygon(p); + g.fillPolygon(p.xpoints, p.ypoints, p.npoints); + } + + public Dimension getPreferredSize() { + return new Dimension(150, 150); + } + + public static Frame createFrame() { + Frame f = new Frame(); + SmallPrimitives sp = new SmallPrimitives(); + sp.setLocation(0, 0); + f.add(sp); + f.setUndecorated(true); + f.pack(); + return f; + } + + public static void main(String argv[]) throws InterruptedException, + InvocationTargetException { + PassFailJFrame.builder() + .title("Small Primitives Instructions") + .instructions(INSTRUCTIONS) + .columns(60) + .testUI(SmallPrimitives::createFrame) + .build() + .awaitAndCheck(); + } +} diff -Nru openjdk-17-17.0.17+10/test/jdk/java/awt/Graphics/TextAfterXor.java openjdk-17-17.0.18+8/test/jdk/java/awt/Graphics/TextAfterXor.java --- openjdk-17-17.0.17+10/test/jdk/java/awt/Graphics/TextAfterXor.java 1970-01-01 00:00:00.000000000 +0000 +++ openjdk-17-17.0.18+8/test/jdk/java/awt/Graphics/TextAfterXor.java 2026-01-15 15:23:06.000000000 +0000 @@ -0,0 +1,123 @@ +/* + * Copyright (c) 2002, 2025, Oracle and/or its affiliates. All rights reserved. + * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. + * + * This code is free software; you can redistribute it and/or modify it + * under the terms of the GNU General Public License version 2 only, as + * published by the Free Software Foundation. + * + * This code is distributed in the hope that it will be useful, but WITHOUT + * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or + * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License + * version 2 for more details (a copy is included in the LICENSE file that + * accompanied this code). + * + * You should have received a copy of the GNU General Public License version + * 2 along with this work; if not, write to the Free Software Foundation, + * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. + * + * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA + * or visit www.oracle.com if you need additional information or have any + * questions. + */ + +import java.awt.Color; +import java.awt.Dimension; +import java.awt.Frame; +import java.awt.Graphics; +import java.awt.Graphics2D; +import java.awt.Panel; +import java.awt.RenderingHints; +import java.awt.image.VolatileImage; +import java.lang.reflect.InvocationTargetException; + +/* + * @test + * @bug 4505650 + * @summary Check that you can render solid text after doing XOR mode + * @library /java/awt/regtesthelpers + * @build PassFailJFrame + * @run main/manual TextAfterXor + */ + +public class TextAfterXor extends Panel { + public static final int TESTW = 300; + public static final int TESTH = 100; + static String INSTRUCTIONS = """ + In the window called "Text After XOR Test" there should be two + composite components, at the bottom of each component the green text + "Test passes if this is green!" should be visible. + + On the top component this text should be green on all platforms. + On the bottom component it is possible that on non-Windows + platforms text can be of other color or not visible at all. + That does not constitute a problem. + + So if platform is Windows and green text appears twice or on any + other platform green text appears at least once press "Pass", + otherwise press "Fail". + """; + + VolatileImage vimg; + + public void paint(Graphics g) { + render(g); + g.drawString("(Drawing to screen)", 10, 60); + if (vimg == null) { + vimg = createVolatileImage(TESTW, TESTH); + } + do { + vimg.validate(null); + Graphics g2 = vimg.getGraphics(); + render(g2); + String not = vimg.getCapabilities().isAccelerated() ? "" : "not "; + g2.drawString("Image was " + not + "accelerated", 10, 55); + g2.drawString("(only matters on Windows)", 10, 65); + g2.dispose(); + g.drawImage(vimg, 0, TESTH, null); + } while (vimg.contentsLost()); + } + + public void render(Graphics g) { + g.setColor(Color.black); + g.fillRect(0, 0, TESTW, TESTH); + g.setColor(Color.white); + g.fillRect(5, 5, TESTW-10, TESTH-10); + + g.setColor(Color.black); + g.drawString("Test only passes if green string appears", 10, 20); + + g.setColor(Color.white); + g.setXORMode(Color.blue); + g.drawRect(30, 30, 10, 10); + g.setPaintMode(); + g.setColor(Color.green); + + ((Graphics2D) g).setRenderingHint(RenderingHints.KEY_TEXT_ANTIALIASING, + RenderingHints.VALUE_TEXT_ANTIALIAS_ON); + g.drawString("Test passes if this is green!", 10, 80); + + g.setColor(Color.black); + } + + public Dimension getPreferredSize() { + return new Dimension(TESTW, TESTH*2); + } + + public static Frame createFrame() { + Frame f = new Frame("Text After XOR Test"); + f.add(new TextAfterXor()); + f.pack(); + return f; + } + + public static void main(String[] args) throws InterruptedException, + InvocationTargetException { + PassFailJFrame.builder() + .title("Text After XOR Instructions") + .instructions(INSTRUCTIONS) + .testUI(TextAfterXor::createFrame) + .build() + .awaitAndCheck(); + } +} diff -Nru openjdk-17-17.0.17+10/test/jdk/java/awt/GridBagLayout/ComponentShortage.java openjdk-17-17.0.18+8/test/jdk/java/awt/GridBagLayout/ComponentShortage.java --- openjdk-17-17.0.17+10/test/jdk/java/awt/GridBagLayout/ComponentShortage.java 1970-01-01 00:00:00.000000000 +0000 +++ openjdk-17-17.0.18+8/test/jdk/java/awt/GridBagLayout/ComponentShortage.java 2026-01-15 15:23:06.000000000 +0000 @@ -0,0 +1,99 @@ +/* + * Copyright (c) 2008, 2025, Oracle and/or its affiliates. All rights reserved. + * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. + * + * This code is free software; you can redistribute 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 4238932 + * @summary JTextField in gridBagLayout does not properly set MinimumSize + * @key headful + * @run main ComponentShortage + */ + +import java.awt.Dimension; +import java.awt.EventQueue; +import java.awt.GridBagConstraints; +import java.awt.GridBagLayout; +import java.awt.Robot; +import javax.swing.JFrame; +import javax.swing.JTextField; + +public class ComponentShortage { + static final int WIDTH_REDUCTION = 50; + static JFrame frame; + static JTextField jtf; + static volatile Dimension size; + static volatile Dimension fSize; + + public static void main(String[] args) throws Exception { + Robot robot = new Robot(); + try { + EventQueue.invokeAndWait(() -> { + frame = new JFrame(); + frame.setLayout(new GridBagLayout()); + GridBagConstraints gBC = new GridBagConstraints(); + + gBC.gridx = 1; + gBC.gridy = 0; + gBC.gridwidth = 1; + gBC.gridheight = 1; + gBC.weightx = 1.0; + gBC.weighty = 0.0; + gBC.fill = GridBagConstraints.NONE; + gBC.anchor = GridBagConstraints.NORTHWEST; + jtf = new JTextField(16); + frame.add(jtf, gBC); + frame.pack(); + frame.setVisible(true); + }); + robot.waitForIdle(); + robot.delay(1000); + + EventQueue.invokeAndWait(() -> { + size = jtf.getSize(); + }); + System.out.println("TextField size before Frame's width reduction : " + size); + + EventQueue.invokeAndWait(() -> { + frame.setSize(frame.getSize().width - WIDTH_REDUCTION, frame.getSize().height); + }); + frame.repaint(); + + EventQueue.invokeAndWait(() -> { + size = jtf.getSize(); + fSize = frame.getSize(); + }); + System.out.println("TextField size after Frame's width reduction : " + size); + + if (size.width < fSize.width - WIDTH_REDUCTION) { + throw new RuntimeException("Width of JTextField is too small to be visible."); + } + System.out.println("Test passed."); + } finally { + EventQueue.invokeAndWait(() -> { + if (frame != null) { + frame.dispose(); + } + }); + } + } +} diff -Nru openjdk-17-17.0.17+10/test/jdk/java/awt/Icon/ChildFrameIconTest.java openjdk-17-17.0.18+8/test/jdk/java/awt/Icon/ChildFrameIconTest.java --- openjdk-17-17.0.17+10/test/jdk/java/awt/Icon/ChildFrameIconTest.java 1970-01-01 00:00:00.000000000 +0000 +++ openjdk-17-17.0.18+8/test/jdk/java/awt/Icon/ChildFrameIconTest.java 2026-01-15 15:23:06.000000000 +0000 @@ -0,0 +1,76 @@ +/* + * 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 + * under the terms of the GNU General Public License version 2 only, as + * published by the Free Software Foundation. + * + * This code is distributed in the hope that it will be useful, but WITHOUT + * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or + * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License + * version 2 for more details (a copy is included in the LICENSE file that + * accompanied this code). + * + * You should have received a copy of the GNU General Public License version + * 2 along with this work; if not, write to the Free Software Foundation, + * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. + * + * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA + * or visit www.oracle.com if you need additional information or have any + * questions. + */ + +import java.awt.event.ActionEvent; +import java.awt.event.ActionListener; + +import javax.swing.JButton; +import javax.swing.JDialog; +import javax.swing.JFrame; +import javax.swing.JOptionPane; + +/* + * @test + * @bug 4284610 + * @summary Tests that a child of the non-resizable dialog acquires valid icon. + * @requires (os.family == "windows") + * @library /java/awt/regtesthelpers + * @build PassFailJFrame + * @run main/manual ChildFrameIconTest + */ + +public class ChildFrameIconTest { + public static void main(String[] args) throws Exception { + final String INSTRUCTIONS = """ + Press "Show Dialog" button to open a dialog with this message: + Do you see a coffee cup icon in the upper left corner ? + + Look at the icon in the upper left corner of the message dialog. + + Press Pass if you see default coffee cup icon else press Fail."""; + + PassFailJFrame.builder() + .title("ChildFrameIconTest Instruction") + .instructions(INSTRUCTIONS) + .columns(35) + .testUI(ChildFrameIconTest::createUI) + .build() + .awaitAndCheck(); + } + + private static JFrame createUI() { + JFrame f = new JFrame("ChildFrameIconTest UI"); + JButton b = new JButton("Show Dialog"); + b.addActionListener(new ActionListener() { + public void actionPerformed(ActionEvent e) { + String msg = "Do you see a coffee cup icon in the upper left corner ?"; + JDialog dlg = new JDialog(f, "Non-resizable JDialog", false); + dlg.setResizable(false); + JOptionPane.showMessageDialog(dlg, msg); + } + }); + f.add(b); + f.setSize(250, 100); + return f; + } +} diff -Nru openjdk-17-17.0.17+10/test/jdk/java/awt/InputMethods/DiacriticsTest/DiacriticsTest.html openjdk-17-17.0.18+8/test/jdk/java/awt/InputMethods/DiacriticsTest/DiacriticsTest.html --- openjdk-17-17.0.17+10/test/jdk/java/awt/InputMethods/DiacriticsTest/DiacriticsTest.html 2025-10-13 07:48:04.000000000 +0000 +++ openjdk-17-17.0.18+8/test/jdk/java/awt/InputMethods/DiacriticsTest/DiacriticsTest.html 1970-01-01 00:00:00.000000000 +0000 @@ -1,53 +0,0 @@ - - - - - DiacriticsTest - - - - -Test run requires the following keyboard layouts to be installed: -Linux OS: English (US, alternative international) -Windows OS: Hungarian -A keyboard layout having compose function or compose-like key. Programmer -Dvorak (http://www.kaufmann.no/roland/dvorak/) is suggested to use. - -To test JDK-8000423 fix (Linux only!): -please switch to US alternative international layout and try to type diacritics -(using the following combinations: `+e; `+u; etc.) - -To test JDK-7197619 fix (Windows only!): -please switch to Hungarian keyboard layout and try to type diacritics -(Ctrl+Alt+2 e; Ctrl+Alt+2 E) - -To test JDK-8139189 fix: -please switch to Programmer Dvorak keyboard layout try to type diacritics -using compose combinations (Compose+z+d, Compose+z+Shift+d). The Compose key -in Programmer Dvorak layout is OEM102 the key which is located between -Left Shift and Z keys on the standard 102-key keyboard. - -If you can do that then the test is passed; otherwise failed. - - diff -Nru openjdk-17-17.0.17+10/test/jdk/java/awt/InputMethods/DiacriticsTest/DiacriticsTest.java openjdk-17-17.0.18+8/test/jdk/java/awt/InputMethods/DiacriticsTest/DiacriticsTest.java --- openjdk-17-17.0.17+10/test/jdk/java/awt/InputMethods/DiacriticsTest/DiacriticsTest.java 2025-10-13 07:48:04.000000000 +0000 +++ openjdk-17-17.0.18+8/test/jdk/java/awt/InputMethods/DiacriticsTest/DiacriticsTest.java 2026-01-15 15:23:06.000000000 +0000 @@ -1,5 +1,5 @@ /* - * Copyright (c) 2013, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2013, 2024, Oracle and/or its affiliates. All rights reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * * This code is free software; you can redistribute it and/or modify it @@ -21,30 +21,94 @@ * questions. */ - -/* - @test - @bug 8000423 7197619 8025649 - @summary Check if diacritical signs could be typed for TextArea and TextField - @run applet/manual=yesno DiacriticsTest.html -*/ - - -import java.applet.Applet; -import java.awt.*; +import jdk.test.lib.Platform; +import java.awt.GridLayout; +import java.awt.TextArea; +import java.awt.TextField; import javax.swing.JPanel; +/* + * @test + * @bug 8000423 7197619 8025649 + * @summary Check if diacritical signs could be typed for TextArea and TextField + * @requires (os.family == "windows" | os.family == "linux") + * @library /java/awt/regtesthelpers /test/lib + * @build PassFailJFrame jdk.test.lib.Platform + * @run main/manual DiacriticsTest + */ -public class DiacriticsTest extends Applet { +public class DiacriticsTest { - public void init() { - this.setLayout(new BorderLayout()); + private static final String INSTRUCTIONS_WIN = """ + Test run requires the following keyboard layouts to be installed: + - Hungarian + - A keyboard layout having compose function or compose-like key. Programmer + Dvorak (http://www.kaufmann.no/roland/dvorak/) is suggested to use. + + To the right are a text area and a text field, you should check the behavior + for both of them. + + To test the JDK-7197619 fix: + Please switch to Hungarian keyboard layout and try to type diacritics + (Ctrl+Alt+2 e; Ctrl+Alt+2 E) + + To test the JDK-8139189 fix: + Please switch to Programmer Dvorak keyboard layout try to type diacritics + using compose combinations (Compose+z+d, Compose+z+Shift+d). + + The Compose key in the Programmer Dvorak layout is OEM102, the key located + between the and Z keys on a standard 102-key keyboard. + If you do not have this key on your keyboard, you can skip this part of the test. + + If you can do that then the test is passed; otherwise failed. + """; + + private static final String INSTRUCTIONS_LIN = """ + Test run requires the following keyboard layouts to be installed: + - English (US, alternative international), aka English (US, alt. intl.) + - A keyboard layout having compose function or compose-like key. Programmer + Dvorak (http://www.kaufmann.no/roland/dvorak/) is suggested to use. + + To the right are a text area and a text field, you should check the behavior + for both of them. + + To test the JDK-8000423 fix: + Please switch to US alternative international layout and try to type diacritics + (using the following combinations: `+e; `+u; etc.) + + To test the JDK-8139189 fix: + Please switch to Programmer Dvorak keyboard layout try to type diacritics + using compose combinations (Compose+z+d, Compose+z+Shift+d).. + + The Compose key in the Programmer Dvorak layout is OEM102, the key located + between the and Z keys on a standard 102-key keyboard. + + If the above key does not work in the Gnome shell, + it can be overridden in the system preferences: + System > Keyboard > Special character entry > Compose key + and set it to another key(e.g. menu key or scroll lock.) + + If you can do that then the test is passed; otherwise failed. + """; + + public static void main(String[] args) throws Exception { + String instructions = Platform.isWindows() + ? INSTRUCTIONS_WIN + : INSTRUCTIONS_LIN; + + PassFailJFrame + .builder() + .title("DiacriticsTest Instructions") + .instructions(instructions) + .splitUIRight(DiacriticsTest::createPanel) + .testTimeOut(10) + .rows((int) instructions.lines().count() + 2) + .columns(50) + .build() + .awaitAndCheck(); } - public void start() { - - setSize(350, 200); - + public static JPanel createPanel() { JPanel panel = new JPanel(); panel.setLayout(new GridLayout(2, 1)); @@ -54,10 +118,6 @@ TextField txtField = new TextField(); panel.add(txtField); - add(panel, BorderLayout.CENTER); - - validate(); - setVisible(true); + return panel; } } - diff -Nru openjdk-17-17.0.17+10/test/jdk/java/awt/InputMethods/SpanishDiacriticsTest/SpanishDiacriticsTest.html openjdk-17-17.0.18+8/test/jdk/java/awt/InputMethods/SpanishDiacriticsTest/SpanishDiacriticsTest.html --- openjdk-17-17.0.17+10/test/jdk/java/awt/InputMethods/SpanishDiacriticsTest/SpanishDiacriticsTest.html 2025-10-13 07:48:04.000000000 +0000 +++ openjdk-17-17.0.18+8/test/jdk/java/awt/InputMethods/SpanishDiacriticsTest/SpanishDiacriticsTest.html 1970-01-01 00:00:00.000000000 +0000 @@ -1,40 +0,0 @@ - - - - - SpanishDiacriticsTest - - - - -Test run requires the following keyboard layout to be installed: -Windows OS: Spanish (United States) with 'Latin American' keyboard layout - -1. A frame with a text field should be displayed at upper left corner -2. Set focus to the text field and switch to Spanish with 'Latin American' keyboard layout -3. Type the following: ' ' o - i.e. single quote two times (using [ key on US keyboard) then o character. - -If you the text field displays ''o, (i.e. o should be without acute) then the test is passed; otherwise failed. - - diff -Nru openjdk-17-17.0.17+10/test/jdk/java/awt/InputMethods/SpanishDiacriticsTest/SpanishDiacriticsTest.java openjdk-17-17.0.18+8/test/jdk/java/awt/InputMethods/SpanishDiacriticsTest/SpanishDiacriticsTest.java --- openjdk-17-17.0.17+10/test/jdk/java/awt/InputMethods/SpanishDiacriticsTest/SpanishDiacriticsTest.java 2025-10-13 07:48:04.000000000 +0000 +++ openjdk-17-17.0.18+8/test/jdk/java/awt/InputMethods/SpanishDiacriticsTest/SpanishDiacriticsTest.java 1970-01-01 00:00:00.000000000 +0000 @@ -1,57 +0,0 @@ -/* - * Copyright (c) 2016, Oracle and/or its affiliates. All rights reserved. - * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. - * - * This code is free software; you can redistribute it and/or modify it - * under the terms of the GNU General Public License version 2 only, as - * published by the Free Software Foundation. - * - * This code is distributed in the hope that it will be useful, but WITHOUT - * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or - * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License - * version 2 for more details (a copy is included in the LICENSE file that - * accompanied this code). - * - * You should have received a copy of the GNU General Public License version - * 2 along with this work; if not, write to the Free Software Foundation, - * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. - * - * Please 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 8169355 - * @summary Check if Spanish diacritical signs could be typed for TextField - * @author Dmitry Markov - * @run applet/manual=yesno SpanishDiacriticsTest.html -*/ - -import javax.swing.*; -import java.applet.Applet; -import java.awt.event.KeyAdapter; -import java.awt.event.KeyEvent; -import java.util.concurrent.locks.LockSupport; - -public class SpanishDiacriticsTest extends Applet { - @Override - public void init() { - SwingUtilities.invokeLater(() -> { - JFrame frame = new JFrame(); - JTextField textField = new JTextField(20); - textField.addKeyListener(new KeyAdapter() { - @Override - public void keyTyped(KeyEvent e) { - LockSupport.parkNanos(1_000_000_000L); - } - }); - frame.add(textField); - frame.setDefaultCloseOperation(WindowConstants.EXIT_ON_CLOSE); - frame.pack(); - frame.setVisible(true); - }); - } -} - diff -Nru openjdk-17-17.0.17+10/test/jdk/java/awt/InputMethods/SpanishDiacriticsTest.java openjdk-17-17.0.18+8/test/jdk/java/awt/InputMethods/SpanishDiacriticsTest.java --- openjdk-17-17.0.17+10/test/jdk/java/awt/InputMethods/SpanishDiacriticsTest.java 1970-01-01 00:00:00.000000000 +0000 +++ openjdk-17-17.0.18+8/test/jdk/java/awt/InputMethods/SpanishDiacriticsTest.java 2026-01-15 15:23:06.000000000 +0000 @@ -0,0 +1,92 @@ +/* + * Copyright (c) 2016, 2024, Oracle and/or its affiliates. All rights reserved. + * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. + * + * This code is free software; you can redistribute it and/or modify it + * 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 8169355 + * @summary Check if Spanish diacritical signs could be typed for TextField + * @requires (os.family == "windows") + * @library /java/awt/regtesthelpers + * @run main/manual SpanishDiacriticsTest +*/ + + +import java.util.concurrent.locks.LockSupport; +import java.awt.event.KeyAdapter; +import java.awt.event.KeyEvent; +import javax.swing.JFrame; +import javax.swing.JTextField; +import javax.swing.SwingUtilities; +import javax.swing.WindowConstants; + +public class SpanishDiacriticsTest { + + static final String INSTRUCTIONS = """ + This test requires the following keyboard layout to be installed: + Windows OS: Spanish (United States) with 'Latin American' keyboard layout. + If using a US layout, the results should still be as described but + you have not tested the real bug. + + 1. A frame with a text field should be displayed. + 2. Set focus to the text field and switch to Spanish + with 'Latin American' keyboard layout. + 3. Type the following: ' ' o - i.e. single quote two times, then o. + If your keyboard has a US physical layout the [ key can be used + to type the single quote when in 'Latin American' keyboard mode. + 4. Type these characters at a normal speed but do NOT be concerned + that they take several seconds to display. That is an + expected behaviour for this test. + + If the text field displays the same three characters you typed: ''o + (i.e. two single quotes followed by o without an acute) + then press Pass; otherwise press Fail. + """; + + public static void main(String[] args) throws Exception { + + PassFailJFrame.builder() + .title("Spanish Diacritics") + .instructions(INSTRUCTIONS) + .rows(20) + .columns(50) + .testUI(SpanishDiacriticsTest::createTestUI) + .build() + .awaitAndCheck(); + } + + static JFrame createTestUI() { + JFrame frame = new JFrame("Spanish Diacritics Test Frame"); + JTextField textField = new JTextField(20); + textField.addKeyListener(new KeyAdapter() { + @Override + public void keyTyped(KeyEvent e) { + LockSupport.parkNanos(1_000_000_000L); + } + }); + frame.add(textField); + frame.setDefaultCloseOperation(WindowConstants.EXIT_ON_CLOSE); + frame.pack(); + return frame; + } +} + diff -Nru openjdk-17-17.0.17+10/test/jdk/java/awt/Label/ContainerValidateTest.java openjdk-17-17.0.18+8/test/jdk/java/awt/Label/ContainerValidateTest.java --- openjdk-17-17.0.17+10/test/jdk/java/awt/Label/ContainerValidateTest.java 1970-01-01 00:00:00.000000000 +0000 +++ openjdk-17-17.0.18+8/test/jdk/java/awt/Label/ContainerValidateTest.java 2026-01-15 15:23:06.000000000 +0000 @@ -0,0 +1,169 @@ +/* + * Copyright (c) 1999, 2024, Oracle and/or its affiliates. All rights reserved. + * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. + * + * This code is free software; you can redistribute it and/or modify it + * under the terms of the GNU General Public License version 2 only, as + * published by the Free Software Foundation. + * + * This code is distributed in the hope that it will be useful, but WITHOUT + * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or + * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License + * version 2 for more details (a copy is included in the LICENSE file that + * accompanied this code). + * + * You should have received a copy of the GNU General Public License version + * 2 along with this work; if not, write to the Free Software Foundation, + * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. + * + * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA + * or visit www.oracle.com if you need additional information or have any + * questions. + */ + +import java.awt.BorderLayout; +import java.awt.Button; +import java.awt.EventQueue; +import java.awt.Frame; +import java.awt.Label; +import java.awt.Panel; +import java.awt.Rectangle; +import java.awt.Robot; +import java.awt.TextField; +import java.awt.event.InputEvent; +import java.awt.event.MouseEvent; +import java.awt.event.MouseListener; + +/* + * @test + * @key headful + * @bug 4247913 + * @summary Tests that Label repaints after call Container.validate() + * @run main ContainerValidateTest + */ + +public class ContainerValidateTest extends Frame implements MouseListener { + private static Robot robot; + private static Panel currentPanel; + private static Button currentBtn; + private static Panel updatedPanel; + private static Label updatedLabel; + private static TextField updatedTxtField; + private static Button updatedBtn; + + private static volatile Rectangle btnBounds; + + Panel pnl1 = new Panel(); + Panel pnl2 = new Panel(); + Label lbl1 = new Label("Label 1"); + Label lbl2 = new Label("Label 2"); + TextField txt1 = new TextField("field1", 20); + TextField txt2 = new TextField("field2", 20); + Button btn1 = new Button("Swap 1"); + Button btn2 = new Button("Swap 2"); + + public static void main(String[] args) throws Exception { + robot = new Robot(); + + ContainerValidateTest containerValidate = new ContainerValidateTest(); + EventQueue.invokeAndWait(containerValidate::createAndShowUI); + robot.waitForIdle(); + robot.delay(1000); + + containerValidate.testUI(); + } + + private void createAndShowUI() { + this.setTitle("ContainerValidateTest Test"); + pnl1.add(lbl1); + pnl1.add(txt1); + pnl1.add(btn1); + + pnl2.add(lbl2); + pnl2.add(txt2); + pnl2.add(btn2); + + btn1.addMouseListener(this); + btn2.addMouseListener(this); + + this.add(pnl1, BorderLayout.CENTER); + pack(); + setLocationRelativeTo(null); + setVisible(true); + } + + private void testUI() throws Exception { + EventQueue.invokeAndWait(() -> btnBounds + = new Rectangle(btn1.getLocationOnScreen().x, + btn1.getLocationOnScreen().y, + btn1.getWidth(), + btn1.getHeight())); + for (int i= 1; i < 4 ; i++) { + EventQueue.invokeAndWait(() -> { + currentPanel = (Panel) this.getComponent(0); + currentBtn = (Button) currentPanel.getComponent(2); + }); + + robot.mouseMove(btnBounds.x + (int) btnBounds.getWidth() / 2, + btnBounds.y + (int) btnBounds.getHeight() / 2); + robot.mousePress(InputEvent.BUTTON1_DOWN_MASK); + robot.mouseRelease(InputEvent.BUTTON1_DOWN_MASK); + robot.waitForIdle(); + //large delay set for completion of UI validate() + robot.delay(500); + + EventQueue.invokeAndWait(() -> { + updatedPanel = (Panel) this.getComponent(0); + updatedLabel = (Label) updatedPanel.getComponent(0); + updatedTxtField = (TextField) updatedPanel.getComponent(1); + updatedBtn = (Button) updatedPanel.getComponent(2); + }); + testPanelComponents(currentBtn.getLabel()); + } + } + + private void testPanelComponents(String btnLabel) { + if (btnLabel.equals("Swap 1")) { + if (!(updatedLabel.getText().equals(lbl2.getText()) + && updatedTxtField.getText().equals(txt2.getText()) + && updatedBtn.getLabel().equals(btn2.getLabel()))) { + throw new RuntimeException("Test Failed!! Labels not repainted" + + " after Container.validate()"); + } + } else { + if (!(updatedLabel.getText().equals(lbl1.getText()) + && updatedTxtField.getText().equals(txt1.getText()) + && updatedBtn.getLabel().equals(btn1.getLabel()))) { + throw new RuntimeException("Test Failed!! Labels not repainted" + + " after Container.validate()"); + } + } + } + + @Override + public void mousePressed(MouseEvent evt) { + if (evt.getComponent() instanceof Button btn) { + if (btn.equals(btn1)) { + remove(pnl1); + add(pnl2, BorderLayout.CENTER); + } else { + remove(pnl2); + add(pnl1, BorderLayout.CENTER); + } + invalidate(); + validate(); + } + } + + @Override + public void mouseReleased(MouseEvent e) {} + + @Override + public void mouseEntered(MouseEvent e) {} + + @Override + public void mouseExited(MouseEvent e) {} + + @Override + public void mouseClicked(MouseEvent e) {} +} diff -Nru openjdk-17-17.0.17+10/test/jdk/java/awt/List/ListEnterExitTest.java openjdk-17-17.0.18+8/test/jdk/java/awt/List/ListEnterExitTest.java --- openjdk-17-17.0.17+10/test/jdk/java/awt/List/ListEnterExitTest.java 2025-10-13 07:48:04.000000000 +0000 +++ openjdk-17-17.0.18+8/test/jdk/java/awt/List/ListEnterExitTest.java 2026-01-15 15:23:06.000000000 +0000 @@ -1,5 +1,5 @@ /* - * Copyright (c) 1999, 2023, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 1999, 2025, Oracle and/or its affiliates. All rights reserved. * 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,16 +36,24 @@ import java.awt.Point; import java.awt.Robot; -import java.awt.event.InputEvent; import java.awt.event.MouseAdapter; import java.awt.event.MouseEvent; +import java.util.concurrent.CountDownLatch; +import java.util.concurrent.TimeUnit; + public class ListEnterExitTest { final List list = new List(); - final MouseEnterExitListener mouseEnterExitListener = new MouseEnterExitListener(); Frame frame; volatile Point p; + private static final int X_OFFSET = 30; + private static final int Y_OFFSET = 40; + private static final int LATCH_TIMEOUT = 3; + + private final CountDownLatch mouseEnterLatch = new CountDownLatch(1); + private final CountDownLatch mouseExitLatch = new CountDownLatch(1); + public static void main(String[] args) throws Exception { ListEnterExitTest test = new ListEnterExitTest(); test.start(); @@ -57,7 +65,11 @@ frame = new Frame("ListEnterExitTest"); list.add("Item 1"); list.add("Item 2"); - list.addMouseListener(mouseEnterExitListener); + list.add("Item 3"); + list.add("Item 4"); + list.add("Item 5"); + list.add("Item 6"); + list.addMouseListener(new MouseEnterExitListener()); frame.add(list); frame.setLayout(new FlowLayout()); frame.setSize(300, 200); @@ -66,25 +78,28 @@ }); final Robot robot = new Robot(); - robot.delay(1000); + robot.setAutoDelay(100); robot.waitForIdle(); + robot.delay(1000); EventQueue.invokeAndWait(() -> { p = list.getLocationOnScreen(); }); - robot.mouseMove(p.x + 10, p.y + 10); - robot.delay(100); + robot.mouseMove(p.x + X_OFFSET, p.y + Y_OFFSET); robot.waitForIdle(); - robot.mouseMove(p.x - 10, p.y - 10); - robot.delay(100); + + robot.mouseMove(p.x - X_OFFSET, p.y + Y_OFFSET); robot.waitForIdle(); - robot.mouseMove(p.x + 10, p.y + 10); - robot.mousePress(InputEvent.BUTTON1_MASK); - robot.mouseRelease(InputEvent.BUTTON1_MASK); + robot.mouseMove(p.x + X_OFFSET, p.y + Y_OFFSET); + robot.waitForIdle(); + + if (!mouseEnterLatch.await(LATCH_TIMEOUT, TimeUnit.SECONDS)) { + throw new RuntimeException("Mouse enter event timeout"); + } - synchronized (mouseEnterExitListener) { - mouseEnterExitListener.wait(2000); + if (!mouseExitLatch.await(LATCH_TIMEOUT, TimeUnit.SECONDS)) { + throw new RuntimeException("Mouse exit event timeout"); } } finally { EventQueue.invokeAndWait(() -> { @@ -93,35 +108,19 @@ } }); } - if (!mouseEnterExitListener.isPassed()) { - throw new RuntimeException("Haven't receive mouse enter/exit events"); - } - } -} - -class MouseEnterExitListener extends MouseAdapter { - - volatile boolean passed_1 = false; - volatile boolean passed_2 = false; - - public void mouseEntered(MouseEvent e) { - passed_1 = true; - } - - public void mouseExited(MouseEvent e) { - passed_2 = true; - } - - public void mousePressed(MouseEvent e) { - synchronized (this) { - System.out.println("mouse pressed"); - this.notifyAll(); + private class MouseEnterExitListener extends MouseAdapter { + @Override + public void mouseEntered(MouseEvent e) { + System.out.println("Mouse Entered Event"); + mouseEnterLatch.countDown(); } - } - public boolean isPassed() { - return passed_1 & passed_2; + @Override + public void mouseExited(MouseEvent e) { + System.out.println("Mouse Exited Event"); + mouseExitLatch.countDown(); + } } } diff -Nru openjdk-17-17.0.17+10/test/jdk/java/awt/List/ListScrollbarCursorTest.java openjdk-17-17.0.18+8/test/jdk/java/awt/List/ListScrollbarCursorTest.java --- openjdk-17-17.0.17+10/test/jdk/java/awt/List/ListScrollbarCursorTest.java 1970-01-01 00:00:00.000000000 +0000 +++ openjdk-17-17.0.18+8/test/jdk/java/awt/List/ListScrollbarCursorTest.java 2026-01-15 15:23:06.000000000 +0000 @@ -0,0 +1,70 @@ +/* + * 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 + * 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 4290684 + * @summary Tests that cursor on the scrollbar of the list is set to default. + * @library /java/awt/regtesthelpers + * @build PassFailJFrame + * @run main/manual ListScrollbarCursorTest + */ + +import java.awt.Cursor; +import java.awt.Frame; +import java.awt.List; +import java.awt.Panel; + +public class ListScrollbarCursorTest { + public static void main(String[] args) throws Exception { + String INSTRUCTIONS = """ + 1. You see the list in the middle of the panel. + This list has two scrollbars. + 2. The cursor should have a shape of hand over the main area + and a shape of arrow over scrollbars. + 3. Move the mouse cursor to either horizontal or vertical scrollbar. + 4. Press PASS if you see the default arrow cursor else press FAIL. + """; + PassFailJFrame.builder() + .instructions(INSTRUCTIONS) + .columns(35) + .testUI(ListScrollbarCursorTest::initialize) + .build() + .awaitAndCheck(); + } + + static Frame initialize() { + Frame frame = new Frame("List Scrollbar Cursor Test"); + Panel panel = new Panel(); + List list = new List(3); + list.add("List item with a very long name" + + "(just to make the horizontal scrollbar visible)"); + list.add("Item 2"); + list.add("Item 3"); + list.setCursor(new Cursor(Cursor.HAND_CURSOR)); + panel.add(list); + frame.add(panel); + frame.setSize(200, 200); + return frame; + } +} diff -Nru openjdk-17-17.0.17+10/test/jdk/java/awt/List/ListScrollbarTest.java openjdk-17-17.0.18+8/test/jdk/java/awt/List/ListScrollbarTest.java --- openjdk-17-17.0.17+10/test/jdk/java/awt/List/ListScrollbarTest.java 1970-01-01 00:00:00.000000000 +0000 +++ openjdk-17-17.0.18+8/test/jdk/java/awt/List/ListScrollbarTest.java 2026-01-15 15:23:06.000000000 +0000 @@ -0,0 +1,197 @@ +/* + * Copyright (c) 2001, 2025, Oracle and/or its affiliates. All rights reserved. + * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. + * + * This code is free software; you can redistribute it and/or modify it + * under the terms of the GNU General Public License version 2 only, as + * published by the Free Software Foundation. + * + * This code is distributed in the hope that it will be useful, but WITHOUT + * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or + * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License + * version 2 for more details (a copy is included in the LICENSE file that + * accompanied this code). + * + * You should have received a copy of the GNU General Public License version + * 2 along with this work; if not, write to the Free Software Foundation, + * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. + * + * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA + * or visit www.oracle.com if you need additional information or have any + * questions. + */ + +/* + * @test + * @bug 4096445 + * @summary Test to verify List Scollbar appears/disappears automatically + * @library /java/awt/regtesthelpers + * @build PassFailJFrame + * @run main/manual ListScrollbarTest + */ + +import java.awt.Button; +import java.awt.Component; +import java.awt.Event; +import java.awt.Frame; +import java.awt.GridBagConstraints; +import java.awt.GridBagLayout; +import java.awt.List; + +public class ListScrollbarTest extends Frame { + static final int ITEMS = 10; + List ltList; + List rtList; + + public static void main(String[] args) throws Exception { + String INSTRUCTIONS = """ + 1. There are two lists added to the Frame separated by + a column of buttons + 2. Double click on any item(s) on the left list, you would see + a '*' added at the end of the item + 3. Keep double clicking on the same item till the length of the + item exceeds the width of the list + 4. Now, if you don't get the horizontal scrollbar on + the left list click FAIL. + 5. If you get horizontal scrollbar, select the item + (that you double clicked) and press the '>' button + to move the item to the right list. + 6. If horizontal scroll bar appears on the right list + as well as disappears from the left list [only if both + happen] proceed with step 8 else click FAIL + 7. Now move the same item to the left list, by pressing + '<' button + 8. If the horizontal scrollbar appears on the left list + and disappears from the right list[only if both happen] + click PASS else click FAIL. + """; + PassFailJFrame.builder() + .instructions(INSTRUCTIONS) + .columns(35) + .testUI(ListScrollbarTest::new) + .build() + .awaitAndCheck(); + } + + public ListScrollbarTest() { + super("List scroll bar test"); + GridBagLayout gbl = new GridBagLayout(); + ltList = new List(ITEMS, true); + rtList = new List(0, true); + setLayout(gbl); + add(ltList, 0, 0, 1, 5, 1.0, 1.0); + add(rtList, 2, 0, 1, 5, 1.0, 1.0); + add(new Button(">"), 1, 0, 1, 1, 0, 1.0); + add(new Button(">>"), 1, 1, 1, 1, 0, 1.0); + add(new Button("<"), 1, 2, 1, 1, 0, 1.0); + add(new Button("<<"), 1, 3, 1, 1, 0, 1.0); + add(new Button("!"), 1, 4, 1, 1, 0, 1.0); + + for (int i = 0; i < ITEMS; i++) { + ltList.addItem("item " + i); + } + setSize(220, 250); + } + + void add(Component comp, int x, int y, int w, int h, double weightx, double weighty) { + GridBagLayout gbl = (GridBagLayout) getLayout(); + GridBagConstraints c = new GridBagConstraints(); + c.fill = GridBagConstraints.BOTH; + c.gridx = x; + c.gridy = y; + c.gridwidth = w; + c.gridheight = h; + c.weightx = weightx; + c.weighty = weighty; + add(comp); + gbl.setConstraints(comp, c); + } + + void reverseSelections(List l) { + for (int i = 0; i < l.countItems(); i++) { + if (l.isSelected(i)) { + l.deselect(i); + } else { + l.select(i); + } + } + } + + void deselectAll(List l) { + for (int i = 0; i < l.countItems(); i++) { + l.deselect(i); + } + } + + void replaceItem(List l, String item) { + for (int i = 0; i < l.countItems(); i++) { + if (l.getItem(i).equals(item)) { + l.replaceItem(item + "*", i); + } + } + } + + void move(List l1, List l2, boolean all) { + + // if all the items are to be moved + if (all) { + for (int i = 0; i < l1.countItems(); i++) { + l2.addItem(l1.getItem(i)); + } + l1.delItems(0, l1.countItems() - 1); + } else { // else move the selected items + String[] items = l1.getSelectedItems(); + int[] itemIndexes = l1.getSelectedIndexes(); + + deselectAll(l2); + for (int i = 0; i < items.length; i++) { + l2.addItem(items[i]); + l2.select(l2.countItems() - 1); + if (i == 0) { + l2.makeVisible(l2.countItems() - 1); + } + } + for (int i = itemIndexes.length - 1; i >= 0; i--) { + l1.delItem(itemIndexes[i]); + } + } + } + + @Override + public boolean action(Event evt, Object arg) { + if (">".equals(arg)) { + move(ltList, rtList, false); + } else if (">>".equals(arg)) { + move(ltList, rtList, true); + } else if ("<".equals(arg)) { + move(rtList, ltList, false); + } else if ("<<".equals(arg)) { + move(rtList, ltList, true); + } else if ("!".equals(arg)) { + if (ltList.getSelectedItems().length > 0) { + reverseSelections(ltList); + } else if (rtList.getSelectedItems().length > 0) { + reverseSelections(rtList); + } + } else if (evt.target == rtList || evt.target == ltList) { + replaceItem((List) evt.target, (String) arg); + } else { + return false; + } + return true; + } + + @Override + public boolean handleEvent(Event evt) { + if (evt.id == Event.LIST_SELECT + || evt.id == Event.LIST_DESELECT) { + if (evt.target == ltList) { + deselectAll(rtList); + } else if (evt.target == rtList) { + deselectAll(ltList); + } + return true; + } + return super.handleEvent(evt); + } +} diff -Nru openjdk-17-17.0.17+10/test/jdk/java/awt/List/MouseDraggedOriginatedByScrollBarTest.java openjdk-17-17.0.18+8/test/jdk/java/awt/List/MouseDraggedOriginatedByScrollBarTest.java --- openjdk-17-17.0.17+10/test/jdk/java/awt/List/MouseDraggedOriginatedByScrollBarTest.java 2025-10-13 07:48:04.000000000 +0000 +++ openjdk-17-17.0.18+8/test/jdk/java/awt/List/MouseDraggedOriginatedByScrollBarTest.java 2026-01-15 15:23:06.000000000 +0000 @@ -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 @@ -24,41 +24,46 @@ /* * @test * @bug 6240151 + * @key headful * @summary XToolkit: Dragging the List scrollbar initiates DnD - * @library /java/awt/regtesthelpers - * @build PassFailJFrame - * @run main/manual MouseDraggedOriginatedByScrollBarTest + * @requires os.family == "linux" + * @run main MouseDraggedOriginatedByScrollBarTest */ +import java.awt.EventQueue; import java.awt.FlowLayout; import java.awt.Frame; import java.awt.List; -import java.awt.event.MouseMotionAdapter; +import java.awt.Point; +import java.awt.Robot; +import java.awt.event.InputEvent; import java.awt.event.MouseAdapter; import java.awt.event.MouseEvent; +import java.awt.event.MouseMotionAdapter; public class MouseDraggedOriginatedByScrollBarTest { - - private static final String INSTRUCTIONS = """ - 1) Click and drag the scrollbar of the list. - 2) Keep dragging till the mouse pointer goes out the scrollbar. - 3) The test failed if you see messages about events. The test passed if you don't."""; + private static Frame frame; + private static volatile Point loc; + private static List list; + private static final int XOFFSET = 10; + private static final int YOFFSET = 20; public static void main(String[] args) throws Exception { - PassFailJFrame.builder() - .title("MouseDraggedOriginatedByScrollBarTest Instructions") - .instructions(INSTRUCTIONS) - .rows((int) INSTRUCTIONS.lines().count() + 2) - .columns(35) - .testUI(MouseDraggedOriginatedByScrollBarTest::createTestUI) - .logArea() - .build() - .awaitAndCheck(); + try { + EventQueue.invokeAndWait(() -> createUI()); + test(); + } finally { + EventQueue.invokeAndWait(() -> { + if (frame != null) { + frame.dispose(); + } + }); + } } - private static Frame createTestUI() { - Frame frame = new Frame(); - List list = new List(4, false); + private static void createUI() { + frame = new Frame(); + list = new List(4, false); list.add("000"); list.add("111"); @@ -77,27 +82,52 @@ new MouseMotionAdapter(){ @Override public void mouseDragged(MouseEvent me){ - PassFailJFrame.log(me.toString()); + System.out.println(me); + throw new RuntimeException("Mouse dragged event detected."); } }); list.addMouseListener( new MouseAdapter() { public void mousePressed(MouseEvent me) { - PassFailJFrame.log(me.toString()); + System.out.println(me); + throw new RuntimeException("Mouse pressed event detected."); } public void mouseReleased(MouseEvent me) { - PassFailJFrame.log(me.toString()); + System.out.println(me); + throw new RuntimeException("Mouse released event detected."); } public void mouseClicked(MouseEvent me){ - PassFailJFrame.log(me.toString()); + System.out.println(me); + throw new RuntimeException("Mouse clicked event detected."); } }); frame.setLayout(new FlowLayout()); frame.pack(); - return frame; + frame.setLocationRelativeTo(null); + frame.setVisible(true); + } + + private static void test() throws Exception { + Robot robot = new Robot(); + robot.waitForIdle(); + robot.delay(1000); + robot.setAutoWaitForIdle(true); + + EventQueue.invokeAndWait(() -> { + Point p = list.getLocationOnScreen(); + p.translate(list.getWidth() - XOFFSET, YOFFSET); + loc = p; + }); + robot.mouseMove(loc.x, loc.y); + robot.mousePress(InputEvent.BUTTON1_DOWN_MASK); + for (int i = 0; i < 30; i++) { + robot.mouseMove(loc.x, loc.y + i); + } + robot.mouseRelease(InputEvent.BUTTON1_DOWN_MASK); + robot.delay(100); } } diff -Nru openjdk-17-17.0.17+10/test/jdk/java/awt/Menu/MenuActionEventTest.java openjdk-17-17.0.18+8/test/jdk/java/awt/Menu/MenuActionEventTest.java --- openjdk-17-17.0.17+10/test/jdk/java/awt/Menu/MenuActionEventTest.java 1970-01-01 00:00:00.000000000 +0000 +++ openjdk-17-17.0.18+8/test/jdk/java/awt/Menu/MenuActionEventTest.java 2026-01-15 15:23:06.000000000 +0000 @@ -0,0 +1,98 @@ +/* + * 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 + * 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 4094620 + * @summary MenuItem.enableEvents does not work + * @library /java/awt/regtesthelpers + * @build PassFailJFrame + * @run main/manual MenuActionEventTest + */ + +import java.awt.AWTEvent; +import java.awt.BorderLayout; +import java.awt.Frame; +import java.awt.Menu; +import java.awt.MenuBar; +import java.awt.MenuItem; +import java.awt.event.ActionEvent; + +public class MenuActionEventTest { + public static void main(String[] args) throws Exception { + String INSTRUCTIONS = """ + 1. Click on the Menu and then on Menuitem on the frame. + 2. If you find the following message being printed in + the test log area:, + _MenuItem: action event", + click PASS, else click FAIL" + """; + PassFailJFrame.builder() + .instructions(INSTRUCTIONS) + .columns(35) + .testUI(MenuActionEventTest::initialize) + .logArea() + .build() + .awaitAndCheck(); + } + + static Frame initialize() { + Frame f = new Frame("Menu Action Event Test"); + f.setLayout(new BorderLayout()); + f.setMenuBar(new MenuBar()); + Menu m = new _Menu("Menu"); + MenuBar mb = f.getMenuBar(); + mb.add(m); + MenuItem mi = new _MenuItem("Menuitem"); + m.add(mi); + f.setBounds(204, 152, 396, 300); + return f; + } + + static class _Menu extends Menu { + public _Menu(String text) { + super(text); + enableEvents(AWTEvent.ACTION_EVENT_MASK); + } + + @Override + protected void processActionEvent(ActionEvent e) { + PassFailJFrame.log("_Menu: action event"); + super.processActionEvent(e); + } + } + + static class _MenuItem extends MenuItem { + public _MenuItem(String text) { + super(text); + enableEvents(AWTEvent.ACTION_EVENT_MASK); + } + + @Override + protected void processActionEvent(ActionEvent e) { + PassFailJFrame.log("_MenuItem: action event"); + super.processActionEvent(e); + } + } + +} diff -Nru openjdk-17-17.0.17+10/test/jdk/java/awt/Menu/MenuVisibilityTest.java openjdk-17-17.0.18+8/test/jdk/java/awt/Menu/MenuVisibilityTest.java --- openjdk-17-17.0.17+10/test/jdk/java/awt/Menu/MenuVisibilityTest.java 1970-01-01 00:00:00.000000000 +0000 +++ openjdk-17-17.0.18+8/test/jdk/java/awt/Menu/MenuVisibilityTest.java 2026-01-15 15:23:06.000000000 +0000 @@ -0,0 +1,71 @@ +/* + * Copyright (c) 2004, 2025, Oracle and/or its affiliates. All rights reserved. + * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. + * + * This code is free software; you can redistribute 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 5046491 6423258 + * @summary CheckboxMenuItem: menu text is missing from test frame + * @library /java/awt/regtesthelpers + * @build PassFailJFrame + * @run main/manual MenuVisibilityTest +*/ + +import java.awt.Frame; +import java.awt.Menu; +import java.awt.MenuBar; +import java.awt.MenuItem; + +public class MenuVisibilityTest { + public static void main(String[] args) throws Exception { + String INSTRUCTIONS = """ + 1. Press on a MenuBar with a long name. + 2. Select "First item" in an opened menu. + If you see that "First menu item was pressed" in + the test log area, press PASS + Otherwise press FAIL" + """; + PassFailJFrame.builder() + .instructions(INSTRUCTIONS) + .columns(35) + .testUI(MenuVisibilityTest::initialize) + .logArea() + .build() + .awaitAndCheck(); + } + + public static Frame initialize() { + Frame frame = new Frame("Menu visibility test"); + String menuTitle = "I_have_never_seen_so_long_Menu_Title_" + + "!_ehe-eha-ehu-ehi_ugu-gu!!!_;)_BANG_BANG..."; + MenuBar menubar = new MenuBar(); + Menu menu = new Menu(menuTitle); + MenuItem menuItem = new MenuItem("First item"); + menuItem.addActionListener(e -> + PassFailJFrame.log("First menu item was pressed.")); + menu.add(menuItem); + menubar.add(menu); + frame.setMenuBar(menubar); + frame.setSize(100, 200); + return frame; + } +} diff -Nru openjdk-17-17.0.17+10/test/jdk/java/awt/Menu/RmInHideTest.java openjdk-17-17.0.18+8/test/jdk/java/awt/Menu/RmInHideTest.java --- openjdk-17-17.0.17+10/test/jdk/java/awt/Menu/RmInHideTest.java 1970-01-01 00:00:00.000000000 +0000 +++ openjdk-17-17.0.18+8/test/jdk/java/awt/Menu/RmInHideTest.java 2026-01-15 15:23:06.000000000 +0000 @@ -0,0 +1,152 @@ +/* + * Copyright (c) 1998, 2025, Oracle and/or its affiliates. All rights reserved. + * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. + * + * This code is free software; you can redistribute 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 4039387 + * @summary Checks that calling Frame.remove() within hide() doesn't + * cause SEGV + * @key headful + * @run main RmInHideTest + */ + +import java.awt.Button; +import java.awt.Dimension; +import java.awt.EventQueue; +import java.awt.Frame; +import java.awt.Menu; +import java.awt.MenuBar; +import java.awt.MenuItem; +import java.awt.Point; +import java.awt.Robot; +import java.awt.event.ActionEvent; +import java.awt.event.ActionListener; +import java.awt.event.MouseEvent; + +public class RmInHideTest { + static volatile Point point; + static RmInHideTestFrame frame; + static volatile Dimension dimension; + + public static void main(String[] args) throws Exception { + Robot robot = new Robot(); + try { + EventQueue.invokeAndWait(() -> { + frame = new RmInHideTestFrame(); + frame.setSize(200, 200); + frame.setVisible(true); + }); + robot.waitForIdle(); + robot.delay(1000); + EventQueue.invokeAndWait(() -> { + point = frame.getButtonLocation(); + dimension = frame.getButtonDimension(); + }); + robot.mouseMove(point.x + dimension.width / 2, point.y + dimension.height / 2); + robot.mousePress(MouseEvent.BUTTON2_DOWN_MASK); + robot.mouseRelease(MouseEvent.BUTTON2_DOWN_MASK); + robot.waitForIdle(); + robot.delay(100); + System.out.println("Test pass"); + } finally { + EventQueue.invokeAndWait(() -> { + if (frame != null) { + frame.dispose(); + } + }); + } + } + + static class RmInHideTestFrame extends Frame implements ActionListener { + MenuBar menubar = null; + Button b; + + public RmInHideTestFrame() { + super("RmInHideTest"); + b = new Button("Hide"); + b.setActionCommand("hide"); + b.addActionListener(this); + add("Center", b); + + MenuBar bar = new MenuBar(); + + Menu menu = new Menu("Test1", true); + menu.add(new MenuItem("Test1A")); + menu.add(new MenuItem("Test1B")); + menu.add(new MenuItem("Test1C")); + bar.add(menu); + + menu = new Menu("Test2", true); + menu.add(new MenuItem("Test2A")); + menu.add(new MenuItem("Test2B")); + menu.add(new MenuItem("Test2C")); + bar.add(menu); + setMenuBar(bar); + } + + @Override + public Dimension minimumSize() { + return new Dimension(200, 200); + } + + @Override + public void actionPerformed(ActionEvent e) { + String cmd = e.getActionCommand(); + if (cmd.equals("hide")) { + hide(); + try { + Thread.currentThread().sleep(2000); + } catch (InterruptedException ex) { + // do nothing + } + show(); + } + } + + @Override + public void hide() { + menubar = getMenuBar(); + if (menubar != null) { + remove(menubar); + } + super.hide(); + } + + + @Override + public void show() { + if (menubar != null) { + setMenuBar(menubar); + } + super.show(); + } + + public Point getButtonLocation() { + return b.getLocationOnScreen(); + } + + public Dimension getButtonDimension() { + return b.getSize(); + } + } +} diff -Nru openjdk-17-17.0.17+10/test/jdk/java/awt/Menu/SetShortCutTest.java openjdk-17-17.0.18+8/test/jdk/java/awt/Menu/SetShortCutTest.java --- openjdk-17-17.0.17+10/test/jdk/java/awt/Menu/SetShortCutTest.java 1970-01-01 00:00:00.000000000 +0000 +++ openjdk-17-17.0.18+8/test/jdk/java/awt/Menu/SetShortCutTest.java 2026-01-15 15:23:06.000000000 +0000 @@ -0,0 +1,132 @@ +/* + * Copyright (c) 1999, 2025, Oracle and/or its affiliates. All rights reserved. + * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. + * + * This code is free software; you can redistribute 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 4203208 + * @summary setShortcut method does not display proper text on Menu component + * @library /java/awt/regtesthelpers + * @build PassFailJFrame + * @run main/manual SetShortCutTest + */ + +import java.awt.Frame; +import java.awt.Menu; +import java.awt.MenuBar; +import java.awt.MenuItem; +import java.awt.MenuShortcut; +import java.awt.event.ActionEvent; +import java.awt.event.ActionListener; +import java.awt.event.KeyEvent; + +import static java.awt.event.KeyEvent.VK_META; +import static java.awt.event.KeyEvent.VK_SHIFT; + +public class SetShortCutTest { + public static void main(String[] args) throws Exception { + boolean isMac = System.getProperty("os.name").startsWith("Mac"); + String shortcut = "Ctrl+Shift+"; + if (isMac) { + shortcut = KeyEvent.getKeyText(VK_SHIFT) + "+" + KeyEvent.getKeyText(VK_META); + } + + String INSTRUCTIONS = """ + 1. Select menuitem 'Stuff -> Second' once to remove 'File -> First'. + 2. Select menuitem 'Stuff -> Second' again to add 'File -> First'. + 3. If menuitem 'File -> First' reads First """ + shortcut + """ + 'C', press PASS. Otherwise press FAIL. + """; + PassFailJFrame.builder() + .instructions(INSTRUCTIONS) + .columns(35) + .testUI(SetShortCutTest::initialize) + .build() + .awaitAndCheck(); + } + + static Frame initialize() { + return new TestMenuShortCut(); + } + + static class TestMenuShortCut extends Frame implements ActionListener { + Menu menu1; + MenuItem item1; + MenuItem item2; + boolean beenHere; + + public TestMenuShortCut() { + setTitle("Set ShortCut test"); + beenHere = false; + MenuBar mTopMenu = buildMenu(); + setSize(300, 300); + this.setMenuBar(mTopMenu); + } + + public MenuBar buildMenu() { + MenuBar bar; + bar = new MenuBar(); + menu1 = new Menu("File"); + item1 = new MenuItem("First"); + menu1.add(item1); + item1.setShortcut(new MenuShortcut(KeyEvent.VK_C, true)); + bar.add(menu1); + + // Stuff menu + item2 = new MenuItem("Second"); + Menu menu2 = new Menu("Stuff"); + menu2.add(item2); + item2.setShortcut(new MenuShortcut(KeyEvent.VK_C, false)); + bar.add(menu2); + + item1.addActionListener(this); + item2.addActionListener(this); + return bar; + } + + @Override + public void actionPerformed(ActionEvent event) { + if (event.getSource() == item1) { + Frame temp = new Frame("Accelerator key is working for 'First'"); + temp.setSize(300, 50); + temp.setVisible(true); + } + + // Click on the "Stuff" menu to remove the "first" menu item + else if (event.getSource() == item2) { + // If the item has not been removed from the menu, + // then remove "First" from the "File" menu + if (beenHere == false) { + item1.removeActionListener(this); + menu1.remove(item1); + beenHere = true; + } else { + item1 = new MenuItem("First"); + menu1.add(item1); + item1.addActionListener(this); + item1.setShortcut(new MenuShortcut(KeyEvent.VK_C, true)); + beenHere = false; + } + } + } + } +} diff -Nru openjdk-17-17.0.17+10/test/jdk/java/awt/Modal/AddRemoveTransientForsTest.java openjdk-17-17.0.18+8/test/jdk/java/awt/Modal/AddRemoveTransientForsTest.java --- openjdk-17-17.0.17+10/test/jdk/java/awt/Modal/AddRemoveTransientForsTest.java 1970-01-01 00:00:00.000000000 +0000 +++ openjdk-17-17.0.18+8/test/jdk/java/awt/Modal/AddRemoveTransientForsTest.java 2026-01-15 15:23:06.000000000 +0000 @@ -0,0 +1,123 @@ +/* + * 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 + * under the terms of the GNU General Public License version 2 only, as + * published by the Free Software Foundation. + * + * This code is distributed in the hope that it will be useful, but WITHOUT + * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or + * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License + * version 2 for more details (a copy is included in the LICENSE file that + * accompanied this code). + * + * You should have received a copy of the GNU General Public License version + * 2 along with this work; if not, write to the Free Software Foundation, + * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. + * + * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA + * or visit www.oracle.com if you need additional information or have any + * questions. + */ + +import java.awt.Button; +import java.awt.Dialog; +import java.awt.Frame; + +import java.awt.event.ActionEvent; +import java.awt.event.ActionListener; +import java.awt.event.WindowAdapter; +import java.awt.event.WindowEvent; +import java.awt.event.WindowListener; + +/* + * @test + * @bug 6271779 + * @summary This test shows and hides a modal dialog several times without destroying its + * peer. Without the fix this may lead to application (or even WM) hang. + * @library /java/awt/regtesthelpers + * @build PassFailJFrame + * @run main/manual AddRemoveTransientForsTest + */ + +public class AddRemoveTransientForsTest { + + private static Dialog d1; + private static Dialog d2; + + public static void main(String[] args) throws Exception { + final String INSTRUCTIONS = """ + When the test starts, a frame is shown with a button 'Show Dialog D1'. + + 1. Press the button 'Show Dialog D1' to show a modal dialog D1 with a button + 'Show dialog D2'. + + 2. Press the button 'Show dialog D2' to show another modal dialog D2 with a button + 'Close'. + + 3. Press the button 'Close' to close dialog D2. + + 4. Repeat steps 2 and 3 several times (at least 3-4 times). + + If the application is not hung, press Pass. + + NOTE: all the modal dialogs must be closed before pressing Pass button."""; + + PassFailJFrame.builder() + .instructions(INSTRUCTIONS) + .columns(45) + .testUI(AddRemoveTransientForsTest::init) + .build() + .awaitAndCheck(); + } + + public static Frame init() { + Frame f = new Frame("AddRemoveTransientForsTest Frame"); + Button b = new Button("Show dialog D1"); + b.addActionListener(new ActionListener() { + @Override + public void actionPerformed(ActionEvent e) + { + d1.setVisible(true); + } + }); + f.add(b); + f.setSize(200, 100); + + WindowListener wl = new WindowAdapter() { + @Override + public void windowClosing(WindowEvent e) + { + e.getWindow().dispose(); + } + }; + + d1 = new Dialog(f, "D1", true); + d1.setBounds(200, 200, 200, 100); + d1.addWindowListener(wl); + Button b1 = new Button("Show dialog D2"); + b1.addActionListener(new ActionListener() { + @Override + public void actionPerformed(ActionEvent e) + { + d2.setVisible(true); + } + }); + d1.add(b1); + + d2 = new Dialog(d1, "D2", true); + d2.setBounds(300, 300, 200, 100); + Button b2 = new Button("Close"); + b2.addActionListener(new ActionListener() { + @Override + public void actionPerformed(ActionEvent e) + { + d2.setVisible(false); + } + }); + d2.add(b2); + + return f; + } +} diff -Nru openjdk-17-17.0.17+10/test/jdk/java/awt/Modal/DialogLosesFocusTest.java openjdk-17-17.0.18+8/test/jdk/java/awt/Modal/DialogLosesFocusTest.java --- openjdk-17-17.0.17+10/test/jdk/java/awt/Modal/DialogLosesFocusTest.java 1970-01-01 00:00:00.000000000 +0000 +++ openjdk-17-17.0.18+8/test/jdk/java/awt/Modal/DialogLosesFocusTest.java 2026-01-15 15:23:06.000000000 +0000 @@ -0,0 +1,107 @@ +/* + * 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 + * under the terms of the GNU General Public License version 2 only, as + * published by the Free Software Foundation. + * + * This code is distributed in the hope that it will be useful, but WITHOUT + * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or + * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License + * version 2 for more details (a copy is included in the LICENSE file that + * accompanied this code). + * + * You should have received a copy of the GNU General Public License version + * 2 along with this work; if not, write to the Free Software Foundation, + * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. + * + * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA + * or visit www.oracle.com if you need additional information or have any + * questions. + */ + +import java.awt.Dialog; +import java.awt.EventQueue; +import java.awt.Frame; + +import java.awt.event.WindowAdapter; +import java.awt.event.WindowEvent; +import java.awt.event.WindowListener; + +/* + * @test + * @bug 6278150 + * @key headful + * @summary Initially modal blocked window causes modal dialog to lose focus + * @run main DialogLosesFocusTest + */ + +public class DialogLosesFocusTest { + private static Frame parent; + private static Dialog dialog; + private static Frame blocked; + private static volatile boolean failed; + + public static void main(String[] args) throws Exception { + try { + createAndShowUI(); + + sleepForMsecs(10000); + + if (failed) { + throw new RuntimeException("Test Failed"); + } + } finally { + EventQueue.invokeAndWait(() -> { + if (parent != null) { + parent.dispose(); + } + if (dialog != null) { + dialog.dispose(); + } + if (blocked != null) { + blocked.dispose(); + } + }); + } + } + + public static void createAndShowUI() throws Exception { + EventQueue.invokeAndWait(() -> { + parent = new Frame("Parent frame"); + parent.setBounds(0, 0, 300, 100); + parent.setVisible(true); + }); + + sleepForMsecs(1000); + + EventQueue.invokeLater(() -> { + dialog = new Dialog(parent, "Modal dialog", Dialog.ModalityType.APPLICATION_MODAL); + dialog.setBounds(100, 120, 300, 100); + dialog.setVisible(true); + }); + + sleepForMsecs(1000); + + EventQueue.invokeAndWait(() -> { + blocked = new Frame("Blocked frame"); + blocked.setBounds(200, 240, 300, 100); + blocked.addWindowListener(new WindowAdapter() { + @Override + public void windowActivated(WindowEvent we) { + if (dialog.isVisible()) { + failed = true; + } + } + }); + blocked.setVisible(true); + }); + } + + private static void sleepForMsecs(int t) { + try { + Thread.sleep(t); + } catch (Exception z) {} + } +} diff -Nru openjdk-17-17.0.17+10/test/jdk/java/awt/Modal/NativeDialogToFrontBackTest.java openjdk-17-17.0.18+8/test/jdk/java/awt/Modal/NativeDialogToFrontBackTest.java --- openjdk-17-17.0.17+10/test/jdk/java/awt/Modal/NativeDialogToFrontBackTest.java 1970-01-01 00:00:00.000000000 +0000 +++ openjdk-17-17.0.18+8/test/jdk/java/awt/Modal/NativeDialogToFrontBackTest.java 2026-01-15 15:23:06.000000000 +0000 @@ -0,0 +1,118 @@ +/* + * Copyright (c) 2006, 2025, Oracle and/or its affiliates. All rights reserved. + * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. + * + * This code is free software; you can redistribute it and/or modify it + * under the terms of the GNU General Public License version 2 only, as + * published by the Free Software Foundation. + * + * This code is distributed in the hope that it will be useful, but WITHOUT + * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or + * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License + * version 2 for more details (a copy is included in the LICENSE file that + * accompanied this code). + * + * You should have received a copy of the GNU General Public License version + * 2 along with this work; if not, write to the Free Software Foundation, + * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. + * + * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA + * or visit www.oracle.com if you need additional information or have any + * questions. + */ + +import java.awt.Button; +import java.awt.Dialog; +import java.awt.FileDialog; +import java.awt.FlowLayout; +import java.awt.Frame; +import java.util.List; + +import java.awt.event.ActionEvent; +import java.awt.event.ActionListener; +import java.awt.print.PageFormat; +import java.awt.print.PrinterJob; + +/* + * @test + * @bug 6393608 + * @summary Tests that toBack/toFront methods works correctly for native dialogs + * @library /java/awt/regtesthelpers + * @build PassFailJFrame + * @run main/manual NativeDialogToFrontBackTest + */ + +public class NativeDialogToFrontBackTest { + public static void main(String[] args) throws Exception { + final String INSTRUCTIONS = """ + When the test starts two frames appear: 'Control' and 'Blocked' + 1. Click on the 'Show file dialog' button + 2. Drag the file dialog so it partially overlaps the 'Blocked' frame + 3. 'Blocked' frame must be below the file dialog, if not - press Fail + 3. Click on the 'Blocked to front' button + 4. 'Blocked' frame must still be below the file dialog, if not - press Fail + 5. Close the file dialog + 6. Repeat steps 2 to 4 with print and page dialogs using the corresponding button + 7. If 'Blocked' frame is always below File/Print/Page dialog, press Pass"""; + + PassFailJFrame.builder() + .instructions(INSTRUCTIONS) + .columns(45) + .testUI(NativeDialogToFrontBackTest::init) + .positionTestUI(WindowLayouts::rightOneColumn) + .build() + .awaitAndCheck(); + } + + public static List init() { + Frame blocked = new Frame("Blocked"); + blocked.setSize(200, 200); + + Frame control = new Frame("Control"); + control.setModalExclusionType(Dialog.ModalExclusionType.APPLICATION_EXCLUDE); + control.setLayout(new FlowLayout()); + + Button showFileDialog = new Button("Show file dialog"); + showFileDialog.addActionListener(new ActionListener() { + @Override + public void actionPerformed(ActionEvent e) + { + new FileDialog(control, "File dialog").setVisible(true); + } + }); + control.add(showFileDialog); + + Button showPrintDialog = new Button("Show print dialog"); + showPrintDialog.addActionListener(new ActionListener() { + @Override + public void actionPerformed(ActionEvent e) + { + PrinterJob.getPrinterJob().printDialog(); + } + }); + control.add(showPrintDialog); + + Button showPageDialog = new Button("Show page dialog"); + showPageDialog.addActionListener(new ActionListener() { + @Override + public void actionPerformed(ActionEvent e) + { + PrinterJob.getPrinterJob().pageDialog(new PageFormat()); + } + }); + control.add(showPageDialog); + + Button blockedToFront = new Button("Blocked to front"); + blockedToFront.addActionListener(new ActionListener() { + @Override + public void actionPerformed(ActionEvent e) + { + blocked.toFront(); + } + }); + control.add(blockedToFront); + + control.setSize(200, 200); + return List.of(control, blocked); + } +} diff -Nru openjdk-17-17.0.17+10/test/jdk/java/awt/Multiscreen/DialogTest.java openjdk-17-17.0.18+8/test/jdk/java/awt/Multiscreen/DialogTest.java --- openjdk-17-17.0.17+10/test/jdk/java/awt/Multiscreen/DialogTest.java 1970-01-01 00:00:00.000000000 +0000 +++ openjdk-17-17.0.18+8/test/jdk/java/awt/Multiscreen/DialogTest.java 2026-01-15 15:23:06.000000000 +0000 @@ -0,0 +1,236 @@ +/* + * Copyright (c) 2001, 2025, Oracle and/or its affiliates. All rights reserved. + * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. + * + * This code is free software; you can redistribute it and/or modify it + * under the terms of the GNU General Public License version 2 only, as + * published by the Free Software Foundation. + * + * This code is distributed in the hope that it will be useful, but WITHOUT + * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or + * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License + * version 2 for more details (a copy is included in the LICENSE file that + * accompanied this code). + * + * You should have received a copy of the GNU General Public License version + * 2 along with this work; if not, write to the Free Software Foundation, + * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. + * + * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA + * or visit www.oracle.com if you need additional information or have any + * questions. + */ + +import java.awt.Button; +import java.awt.Color; +import java.awt.Dialog; +import java.awt.Dimension; +import java.awt.Frame; +import java.awt.GraphicsConfiguration; +import java.awt.GraphicsDevice; +import java.awt.GraphicsEnvironment; +import java.awt.GridLayout; +import java.awt.Label; +import java.awt.Panel; +import java.awt.Point; +import java.awt.ScrollPane; + +import java.awt.event.ActionEvent; +import java.awt.event.ActionListener; +import java.awt.event.WindowAdapter; +import java.awt.event.WindowEvent; + +import javax.swing.JDialog; +import javax.swing.JLabel; +import javax.swing.WindowConstants; + +import jtreg.SkippedException; + +/* + * @test + * @bug 4368500 + * @key multimon + * @summary Dialog needs a constructor with GraphicsConfiguration + * @library /java/awt/regtesthelpers /test/lib + * @build PassFailJFrame + * @run main/manual DialogTest + */ + +public class DialogTest { + static GraphicsDevice[] gds; + + private static Frame f; + private static Frame dummyFrame = new Frame(); + private static Dialog dummyDialog = new Dialog(dummyFrame); + + public static void main(String[] args) throws Exception { + gds = GraphicsEnvironment.getLocalGraphicsEnvironment().getScreenDevices(); + if (gds.length < 2) { + throw new SkippedException("You have only one monitor in your system" + + " - test skipped"); + } + + String INSTRUCTIONS = """ + This test tests the multiscreen functionality of Dialogs and JDialogs. + You should see the message "X screens detected", where X + is the number of screens on your system. If X is incorrect, press Fail. + + In the test window, there are a list of buttons representing each + type of dialog for each screen. + If there aren't buttons for every screen in your system, press Fail. + + Press each button, and the indicated type of dialog should appear + on the indicated screen. + Modal dialogs should not allow to click on the Instructions or + DialogTest windows. + + The buttons turn yellow once they have been pressed, to keep track + of test progress. + + If all Dialogs appear correctly, press Pass. + If Dialogs appear on the wrong screen or don't behave in + proper modality, press Fail."""; + + PassFailJFrame.builder() + .instructions(INSTRUCTIONS) + .columns(40) + .logArea(5) + .testUI(DialogTest::init) + .build() + .awaitAndCheck(); + } + + public static Frame init() { + PassFailJFrame.log(gds.length + " screens detected."); + f = new Frame("DialogTest UI"); + f.setSize(400, 400); + MyScrollPane sp = new MyScrollPane(); + + Panel p = new Panel(); + p.setLayout(new GridLayout(0, 1)); + + for (int i = 0; i < gds.length; i++) { + Button btn; + + //screen # , modal, frame-owned, swing + btn = new MyButton(new DialogInfo(i, false, false, false)); + p.add(btn); + + btn = new MyButton(new DialogInfo(i, true, false, false)); + p.add(btn); + + btn = new MyButton(new DialogInfo(i, false, true, false)); + p.add(btn); + + btn = new MyButton(new DialogInfo(i, true, true, false)); + p.add(btn); + + btn = new MyButton(new DialogInfo(i, false, false, true)); + p.add(btn); + + btn = new MyButton(new DialogInfo(i, true, false, true)); + p.add(btn); + + btn = new MyButton(new DialogInfo(i, false, true, true)); + p.add(btn); + + btn = new MyButton(new DialogInfo(i, true, true, true)); + p.add(btn); + + } + sp.add(p); + f.add(sp); + return f; + } + + static class MyScrollPane extends ScrollPane { + @Override + public Dimension getPreferredSize() { + return f.getSize(); + } + } + + static class MyButton extends Button { + public MyButton(DialogInfo info) { + setLabel(info.toString()); + addActionListener(new PutupDialog(info)); + } + } + + static class PutupDialog implements ActionListener { + DialogInfo info; + + public PutupDialog(DialogInfo info) { + this.info = info; + } + + @Override + public void actionPerformed(ActionEvent e) { + ((Button) (e.getSource())).setBackground(Color.yellow); + Dialog d = info.createDialog(); + d.show(); + } + } + + static class DialogInfo { + int num; + boolean modal; + boolean frameOwned; + boolean swing; + + public DialogInfo(int num, boolean modal, boolean frameOwned, boolean swing) { + this.num = num; + this.modal = modal; + this.frameOwned = frameOwned; + this.swing = swing; + } + + public Dialog createDialog() { + GraphicsConfiguration gc = gds[num].getDefaultConfiguration(); + + Dialog d; + + if (swing) { + if (frameOwned) { + d = new JDialog(dummyFrame, toString(), modal, gc); + } else { + d = new JDialog(dummyDialog, toString(), modal, gc); + } + + ((JDialog) d).setDefaultCloseOperation(WindowConstants.HIDE_ON_CLOSE); + if (modal) { + ((JDialog) d).getContentPane().add(new JLabel("Check that I am modal!")); + } + } else { + if (frameOwned) { + d = new Dialog(dummyFrame, toString(), modal, gc); + } else { + d = new Dialog(dummyDialog, toString(), modal, gc); + } + + d.addWindowListener(new WindowAdapter() { + public void windowClosing(WindowEvent e) { + e.getComponent().hide(); + } + }); + if (modal) { + d.add(new Label("Check that I am modal!")); + } + } + + d.setLocation(new Point((int) (gc.getBounds().getX() + 20) + , (int) (gc.getBounds().getY() + 20))); + d.setSize(300, 100); + + return d; + } + + public String toString() { + return "Screen " + num + (frameOwned ? " Frame-owned" : " Dialog-owned") + + (modal ? " modal " : " non-modal ") + + (swing ? "JDialog" : "Dialog"); + } + } +} + + diff -Nru openjdk-17-17.0.17+10/test/jdk/java/awt/Multiscreen/FillThisScreen.java openjdk-17-17.0.18+8/test/jdk/java/awt/Multiscreen/FillThisScreen.java --- openjdk-17-17.0.17+10/test/jdk/java/awt/Multiscreen/FillThisScreen.java 1970-01-01 00:00:00.000000000 +0000 +++ openjdk-17-17.0.18+8/test/jdk/java/awt/Multiscreen/FillThisScreen.java 2026-01-15 15:23:06.000000000 +0000 @@ -0,0 +1,140 @@ +/* + * Copyright (c) 2001, 2025, Oracle and/or its affiliates. All rights reserved. + * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. + * + * This code is free software; you can redistribute it and/or modify it + * under the terms of the GNU General Public License version 2 only, as + * published by the Free Software Foundation. + * + * This code is distributed in the hope that it will be useful, but WITHOUT + * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or + * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License + * version 2 for more details (a copy is included in the LICENSE file that + * accompanied this code). + * + * You should have received a copy of the GNU General Public License version + * 2 along with this work; if not, write to the Free Software Foundation, + * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. + * + * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA + * or visit www.oracle.com if you need additional information or have any + * questions. + */ + +import java.awt.Button; +import java.awt.Frame; +import java.awt.GraphicsConfiguration; +import java.awt.GraphicsDevice; +import java.awt.GraphicsEnvironment; +import java.awt.GridLayout; +import java.awt.Rectangle; + +import java.awt.event.ActionEvent; +import java.awt.event.ActionListener; + +import jtreg.SkippedException; + +/* + * @test + * @bug 4356756 + * @key multimon + * @summary Return all screen devices for physical and virtual display devices + * @library /java/awt/regtesthelpers /test/lib + * @build PassFailJFrame + * @run main/manual FillThisScreen + */ + +public class FillThisScreen { + private static Frame f; + private static Button b; + private static Rectangle oldSize; + private static boolean fillmode = true; + static GraphicsDevice[] gs; + + public static void main(String[] args) throws Exception { + gs = GraphicsEnvironment.getLocalGraphicsEnvironment().getScreenDevices(); + if (gs.length < 2) { + throw new SkippedException("You have only one monitor in your system" + + " - test skipped"); + } + + String INSTRUCTIONS = """ + This test is for testing the bounds of a multimonitor system. + You will see a Frame with several buttons: one marked 'Fill + This Screen' and an additional button for each display on your system. + + First, drag the Frame onto each display and click the + 'Fill This Screen' button. + + The Frame should resize to take up the entire display area + of the screen it is on, and the button text changes to say, + 'Get Smaller'. + + Click the button again to restore the Frame. + + Next, use the 'Move to screen' buttons to move the Frame to + each display and again click the 'Fill This Screen' button. + + If the number of 'Move to Screen' buttons is not equals to + the number of screens on your system, the test fails. + + If the Frame always correctly resizes to take up ONLY the + entire screen it is on (and not a different screen, or all + screens), the test passes else it fails."""; + + PassFailJFrame.builder() + .instructions(INSTRUCTIONS) + .columns(40) + .testUI(FillThisScreen::init) + .build() + .awaitAndCheck(); + } + + public static Frame init() { + Button tempBtn; + + f = new Frame("Drag Me Around"); + f.setLayout(new GridLayout(0, 1)); + + b = new Button("Fill This Screen"); + b.addActionListener(new ActionListener() { + @Override + public void actionPerformed(ActionEvent e) { + if (fillmode) { + oldSize = f.getBounds(); + Rectangle r = f.getGraphicsConfiguration().getBounds(); + f.setBounds(r); + b.setLabel("Get Smaller"); + } else { + f.setBounds(oldSize); + b.setLabel("Fill This Screen"); + } + fillmode = !fillmode; + } + }); + f.add(b); + + for (int i = 0; i < gs.length; i++) { + tempBtn = new Button("Move to screen:" + i); + tempBtn.addActionListener(new WinMover(i)); + f.add(tempBtn); + } + f.setSize(300, 100); + return f; + } + + private static class WinMover implements ActionListener { + int scrNum; + + public WinMover(int scrNum) { + this.scrNum = scrNum; + } + + public void actionPerformed(ActionEvent e) { + Rectangle newBounds = gs[scrNum].getDefaultConfiguration().getBounds(); + f.setLocation(newBounds.x + newBounds.width / 2, + newBounds.y + newBounds.height / 2); + } + + } +} diff -Nru openjdk-17-17.0.17+10/test/jdk/java/awt/Multiscreen/IMCandidateWindowTest.java openjdk-17-17.0.18+8/test/jdk/java/awt/Multiscreen/IMCandidateWindowTest.java --- openjdk-17-17.0.17+10/test/jdk/java/awt/Multiscreen/IMCandidateWindowTest.java 1970-01-01 00:00:00.000000000 +0000 +++ openjdk-17-17.0.18+8/test/jdk/java/awt/Multiscreen/IMCandidateWindowTest.java 2026-01-15 15:23:06.000000000 +0000 @@ -0,0 +1,104 @@ +/* + * 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 + * under the terms of the GNU General Public License version 2 only, as + * published by the Free Software Foundation. + * + * This code is distributed in the hope that it will be useful, but WITHOUT + * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or + * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License + * version 2 for more details (a copy is included in the LICENSE file that + * accompanied this code). + * + * You should have received a copy of the GNU General Public License version + * 2 along with this work; if not, write to the Free Software Foundation, + * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. + * + * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA + * or visit www.oracle.com if you need additional information or have any + * questions. + */ + +import java.awt.FlowLayout; +import java.awt.GraphicsConfiguration; +import java.awt.GraphicsDevice; +import java.awt.GraphicsEnvironment; +import java.awt.Rectangle; + +import javax.swing.JFrame; +import javax.swing.JTextField; + +import jtreg.SkippedException; + +/* + * @test + * @bug 4805862 + * @key multimon + * @requires (os.family == "windows") + * @summary Tests IM candidate window is positioned correctly for the + * text components inside a window in multiscreen configurations, if + * this window has negative coordinates + * @library /java/awt/regtesthelpers /test/lib + * @build PassFailJFrame + * @run main/manual IMCandidateWindowTest + */ + +public class IMCandidateWindowTest { + static GraphicsConfiguration gc; + + public static void main(String[] args) throws Exception { + GraphicsDevice[] gds = GraphicsEnvironment.getLocalGraphicsEnvironment() + .getScreenDevices(); + if (gds.length < 2) { + throw new SkippedException("You have only one monitor in your system" + + " - test skipped"); + } + + GraphicsDevice gd = null; + + for (int i = 0; i < gds.length; i++) { + gc = gds[i].getDefaultConfiguration(); + if ((gc.getBounds().x < 0) || (gc.getBounds().y < 0)) { + gd = gds[i]; + break; + } + } + + if (gd == null) { + // no screens with negative coords + throw new SkippedException("No screens with negative coords - test skipped"); + } + + String INSTRUCTIONS = """ + This test is for windows + Test requirements: installed support for asian languages + Chinese (PRC) w/ Chinese QuanPing input method. + Multiscreen environment where one of the monitors has negative coords + Go to the text field in the opened Frame. Switch to Chinese language and + start typing "ka". + Note, that IM helper window is appeared. + If this window is appeared near the text field, press PASS button. + If this window is appeared at the edge of the screen or on another + screen, press FAIL button"""; + + PassFailJFrame.builder() + .instructions(INSTRUCTIONS) + .columns(40) + .testUI(IMCandidateWindowTest::createUI) + .build() + .awaitAndCheck(); + } + + public static JFrame createUI() { + Rectangle b = gc.getBounds(); + + JFrame f = new JFrame("Frame", gc); + f.setBounds(b.x + b.width / 2 - 150, b.y + b.height / 2 - 100, 300, 200); + f.getContentPane().setLayout(new FlowLayout()); + JTextField tf = new JTextField(10); + f.getContentPane().add(tf); + return f; + } +} diff -Nru openjdk-17-17.0.17+10/test/jdk/java/awt/PrintJob/PrintCompatibilityTest.java openjdk-17-17.0.18+8/test/jdk/java/awt/PrintJob/PrintCompatibilityTest.java --- openjdk-17-17.0.17+10/test/jdk/java/awt/PrintJob/PrintCompatibilityTest.java 1970-01-01 00:00:00.000000000 +0000 +++ openjdk-17-17.0.18+8/test/jdk/java/awt/PrintJob/PrintCompatibilityTest.java 2026-01-15 15:23:06.000000000 +0000 @@ -0,0 +1,446 @@ +/* + * Copyright (c) 1999, 2024, Oracle and/or its affiliates. All rights reserved. + * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. + * + * This code is free software; you can redistribute it and/or modify it + * under the terms of the GNU General Public License version 2 only, as + * published by the Free Software Foundation. + * + * This code is distributed in the hope that it will be useful, but WITHOUT + * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or + * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License + * version 2 for more details (a copy is included in the LICENSE file that + * accompanied this code). + * + * You should have received a copy of the GNU General Public License version + * 2 along with this work; if not, write to the Free Software Foundation, + * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. + * + * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA + * or visit www.oracle.com if you need additional information or have any + * questions. + */ + +import java.awt.Button; +import java.awt.Canvas; +import java.awt.Checkbox; +import java.awt.Choice; +import java.awt.Color; +import java.awt.Component; +import java.awt.Container; +import java.awt.Dimension; +import java.awt.FlowLayout; +import java.awt.Font; +import java.awt.Frame; +import java.awt.Graphics; +import java.awt.Insets; +import java.awt.JobAttributes; +import java.awt.Label; +import java.awt.List; +import java.awt.Menu; +import java.awt.MenuBar; +import java.awt.MenuItem; +import java.awt.PageAttributes; +import java.awt.Panel; +import java.awt.PrintJob; +import java.awt.Scrollbar; +import java.awt.ScrollPane; +import java.awt.TextArea; +import java.awt.TextField; +import java.awt.event.ActionEvent; +import java.awt.event.ActionListener; +import java.awt.event.WindowAdapter; +import java.awt.event.WindowEvent; +import java.awt.JobAttributes.DialogType; +import java.awt.PageAttributes.OriginType; + +import java.util.Enumeration; +import java.util.Properties; + +/* + * @test + * @bug 4247583 + * @key printer + * @library /java/awt/regtesthelpers + * @build PassFailJFrame + * @summary Tests that the old Properties API still works + * @run main/manual PrintCompatibilityTest + */ + +public class PrintCompatibilityTest { + + public static void main(String[] args) throws Exception { + + String INSTRUCTIONS = """ + A frame window will appear. + Choose 'Print to Printer...' from the 'Print' menu. Make sure that you print + to a printer, not a file. Examine the output and verify that the frame and all + the components in it get printed properly. + + Known problems: + * The text in the second row of the menubar is not indented correctly. + + You can also use the 'Print to Screen...' command for a quick manual check that + printing works, but this is only for debugging purposes."""; + + PassFailJFrame.builder() + .title("PrintComponentTest Test Instructions") + .instructions(INSTRUCTIONS) + .rows((int) INSTRUCTIONS.lines().count() + 2) + .columns(60) + .testTimeOut(10) + .testUI(new MainFrame()) + .logArea(8) + .build() + .awaitAndCheck(); + } +} + +class MainFrame extends Frame { + private LWContainer lwc; + + public MainFrame() { + super("PrintCompatibilityTest"); + + setSize(800, 400); + setLayout(new FlowLayout()); + + // peered components + Button button = new Button("Button"); + button.setFont(new Font("Dialog", Font.PLAIN, 12)); + add(button); + add(new TestCanvas()); + Checkbox cbox = new Checkbox("Checkbox", true); + cbox.setFont(new Font("DialogInput", Font.PLAIN, 12)); + add(cbox); + Choice choice = new Choice(); + choice.add("Choice 1"); + choice.add("Choice Two"); + choice.setFont(new Font("Monospaced", Font.PLAIN, 12)); + add(choice); + Label label = new Label("Label"); + label.setFont(new Font("Serif", Font.PLAIN, 12)); + add(label); + List list = new List(); + list.add("List 1"); + list.add("List Two"); + list.setFont(new Font("SansSerif", Font.PLAIN, 12)); + add(list); + add(new Scrollbar(Scrollbar.VERTICAL) ); + add(new Scrollbar(Scrollbar.HORIZONTAL) ); + ScrollPane scrollpane = new ScrollPane(); + Button spButton = new Button("Button in a scrollpane"); + spButton.setFont(new Font("Monospaced", Font.PLAIN, 12)); + scrollpane.add(spButton); + add(scrollpane); + TextArea textarea = new TextArea("TextArea", 3, 30); + textarea.setFont(new Font("Dialog", Font.ITALIC, 10)); + add(textarea); + TextField textfield = new TextField("TextField"); + textfield.setFont(new Font("DialogInput", Font.ITALIC, 10)); + add(textfield); + + // nested components + Panel panel1 = new Panel(); + panel1.setLayout(new FlowLayout()); + panel1.setBackground(Color.red); + this.add(panel1); + + Button p1Button = new Button("level 2"); + p1Button.setFont(new Font("Monospaced", Font.ITALIC, 10)); + panel1.add(p1Button); + + Panel panel2 = new Panel(); + panel2.setLayout(new FlowLayout()); + panel2.setBackground(Color.green); + panel1.add(panel2); + + Button p2Button = new Button("level 3"); + p2Button.setFont(new Font("Serif", Font.ITALIC, 10)); + panel2.add(p2Button); + + + // lightweight components + LWButton lwbutton = new LWButton("LWbutton"); + lwbutton.setFont(new Font("SansSerif", Font.ITALIC, 10)); + add(lwbutton); + + lwc = new LWContainer("LWContainerLWContainerLWContainerLWContainerLWContainerLWContainerLWContainerLWContainerLWContainerLWContainerLWContainerLWContainerLWContainer"); + lwc.setFont(new Font("Monospaced", Font.ITALIC, 10)); + add(lwc); + Button lwcButton1 = new Button("HW Button 1"); + Button lwcButton2 = new Button("HW Button 2"); + LWButton lwcButton3 = new LWButton("LW Button"); + lwcButton1.setFont(new Font("Dialog", Font.BOLD, 14)); + lwcButton2.setFont(new Font("DialogInput", Font.BOLD, 14)); + lwcButton3.setFont(new Font("Monospaced", Font.BOLD, 14)); + lwc.add(lwcButton1); + lwc.add(lwcButton2); + lwc.add(lwcButton3); + + // overlapping components + add(new ZOrderPanel()); + + /////////////////////// + + Menu menu = new Menu("Print"); + Menu menu2 = new Menu("File"); + Menu menu3 = new Menu("Edit"); + Menu menu4 = new Menu("ReallyReallyReallyReallyReallyReallyReallyReallyReallyReallyReallyReallyReallyReallyReallyReallyReallyReallyReallyReallyReallyReallyReallyReallyReallyReallyReallyReallyReallyReallyLong"); + menu2.setFont(new Font("SansSerif", Font.BOLD, 20)); + menu2.setEnabled(false); + menu3.setFont(new Font("Monospaced", Font.ITALIC, 18)); + menu3.setEnabled(false); + menu4.setEnabled(false); + MenuItem itemPrinter = new MenuItem("Print to Printer..."); + MenuItem itemScreen = new MenuItem("Print to Screen..."); + menu.add(itemPrinter); + menu.add(itemScreen); + MenuBar menuBar = new MenuBar(); + menuBar.add( menu ); + menuBar.add( menu2 ); + menuBar.add( menu3 ); + menuBar.add( menu4 ); + setMenuBar(menuBar); + + itemPrinter.addActionListener( new ActionPrint() ); + itemScreen.addActionListener( new ActionPrintToScreen() ); + setVisible(true); + } + + static void printProps(Properties props) + { + Enumeration propNames = props.propertyNames(); + while (propNames.hasMoreElements()) { + String propName = (String)propNames.nextElement(); + PassFailJFrame.log( propName + " = " + props.getProperty(propName)); + } + } + + class ActionPrint implements ActionListener { + private final int ITERATIONS = 1; + private Properties props = new Properties(); + + public void actionPerformed(ActionEvent ev) { + PassFailJFrame.log("About to show print dialog..."); + printProps(props); + PrintJob pj = getToolkit().getPrintJob( + MainFrame.this, "Print test!", props); + if (pj == null) { + return; + } + Dimension d = pj.getPageDimension(); + PassFailJFrame.log("About to print..."); + PassFailJFrame.log("Dimensions: " + d); + printProps(props); + + // For xor mode set, there is a printing issue with number of copies to be print. + // So, ITERATIONS are changed to 1 from 3. + // So, for now the XOR related code is commented out. + + //boolean xor = false; + + for (int i = 0; i < ITERATIONS; i++) { + Graphics g = pj.getGraphics(); + g.setColor(Color.red); + //if (xor) { + // g.setXORMode(Color.blue); + //} + g.translate(13, 13); + printAll(g); + g.dispose(); + //xor = (xor) ? false : true; + } + + // For xor mode set, LWC components don't get printed. + // So, for now the code is commented out and separate bug + // (JDK-8340495) is filed to handle it. + + // one more page so that we can test printing a lightweight + // at the top of the hierarchy (BugId 4212564) + //Graphics g = pj.getGraphics(); + //g.setColor(Color.red); + //g.translate(13, 13); + //lwc.printAll(g); + //g.dispose(); + // end 4212564 + + pj.end(); + } + } + + class ActionPrintToScreen implements ActionListener { + public void actionPerformed(ActionEvent ev) { + PrintFrame printFrame = new PrintFrame(MainFrame.this); + printFrame.show(); + Graphics g = printFrame.getGraphics(); + g.setColor(Color.red); + printAll(g); + g.dispose(); + } + } + + // Frame window that displays results of printing + // main window to a screen Graphics-- useful for + // quick testing of printing + class PrintFrame extends Frame + { + private Component printComponent; + public PrintFrame( Component c ) + { + super("Print to Screen"); + printComponent = c ; + addWindowListener( new WindowAdapter() { + public void windowClosing(WindowEvent ev) { + setVisible(false); + dispose(); + } + } + ); + setSize(printComponent.getSize()); + setResizable(false); + } + + public void paint( Graphics g ) { + printComponent.printAll(g); + } + } + + class LWButton extends Component { + String label; + int width = 100; + int height = 30; + + public LWButton(String label) { + super(); + this.label = label; + } + + public void paint(Graphics g) { + Dimension d = getSize(); + g.setColor(Color.orange); + g.setFont(getFont()); + g.fillRect(0, 0, d.width, d.height); + g.setColor(Color.black); + int x = 5; + int y = (d.height - 5); + g.drawString(label, x, y); + } + + public Dimension getPreferredSize() + { + return new Dimension(width, height); + } + } + + class LWContainer extends Container { + String label; + int width = 300; + int height = 100; + + public LWContainer(String label) { + super(); + this.label = label; + setLayout(new FlowLayout()); + } + + public void paint(Graphics g) { + super.paint(g); + Dimension d = getSize(); + g.setColor(Color.green); + g.setFont(getFont()); + g.drawLine(0, 0, d.width - 1, 0); + g.drawLine(d.width - 1, 0, d.width - 1, d.height - 1); + g.drawLine(d.width - 1, d.height - 1, 0, d.height - 1); + g.drawLine(0, d.height - 1, 0, 0); + g.setColor(Color.black); + int x = 5; + int y = (d.height - 5); + g.drawString(label, x, y); + } + + public Dimension getPreferredSize() + { + return new Dimension(width, height); + } + } + + class TestCanvas extends Canvas { + int width = 100; + int height = 100; + + public void paint(Graphics g) { + g.setColor(Color.blue); + g.fillRoundRect(10, 10, 50, 50, 15, 30); + g.setColor(Color.red); + g.fillOval(70, 70, 25, 25); + } + public Dimension getPreferredSize() { + return new Dimension(width, height); + } + } + + class ZOrderPanel extends Panel + { + ZOrderPanel() + { + setLayout(null); + + Component first, second, third, fourth; + + setVisible(true); + // add first component + first = makeBox("Second", Color.blue, + new Font("Serif", Font.BOLD, 14), + -1); + // insert on top + second = makeBox("First", Color.yellow, + new Font("SansSerif", Font.BOLD, 14), + 0); + // put at the back + fourth = makeBox("Fourth", Color.red, + new Font("Monospaced", Font.BOLD, 14), + 2); + // insert in last position + third = makeBox("Third", Color.green, + new Font("Dialog", Font.PLAIN, 12), + 3); + // swap third and fourth to correct positions + remove(third); + add(third, 2); + // re-validate so third and fourth peers change position + validate(); + // now make things really interesting with a lightweight + // component at the top of the z-order, that should print + // _below_ the native guys to match the screen... + add(new LWButton("LWButton"), 0); + } + + public Dimension preferredSize() + { + return new Dimension(260, 80); + } + + public void layout() + { + int i, n; + Insets ins = getInsets(); + n = getComponentCount(); + for (i = n-1; i >= 0; i--) { + Component p = getComponent(i); + p.setBounds(ins.left + 40 * i, ins.top + 5 * i, 60, 60); + } + } + + public Component makeBox(String s, Color c, Font f, int index) + { + Label l = new Label(s); + l.setBackground(c); + l.setAlignment(Label.RIGHT); + l.setFont(f); + add(l, index); + validate(); + return l; + } + } +} diff -Nru openjdk-17-17.0.17+10/test/jdk/java/awt/PrintJob/PrintComponentTest.java openjdk-17-17.0.18+8/test/jdk/java/awt/PrintJob/PrintComponentTest.java --- openjdk-17-17.0.17+10/test/jdk/java/awt/PrintJob/PrintComponentTest.java 1970-01-01 00:00:00.000000000 +0000 +++ openjdk-17-17.0.18+8/test/jdk/java/awt/PrintJob/PrintComponentTest.java 2026-01-15 15:23:06.000000000 +0000 @@ -0,0 +1,486 @@ +/* + * Copyright (c) 1999, 2024, Oracle and/or its affiliates. All rights reserved. + * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. + * + * This code is free software; you can redistribute it and/or modify it + * under the terms of the GNU General Public License version 2 only, as + * published by the Free Software Foundation. + * + * This code is distributed in the hope that it will be useful, but WITHOUT + * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or + * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License + * version 2 for more details (a copy is included in the LICENSE file that + * accompanied this code). + * + * You should have received a copy of the GNU General Public License version + * 2 along with this work; if not, write to the Free Software Foundation, + * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. + * + * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA + * or visit www.oracle.com if you need additional information or have any + * questions. + */ + +import java.awt.Button; +import java.awt.Canvas; +import java.awt.Checkbox; +import java.awt.Choice; +import java.awt.Color; +import java.awt.Component; +import java.awt.Container; +import java.awt.Dimension; +import java.awt.FlowLayout; +import java.awt.Font; +import java.awt.Frame; +import java.awt.Graphics; +import java.awt.Insets; +import java.awt.JobAttributes; +import java.awt.Label; +import java.awt.List; +import java.awt.Menu; +import java.awt.MenuBar; +import java.awt.MenuItem; +import java.awt.PageAttributes; +import java.awt.Panel; +import java.awt.PrintJob; +import java.awt.Scrollbar; +import java.awt.ScrollPane; +import java.awt.TextArea; +import java.awt.TextField; +import java.awt.event.ActionEvent; +import java.awt.event.ActionListener; +import java.awt.event.WindowAdapter; +import java.awt.event.WindowEvent; +import java.awt.JobAttributes.DialogType; +import java.awt.PageAttributes.OriginType; + + +/* + * @test + * @bug 4111262 4035285 4038900 4046147 4049680 4084038 4100004 4105875 + * @bug 4117502 4037486 4068433 4128031 4151161 4151707 4155884 4212564 + * @bug 4025626 4029565 4034365 4036068 4040622 4061890 4067405 4086256 + * @bug 4113827 4116722 4121984 4145350 4146510 4172659 4179886 4218471 + * @bug 4219657 4227128 4242308 4245917 4265746 + * @key printer + * @library /java/awt/regtesthelpers + * @build PassFailJFrame + * @summary Test printing of lightweight (and heavyweight) components + * @run main/manual PrintComponentTest + */ + +public class PrintComponentTest { + public static void main(String[] args) throws Exception { + + String INSTRUCTIONS = """ + A frame window will appear. + Choose 'Print to Printer...' from the 'Print' menu. Examine the output + and verify that the frame and all the components in it get printed properly. + + Print using both 'Portrait' and 'Landscape' orientation. + Verify that the paper dimensions printed to standard error + are exactly inverted. + (That is, if the output for 'Portrait' is + "Dimensions: java.awt.Dimension[width=612,height=792]" then the output + for 'Landscape' should be "Dimensions: java.awt.Dimension[width=792, height=612].) + + Now, attempt to print a second time. When the print dialog box appears, + however, cancel the print request. + Verify that _no_ output is sent to standard error. + + You should attempt to print with both the native and common print dialogs, + as well as with no dialog. + Note that on Linux the native and common print dialogs are identical. + + On Windows, the common print dialog communicates with the printer to + determine supported paper sizes and duplex capability. + Verify that these constraints are properly enforced in the common dialog + for the target printer. + + Known problems: + * The text in the second row of the menubar is not indented + correctly. + + You can also use the 'Print to Screen...' command for a quick manual + check that printing works, but this is only for debugging purposes."""; + + PassFailJFrame.builder() + .title("PrintComponentTest Test Instructions") + .instructions(INSTRUCTIONS) + .rows((int) INSTRUCTIONS.lines().count() + 2) + .columns(60) + .testTimeOut(10) + .testUI(new MainFrame()) + .logArea(8) + .build() + .awaitAndCheck(); + } +} + +class MainFrame extends Frame { + private LWContainer lwc; + + public MainFrame() { + super("PrintComponentTest"); + + setSize(800, 400); + setLayout(new FlowLayout()); + + // peered components + Button button = new Button("Button"); + button.setFont(new Font("Dialog", Font.PLAIN, 12)); + add(button); + add(new TestCanvas()); + Checkbox cbox = new Checkbox("Checkbox", true); + cbox.setFont(new Font("DialogInput", Font.PLAIN, 12)); + add(cbox); + Choice choice = new Choice(); + choice.add("Choice 1"); + choice.add("Choice Two"); + choice.setFont(new Font("Monospaced", Font.PLAIN, 12)); + add(choice); + Label label = new Label("Label"); + label.setFont(new Font("Serif", Font.PLAIN, 12)); + add(label); + List list = new List(); + list.add("List 1"); + list.add("List Two"); + list.setFont(new Font("SansSerif", Font.PLAIN, 12)); + add(list); + add(new Scrollbar(Scrollbar.VERTICAL) ); + add(new Scrollbar(Scrollbar.HORIZONTAL) ); + ScrollPane scrollpane = new ScrollPane(); + Button spButton = new Button("Button in a scrollpane"); + spButton.setFont(new Font("Monospaced", Font.PLAIN, 12)); + scrollpane.add(spButton); + add(scrollpane); + TextArea textarea = new TextArea("TextArea", 3, 30); + textarea.setFont(new Font("Dialog", Font.ITALIC, 10)); + add(textarea); + TextField textfield = new TextField("TextField"); + textfield.setFont(new Font("DialogInput", Font.ITALIC, 10)); + add(textfield); + + // nested components + Panel panel1 = new Panel(); + panel1.setLayout(new FlowLayout()); + panel1.setBackground(Color.red); + this.add(panel1); + + Button p1Button = new Button("level 2"); + p1Button.setFont(new Font("Monospaced", Font.ITALIC, 10)); + panel1.add(p1Button); + + Panel panel2 = new Panel(); + panel2.setLayout(new FlowLayout()); + panel2.setBackground(Color.green); + panel1.add(panel2); + + Button p2Button = new Button("level 3"); + p2Button.setFont(new Font("Serif", Font.ITALIC, 10)); + panel2.add(p2Button); + + + // lightweight components + LWButton lwbutton = new LWButton("LWbutton"); + lwbutton.setFont(new Font("SansSerif", Font.ITALIC, 10)); + add(lwbutton); + + lwc = new LWContainer("LWContainerLWContainerLWContainerLWContainerLWContainerLWContainerLWContainerLWContainerLWContainerLWContainerLWContainerLWContainerLWContainer"); + lwc.setFont(new Font("Monospaced", Font.ITALIC, 10)); + add(lwc); + Button lwcButton1 = new Button("HW Button 1"); + Button lwcButton2 = new Button("HW Button 2"); + LWButton lwcButton3 = new LWButton("LW Button"); + lwcButton1.setFont(new Font("Dialog", Font.BOLD, 14)); + lwcButton2.setFont(new Font("DialogInput", Font.BOLD, 14)); + lwcButton3.setFont(new Font("Monospaced", Font.BOLD, 14)); + lwc.add(lwcButton1); + lwc.add(lwcButton2); + lwc.add(lwcButton3); + + // overlapping components + add(new ZOrderPanel()); + + /////////////////////// + + Menu menu = new Menu("Print"); + Menu menu2 = new Menu("File"); + Menu menu3 = new Menu("Edit"); + Menu menu4 = new Menu("ReallyReallyReallyReallyReallyReallyReallyReally" + + "ReallyReallyReallyReallyReallyReallyReallyReallyReallyReallyReally" + + "ReallyReallyReallyReallyReallyReallyReallyReallyReallyReallyReallyLong"); + menu2.setFont(new Font("SansSerif", Font.BOLD, 20)); + menu2.setEnabled(false); + menu3.setFont(new Font("Monospaced", Font.ITALIC, 18)); + menu3.setEnabled(false); + menu4.setEnabled(false); + MenuItem itemJFC = + new MenuItem("Print to Printer with Cross-Platform Dialog..."); + itemJFC.setActionCommand("common"); + MenuItem itemNative = + new MenuItem("Print to Printer with Native Dialog..."); + itemNative.setActionCommand("native"); + MenuItem itemBackground = + new MenuItem("Print to Printer in Background"); + itemBackground.setActionCommand("none"); + MenuItem itemScreen = new MenuItem("Print to Screen..."); + menu.add(itemJFC); + menu.add(itemNative); + menu.add(itemBackground); + menu.add(itemScreen); + MenuBar menuBar = new MenuBar(); + menuBar.add( menu ); + menuBar.add( menu2 ); + menuBar.add( menu3 ); + menuBar.add( menu4 ); + setMenuBar(menuBar); + + ActionPrint actionPrint = new ActionPrint(); + + itemJFC.addActionListener( actionPrint ); + itemNative.addActionListener( actionPrint ); + itemBackground.addActionListener( actionPrint ); + itemScreen.addActionListener( new ActionPrintToScreen() ); + } + + class ActionPrint implements ActionListener { + private final int ITERATIONS = 1; + private PageAttributes pageAttributes = new PageAttributes(); + private JobAttributes jobAttributes = new JobAttributes(); + + public void actionPerformed(ActionEvent ev) { + DialogType dialog; + if (ev.getActionCommand().equals("common")) { + dialog = DialogType.COMMON; + } else if (ev.getActionCommand().equals("native")) { + dialog = DialogType.NATIVE; + } else { + dialog = DialogType.NONE; + } + jobAttributes.setDialog(dialog); + pageAttributes.setOrigin(OriginType.PRINTABLE); + System.err.println(jobAttributes); + System.err.println(pageAttributes); + + PassFailJFrame.log("About to show print dialog..."); + + PrintJob pj = getToolkit().getPrintJob( + MainFrame.this, "Print test!", jobAttributes, pageAttributes); + if (pj == null) { + return; + } + Dimension d = pj.getPageDimension(); + PassFailJFrame.log("About to print..."); + PassFailJFrame.log("Dimensions: " + d); + System.err.println(jobAttributes); + System.err.println(pageAttributes); + + // For xor mode set, there is a printing issue with number of copies to be print. + // So, ITERATIONS are changed to 1 from 3. + // So, for now the XOR related code is commented out. + + //boolean xor = false; + + for (int i = 0; i < ITERATIONS; i++) { + Graphics g = pj.getGraphics(); + g.setColor(Color.red); + //if (xor) { + // g.setXORMode(Color.blue); + //} + printAll(g); + g.dispose(); + //xor = (xor) ? false : true; + } + + // For xor mode set, LWC components don't get printed. + // So, for now the code is commented out and separate bug + // (JDK-8340495) is filed to handle it. + + // one more page so that we can test printing a lightweight + // at the top of the hierarchy (BugId 4212564) + //Graphics g = pj.getGraphics(); + //g.setColor(Color.red); + //lwc.printAll(g); + //g.dispose(); + // end 4212564 + + pj.end(); + } + } + + class ActionPrintToScreen implements ActionListener { + public void actionPerformed(ActionEvent ev) { + PrintFrame printFrame = new PrintFrame(MainFrame.this); + printFrame.show(); + Graphics g = printFrame.getGraphics(); + g.setColor(Color.red); + printAll(g); + g.dispose(); + } + } + + // Frame window that displays results of printing + // main window to a screen Graphics-- useful for + // quick testing of printing + class PrintFrame extends Frame + { + private Component printComponent; + public PrintFrame( Component c ) + { + super("Print to Screen"); + printComponent = c ; + addWindowListener( new WindowAdapter() { + public void windowClosing(WindowEvent ev) { + setVisible(false); + dispose(); + } + } + ); + setSize(printComponent.getSize()); + setResizable(false); + } + + public void paint( Graphics g ) { + printComponent.printAll(g); + } + } + + class LWButton extends Component { + String label; + int width = 100; + int height = 30; + + public LWButton(String label) { + super(); + this.label = label; + } + + public void paint(Graphics g) { + Dimension d = getSize(); + g.setColor(Color.orange); + g.setFont(getFont()); + g.fillRect(0, 0, d.width, d.height); + g.setColor(Color.black); + int x = 5; + int y = (d.height - 5); + g.drawString(label, x, y); + } + + public Dimension getPreferredSize() + { + return new Dimension(width, height); + } + } + + class LWContainer extends Container { + String label; + int width = 300; + int height = 100; + + public LWContainer(String label) { + super(); + this.label = label; + setLayout(new FlowLayout()); + } + + public void paint(Graphics g) { + super.paint(g); + Dimension d = getSize(); + g.setColor(Color.green); + g.setFont(getFont()); + g.drawLine(0, 0, d.width - 1, 0); + g.drawLine(d.width - 1, 0, d.width - 1, d.height - 1); + g.drawLine(d.width - 1, d.height - 1, 0, d.height - 1); + g.drawLine(0, d.height - 1, 0, 0); + g.setColor(Color.black); + int x = 5; + int y = (d.height - 5); + g.drawString(label, x, y); + } + + public Dimension getPreferredSize() + { + return new Dimension(width, height); + } + } + + class TestCanvas extends Canvas { + int width = 100; + int height = 100; + + public void paint(Graphics g) { + g.setColor(Color.blue); + g.fillRoundRect(10, 10, 50, 50, 15, 30); + g.setColor(Color.red); + g.fillOval(70, 70, 25, 25); + } + public Dimension getPreferredSize() { + return new Dimension(width, height); + } + } + + class ZOrderPanel extends Panel + { + ZOrderPanel() + { + setLayout(null); + + Component first, second, third, fourth; + + setVisible(true); + // add first component + first = makeBox("Second", Color.blue, + new Font("Serif", Font.BOLD, 14), + -1); + // insert on top + second = makeBox("First", Color.yellow, + new Font("SansSerif", Font.BOLD, 14), + 0); + // put at the back + fourth = makeBox("Fourth", Color.red, + new Font("Monospaced", Font.BOLD, 14), + 2); + // insert in last position + third = makeBox("Third", Color.green, + new Font("Dialog", Font.PLAIN, 12), + 3); + // swap third and fourth to correct positions + remove(third); + add(third, 2); + // re-validate so third and fourth peers change position + validate(); + // now make things really interesting with a lightweight + // component at the top of the z-order, that should print + // _below_ the native guys to match the screen... + add(new LWButton("LWButton"), 0); + } + + public Dimension preferredSize() + { + return new Dimension(260, 80); + } + + public void layout() + { + int i, n; + Insets ins = getInsets(); + n = getComponentCount(); + for (i = n-1; i >= 0; i--) { + Component p = getComponent(i); + p.setBounds(ins.left + 40 * i, ins.top + 5 * i, 60, 60); + } + } + + public Component makeBox(String s, Color c, Font f, int index) + { + Label l = new Label(s); + l.setBackground(c); + l.setAlignment(Label.RIGHT); + l.setFont(f); + add(l, index); + validate(); + return l; + } + } +} diff -Nru openjdk-17-17.0.17+10/test/jdk/java/awt/PrintJob/ScaledImagePrintingTest.java openjdk-17-17.0.18+8/test/jdk/java/awt/PrintJob/ScaledImagePrintingTest.java --- openjdk-17-17.0.17+10/test/jdk/java/awt/PrintJob/ScaledImagePrintingTest.java 1970-01-01 00:00:00.000000000 +0000 +++ openjdk-17-17.0.18+8/test/jdk/java/awt/PrintJob/ScaledImagePrintingTest.java 2026-01-15 15:23:06.000000000 +0000 @@ -0,0 +1,102 @@ +/* + * Copyright (c) 1999, 2024, Oracle and/or its affiliates. All rights reserved. + * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. + * + * This code is free software; you can redistribute it and/or modify it + * under the terms of the GNU General Public License version 2 only, as + * published by the Free Software Foundation. + * + * This code is distributed in the hope that it will be useful, but WITHOUT + * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or + * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License + * version 2 for more details (a copy is included in the LICENSE file that + * accompanied this code). + * + * You should have received a copy of the GNU General Public License version + * 2 along with this work; if not, write to the Free Software Foundation, + * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. + * + * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA + * or visit www.oracle.com if you need additional information or have any + * questions. + */ + +import java.awt.Button; +import java.awt.Color; +import java.awt.Dimension; +import java.awt.Frame; +import java.awt.Graphics; +import java.awt.Image; +import java.awt.PrintJob; +import java.awt.Toolkit; +import java.awt.event.ActionEvent; +import java.awt.event.ActionListener; + +/* + * @test + * @bug 4257962 + * @library /java/awt/regtesthelpers + * @build PassFailJFrame + * @summary tests that scaled images are printed at resolution greater than 72dpi + * @run main/manual ScaledImagePrintingTest + */ + +public class ScaledImagePrintingTest { + + public static void main(String[] args) throws Exception { + String INSTRUCTIONS = """ + Press 'Print' button from the test UI. + + The test will bring up a print dialog. Select a printer and proceed. + Verify that the output is a series of a horizontal lines in a + rectangular box in the center of the page. + + If output is as mentioned above, press Pass else Fail."""; + + PassFailJFrame.builder() + .title("ScaledImagePrintingTest Test Instructions") + .instructions(INSTRUCTIONS) + .rows((int) INSTRUCTIONS.lines().count() + 2) + .columns(40) + .testTimeOut(5) + .testUI(ScaledImagePrintingTest::createUI) + .logArea(8) + .build() + .awaitAndCheck(); + } + + private static Frame createUI() { + Frame frame = new Frame("ResolutionTest"); + Button b = new Button("Print"); + b.addActionListener(new ActionListener() { + public void actionPerformed(ActionEvent e) { + PrintJob pj = frame.getToolkit().getPrintJob(frame, "ResolutionTest", null); + PassFailJFrame.log("Printing code started."); + if (pj != null) { + Graphics g = pj.getGraphics(); + g.setColor(Color.black); + int w = 200; + int h = 200; + Image image = frame.createImage(w, h); + Graphics imageGraphics = image.getGraphics(); + Dimension d = pj.getPageDimension(); + imageGraphics.setColor(Color.black); + for (int i = 0; i < h; i += 20) { + imageGraphics.drawLine(0, i, w, i); + } + g.translate(d.width / 2, d.height / 2); + g.drawImage(image, -w / 8, -h / 8, w / 4, h / 4, frame); + g.setColor(Color.black); + g.drawRect(-w / 4, -h / 4, w / 2, h / 2); + imageGraphics.dispose(); + g.dispose(); + pj.end(); + } + PassFailJFrame.log("Printing code finished."); + } + }); + frame.add(b); + frame.setSize(50, 50); + return frame; + } +} diff -Nru openjdk-17-17.0.17+10/test/jdk/java/awt/ScrollPane/ScrollPaneAsNeededTest.java openjdk-17-17.0.18+8/test/jdk/java/awt/ScrollPane/ScrollPaneAsNeededTest.java --- openjdk-17-17.0.17+10/test/jdk/java/awt/ScrollPane/ScrollPaneAsNeededTest.java 1970-01-01 00:00:00.000000000 +0000 +++ openjdk-17-17.0.18+8/test/jdk/java/awt/ScrollPane/ScrollPaneAsNeededTest.java 2026-01-15 15:23:06.000000000 +0000 @@ -0,0 +1,67 @@ +/* + * Copyright (c) 2003, 2025, Oracle and/or its affiliates. All rights reserved. + * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. + * + * This code is free software; you can redistribute 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 4152524 + * @summary ScrollPane AS_NEEDED always places scrollbars first time component + * is laid out + * @library /java/awt/regtesthelpers + * @build PassFailJFrame + * @run main/manual ScrollPaneAsNeededTest + */ + +import java.awt.BorderLayout; +import java.awt.Button; +import java.awt.Frame; +import java.awt.ScrollPane; + +public class ScrollPaneAsNeededTest { + public static void main(String[] args) throws Exception { + String INSTRUCTIONS = """ + 1. You will see a frame titled 'ScrollPane as needed' + of minimum possible size in the middle of the screen. + 2. If for the first resize of frame(using mouse) to + a very big size(may be, to half the area of the screen) + the scrollbars(any - horizontal, vertical or both) + appear, click FAIL else, click PASS. + """; + PassFailJFrame.builder() + .title("Test Instructions") + .instructions(INSTRUCTIONS) + .columns(35) + .testUI(ScrollPaneAsNeededTest::initialize) + .build() + .awaitAndCheck(); + } + + static Frame initialize() { + Frame f = new Frame("ScrollPane as needed"); + f.setLayout(new BorderLayout()); + ScrollPane sp = new ScrollPane(ScrollPane.SCROLLBARS_AS_NEEDED); + sp.add(new Button("TEST")); + f.add("Center", sp); + f.setSize(200, 200); + return f; + } +} diff -Nru openjdk-17-17.0.17+10/test/jdk/java/awt/ScrollPane/ScrollPaneComponentTest.java openjdk-17-17.0.18+8/test/jdk/java/awt/ScrollPane/ScrollPaneComponentTest.java --- openjdk-17-17.0.17+10/test/jdk/java/awt/ScrollPane/ScrollPaneComponentTest.java 1970-01-01 00:00:00.000000000 +0000 +++ openjdk-17-17.0.18+8/test/jdk/java/awt/ScrollPane/ScrollPaneComponentTest.java 2026-01-15 15:23:06.000000000 +0000 @@ -0,0 +1,125 @@ +/* + * Copyright (c) 2003, 2025, Oracle and/or its affiliates. All rights reserved. + * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. + * + * This code is free software; you can redistribute 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 4100671 + * @summary removing and adding back ScrollPane component does not work + * @library /java/awt/regtesthelpers + * @build PassFailJFrame + * @run main/manual ScrollPaneComponentTest + */ + +import java.awt.Adjustable; +import java.awt.BorderLayout; +import java.awt.Button; +import java.awt.Color; +import java.awt.Component; +import java.awt.Dimension; +import java.awt.Frame; +import java.awt.Graphics; +import java.awt.Panel; +import java.awt.ScrollPane; +import java.awt.event.ActionEvent; +import java.awt.event.ActionListener; + +public class ScrollPaneComponentTest { + public static void main(String[] args) throws Exception { + String INSTRUCTIONS = """ + 1. Notice the scrollbars (horizontal and vertical) + in the Frame titled 'ScrollPane Component Test' + 2. Click the button labeled 'Remove and add back + ScrollPane Contents' + 3. If the Scrollbars (horizontal or vertical or both) + disappears in the Frame, then press FAIL, else press PASS. + """; + PassFailJFrame.builder() + .title("Test Instructions") + .instructions(INSTRUCTIONS) + .columns(35) + .testUI(ScrollPaneComponentTest::initialize) + .build() + .awaitAndCheck(); + } + + static Frame initialize() { + Frame fr = new Frame("ScrollPane Component Test"); + fr.setLayout(new BorderLayout()); + ScrollTester test = new ScrollTester(); + + fr.add(test); + fr.pack(); + fr.setSize(200, 200); + + Adjustable vadj = test.pane.getVAdjustable(); + Adjustable hadj = test.pane.getHAdjustable(); + vadj.setUnitIncrement(5); + hadj.setUnitIncrement(5); + return fr; + } +} + +class Box extends Component { + public Dimension getPreferredSize() { + System.out.println("asked for size"); + return new Dimension(300, 300); + } + + public void paint(Graphics gr) { + super.paint(gr); + gr.setColor(Color.red); + gr.drawLine(5, 5, 295, 5); + gr.drawLine(295, 5, 295, 295); + gr.drawLine(295, 295, 5, 295); + gr.drawLine(5, 295, 5, 5); + System.out.println("Painted!!"); + } +} + +class ScrollTester extends Panel { + public ScrollPane pane; + private final Box child; + + class Handler implements ActionListener { + public void actionPerformed(ActionEvent e) { + System.out.println("Removing scrollable component"); + pane.remove(child); + System.out.println("Adding back scrollable component"); + pane.add(child); + System.out.println("Done Adding back scrollable component"); + } + } + + public ScrollTester() { + pane = new ScrollPane(); + pane.setSize(200, 200); + child = new Box(); + pane.add(child); + setLayout(new BorderLayout()); + Button changeScrollContents = new Button("Remove and add back ScrollPane Contents"); + changeScrollContents.setBackground(Color.red); + changeScrollContents.addActionListener(new Handler()); + add("North", changeScrollContents); + add("Center", pane); + } +} diff -Nru openjdk-17-17.0.17+10/test/jdk/java/awt/ScrollPane/ScrollPaneEventType.java openjdk-17-17.0.18+8/test/jdk/java/awt/ScrollPane/ScrollPaneEventType.java --- openjdk-17-17.0.17+10/test/jdk/java/awt/ScrollPane/ScrollPaneEventType.java 1970-01-01 00:00:00.000000000 +0000 +++ openjdk-17-17.0.18+8/test/jdk/java/awt/ScrollPane/ScrollPaneEventType.java 2026-01-15 15:23:06.000000000 +0000 @@ -0,0 +1,81 @@ +/* + * Copyright (c) 2003, 2025, Oracle and/or its affiliates. All rights reserved. + * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. + * + * This code is free software; you can redistribute 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 4075484 + * @summary Tests that events of different types are generated for the + * corresponding scroll actions. + * @library /java/awt/regtesthelpers + * @build PassFailJFrame + * @run main/manual ScrollPaneEventType + */ + +import java.awt.BorderLayout; +import java.awt.Button; +import java.awt.Dimension; +import java.awt.Frame; +import java.awt.ScrollPane; +import java.awt.event.AdjustmentListener; + +public class ScrollPaneEventType { + public static void main(String[] args) throws Exception { + String INSTRUCTIONS = """ + 1. This test verifies that when user performs some scrolling operation on + ScrollPane the correct AdjustmentEvent is being generated. + 2. To test this, press on: + - scrollbar's arrows and verify that UNIT event is generated, + - scrollbar's grey area(non-thumb) and verify that BLOCK event is + generated, + - drag scrollbar's thumb and verify that TRACK event is generated + If you see correct events for both scroll bars then test is PASSED. + Otherwise it is FAILED. + """; + PassFailJFrame.builder() + .title("Test Instructions") + .instructions(INSTRUCTIONS) + .columns(35) + .testUI(ScrollPaneEventType::initialize) + .logArea() + .build() + .awaitAndCheck(); + } + + static Frame initialize() { + Frame frame = new Frame("ScrollPane event type test"); + frame.setLayout(new BorderLayout()); + ScrollPane pane = new ScrollPane(ScrollPane.SCROLLBARS_ALWAYS); + pane.add(new Button("press") { + public Dimension getPreferredSize() { + return new Dimension(1000, 1000); + } + }); + + AdjustmentListener listener = e -> PassFailJFrame.log(e.toString()); + pane.getHAdjustable().addAdjustmentListener(listener); + pane.getVAdjustable().addAdjustmentListener(listener); + frame.add(pane); + frame.setSize(200, 200); + return frame; + } +} diff -Nru openjdk-17-17.0.17+10/test/jdk/java/awt/ScrollPane/ScrollPaneFlicker.java openjdk-17-17.0.18+8/test/jdk/java/awt/ScrollPane/ScrollPaneFlicker.java --- openjdk-17-17.0.17+10/test/jdk/java/awt/ScrollPane/ScrollPaneFlicker.java 1970-01-01 00:00:00.000000000 +0000 +++ openjdk-17-17.0.18+8/test/jdk/java/awt/ScrollPane/ScrollPaneFlicker.java 2026-01-15 15:23:06.000000000 +0000 @@ -0,0 +1,215 @@ +/* + * Copyright (c) 1999, 2025, Oracle and/or its affiliates. All rights reserved. + * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. + * + * This code is free software; you can redistribute 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 4073822 + * @summary ScrollPane repaints entire window when scrolling fast + * @library /java/awt/regtesthelpers + * @build PassFailJFrame + * @run main/manual ScrollPaneFlicker + */ + +import java.awt.Button; +import java.awt.Canvas; +import java.awt.Checkbox; +import java.awt.Choice; +import java.awt.Color; +import java.awt.Component; +import java.awt.Dimension; +import java.awt.Font; +import java.awt.Frame; +import java.awt.Graphics; +import java.awt.Label; +import java.awt.Menu; +import java.awt.MenuBar; +import java.awt.MenuItem; +import java.awt.Panel; +import java.awt.Rectangle; +import java.awt.ScrollPane; +import java.awt.Scrollbar; +import java.awt.TextArea; +import java.awt.TextField; +import javax.swing.JButton; +import javax.swing.JCheckBox; +import javax.swing.JComboBox; +import javax.swing.JLabel; +import javax.swing.JList; +import javax.swing.JPanel; +import javax.swing.JScrollBar; +import javax.swing.JTextArea; +import javax.swing.JTextField; + +public class ScrollPaneFlicker { + public static void main(String[] args) throws Exception { + String INSTRUCTIONS = """ + When scrolling a ScrollPane fast(i.e. holding the down/up arrow + down for a while), the ScrollPane would inexplicably refresh + the entire window. + + 1. Select a type of ScrollPane content from the content menu. + 2. Scroll the content using the up/down/left/right arrows on + the scroll bar. Try scrolling the entire content area using + the scroll arrows-- from top to bottom and left to right. + 3. Verify that the entire pane does not refresh when scrolling + - only the newly exposed areas should be repainting. + 4. Repeat for all content types. + """; + PassFailJFrame.builder() + .title("Test Instructions") + .instructions(INSTRUCTIONS) + .columns(35) + .testUI(ScrollPaneFlicker::initialize) + .build() + .awaitAndCheck(); + } + + static Frame initialize() { + return new FlickerFrame(); + } +} + +class FlickerFrame extends Frame { + ScrollPane pane; + + public FlickerFrame() { + super("ScrollPane Flicker Test"); + TextPanel textPanel = new TextPanel(); + GradientPanel gradientPanel = new GradientPanel(); + ComponentPanel componentPanel = new ComponentPanel(); + SwingPanel swingPanel = new SwingPanel(); + MenuBar menubar = new MenuBar(); + Menu testMenu = new Menu("Test Options"); + + pane = new ScrollPane(); + pane.getHAdjustable().setUnitIncrement(8); + pane.getVAdjustable().setUnitIncrement(16); + pane.add(textPanel); + add(pane); + + testMenu.add(makeContentItem("Text Lines", textPanel)); + testMenu.add(makeContentItem("Gradient Fill", gradientPanel)); + testMenu.add(makeContentItem("AWT Components", componentPanel)); + testMenu.add(makeContentItem("Swing Components", swingPanel)); + menubar.add(testMenu); + + setMenuBar(menubar); + setSize(400, 300); + } + + public MenuItem makeContentItem(String title, final Component content) { + MenuItem menuItem = new MenuItem(title); + menuItem.addActionListener( + ev -> { + pane.add(content); + pane.validate(); + } + ); + return menuItem; + } +} + +class GradientPanel extends Canvas { + public void paint(Graphics g) { + // just paint something that'll take a while + int x, y; + int width = getSize().width; + int height = getSize().height; + int step = 8; + + for (x = 0; x < width; x += step) { + for (y = 0; y < height; y += step) { + int red = (255 * y) / height; + int green = (255 * x * y) / (width * height); + int blue = (255 * x) / width; + Rectangle bounds = g.getClipBounds(); + Rectangle fbounds = new Rectangle(x, y, x + step, y + step); + if (bounds.intersects(fbounds)) { + Color color = new Color(red, green, blue); + g.setColor(color); + g.fillRect(x, y, x + step, y + step); + } + } + } + } + + public Dimension getPreferredSize() { + return new Dimension(200, 1000); + } +} + +class TextPanel extends Canvas { + public void paint(Graphics g) { + Font font = new Font("SanSerif", Font.ITALIC, 12); + + g.setFont(font); + // just paint something that'll take a while + int x, y; + int width = getWidth(); + int height = getHeight(); + int step = 16; + + for (x = y = 0; y < height; y += step) { + Rectangle bounds = g.getClipBounds(); + Rectangle tbounds = new Rectangle(x, y - 16, x + width, y); + if (bounds.intersects(tbounds)) { + g.drawString(y + " : The quick brown fox jumps over the lazy dog. " + + "The rain in Spain falls mainly on the plain.", x, y); + } + } + } + + public Dimension getPreferredSize() { + return new Dimension(640, 1000); + } +} + +class ComponentPanel extends Panel { + ComponentPanel() { + add(new Label("Label")); + add(new Button("Button")); + add(new Checkbox("Checkbox")); + Choice c = new Choice(); + c.add("choice"); + java.awt.List l = new java.awt.List(); + l.add("list"); + add(new Scrollbar()); + add(new TextField("TextField")); + add(new TextArea("TextArea")); + add(new Panel()); + add(new Canvas()); + } +} + +class SwingPanel extends JPanel { + SwingPanel() { + add(new JLabel("JLabel")); + add(new JButton("JButton")); + add(new JCheckBox("JCheckBox")); + JComboBox c = new JComboBox(); + JList l = new JList(); + add(new JScrollBar()); + add(new JTextField("This is a JTextField with some text in it to make it longer.")); + add(new JTextArea("This is a JTextArea with some text in it to make it longer.")); + } +} diff -Nru openjdk-17-17.0.17+10/test/jdk/java/awt/ScrollPane/ScrollPanePaint.java openjdk-17-17.0.18+8/test/jdk/java/awt/ScrollPane/ScrollPanePaint.java --- openjdk-17-17.0.17+10/test/jdk/java/awt/ScrollPane/ScrollPanePaint.java 1970-01-01 00:00:00.000000000 +0000 +++ openjdk-17-17.0.18+8/test/jdk/java/awt/ScrollPane/ScrollPanePaint.java 2026-01-15 15:23:06.000000000 +0000 @@ -0,0 +1,132 @@ +/* + * Copyright (c) 1999, 2025, Oracle and/or its affiliates. All rights reserved. + * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. + * + * This code is free software; you can redistribute 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. + */ + +/* + * Licensed Materials - Property of IBM + * + * (C) Copyright IBM Corporation 1998 All Rights Reserved. + * + * US Government Users Restricted Rights - Use, duplication or disclosure + * restricted by GSA ADP Schedule Contract with IBM Corp. + */ + +/* + * @test + * @bug 4160721 + * @summary AWT ScrollPane painting problem + * @library /java/awt/regtesthelpers + * @build PassFailJFrame + * @run main/manual ScrollPanePaint + */ + +import java.awt.BorderLayout; +import java.awt.Button; +import java.awt.Color; +import java.awt.Container; +import java.awt.Dimension; +import java.awt.Frame; +import java.awt.GridLayout; +import java.awt.Panel; +import java.awt.ScrollPane; +import java.awt.event.ActionEvent; +import java.awt.event.ActionListener; +import java.util.List; + +public class ScrollPanePaint { + public static void main(String[] args) throws Exception { + String INSTRUCTIONS = """ + 1. Press the button marked "Toggle" a few times. + 2. The contents of the frame should alternate between + a red panel and a scroll pane containing a green panel. + If this does not happen (specifically, if the scroll + pane does not consistently contain a green panel), + then the test has FAILED. + """; + ScrollPaintTest scrollPaintTest = new ScrollPaintTest(); + PassFailJFrame.builder() + .title("Test Instructions") + .instructions(INSTRUCTIONS) + .columns(35) + .testUI(scrollPaintTest::initialize) + .positionTestUI(WindowLayouts::rightOneColumn) + .build() + .awaitAndCheck(); + } + + private static class ScrollPaintTest implements ActionListener { + static Frame f; + static boolean showScroll; + + public List initialize() { + Frame frame = new Frame("Scrollpane paint test"); + frame.setLayout(new BorderLayout()); + f = new Frame("Scrollpane paint test"); + f.setLayout(new GridLayout(0, 1)); + + Button b = new Button("Toggle"); + b.addActionListener(this); + + frame.add(b, BorderLayout.CENTER); + frame.pack(); + + showScroll = false; + actionPerformed(null); + return List.of(frame, f); + } + + public void actionPerformed(ActionEvent e) { + Container c; + if (!showScroll) { + c = (Container) new TestPanel(new Dimension(100, 100)); + c.setBackground(Color.red); + } else { + c = new ScrollPane(ScrollPane.SCROLLBARS_ALWAYS); + Panel p = new TestPanel(new Dimension(20, 20)); + p.setBackground(Color.green); + c.add(p); + } + + f.removeAll(); + f.add("Center", c); + f.pack(); + showScroll = !showScroll; + } + } + + private static class TestPanel extends Panel { + Dimension dim; + + TestPanel(Dimension d) { + dim = d; + } + + public Dimension getMinimumSize() { + return getPreferredSize(); + } + + public Dimension getPreferredSize() { + return dim; + } + } + +} diff -Nru openjdk-17-17.0.17+10/test/jdk/java/awt/ScrollPane/ScrollPaneSize.java openjdk-17-17.0.18+8/test/jdk/java/awt/ScrollPane/ScrollPaneSize.java --- openjdk-17-17.0.17+10/test/jdk/java/awt/ScrollPane/ScrollPaneSize.java 1970-01-01 00:00:00.000000000 +0000 +++ openjdk-17-17.0.18+8/test/jdk/java/awt/ScrollPane/ScrollPaneSize.java 2026-01-15 15:23:06.000000000 +0000 @@ -0,0 +1,97 @@ +/* + * Copyright (c) 1999, 2025, Oracle and/or its affiliates. All rights reserved. + * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. + * + * This code is free software; you can redistribute 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 4117404 + * @summary Tests that child component is always at least large as scrollpane + * @library /java/awt/regtesthelpers + * @build PassFailJFrame + * @run main/manual ScrollPaneSize + */ + +import java.awt.Button; +import java.awt.Color; +import java.awt.Dimension; +import java.awt.FlowLayout; +import java.awt.Frame; +import java.awt.GridLayout; +import java.awt.Insets; +import java.awt.Panel; +import java.awt.ScrollPane; +import java.util.List; + +public class ScrollPaneSize { + public static void main(String[] args) throws Exception { + String INSTRUCTIONS = """ + 1. Three frames representing the three different ScrollPane scrollbar + policies will appear. + 2. Verify that when you resize the windows, the child component in the + scrollpane always expands to fill the scrollpane. The scrollpane + background is colored red to show any improper bleed through. + """; + PassFailJFrame.builder() + .title("Test Instructions") + .instructions(INSTRUCTIONS) + .columns(40) + .testUI(ScrollPaneSize::initialize) + .positionTestUIRightColumn() + .build() + .awaitAndCheck(); + } + + static List initialize() { + return List.of(new ScrollFrame("SCROLLBARS_AS_NEEDED", ScrollPane.SCROLLBARS_AS_NEEDED), + new ScrollFrame("SCROLLBARS_ALWAYS", ScrollPane.SCROLLBARS_ALWAYS), + new ScrollFrame("SCROLLBARS_NEVER", ScrollPane.SCROLLBARS_NEVER)); + } +} + +class ScrollFrame extends Frame { + ScrollFrame(String title, int policy) { + super(title); + setLayout(new GridLayout(1, 1)); + ScrollPane c = new ScrollPane(policy); + c.setBackground(Color.red); + Panel panel = new TestPanel(); + c.add(panel); + add(c); + pack(); + Dimension size = panel.getPreferredSize(); + Insets insets = getInsets(); + setSize(size.width + 45 + insets.right + insets.left, + size.height + 20 + insets.top + insets.bottom); + } +} + +class TestPanel extends Panel { + TestPanel() { + setLayout(new FlowLayout()); + setBackground(Color.white); + + Button b1, b2, b3; + add(b1 = new Button("Button1")); + add(b2 = new Button("Button2")); + add(b3 = new Button("Button3")); + } +} diff -Nru openjdk-17-17.0.17+10/test/jdk/java/awt/ScrollPane/ScrollPanechildViewportTest.java openjdk-17-17.0.18+8/test/jdk/java/awt/ScrollPane/ScrollPanechildViewportTest.java --- openjdk-17-17.0.17+10/test/jdk/java/awt/ScrollPane/ScrollPanechildViewportTest.java 1970-01-01 00:00:00.000000000 +0000 +++ openjdk-17-17.0.18+8/test/jdk/java/awt/ScrollPane/ScrollPanechildViewportTest.java 2026-01-15 15:23:06.000000000 +0000 @@ -0,0 +1,146 @@ +/* + * Copyright (c) 1998, 2025, Oracle and/or its affiliates. All rights reserved. + * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. + * + * This code is free software; you can redistribute 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 4094581 + * @summary ScrollPane does not refresh properly when child is just smaller than viewport + * @library /java/awt/regtesthelpers + * @build PassFailJFrame + * @run main/manual ScrollPanechildViewportTest + */ + +import java.awt.Button; +import java.awt.Color; +import java.awt.Dimension; +import java.awt.Frame; +import java.awt.Panel; +import java.awt.ScrollPane; +import java.awt.event.ActionEvent; +import java.awt.event.ActionListener; + +public class ScrollPanechildViewportTest { + public static void main(String[] args) throws Exception { + String INSTRUCTIONS = """ + 1. Click "Slightly Large" and ensure scrollbars are VISIBLE + 2. Click "Slightly Small" and ensure there are NO scrollbars + 3. Click "Smaller" and ensure there are NO scrollbars + 4. If everything is ok, click PASS, else click FAIL. + """; + PassFailJFrame.builder() + .title("Test Instructions") + .instructions(INSTRUCTIONS) + .columns(35) + .testUI(ScrollPanechildViewportTest::initialize) + .build() + .awaitAndCheck(); + } + + static Frame initialize() { + return new Test(); + } +} + +class Test extends Frame implements ActionListener { + Button b1, b2, b3; + MyPanel p; + int state; // 0 = slightly large, 1 = slightly smaller, 2 = smaller + + public Test() { + ScrollPane sp = new ScrollPane(); + p = new MyPanel(); + p.setBackground(Color.yellow); + state = 1; + sp.add(p); + add(sp, "Center"); + + Panel p1 = new Panel(); + b1 = new Button("Slightly Large"); + b1.addActionListener(this); + p1.add(b1); + b2 = new Button("Slightly Small"); + b2.addActionListener(this); + p1.add(b2); + b3 = new Button("Smaller"); + b3.addActionListener(this); + p1.add(b3); + + add(p1, "South"); + + setSize(400, 200); + //added to test to move test frame away from instructions + setLocation(0, 350); + } + + public void actionPerformed(ActionEvent e) { + Object source = e.getSource(); + + // set size to small and re-validate the panel to get correct size of + // scrollpane viewport without scrollbars + + state = 2; + p.invalidate(); + validate(); + + Dimension pd = ((ScrollPane) p.getParent()).getViewportSize(); + + if (source.equals(b1)) { + p.setBackground(Color.green); + state = 0; + } else if (source.equals(b2)) { + p.setBackground(Color.yellow); + state = 1; + } else if (source.equals(b3)) { + p.setBackground(Color.red); + state = 2; + } + + p.invalidate(); + validate(); + System.out.println("Panel Size = " + p.getSize()); + System.out.println("ScrollPane Viewport Size = " + pd); + System.out.println(" "); + } + + class MyPanel extends Panel { + public Dimension getPreferredSize() { + Dimension d = null; + Dimension pd = ((ScrollPane) getParent()).getViewportSize(); + switch (state) { + case 0 -> { + d = new Dimension(pd.width + 2, pd.height + 2); + System.out.println("Preferred size: " + d); + } + case 1 -> { + d = new Dimension(pd.width - 2, pd.height - 2); + System.out.println("Preferred size: " + d); + } + case 2 -> { + d = new Dimension(50, 50); + System.out.println("Preferred size: " + d); + } + } + return d; + } + } +} diff -Nru openjdk-17-17.0.17+10/test/jdk/java/awt/ScrollPane/ScrollPositionTest.java openjdk-17-17.0.18+8/test/jdk/java/awt/ScrollPane/ScrollPositionTest.java --- openjdk-17-17.0.17+10/test/jdk/java/awt/ScrollPane/ScrollPositionTest.java 1970-01-01 00:00:00.000000000 +0000 +++ openjdk-17-17.0.18+8/test/jdk/java/awt/ScrollPane/ScrollPositionTest.java 2026-01-15 15:23:06.000000000 +0000 @@ -0,0 +1,100 @@ +/* + * Copyright (c) 2003, 2025, Oracle and/or its affiliates. All rights reserved. + * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. + * + * This code is free software; you can redistribute 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 4008152 + * @summary ScrollPane position does not return correct values + * @key headful + * @run main ScrollPositionTest + */ + +import java.awt.Adjustable; +import java.awt.BorderLayout; +import java.awt.Canvas; +import java.awt.EventQueue; +import java.awt.Frame; +import java.awt.Point; +import java.awt.Robot; +import java.awt.ScrollPane; +import java.awt.event.AdjustmentEvent; +import java.awt.event.AdjustmentListener; + +public class ScrollPositionTest { + static Frame frame; + static int i = 0; + static Point p; + static ScrollPane sp; + + public static void main(String[] args) throws Exception { + Robot robot = new Robot(); + try { + EventQueue.invokeAndWait(() -> { + frame = new Frame("Scroll Position Test"); + frame.setLayout(new BorderLayout()); + frame.setSize(200, 200); + sp = new ScrollPane(ScrollPane.SCROLLBARS_AS_NEEDED); + Canvas canvas = new Canvas(); + canvas.setSize(300, 300); + sp.add(canvas); + frame.add("Center", sp); + frame.setLocationRelativeTo(null); + frame.setVisible(true); + }); + robot.waitForIdle(); + robot.delay(1000); + EventQueue.invokeAndWait(() -> { + Adjustable saH = sp.getHAdjustable(); + saH.addAdjustmentListener(new TestAdjustmentListener()); + }); + for (i = 0; i < 1000; i++) { + EventQueue.invokeAndWait(() -> { + p = new Point(i % 100, i % 100); + sp.setScrollPosition(p); + }); + + robot.waitForIdle(); + robot.delay(10); + EventQueue.invokeAndWait(() -> { + if (!sp.getScrollPosition().equals(p)) { + throw new RuntimeException("Test failed. " + i + " : " + + "Expected " + p + ", but Returned: " + sp.getScrollPosition()); + } + }); + } + System.out.println("Test Passed."); + } finally { + EventQueue.invokeAndWait(() -> { + if (frame != null) { + frame.dispose(); + } + }); + } + } + + private static class TestAdjustmentListener implements AdjustmentListener { + public void adjustmentValueChanged(AdjustmentEvent e) { + System.out.println("AdjEvent caught:" + e); + } + } +} diff -Nru openjdk-17-17.0.17+10/test/jdk/java/awt/ScrollPane/ScrollbarsAsNeededTest.java openjdk-17-17.0.18+8/test/jdk/java/awt/ScrollPane/ScrollbarsAsNeededTest.java --- openjdk-17-17.0.17+10/test/jdk/java/awt/ScrollPane/ScrollbarsAsNeededTest.java 1970-01-01 00:00:00.000000000 +0000 +++ openjdk-17-17.0.18+8/test/jdk/java/awt/ScrollPane/ScrollbarsAsNeededTest.java 2026-01-15 15:23:06.000000000 +0000 @@ -0,0 +1,72 @@ +/* + * Copyright (c) 1998, 2025, Oracle and/or its affiliates. All rights reserved. + * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. + * + * This code is free software; you can redistribute 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 4094248 + * @summary Test initial appearance of SCROLLBARS_AS_NEEDED policy + * @library /java/awt/regtesthelpers + * @build PassFailJFrame + * @run main/manual ScrollbarsAsNeededTest + */ + +import java.awt.Color; +import java.awt.FlowLayout; +import java.awt.Frame; +import java.awt.Graphics; +import java.awt.ScrollPane; + +public class ScrollbarsAsNeededTest { + public static void main(String[] args) throws Exception { + String INSTRUCTIONS = """ + 1. A Frame window with a ScrollPane that is + initially created with the SCROLLBARS_AS_NEEDED policy. + 2. If there are no scrollbars around the ScrollPane then + the test PASS. Otherwise the test FAILS. + """; + PassFailJFrame.builder() + .title("Test Instructions") + .instructions(INSTRUCTIONS) + .columns(35) + .testUI(ScrollbarsAsNeededTest::initialize) + .build() + .awaitAndCheck(); + } + + static Frame initialize() { + Frame frame = new Frame("Scrollbar as needed test"); + ScrollPane scrollPane = new ScrollPane() { + @Override + public void paint(Graphics g) { + super.paint(g); + g.drawString("ScrollPane", 10, 50); + } + }; + scrollPane.setBackground(Color.WHITE); + frame.setBackground(Color.GRAY); + frame.setSize(200, 200); + frame.setLayout(new FlowLayout()); + frame.add(scrollPane); + return frame; + } +} diff -Nru openjdk-17-17.0.17+10/test/jdk/java/awt/Scrollbar/ListScrollbarTest.java openjdk-17-17.0.18+8/test/jdk/java/awt/Scrollbar/ListScrollbarTest.java --- openjdk-17-17.0.17+10/test/jdk/java/awt/Scrollbar/ListScrollbarTest.java 1970-01-01 00:00:00.000000000 +0000 +++ openjdk-17-17.0.18+8/test/jdk/java/awt/Scrollbar/ListScrollbarTest.java 2026-01-15 15:23:06.000000000 +0000 @@ -0,0 +1,139 @@ +/* + * Copyright (c) 1998, 2025, Oracle and/or its affiliates. All rights reserved. + * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. + * + * This code is free software; you can redistribute 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 4029465 + * @summary Win95 Multiselect List doesn't display scrollbar + * @key headful + * @run main ListScrollbarTest + */ + +import java.awt.Color; +import java.awt.Dimension; +import java.awt.EventQueue; +import java.awt.Frame; +import java.awt.List; +import java.awt.Point; +import java.awt.Rectangle; +import java.awt.Robot; + +public class ListScrollbarTest { + + private static final Color BG_COLOR = Color.RED; + private static Robot robot; + private static Frame frame; + private static List list; + private static int counter = 0; + private static volatile Rectangle listBounds; + + public static void main(String[] args) throws Exception { + try { + EventQueue.invokeAndWait(ListScrollbarTest::createAndShowUI); + test(); + } finally { + EventQueue.invokeAndWait(() -> { + if (frame != null) { + frame.dispose(); + } + }); + } + } + + private static void test() throws Exception { + robot = new Robot(); + robot.waitForIdle(); + robot.delay(500); + + EventQueue.invokeAndWait(() -> { + Point locationOnScreen = list.getLocationOnScreen(); + Dimension size = list.getSize(); + listBounds = new Rectangle(locationOnScreen, size); + }); + + Point point = new Point(listBounds.x + listBounds.width - 5, + listBounds.y + listBounds.height / 2); + + + for (int i = 0; i < 4; i++) { + scrollbarCheck(point, false); + addListItem(); + } + scrollbarCheck(point, true); + } + + public static boolean areColorsSimilar(Color c1, Color c2, int tolerance) { + return Math.abs(c1.getRed() - c2.getRed()) <= tolerance + && Math.abs(c1.getGreen() - c2.getGreen()) <= tolerance + && Math.abs(c1.getBlue() - c2.getBlue()) <= tolerance; + } + + private static void scrollbarCheck(Point point, boolean isScrollbarExpected) { + Color pixelColor = robot.getPixelColor(point.x, point.y); + boolean areColorsSimilar = areColorsSimilar(BG_COLOR, pixelColor, 5); + + if (isScrollbarExpected && areColorsSimilar) { + throw new RuntimeException((""" + Scrollbar is expected, but pixel color \ + is similar to the background color + %s pixel color + %s bg color""") + .formatted(pixelColor, BG_COLOR)); + } + + if (!isScrollbarExpected && !areColorsSimilar) { + throw new RuntimeException((""" + Scrollbar is not expected, but pixel color \ + is not similar to the background color + %s pixel color + %s bg color""") + .formatted(pixelColor, BG_COLOR)); + } + } + + private static void addListItem() throws Exception { + EventQueue.invokeAndWait(() -> { + counter++; + System.out.println("Adding list item " + counter); + list.add("List Item " + counter); + frame.validate(); + }); + robot.waitForIdle(); + robot.delay(150); + } + + private static void createAndShowUI() { + frame = new Frame("ListScrollbarTest"); + list = new List(3, true); + list.setBackground(BG_COLOR); + + // do not draw border around items, it can affect screen capture + list.setFocusable(false); + + frame.add(list); + + frame.pack(); + frame.setLocationRelativeTo(null); + frame.setVisible(true); + } +} diff -Nru openjdk-17-17.0.17+10/test/jdk/java/awt/Scrollbar/ScrollbarCtrlClickTest.java openjdk-17-17.0.18+8/test/jdk/java/awt/Scrollbar/ScrollbarCtrlClickTest.java --- openjdk-17-17.0.17+10/test/jdk/java/awt/Scrollbar/ScrollbarCtrlClickTest.java 1970-01-01 00:00:00.000000000 +0000 +++ openjdk-17-17.0.18+8/test/jdk/java/awt/Scrollbar/ScrollbarCtrlClickTest.java 2026-01-15 15:23:06.000000000 +0000 @@ -0,0 +1,114 @@ +/* + * Copyright (c) 2002, 2025, Oracle and/or its affiliates. All rights reserved. + * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. + * + * This code is free software; you can redistribute it and/or modify it + * under the terms of the GNU General Public License version 2 only, as + * published by the Free Software Foundation. + * + * This code is distributed in the hope that it will be useful, but WITHOUT + * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or + * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License + * version 2 for more details (a copy is included in the LICENSE file that + * accompanied this code). + * + * You should have received a copy of the GNU General Public License version + * 2 along with this work; if not, write to the Free Software Foundation, + * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. + * + * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA + * or visit www.oracle.com if you need additional information or have any + * questions. + */ + +/* + * @test + * @bug 4075950 + * @summary Test for functionality of Control Click on Scrollbar + * @key headful + * @run main ScrollbarCtrlClickTest + */ + +import java.awt.BorderLayout; +import java.awt.Dimension; +import java.awt.EventQueue; +import java.awt.Frame; +import java.awt.Point; +import java.awt.Rectangle; +import java.awt.Robot; +import java.awt.Scrollbar; +import java.awt.TextArea; +import java.awt.event.KeyEvent; +import java.awt.event.MouseEvent; +import java.util.concurrent.CountDownLatch; +import java.util.concurrent.TimeUnit; + +public class ScrollbarCtrlClickTest { + private static Frame frame; + private static TextArea ta; + private static Scrollbar scrollbar; + private static final CountDownLatch latch = new CountDownLatch(1); + private static volatile Rectangle sbBounds; + + public static void main(String[] args) throws Exception { + try { + EventQueue.invokeAndWait(ScrollbarCtrlClickTest::initAndShowGUI); + test(); + } finally { + EventQueue.invokeAndWait(() -> { + if (frame != null) { + frame.dispose(); + } + }); + } + } + + private static void initAndShowGUI() { + frame = new Frame("ScrollbarDimensionTest"); + ta = new TextArea("", 30, 100); + + + scrollbar = new Scrollbar(Scrollbar.VERTICAL, + 0, 10, 0, 20); + + // Just setting layout so scrollbar thumb will be big enough to use + frame.setLayout(new BorderLayout()); + frame.add("East", scrollbar); + frame.add("West", ta); + + scrollbar.addAdjustmentListener(e -> { + System.out.println(e.paramString()); + ta.append(e.paramString() + "\n"); + latch.countDown(); + }); + + frame.pack(); + frame.setLocationRelativeTo(null); + frame.setVisible(true); + } + + private static void test() throws Exception { + Robot robot = new Robot(); + robot.waitForIdle(); + robot.setAutoDelay(25); + robot.delay(500); + + EventQueue.invokeAndWait(() -> { + Point locationOnScreen = scrollbar.getLocationOnScreen(); + Dimension size = scrollbar.getSize(); + sbBounds = new Rectangle(locationOnScreen, size); + }); + + robot.mouseMove(sbBounds.x + sbBounds.width / 2, + sbBounds.y + sbBounds.height - 50); + + robot.keyPress(KeyEvent.VK_CONTROL); + robot.mousePress(MouseEvent.BUTTON1_DOWN_MASK); + robot.mouseRelease(MouseEvent.BUTTON1_DOWN_MASK); + robot.keyRelease(KeyEvent.VK_CONTROL); + + if (!latch.await(1, TimeUnit.SECONDS)) { + throw new RuntimeException("Timed out waiting for latch"); + } + } +} diff -Nru openjdk-17-17.0.17+10/test/jdk/java/awt/Scrollbar/UnitIncrementTest.java openjdk-17-17.0.18+8/test/jdk/java/awt/Scrollbar/UnitIncrementTest.java --- openjdk-17-17.0.17+10/test/jdk/java/awt/Scrollbar/UnitIncrementTest.java 1970-01-01 00:00:00.000000000 +0000 +++ openjdk-17-17.0.18+8/test/jdk/java/awt/Scrollbar/UnitIncrementTest.java 2026-01-15 15:23:06.000000000 +0000 @@ -0,0 +1,129 @@ +/* + * Copyright (c) 1999, 2025, Oracle and/or its affiliates. All rights reserved. + * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. + * + * This code is free software; you can redistribute 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 4169461 + * @summary Test for Motif Scrollbar unit increment + * @key headful + * @run main UnitIncrementTest + */ + +import javax.swing.UIManager; +import java.awt.Dimension; +import java.awt.EventQueue; +import java.awt.Frame; +import java.awt.Point; +import java.awt.Rectangle; +import java.awt.Robot; +import java.awt.Scrollbar; +import java.awt.event.AdjustmentEvent; +import java.awt.event.MouseEvent; +import java.util.ArrayList; + +public class UnitIncrementTest { + private static Frame frame; + private static Scrollbar scrollbar; + private static final java.util.List eventsList = new ArrayList<>(); + private static final int UNIT_INCREMENT_VALUE = 5; + private static final int INCREMENTS_COUNT = 10; + private static volatile Rectangle scrollbarBounds; + + public static void main(String[] args) throws Exception { + UIManager.setLookAndFeel("com.sun.java.swing.plaf.motif.MotifLookAndFeel"); + + try { + EventQueue.invokeAndWait(UnitIncrementTest::createAndShowUI); + test(); + } finally { + EventQueue.invokeAndWait(() -> { + if (frame != null) { + frame.dispose(); + } + }); + } + } + + private static void createAndShowUI() { + frame = new Frame("UnitIncrementTest"); + + scrollbar = new Scrollbar(Scrollbar.HORIZONTAL); + + scrollbar.setUnitIncrement(UNIT_INCREMENT_VALUE); + scrollbar.setBlockIncrement(20); + + scrollbar.addAdjustmentListener(e -> { + eventsList.add(e); + System.out.println(e); + }); + + frame.add(scrollbar); + + frame.setSize(300, 100); + frame.setLocationRelativeTo(null); + frame.setVisible(true); + } + + private static void test() throws Exception { + Robot robot = new Robot(); + robot.waitForIdle(); + robot.setAutoDelay(25); + robot.delay(500); + + EventQueue.invokeAndWait(() -> { + Point locationOnScreen = scrollbar.getLocationOnScreen(); + Dimension size = scrollbar.getSize(); + scrollbarBounds = new Rectangle(locationOnScreen, size); + }); + + robot.mouseMove(scrollbarBounds.x + scrollbarBounds.width - 10, + scrollbarBounds.y + scrollbarBounds.height / 2); + + for (int i = 0; i < INCREMENTS_COUNT; i++) { + robot.mousePress(MouseEvent.BUTTON1_DOWN_MASK); + robot.mouseRelease(MouseEvent.BUTTON1_DOWN_MASK); + robot.delay(150); + } + + robot.waitForIdle(); + robot.delay(250); + + if (eventsList.size() != INCREMENTS_COUNT) { + throw new RuntimeException("Wrong number of events: " + eventsList.size()); + } + + int oldValue = 0; + for (AdjustmentEvent event : eventsList) { + System.out.println("\nChecking event " + event); + + int diff = event.getValue() - oldValue; + System.out.printf("diff: %d - %d = %d\n", event.getValue(), oldValue, diff); + + if (diff != UNIT_INCREMENT_VALUE) { + throw new RuntimeException("Unexpected adjustment value: %d".formatted(diff)); + } + + oldValue = event.getValue(); + } + } +} diff -Nru openjdk-17-17.0.17+10/test/jdk/java/awt/Selection/TestClipboard.java openjdk-17-17.0.18+8/test/jdk/java/awt/Selection/TestClipboard.java --- openjdk-17-17.0.17+10/test/jdk/java/awt/Selection/TestClipboard.java 1970-01-01 00:00:00.000000000 +0000 +++ openjdk-17-17.0.18+8/test/jdk/java/awt/Selection/TestClipboard.java 2026-01-15 15:23:06.000000000 +0000 @@ -0,0 +1,113 @@ +/* + * Copyright (c) 1999, 2025, Oracle and/or its affiliates. All rights reserved. + * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. + * + * This code is free software; you can redistribute it and/or modify it + * under the terms of the GNU General Public License version 2 only, as + * published by the Free Software Foundation. + * + * This code is distributed in the hope that it will be useful, but WITHOUT + * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or + * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License + * version 2 for more details (a copy is included in the LICENSE file that + * accompanied this code). + * + * You should have received a copy of the GNU General Public License version + * 2 along with this work; if not, write to the Free Software Foundation, + * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. + * + * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA + * or visit www.oracle.com if you need additional information or have any + * questions. + */ + +import java.awt.Toolkit; +import java.awt.datatransfer.Clipboard; +import java.awt.datatransfer.DataFlavor; +import java.awt.datatransfer.Transferable; +import java.awt.event.ActionEvent; +import java.awt.event.ActionListener; + +import java.io.Serializable; + +import javax.swing.JButton; +import javax.swing.JFrame; +import javax.swing.JOptionPane; + +/* + * @test + * @bug 4139552 + * @summary Checks to see if 'isDataFlavorSupported' throws exception. + * @library /java/awt/regtesthelpers + * @build PassFailJFrame + * @run main/manual TestClipboard + */ + +public class TestClipboard { + + public static void main(String[] args) throws Exception { + final String INSTRUCTIONS = """ + This test has two steps: + + 1. you need to place some text onto the system clipboard, + for example, + on Windows, you could highlight some text in notepad, and do a Ctrl-C + or select menu Edit->Copy; + + on Linux or Mac, you can do the same with any Terminal or Console or + Text application. + + 2. After you copy to system clipboard, press "Click Me" button. + + Test will fail if any exception is thrown. + + Press Pass if you see "Test Passed" in log area."""; + + PassFailJFrame.builder() + .title("TestClipboard Instruction") + .instructions(INSTRUCTIONS) + .columns(45) + .testUI(TestClipboard::createUI) + .logArea(4) + .build() + .awaitAndCheck(); + } + + private static JFrame createUI() { + JFrame f = new JFrame("ChildFrameIconTest UI"); + JButton b = new JButton("Click Me"); + b.addActionListener(new ActionListener() { + public void actionPerformed(ActionEvent e) { + try { + new MyTest(); + } catch (Exception ex) { + throw new RuntimeException("Exception Thrown : " + ex); + } + } + }); + f.add(b); + f.setSize(200, 100); + return f; + } + + static class MyFlavor extends Object implements Serializable { + // Stub class needed in order to define the data flavor type + } + + static class MyTest { + public MyTest() throws Exception { + // Create an arbitrary dataflavor + DataFlavor myFlavor = new DataFlavor(MyFlavor.class, "TestClipboard"); + // Get the system clipboard + Clipboard theClipboard = + Toolkit.getDefaultToolkit().getSystemClipboard(); + // Get the current contents of the clipboard + Transferable theTransfer = theClipboard.getContents(this); + + // See if the flavor is supported. This may result in a null + // pointer exception. + theTransfer.isDataFlavorSupported(myFlavor); + PassFailJFrame.log("Test Passed"); + } + } +} diff -Nru openjdk-17-17.0.17+10/test/jdk/java/awt/TextComponent/AltPlusNumberKeyCombinationsTest.java openjdk-17-17.0.18+8/test/jdk/java/awt/TextComponent/AltPlusNumberKeyCombinationsTest.java --- openjdk-17-17.0.17+10/test/jdk/java/awt/TextComponent/AltPlusNumberKeyCombinationsTest.java 1970-01-01 00:00:00.000000000 +0000 +++ openjdk-17-17.0.18+8/test/jdk/java/awt/TextComponent/AltPlusNumberKeyCombinationsTest.java 2026-01-15 15:23:06.000000000 +0000 @@ -0,0 +1,74 @@ +/* + * Copyright (c) 2002, 2025, Oracle and/or its affiliates. All rights reserved. + * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. + * + * This code is free software; you can redistribute it and/or modify it + * under the terms of the GNU General Public License version 2 only, as + * published by the Free Software Foundation. + * + * This code is distributed in the hope that it will be useful, but WITHOUT + * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or + * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License + * version 2 for more details (a copy is included in the LICENSE file that + * accompanied this code). + * + * You should have received a copy of the GNU General Public License version + * 2 along with this work; if not, write to the Free Software Foundation, + * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. + * + * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA + * or visit www.oracle.com if you need additional information or have any + * questions. + */ + +/* + * @test + * @bug 4737679 4623376 4501485 4740906 4708221 + * @requires (os.family == "windows") + * @summary Alt+Left/right/up/down generate characters in JTextArea + * @library /java/awt/regtesthelpers + * @build PassFailJFrame + * @run main/manual AltPlusNumberKeyCombinationsTest + */ + +import java.awt.FlowLayout; +import java.awt.Frame; +import java.awt.TextArea; +import java.awt.TextField; + +public class AltPlusNumberKeyCombinationsTest { + public static void main(String[] args) throws Exception { + String INSTRUCTIONS = """ + [WINDOWS PLATFORM ONLY] + Please do the following steps for both TextField and TextArea: + 1. Hold down ALT and press a NON-NUMPAD right arrow, then release + ALT key. If any symbol is typed the test failed. + 2. Hold down ALT and press one after another the following + NUMPAD keys: 0, 1, 2, 8. Release ALT key. If the Euro symbol + is not typed the test failed + 3. Hold down ALT and press one after another the following + NUMPAD keys: 0, 2, 2, 7. Release ALT key. If nothing or + the blank symbol is typed the test failed + If all the steps are done successfully the test PASSed, + else test FAILS. + """; + PassFailJFrame.builder() + .title("Test Instructions") + .instructions(INSTRUCTIONS) + .columns(35) + .testUI(initialize()) + .build() + .awaitAndCheck(); + } + + public static Frame initialize() { + Frame f = new Frame("key combination test"); + f.setLayout(new FlowLayout()); + TextField tf = new TextField("TextField"); + f.add(tf); + TextArea ta = new TextArea("TextArea"); + f.add(ta); + f.setSize(200, 200); + return f; + } +} diff -Nru openjdk-17-17.0.17+10/test/jdk/java/awt/TextComponent/BackgroundTest.java openjdk-17-17.0.18+8/test/jdk/java/awt/TextComponent/BackgroundTest.java --- openjdk-17-17.0.17+10/test/jdk/java/awt/TextComponent/BackgroundTest.java 1970-01-01 00:00:00.000000000 +0000 +++ openjdk-17-17.0.18+8/test/jdk/java/awt/TextComponent/BackgroundTest.java 2026-01-15 15:23:06.000000000 +0000 @@ -0,0 +1,127 @@ +/* + * Copyright (c) 1999, 2025, Oracle and/or its affiliates. All rights reserved. + * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. + * + * This code is free software; you can redistribute 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 4258667 4405602 + * @summary Make sure TextComponents are grayed out when non-editable + * if the background color has not been set by client code. + * Make sure TextComponents are not grayed out when non-editable + * if the background color has been set by client code. + * @library /java/awt/regtesthelpers + * @build PassFailJFrame + * @run main/manual BackgroundTest + */ + +import java.awt.Button; +import java.awt.Color; +import java.awt.FlowLayout; +import java.awt.Frame; +import java.awt.TextArea; +import java.awt.TextField; + +public class BackgroundTest { + private static final String enableString = "EnableText"; + private static final String disableString = "DisableText"; + + public static void main(String[] args) throws Exception { + String INSTRUCTIONS = """ + 1. When the frame appears, it should have a blue background. + 2. The first TextField and TextArea will be the default color. + The second TextField and TextArea will be green. + 3. Press the "DisableText" button. + The first TextField and TextArea should change colors to the + default disabled color. On Windows, this is usually gray. + On linux and macos it will match the environment settings. + If the TextField or the TextArea do not change colors as described, + the test FAILS. + 4. The second TextField and TextArea should still be green. + If either of them are not green, the test FAILS. + Press the "EnableText" button (same button as before). + The first TextField and TextArea should return to their + original colors as described in the first paragraph. If they + do not, the test FAILS. + 5. The second TextField and TextArea should still be green. + If either of them are not green, the test FAILS. + Otherwise, the test PASSES. + """; + + PassFailJFrame.builder() + .instructions(INSTRUCTIONS) + .columns(35) + .testUI(BackgroundTest::initialize) + .build() + .awaitAndCheck(); + } + + public static Frame initialize() { + Frame frame = new Frame("Background Test"); + frame.setLayout(new FlowLayout()); + TextField tf = new TextField(30); + TextArea ta = new TextArea(4, 30); + TextField setTf = new TextField(30); + TextArea setTa = new TextArea(4, 30); + Button enableButton = new Button(disableString); + + enableButton.setBackground(Color.red); + frame.setSize(500, 250); + + frame.setBackground(Color.blue); + + tf.setText("Background not set - should be default"); + tf.setEditable(true); + frame.add(tf); + ta.setText("Background not set - should be default"); + ta.setEditable(true); + frame.add(ta); + + setTf.setText("Background is set - should be Green"); + setTf.setBackground(Color.green); + setTf.setEditable(true); + frame.add(setTf); + setTa.setText("Background is set - should be Green"); + setTa.setBackground(Color.green); + setTa.setEditable(true); + frame.add(setTa); + + enableButton.addActionListener(e -> { + boolean currentlyEditable = tf.isEditable(); + + if (currentlyEditable) { + tf.setEditable(false); + ta.setEditable(false); + setTf.setEditable(false); + setTa.setEditable(false); + enableButton.setLabel(enableString); + } else { + tf.setEditable(true); + ta.setEditable(true); + setTf.setEditable(true); + setTa.setEditable(true); + enableButton.setLabel(disableString); + } + }); + frame.add(enableButton); + return frame; + } +} \ No newline at end of file diff -Nru openjdk-17-17.0.17+10/test/jdk/java/awt/TextComponent/CorrectTextComponentSelectionTest.java openjdk-17-17.0.18+8/test/jdk/java/awt/TextComponent/CorrectTextComponentSelectionTest.java --- openjdk-17-17.0.17+10/test/jdk/java/awt/TextComponent/CorrectTextComponentSelectionTest.java 1970-01-01 00:00:00.000000000 +0000 +++ openjdk-17-17.0.18+8/test/jdk/java/awt/TextComponent/CorrectTextComponentSelectionTest.java 2026-01-15 15:23:06.000000000 +0000 @@ -0,0 +1,139 @@ +/* + * 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 + * 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 5100806 + * @summary TextArea.select(0,0) does not de-select the selected text properly + * @key headful + * @run main CorrectTextComponentSelectionTest + */ + +import java.awt.BorderLayout; +import java.awt.Color; +import java.awt.EventQueue; +import java.awt.Frame; +import java.awt.Point; +import java.awt.Robot; +import java.awt.TextArea; +import java.awt.TextComponent; +import java.awt.TextField; +import java.lang.reflect.InvocationTargetException; + +public class CorrectTextComponentSelectionTest { + static TextField tf = new TextField("TextField"); + static TextArea ta = new TextArea("TextArea"); + static Robot r; + static Frame frame; + static volatile Color color_center; + static volatile Point loc; + + public static void main(String[] args) throws Exception { + try { + r = new Robot(); + EventQueue.invokeAndWait(() -> { + initialize(); + }); + r.waitForIdle(); + r.delay(1000); + + test(tf); + test(ta); + System.out.println("Test Passed!"); + } finally { + EventQueue.invokeAndWait(() -> { + if (frame != null) { + frame.dispose(); + } + }); + } + } + + public static void initialize() { + frame = new Frame("TextComponent Selection Test"); + frame.setLayout(new BorderLayout()); + + // We should place to the text components the long strings in order to + // cover the components by the selection completely + String sf = ""; + for (int i = 0; i < 50; i++) { + sf = sf + " "; + } + tf.setText(sf); + // We check the color of the text component in order to find out the + // bug reproducible situation + tf.setForeground(Color.WHITE); + tf.setBackground(Color.WHITE); + + String sa = ""; + for (int i = 0; i < 50; i++) { + for (int j = 0; j < 50; j++) { + sa = sa + " "; + } + sa = sa + "\n"; + } + ta.setText(sa); + ta.setForeground(Color.WHITE); + ta.setBackground(Color.WHITE); + + frame.add(tf, "North"); + frame.add(ta, "South"); + frame.setSize(200, 200); + frame.setVisible(true); + } + + private static void test(TextComponent tc) throws Exception { + if (tc instanceof TextField) { + System.out.println("TextField testing ..."); + } else if (tc instanceof TextArea) { + System.out.println("TextArea testing ..."); + } + + r.waitForIdle(); + r.delay(100); + EventQueue.invokeAndWait(() -> { + tc.requestFocus(); + tc.selectAll(); + tc.select(0, 0); + }); + + r.waitForIdle(); + r.delay(100); + EventQueue.invokeAndWait(() -> { + loc = tc.getLocationOnScreen(); + }); + r.waitForIdle(); + r.delay(100); + + EventQueue.invokeAndWait(() -> { + color_center = r.getPixelColor(loc.x + tc.getWidth() / 2, loc.y + tc.getHeight() / 2); + }); + + System.out.println("Color of the text component (CENTER) =" + color_center); + System.out.println("White color=" + Color.WHITE); + + if (color_center.getRGB() != Color.WHITE.getRGB()) { + throw new RuntimeException("Test Failed"); + } + } +} diff -Nru openjdk-17-17.0.17+10/test/jdk/java/awt/TextComponent/DisableTest.java openjdk-17-17.0.18+8/test/jdk/java/awt/TextComponent/DisableTest.java --- openjdk-17-17.0.17+10/test/jdk/java/awt/TextComponent/DisableTest.java 1970-01-01 00:00:00.000000000 +0000 +++ openjdk-17-17.0.18+8/test/jdk/java/awt/TextComponent/DisableTest.java 2026-01-15 15:23:06.000000000 +0000 @@ -0,0 +1,98 @@ +/* + * 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 + * 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 5042122 + * @summary Verifies the TextComponent is grayed out when disabled + * @library /java/awt/regtesthelpers + * @build PassFailJFrame + * @run main/manual DisableTest + */ + +import javax.swing.BoxLayout; +import java.awt.BorderLayout; +import java.awt.Button; +import java.awt.Component; +import java.awt.Frame; +import java.awt.Panel; +import java.awt.TextArea; +import java.awt.TextField; +import java.awt.event.ActionListener; +import java.util.Vector; +import java.util.Iterator; + +public class DisableTest { + public static void main(String[] args) throws Exception { + String INSTRUCTIONS = """ + 1. Click "Enable" and "Disable" buttons and verify the text + components are disabled and enabled correctly. + 2. Verify that the disabled text components are grayed + out and are uneditable. + 3. Click PASS or FAIL accordingly. + """; + + PassFailJFrame.builder() + .instructions(INSTRUCTIONS) + .columns(35) + .testUI(DisableTest::initialize) + .build() + .awaitAndCheck(); + } + + public static Frame initialize() { + Frame frame = new Frame("TextComponent Disabled test"); + frame.setLayout(new BorderLayout()); + frame.setSize(200, 200); + final Vector comps = new Vector(); + comps.add(new TextField("TextField")); + TextArea ta = new TextArea("TextArea", 2, 100, TextArea.SCROLLBARS_NONE); + comps.add(ta); + Panel pc = new Panel(); + pc.setLayout(new BoxLayout(pc, BoxLayout.Y_AXIS)); + Iterator iter = comps.iterator(); + while (iter.hasNext()) { + Component c = (Component) iter.next(); + c.setEnabled(false); + pc.add(c); + } + frame.add(pc, BorderLayout.CENTER); + Panel p = new Panel(); + final Button be = new Button("Enable"); + final Button bd = new Button("Disable"); + p.add(be); + p.add(bd); + ActionListener al = ev -> { + boolean enable = (ev.getSource() == be); + Iterator iterator = comps.iterator(); + while (iterator.hasNext()) { + Component c = (Component) iterator.next(); + c.setEnabled(enable); + } + }; + be.addActionListener(al); + bd.addActionListener(al); + frame.add(p, BorderLayout.SOUTH); + return frame; + } +} diff -Nru openjdk-17-17.0.17+10/test/jdk/java/awt/TextComponent/ModifiersTest.java openjdk-17-17.0.18+8/test/jdk/java/awt/TextComponent/ModifiersTest.java --- openjdk-17-17.0.17+10/test/jdk/java/awt/TextComponent/ModifiersTest.java 1970-01-01 00:00:00.000000000 +0000 +++ openjdk-17-17.0.18+8/test/jdk/java/awt/TextComponent/ModifiersTest.java 2026-01-15 15:23:06.000000000 +0000 @@ -0,0 +1,85 @@ +/* + * Copyright (c) 1999, 2025, Oracle and/or its affiliates. All rights reserved. + * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. + * + * This code is free software; you can redistribute 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 4035364 + * @summary Checks that Caps Lock key works + * @library /java/awt/regtesthelpers + * @build PassFailJFrame + * @run main/manual ModifiersTest + */ + +import java.awt.Frame; +import java.awt.GridLayout; +import java.awt.Label; +import java.awt.TextArea; +import java.awt.event.KeyAdapter; +import java.awt.event.KeyEvent; + +public class ModifiersTest { + public static void main(String[] args) throws Exception { + String INSTRUCTIONS = """ + 1. Type some text in the TextArea in upper and lowercase, + using the Caps Lock ON/OFF. + 2. If Caps Lock toggles correctly and you are able to type in + both cases, the test PASS. Else Test FAILS. + """; + PassFailJFrame.builder() + .instructions(INSTRUCTIONS) + .columns(35) + .testUI(ModifiersTest::initialize) + .build() + .awaitAndCheck(); + } + + public static Frame initialize() { + Frame frame = new Frame("Modifiers Test"); + frame.setLayout(new GridLayout(1, 1)); + frame.addKeyListener(new KeyChecker()); + frame.setLayout(new GridLayout(2, 1)); + Label label = new Label("See if you can type in upper and lowercase using Caps Lock:"); + frame.add(label); + TextArea ta = new TextArea(); + frame.add(ta); + ta.addKeyListener(new KeyChecker()); + ta.requestFocus(); + frame.setSize(400, 300); + return frame; + } +} + +// a KeyListener for debugging purposes +class KeyChecker extends KeyAdapter { + public void keyPressed(KeyEvent ev) { + System.out.println(ev); + } + + public void keyReleased(KeyEvent ev) { + System.out.println(ev); + } + + public void keyTyped(KeyEvent ev) { + System.out.println(ev); + } +} diff -Nru openjdk-17-17.0.17+10/test/jdk/java/awt/TextComponent/SelectionAndCaretColor.java openjdk-17-17.0.18+8/test/jdk/java/awt/TextComponent/SelectionAndCaretColor.java --- openjdk-17-17.0.17+10/test/jdk/java/awt/TextComponent/SelectionAndCaretColor.java 1970-01-01 00:00:00.000000000 +0000 +++ openjdk-17-17.0.18+8/test/jdk/java/awt/TextComponent/SelectionAndCaretColor.java 2026-01-15 15:23:06.000000000 +0000 @@ -0,0 +1,162 @@ +/* + * Copyright (c) 2006, 2025, Oracle and/or its affiliates. All rights reserved. + * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. + * + * This code is free software; you can redistribute 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 6287895 + * @requires (os.family == "linux") + * @summary Test cursor and selected text incorrectly colored in TextField + * @key headful + * @run main SelectionAndCaretColor + */ + +import java.awt.BorderLayout; +import java.awt.Color; +import java.awt.EventQueue; +import java.awt.Font; +import java.awt.Frame; +import java.awt.Rectangle; +import java.awt.Robot; +import java.awt.TextArea; +import java.awt.TextComponent; +import java.awt.TextField; +import java.awt.image.BufferedImage; + +public class SelectionAndCaretColor { + static TextField tf = new TextField(20); + static TextArea ta = new TextArea("", 1, 20, TextArea.SCROLLBARS_NONE); + static Robot r; + static Frame frame; + static volatile int flips; + + public static void main(String[] args) throws Exception { + try { + frame = new Frame("Selection and Caret color test"); + r = new Robot(); + + EventQueue.invokeAndWait(() -> { + frame.setLayout(new BorderLayout()); + tf.setFont(new Font("Monospaced", Font.PLAIN, 15)); + ta.setFont(new Font("Monospaced", Font.PLAIN, 15)); + + frame.add(tf, BorderLayout.NORTH); + frame.add(ta, BorderLayout.SOUTH); + frame.setSize(200, 200); + frame.setVisible(true); + }); + r.waitForIdle(); + r.delay(1000); + test(tf); + test(ta); + } finally { + EventQueue.invokeAndWait(() -> { + if (frame != null) { + frame.dispose(); + } + }); + } + } + + private static int countFlips(TextComponent tc) { + int y = tc.getLocationOnScreen().y + tc.getHeight() / 2; + int x1 = tc.getLocationOnScreen().x + 5; + int x2 = tc.getLocationOnScreen().x + tc.getWidth() - 5; + + int[] fb = {tc.getBackground().getRGB(), tc.getForeground().getRGB()}; + int i = 0; + int flips = 0; + + BufferedImage img = r.createScreenCapture(new Rectangle(x1, y, x2 - x1, 1)); + for (int x = 0; x < x2 - x1; x++) { + int c = img.getRGB(x, 0); + if (c == fb[i]) { + ; + } else if (c == fb[1 - i]) { + flips++; + i = 1 - i; + } else { + throw new RuntimeException("Invalid color detected: " + + Integer.toString(c, 16) + " instead of " + + Integer.toString(fb[i], 16)); + } + } + return flips; + } + + private static void test(TextComponent tc) throws Exception { + if (tc instanceof TextField) { + System.out.println("TextField testing ..."); + } else if (tc instanceof TextArea) { + System.out.println("TextArea testing ..."); + } + + // now passing along the component's vertical center, + // skipping 5px from both sides, + // we should see bg - textcolor - bg - selcolor - + // seltextcolor - selcolor - bg + // that is bg-fg-bg-fg-bg-fg-bg, 6 flips + + EventQueue.invokeAndWait(() -> { + tc.setForeground(Color.green); + tc.setBackground(Color.magenta); + + tc.setText(" I I "); + tc.select(5, 10); + tc.requestFocus(); + }); + r.waitForIdle(); + r.delay(200); + EventQueue.invokeAndWait(() -> { + flips = countFlips(tc); + }); + if (flips != 6) { + throw new RuntimeException("Invalid number of flips: " + + flips + " instead of 6"); + } + EventQueue.invokeAndWait(() -> { + // same for caret: spaces in the tc, caret in the middle + // bg-fg-bg - 2 flips + + tc.select(0, 0); + tc.setText(" "); + tc.setCaretPosition(5); + }); + r.waitForIdle(); + r.delay(200); + + for (int i = 0; i < 10; i++) { + EventQueue.invokeAndWait(() -> { + flips = countFlips(tc); + }); + + if (flips == 2) { + break; + } + if (flips == 0) { + continue; + } + throw new RuntimeException("Invalid number of flips: " + + flips + " instead of 2"); + } + } +} diff -Nru openjdk-17-17.0.17+10/test/jdk/java/awt/TextComponent/SelectionTest.java openjdk-17-17.0.18+8/test/jdk/java/awt/TextComponent/SelectionTest.java --- openjdk-17-17.0.17+10/test/jdk/java/awt/TextComponent/SelectionTest.java 1970-01-01 00:00:00.000000000 +0000 +++ openjdk-17-17.0.18+8/test/jdk/java/awt/TextComponent/SelectionTest.java 2026-01-15 15:23:06.000000000 +0000 @@ -0,0 +1,73 @@ +/* + * Copyright (c) 1998, 2025, Oracle and/or its affiliates. All rights reserved. + * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. + * + * This code is free software; you can redistribute 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 4056231 + * @summary Checks that TextComponents don't grab the global CDE selection + * upon construction if their own selection is null. + * @library /java/awt/regtesthelpers + * @build PassFailJFrame + * @run main/manual SelectionTest + */ + +import java.awt.BorderLayout; +import java.awt.Button; +import java.awt.Frame; +import java.awt.TextArea; +import java.awt.TextField; +import java.awt.event.ActionEvent; +import java.awt.event.ActionListener; + +public class SelectionTest { + public static void main(String[] args) throws Exception { + String INSTRUCTIONS = """ + 1. "Select some text in another window, then click the button.", + 2. "If the text in the other window is de-selected, the test FAILS.", + "If the text remains selected, the test PASSES." + """; + PassFailJFrame.builder() + .title("Test Instructions") + .instructions(INSTRUCTIONS) + .columns(35) + .testUI(initialize()) + .build() + .awaitAndCheck(); + } + + public static Frame initialize() { + Frame frame = new Frame("Selection Test"); + frame.setLayout(new BorderLayout()); + Button b = new Button("Select some text in another window, then" + + " click me"); + b.addActionListener(new ActionListener() { + public void actionPerformed(ActionEvent e) { + frame.add(new TextField("text field test")); + frame.add(new TextArea("text area test")); + } + }); + frame.add(b); + frame.setSize(400, 400); + return frame; + } +} diff -Nru openjdk-17-17.0.17+10/test/jdk/java/awt/TextComponent/TextFieldMargin.java openjdk-17-17.0.18+8/test/jdk/java/awt/TextComponent/TextFieldMargin.java --- openjdk-17-17.0.17+10/test/jdk/java/awt/TextComponent/TextFieldMargin.java 1970-01-01 00:00:00.000000000 +0000 +++ openjdk-17-17.0.18+8/test/jdk/java/awt/TextComponent/TextFieldMargin.java 2026-01-15 15:23:06.000000000 +0000 @@ -0,0 +1,67 @@ +/* + * Copyright (c) 1999, 2025, Oracle and/or its affiliates. All rights reserved. + * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. + * + * This code is free software; you can redistribute 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 4129511 + * @summary Tests that TextField margins are not exceedingly wide + * @library /java/awt/regtesthelpers + * @build PassFailJFrame + * @run main/manual TextFieldMargin + */ + +import java.awt.Frame; +import java.awt.GridLayout; +import java.awt.Label; +import java.awt.TextArea; +import java.awt.TextField; + +public class TextFieldMargin { + public static void main(String[] args) throws Exception { + String INSTRUCTIONS = """ + 1. Examine the TextField, Label, and TextArea to see + that the text is vertically aligned along the left + 2. If all are aligned along the left, then test PASS, + else test FAILS. + """; + PassFailJFrame.builder() + .instructions(INSTRUCTIONS) + .columns(35) + .testUI(TextFieldMargin::initialize) + .build() + .awaitAndCheck(); + } + + public static Frame initialize() { + Frame frame = new Frame("Frame with a text field & a label"); + frame.setLayout(new GridLayout(5, 1)); + TextField text_field = new TextField("Left Textfield"); + frame.add(text_field); + Label label = new Label("Left Label"); + frame.add(label); + TextArea text_area = new TextArea("Left Textfield"); + frame.add(text_area); + frame.setBounds(50, 50, 300, 300); + return frame; + } +} diff -Nru openjdk-17-17.0.17+10/test/jdk/java/awt/TextField/SetEchoCharTest.java openjdk-17-17.0.18+8/test/jdk/java/awt/TextField/SetEchoCharTest.java --- openjdk-17-17.0.17+10/test/jdk/java/awt/TextField/SetEchoCharTest.java 1970-01-01 00:00:00.000000000 +0000 +++ openjdk-17-17.0.18+8/test/jdk/java/awt/TextField/SetEchoCharTest.java 2026-01-15 15:23:06.000000000 +0000 @@ -0,0 +1,178 @@ +/* + * Copyright (c) 1999, 2024, Oracle and/or its affiliates. All rights reserved. + * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. + * + * This code is free software; you can redistribute it and/or modify it + * under the terms of the GNU General Public License version 2 only, as + * published by the Free Software Foundation. + * + * This code is distributed in the hope that it will be useful, but WITHOUT + * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or + * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License + * version 2 for more details (a copy is included in the LICENSE file that + * accompanied this code). + * + * You should have received a copy of the GNU General Public License version + * 2 along with this work; if not, write to the Free Software Foundation, + * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. + * + * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA + * or visit www.oracle.com if you need additional information or have any + * questions. + */ + +import java.awt.Button; +import java.awt.EventQueue; +import java.awt.FlowLayout; +import java.awt.Frame; +import java.awt.Label; +import java.awt.Point; +import java.awt.Robot; +import java.awt.TextField; +import java.awt.Toolkit; +import java.awt.datatransfer.Clipboard; +import java.awt.datatransfer.StringSelection; +import java.awt.event.ActionEvent; +import java.awt.event.ActionListener; +import java.awt.event.InputEvent; +import java.awt.event.KeyEvent; + +import jdk.test.lib.Platform; + +/* + * @test + * @bug 4124697 + * @key headful + * @summary Make sure that after setting and then changing the echo + * character again, the TextField continues to function as expected. + * @library /test/lib + * @build jdk.test.lib.Platform + * @run main SetEchoCharTest + */ + +public class SetEchoCharTest { + private static Frame frame; + private static Robot robot; + private static TextField tfPassword; + private static Button btn1; + private static Button btn2; + private static volatile Point btn1Loc; + private static volatile Point btn2Loc; + + private static final String CHANGE = "Change echo char"; + private static final String PRINT = "Print text"; + private static final String INITIAL_TEXT = "DefaultPwd"; + private static final String CHANGED_TEXT = "NewPwd"; + private static final char NEW_ECHO_CHAR = '*'; + + public static void main(String[] args) throws Exception { + try { + robot = new Robot(); + robot.setAutoWaitForIdle(true); + robot.setAutoDelay(50); + + EventQueue.invokeAndWait(() -> createAndShowUI()); + robot.waitForIdle(); + robot.delay(1000); + + testEchoChar(); + robot.waitForIdle(); + robot.delay(200); + + testNewEchoChar(); + robot.waitForIdle(); + robot.delay(200); + } finally { + EventQueue.invokeAndWait(() -> { + if (frame != null) { + frame.dispose(); + } + }); + } + } + + private static void createAndShowUI() { + frame = new Frame("SetEchoCharTest"); + frame.setLayout(new FlowLayout()); + + Label label = new Label("Pwd:"); + tfPassword = new TextField(INITIAL_TEXT, 10); + tfPassword.setEchoChar('X'); + tfPassword.addActionListener((ActionListener) e -> { + if (e.getActionCommand().equals(CHANGED_TEXT)) { + //check the 2nd condition only if ActionEvent + //is triggered by changed text + if (!(tfPassword.getText().equals(CHANGED_TEXT) + && tfPassword.getEchoChar() == NEW_ECHO_CHAR)) { + throw new RuntimeException("Test Failed!!! TextField not working" + + " as expected after echo char change"); + } + } + }); + frame.add(label); + frame.add(tfPassword); + + btn1 = new Button(PRINT); + btn1.addActionListener(new BtnActionListener()); + frame.add(btn1); + + btn2 = new Button(CHANGE); + btn2.addActionListener(new BtnActionListener()); + frame.add(btn2); + frame.setSize(200,200); + frame.setLocationRelativeTo(null); + frame.setVisible(true); + } + + private static void testEchoChar() throws Exception { + EventQueue.invokeAndWait(() -> { + btn1Loc = btn1.getLocationOnScreen(); + btn2Loc = btn2.getLocationOnScreen(); + }); + + robot.mouseMove(btn1Loc.x + btn1.getWidth() / 2, + btn1Loc.y + btn1.getHeight() / 2); + robot.mousePress(InputEvent.BUTTON1_DOWN_MASK); + robot.mouseRelease(InputEvent.BUTTON1_DOWN_MASK); + robot.delay(1000); + + robot.mouseMove(btn2Loc.x + btn2.getWidth() / 2, + btn2Loc.y + btn2.getHeight() / 2); + robot.mousePress(InputEvent.BUTTON1_DOWN_MASK); + robot.mouseRelease(InputEvent.BUTTON1_DOWN_MASK); + robot.delay(1000); + } + + private static void testNewEchoChar() { + StringSelection stringSelection = new StringSelection(CHANGED_TEXT); + Clipboard clipboard = Toolkit.getDefaultToolkit().getSystemClipboard(); + clipboard.setContents(stringSelection, stringSelection); + + int ctrlKey = Platform.isOSX() ? KeyEvent.VK_META : KeyEvent.VK_CONTROL; + robot.keyPress(ctrlKey); + robot.keyPress(KeyEvent.VK_V); + robot.keyRelease(KeyEvent.VK_V); + robot.keyRelease(ctrlKey); + + robot.keyPress(KeyEvent.VK_ENTER); + robot.keyRelease(KeyEvent.VK_ENTER); + } + + private static class BtnActionListener implements ActionListener { + public void actionPerformed(ActionEvent evt) { + String ac = evt.getActionCommand(); + if (CHANGE.equals(ac)) { + tfPassword.setText(""); + tfPassword.setEchoChar(NEW_ECHO_CHAR); + tfPassword.requestFocus(); + } + if (PRINT.equals(ac)) { + if (!tfPassword.getText().equals(INITIAL_TEXT)) { + throw new RuntimeException("Test Failed!!!" + + " Initial text not as expected"); + } + } + } + } +} + diff -Nru openjdk-17-17.0.17+10/test/jdk/java/awt/TextField/SetEchoCharTest4/SetEchoCharTest4.java openjdk-17-17.0.18+8/test/jdk/java/awt/TextField/SetEchoCharTest4/SetEchoCharTest4.java --- openjdk-17-17.0.17+10/test/jdk/java/awt/TextField/SetEchoCharTest4/SetEchoCharTest4.java 2025-10-13 07:48:04.000000000 +0000 +++ openjdk-17-17.0.18+8/test/jdk/java/awt/TextField/SetEchoCharTest4/SetEchoCharTest4.java 2026-01-15 15:23:06.000000000 +0000 @@ -1,5 +1,5 @@ /* - * Copyright (c) 1999, 2024, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 1999, 2025, Oracle and/or its affiliates. All rights reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * * This code is free software; you can redistribute it and/or modify it @@ -27,7 +27,6 @@ import java.awt.TextField; import java.awt.event.ActionEvent; import java.awt.event.ActionListener; -import java.lang.reflect.InvocationTargetException; /* * @test @@ -54,16 +53,17 @@ Make sure the actual text matches what you typed in for each field. Press Pass if everything's ok, otherwise Fail - """; + """; public SetEchoCharTest4() { + super("SetEchoCharTest4"); setLayout(new FlowLayout()); tf1.setEchoChar('*'); tf2.setEchoChar('$'); tf3.setEchoChar('#'); addStuff(); b.addActionListener(this); - setSize (200,200); + setSize (300, 150); } private void addStuff() { @@ -78,7 +78,6 @@ PassFailJFrame.log("TextField2 = " + tf2.getText()); PassFailJFrame.log("TextField3 = " + tf3.getText()); PassFailJFrame.log("--------------"); - setVisible(false); remove(tf1); remove(tf2); remove(tf3); @@ -86,16 +85,14 @@ addStuff(); } - public static void main(String[] args) throws InterruptedException, - InvocationTargetException { + public static void main(String[] args) throws Exception { PassFailJFrame.builder() - .title("Set Echo Character Test") - .testUI(SetEchoCharTest4::new) - .instructions(INSTRUCTIONS) - .rows((int) INSTRUCTIONS.lines().count() + 1) - .columns(40) - .logArea() - .build() - .awaitAndCheck(); + .title("Set Echo Character Test") + .testUI(SetEchoCharTest4::new) + .instructions(INSTRUCTIONS) + .columns(40) + .logArea() + .build() + .awaitAndCheck(); } } diff -Nru openjdk-17-17.0.17+10/test/jdk/java/awt/TextField/SetEchoCharWordOpsTest.java openjdk-17-17.0.18+8/test/jdk/java/awt/TextField/SetEchoCharWordOpsTest.java --- openjdk-17-17.0.17+10/test/jdk/java/awt/TextField/SetEchoCharWordOpsTest.java 1970-01-01 00:00:00.000000000 +0000 +++ openjdk-17-17.0.18+8/test/jdk/java/awt/TextField/SetEchoCharWordOpsTest.java 2026-01-15 15:23:06.000000000 +0000 @@ -0,0 +1,90 @@ +/* + * 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 + * under the terms of the GNU General Public License version 2 only, as + * published by the Free Software Foundation. + * + * This code is distributed in the hope that it will be useful, but WITHOUT + * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or + * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License + * version 2 for more details (a copy is included in the LICENSE file that + * accompanied this code). + * + * You should have received a copy of the GNU General Public License version + * 2 along with this work; if not, write to the Free Software Foundation, + * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. + * + * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA + * or visit www.oracle.com if you need additional information or have any + * questions. + */ + +import java.awt.FlowLayout; +import java.awt.Label; +import java.awt.TextField; +import javax.swing.JPanel; + +import jdk.test.lib.Platform; + +/* + * @test + * @bug 6191897 8354646 + * @summary Verifies that ctrl+left/right does not move word-by-word in a TextField + * with echo character set + * @library /java/awt/regtesthelpers /test/lib + * @build PassFailJFrame jdk.test.lib.Platform + * @run main/manual SetEchoCharWordOpsTest + */ + +public class SetEchoCharWordOpsTest { + + public static void main(String[] args) throws Exception { + String selectAllKey; + String moveKeys; + String selectKeys; + + if (Platform.isOSX()) { + selectAllKey = "Cmd + A"; + moveKeys = "Alt + Right/Left"; + selectKeys = "Shift + Alt + Right/Left"; + } else { + selectAllKey = "Ctrl + A"; + moveKeys = "Ctrl + Right/Left"; + selectKeys = "Shift + Ctrl + Right/Left"; + } + + String instructions = + "The password field (in the bottom panel) in this test contains" + + " a few words (3 words).\n" + + "Move the focus to the text field and press " + selectAllKey + ".\n" + + "Try moving the caret word-by-word with " + moveKeys + " or" + + " extending selection with " + selectKeys + "." + + " You should NOT be able to do that.\n\n" + + "If you are able to move the caret word-by-word press FAIL," + + " else press PASS."; + + PassFailJFrame.builder() + .title("SetEchoCharClipboard Instructions") + .instructions(instructions) + .rows((int) instructions.lines().count() + 3) + .columns(45) + .splitUIBottom(SetEchoCharWordOpsTest::createAndShowUI) + .build() + .awaitAndCheck(); + } + + + private static JPanel createAndShowUI() { + JPanel jPanel = new JPanel(); + TextField tf = new TextField("one two three", 15); + Label tfLabel = new Label("Password Field:"); + + jPanel.setLayout(new FlowLayout()); + tf.setEchoChar('*'); + jPanel.add(tfLabel); + jPanel.add(tf); + return jPanel; + } +} diff -Nru openjdk-17-17.0.17+10/test/jdk/java/awt/Toolkit/DesktopProperties/DesktopPropertyTest.java openjdk-17-17.0.18+8/test/jdk/java/awt/Toolkit/DesktopProperties/DesktopPropertyTest.java --- openjdk-17-17.0.17+10/test/jdk/java/awt/Toolkit/DesktopProperties/DesktopPropertyTest.java 1970-01-01 00:00:00.000000000 +0000 +++ openjdk-17-17.0.18+8/test/jdk/java/awt/Toolkit/DesktopProperties/DesktopPropertyTest.java 2026-01-15 15:23:06.000000000 +0000 @@ -0,0 +1,272 @@ +/* + * Copyright (c) 1999, 2025, Oracle and/or its affiliates. All rights reserved. + * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. + * + * This code is free software; you can redistribute 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 4287882 + * @summary Tests internal use Windows properties + * @requires os.family == "windows" + * @key headful + * @run main DesktopPropertyTest + */ + +import java.awt.Color; +import java.awt.Component; +import java.awt.Font; +import java.awt.Rectangle; +import java.awt.RenderingHints; +import javax.swing.JFrame; +import javax.swing.JLabel; +import javax.swing.JScrollPane; +import javax.swing.JTable; +import javax.swing.SwingUtilities; +import javax.swing.UIManager; +import javax.swing.table.AbstractTableModel; +import javax.swing.table.TableCellRenderer; +import javax.swing.table.TableModel; +import java.awt.Robot; +import java.awt.event.MouseAdapter; +import java.awt.event.MouseEvent; +import java.beans.PropertyChangeEvent; +import java.beans.PropertyChangeListener; +import java.util.Arrays; +import java.util.Vector; + +/* + * This is a test of new Windows-specific desktop + * properties added in Kestrel. + * + * The new properties are meant for the use of the + * Windows PLAF only and are not public at this time. + */ +public class DesktopPropertyTest { + private static JFrame frame; + + public static void main(String[] args) throws Exception { + Robot robot = new Robot(); + try { + SwingUtilities.invokeAndWait(DesktopPropertyTest::runTest); + robot.waitForIdle(); + robot.delay(1000); + } finally { + SwingUtilities.invokeAndWait(() -> { + if (frame != null) { + frame.dispose(); + } + }); + } + } + + public static void runTest() { + try { + UIManager.setLookAndFeel(UIManager.getSystemLookAndFeelClassName()); + } catch (Exception e) { + throw new RuntimeException(e); + } + frame = new DesktopPropertyFrame(); + frame.setVisible(true); + } + + static class DesktopPropertyFrame extends JFrame { + JTable table; + + DesktopPropertyFrame() { + super("Toolkit.getDesktopProperty API Test"); + setBackground(Color.white); + add(new JScrollPane(createTable())); + setLocationRelativeTo(null); + setSize(500, 400); + } + + public JTable createTable() { + TableModel dataModel = new AbstractTableModel() { + final PropertyVector pv = new PropertyVector(); + + public int getColumnCount() { + return 3; + } + + public int getRowCount() { + return pv.size(); + } + + public String getColumnName(int column) { + String[] colnames = {"Property", "Type", "Value"}; + return colnames[column]; + } + + public Object getValueAt(int row, int col) { + Object[] prow = pv.get(row); + return prow[col]; + } + }; + + table = new JTable(dataModel); + table.setDefaultRenderer(Object.class, new DesktopPropertyRenderer()); + table.addMouseListener(new ClickListener()); + return table; + } + + class ClickListener extends MouseAdapter { + ClickListener() { + } + + public void mouseClicked(MouseEvent e) { + for (int row = 0; row <= table.getModel().getRowCount(); row++) { + Rectangle r = table.getCellRect(row, 2, false); + if (r.contains(e.getX(), e.getY())) { + Object value = table.getModel().getValueAt(row, 2); + if (value instanceof Runnable) { + ((Runnable) value).run(); + } + } + } + } + } + + class PropertyVector { + private static final int NAME = 0; + private static final int TYPE = 1; + private static final int VALUE = 2; + + private final Vector vector = new Vector<>(); + + PropertyVector() { + Object[] props = (Object[]) getToolkit() + .getDesktopProperty("win.propNames"); + if (props == null) { + throw new RuntimeException( + "'win.propNames' property not available. " + + "This test is valid only on Windows."); + } + for (Object prop : props) { + String propertyName = prop.toString(); + vector.addElement(createEntry(propertyName)); + } + } + + Object[] createEntry(String name) { + Object[] row = new Object[3]; + Object value = getToolkit().getDesktopProperty(name); + row[NAME] = name; + row[TYPE] = value.getClass().getName(); + row[VALUE] = value; + + System.out.println(Arrays.toString(row)); + // update this vector when property changes + getToolkit().addPropertyChangeListener(name, new DesktopPropertyChangeListener(row)); + return row; + } + + Object[] get(int row) { + return (Object[]) vector.elementAt(row); + } + + int size() { + return vector.size(); + } + + static class DesktopPropertyChangeListener implements PropertyChangeListener { + Object[] row; + + DesktopPropertyChangeListener(Object[] row) { + this.row = row; + } + + public void propertyChange(PropertyChangeEvent evt) { + this.row[VALUE] = evt.getNewValue(); + } + } + } + + static class DesktopPropertyRenderer implements TableCellRenderer { + ValueProp vprop = new ValueProp(); + FontProp fprop = new FontProp(); + ColorProp cprop = new ColorProp(); + RunnableProp rprop = new RunnableProp(); + RenderingHintsProp rhprop = new RenderingHintsProp(); + + public Component getTableCellRendererComponent(JTable table, Object value, + boolean isSelected, boolean hasFocus, + int row, int column) { + + ValueProp propComponent; + if (value instanceof Boolean + || value instanceof Integer + || value instanceof String) { + propComponent = vprop; + } else if (value instanceof Font) { + propComponent = fprop; + } else if (value instanceof Color) { + propComponent = cprop; + } else if (value instanceof Runnable) { + propComponent = rprop; + } else if (value instanceof RenderingHints) { + propComponent = rhprop; + } else { + throw new RuntimeException("ASSERT unexpected value %s / %s\n" + .formatted(value != null ? value.getClass() : "", value)); + } + + propComponent.setValue(value); + + return propComponent; + } + } + + static class ValueProp extends JLabel { + public void setValue(Object value) { + setText(value.toString()); + } + } + + static class FontProp extends ValueProp { + public void setValue(Object value) { + Font font = (Font) value; + String style; + if (font.getStyle() == Font.BOLD) { + style = "Bold"; + } else if (font.getStyle() > Font.BOLD) { + style = "BoldItalic"; + } else { + style = "Plain"; + } + setText(font.getName() + ", " + style + ", " + font.getSize()); + setFont(font); + } + } + + static class ColorProp extends ValueProp { + public void setValue(Object value) { + Color color = (Color) value; + setText("%d, %d, %d" + .formatted(color.getRed(), color.getGreen(), color.getBlue())); + setBackground(color); + setOpaque(true); + } + } + + static class RunnableProp extends ValueProp {} + static class RenderingHintsProp extends ValueProp {} + } +} \ No newline at end of file diff -Nru openjdk-17-17.0.17+10/test/jdk/java/awt/Toolkit/Headless/WrappedToolkitTest/TestWrapped.java openjdk-17-17.0.18+8/test/jdk/java/awt/Toolkit/Headless/WrappedToolkitTest/TestWrapped.java --- openjdk-17-17.0.17+10/test/jdk/java/awt/Toolkit/Headless/WrappedToolkitTest/TestWrapped.java 2025-10-13 07:48:04.000000000 +0000 +++ openjdk-17-17.0.18+8/test/jdk/java/awt/Toolkit/Headless/WrappedToolkitTest/TestWrapped.java 2026-01-15 15:23:06.000000000 +0000 @@ -1,5 +1,5 @@ /* - * Copyright (c) 2012, 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,55 +22,52 @@ */ /* - * test + * @test * @bug 6282388 - * @summary Tests that AWT use correct toolkit to be wrapped into HeadlessToolkit - * @author artem.ananiev@sun.com: area=awt.headless - * @run shell WrappedToolkitTest.sh + * @summary Tests that AWT uses correct toolkit wrapped into HeadlessToolkit + * @modules java.desktop/sun.awt:open + * @library /test/lib + * @run main/othervm -Djava.awt.headless=true TestWrapped */ -import java.awt.*; - -import java.lang.reflect.*; - -import sun.awt.*; - -public class TestWrapped -{ - public static void main(String[] args) - { - try - { - if (args.length != 1) { - System.err.println("No correct toolkit class name is specified, test is not run"); - System.exit(0); +import java.awt.Toolkit; +import java.lang.Class; +import java.lang.reflect.Field; + +import jdk.test.lib.Platform; + +public final class TestWrapped { + + private static final String HEADLESS_TOOLKIT = "sun.awt.HeadlessToolkit"; + private static final String MACOSX_TOOLKIT = "sun.lwawt.macosx.LWCToolkit"; + private static final String UNIX_TOOLKIT = "sun.awt.X11.XToolkit"; + private static final String WINDOWS_TOOLKIT = "sun.awt.windows.WToolkit"; + + public static void main(String[] args) throws Exception { + String expectedToolkitClassName; + if (Platform.isWindows()) { + expectedToolkitClassName = WINDOWS_TOOLKIT; + } else if (Platform.isOSX()) { + expectedToolkitClassName = MACOSX_TOOLKIT; + } else { + expectedToolkitClassName = UNIX_TOOLKIT; } - String correctToolkitClassName = args[0]; Toolkit tk = Toolkit.getDefaultToolkit(); - Class tkClass = tk.getClass(); - if (!tkClass.getName().equals("sun.awt.HeadlessToolkit")) - { - System.err.println(tkClass.getName()); - System.err.println("Error: default toolkit is not an instance of HeadlessToolkit"); - System.exit(-1); + Class tkClass = tk.getClass(); + if (!tkClass.getName().equals(HEADLESS_TOOLKIT)) { + System.err.println("Expected: " + HEADLESS_TOOLKIT); + System.err.println("Actual: " + tkClass.getName()); + throw new RuntimeException("Wrong default toolkit"); } Field f = tkClass.getDeclaredField("tk"); f.setAccessible(true); - Class wrappedClass = f.get(tk).getClass(); - if (!wrappedClass.getName().equals(correctToolkitClassName)) { - System.err.println(wrappedClass.getName()); - System.err.println("Error: wrapped toolkit is not an instance of " + correctToolkitClassName); - System.exit(-1); + Class wrappedClass = f.get(tk).getClass(); + if (!wrappedClass.getName().equals(expectedToolkitClassName)) { + System.err.println("Expected: " + expectedToolkitClassName); + System.err.println("Actual: " + wrappedClass.getName()); + throw new RuntimeException("Wrong wrapped toolkit"); } - } - catch (Exception z) - { - z.printStackTrace(System.err); - System.exit(-1); - } - - System.exit(0); } } diff -Nru openjdk-17-17.0.17+10/test/jdk/java/awt/Toolkit/Headless/WrappedToolkitTest/WrappedToolkitTest.sh openjdk-17-17.0.18+8/test/jdk/java/awt/Toolkit/Headless/WrappedToolkitTest/WrappedToolkitTest.sh --- openjdk-17-17.0.17+10/test/jdk/java/awt/Toolkit/Headless/WrappedToolkitTest/WrappedToolkitTest.sh 2025-10-13 07:48:04.000000000 +0000 +++ openjdk-17-17.0.18+8/test/jdk/java/awt/Toolkit/Headless/WrappedToolkitTest/WrappedToolkitTest.sh 1970-01-01 00:00:00.000000000 +0000 @@ -1,221 +0,0 @@ -#!/bin/ksh -p - -# -# Copyright (c) 2012, 2020, Oracle and/or its affiliates. All rights reserved. -# DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. -# -# This code is free software; you can redistribute it and/or modify it -# under the terms of the GNU General Public License version 2 only, as -# published by the Free Software Foundation. -# -# This code is distributed in the hope that it will be useful, but WITHOUT -# ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or -# FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License -# version 2 for more details (a copy is included in the LICENSE file that -# accompanied this code). -# -# You should have received a copy of the GNU General Public License version -# 2 along with this work; if not, write to the Free Software Foundation, -# Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. -# -# Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA -# or visit www.oracle.com if you need additional information or have any -# questions. -# - -# -# @test -# @bug 6282388 8030640 -# @summary Tests that AWT use correct toolkit to be wrapped into HeadlessToolkit -# @author artem.ananiev@sun.com: area=awt.headless -# compile TestWrapped.java -# @run shell WrappedToolkitTest.sh - -# Beginning of subroutines: -status=1 - -#Call this from anywhere to fail the test with an error message -# usage: fail "reason why the test failed" -fail() - { echo "The test failed :-(" - echo "$*" 1>&2 - echo "exit status was $status" - exit $status - } #end of fail() - -#Call this from anywhere to pass the test with a message -# usage: pass "reason why the test passed if applicable" -pass() - { echo "The test passed!!!" - echo "$*" 1>&2 - exit 0 - } #end of pass() - -# end of subroutines - - -# The beginning of the script proper - -# Checking for proper OS -OS=`uname -s` -case "$OS" in - AIX | CYGWIN* | Darwin | Linux ) - FILESEP="/" - ;; - - Windows* ) - FILESEP="\\" - ;; - - # catch all other OSs - * ) - echo "Unrecognized system! $OS" - fail "Unrecognized system! $OS" - ;; -esac - -# check that some executable or other file you need is available, abort if not -# note that the name of the executable is in the fail string as well. -# this is how to check for presence of the compiler, etc. -#RESOURCE=`whence SomeProgramOrFileNeeded` -#if [ "${RESOURCE}" = "" ] ; -# then fail "Need SomeProgramOrFileNeeded to perform the test" ; -#fi - -# Want this test to run standalone as well as in the harness, so do the -# following to copy the test's directory into the harness's scratch directory -# and set all appropriate variables: - -if [ -z "${TESTJAVA}" ] ; then - # TESTJAVA is not set, so the test is running stand-alone. - # TESTJAVA holds the path to the root directory of the build of the JDK - # to be tested. That is, any java files run explicitly in this shell - # should use TESTJAVA in the path to the java interpreter. - # So, we'll set this to the JDK spec'd on the command line. If none - # is given on the command line, tell the user that and use a cheesy - # default. - # THIS IS THE JDK BEING TESTED. - if [ -n "$1" ] ; - then TESTJAVA=$1 - else fail "no JDK specified on command line!" - fi - TESTSRC=. - TESTCLASSES=. - STANDALONE=1; -fi -echo "JDK under test is: $TESTJAVA" - -#if in test harness, then copy the entire directory that the test is in over -# to the scratch directory. This catches any support files needed by the test. -if [ -z "${STANDALONE}" ] ; - then cp ${TESTSRC}/* . -fi -case "$OS" in - Windows* | CYGWIN* ) - ${COMPILEJAVA}/bin/javac ${TESTJAVACOPTS} \ - --add-exports java.desktop/sun.awt=ALL-UNNAMED \ - --add-exports java.desktop/sun.awt.windows=ALL-UNNAMED ${CP} \ - *.java - status=$? - if [ ! $status -eq "0" ]; then - fail "Compilation failed"; - fi - ;; - - AIX | Linux ) - ${COMPILEJAVA}/bin/javac ${TESTJAVACOPTS} \ - --add-exports java.desktop/sun.awt=ALL-UNNAMED \ - --add-exports java.desktop/sun.awt.X11=ALL-UNNAMED ${CP} \ - *.java - status=$? - if [ ! $status -eq "0" ]; then - fail "Compilation failed"; - fi - ;; - - Darwin) - ${COMPILEJAVA}/bin/javac ${TESTJAVACOPTS} \ - --add-exports java.desktop/sun.awt=ALL-UNNAMED \ - --add-exports java.desktop/sun.lwawt.macosx=ALL-UNNAMED ${CP} \ - *.java - status=$? - if [ ! $status -eq "0" ]; then - fail "Compilation failed"; - fi - ;; - -esac - -#Just before executing anything, make sure it has executable permission! -chmod 777 ./* - -############### YOUR TEST CODE HERE!!!!!!! ############# - -case "$OS" in - Windows* | CYGWIN* ) - ${TESTJAVA}/bin/java ${TESTVMOPTS} -Djava.awt.headless=true \ - --add-opens java.desktop/sun.awt=ALL-UNNAMED \ - --add-opens java.desktop/sun.awt.windows=ALL-UNNAMED ${CP} \ - TestWrapped sun.awt.windows.WToolkit - status=$? - if [ ! $status -eq "0" ]; then - fail "Test FAILED: toolkit wrapped into HeadlessToolkit is not an instance of sun.awt.windows.WToolkit"; - fi - ${TESTJAVA}/bin/java ${TESTVMOPTS} -Djava.awt.headless=true \ - --add-opens java.desktop/sun.awt=ALL-UNNAMED \ - --add-opens java.desktop/sun.awt.windows=ALL-UNNAMED ${CP} \ - -Dawt.toolkit=sun.awt.windows.WToolkit \ - TestWrapped sun.awt.windows.WToolkit - status=$? - if [ ! $status -eq "0" ]; then - fail "Test FAILED: toolkit wrapped into HeadlessToolkit is not an instance of sun.awt.windows.WToolkit"; - fi - ;; - - AIX | Linux ) - ${TESTJAVA}/bin/java ${TESTVMOPTS} -Djava.awt.headless=true \ - --add-opens java.desktop/sun.awt=ALL-UNNAMED \ - --add-opens java.desktop/sun.awt.X11=ALL-UNNAMED ${CP} \ - -Dawt.toolkit=sun.awt.X11.XToolkit \ - TestWrapped sun.awt.X11.XToolkit - status=$? - if [ ! $status -eq "0" ]; then - fail "Test FAILED: toolkit wrapped into HeadlessToolkit is not an instance of sun.awt.xawt.XToolkit"; - fi - AWT_TOOLKIT=XToolkit ${TESTJAVA}/bin/java ${TESTVMOPTS} \ - --add-opens java.desktop/sun.awt=ALL-UNNAMED \ - --add-opens java.desktop/sun.awt.X11=ALL-UNNAMED ${CP} \ - -Djava.awt.headless=true \ - TestWrapped sun.awt.X11.XToolkit - status=$? - if [ ! $status -eq "0" ]; then - fail "Test FAILED: toolkit wrapped into HeadlessToolkit is not an instance of sun.awt.xawt.XToolkit"; - fi - ;; - - Darwin) - ${TESTJAVA}/bin/java ${TESTVMOPTS} -Djava.awt.headless=true \ - --add-opens java.desktop/sun.awt=ALL-UNNAMED \ - --add-opens java.desktop/sun.lwawt.macosx=ALL-UNNAMED ${CP} \ - TestWrapped sun.lwawt.macosx.LWCToolkit - status=$? - if [ ! $status -eq "0" ]; then - fail "Test FAILED: toolkit wrapped into HeadlessToolkit is not an instance of sun.lwawt.macosx.LWCToolkit"; - fi - ${TESTJAVA}/bin/java ${TESTVMOPTS} -Djava.awt.headless=true \ - --add-opens java.desktop/sun.awt=ALL-UNNAMED \ - --add-opens java.desktop/sun.lwawt.macosx=ALL-UNNAMED ${CP} \ - -Dawt.toolkit=sun.lwawt.macosx.LWCToolkit \ - TestWrapped sun.lwawt.macosx.LWCToolkit - status=$? - if [ ! $status -eq "0" ]; then - fail "Test FAILED: toolkit wrapped into HeadlessToolkit is not an instance of sun.lwawt.macosx.LWCToolkit"; - fi - ;; - -esac - -pass "All the tests are PASSED"; - -#For additional examples of how to write platform independent KSH scripts, -# see the jtreg file itself. It is a KSH script for both Solaris and Win32 diff -Nru openjdk-17-17.0.17+10/test/jdk/java/awt/Toolkit/TimeUnsignedConversionTest.java openjdk-17-17.0.18+8/test/jdk/java/awt/Toolkit/TimeUnsignedConversionTest.java --- openjdk-17-17.0.17+10/test/jdk/java/awt/Toolkit/TimeUnsignedConversionTest.java 1970-01-01 00:00:00.000000000 +0000 +++ openjdk-17-17.0.18+8/test/jdk/java/awt/Toolkit/TimeUnsignedConversionTest.java 2026-01-15 15:23:06.000000000 +0000 @@ -0,0 +1,128 @@ +/* + * Copyright (c) 1999, 2025, Oracle and/or its affiliates. All rights reserved. + * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. + * + * This code is free software; you can redistribute 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 5097241 + * @summary Tests the problem of time type conversion on XToolkit. The conversion should be unsigned. + * @requires os.family == "linux" + * @key headful + * @library /java/awt/regtesthelpers /test/lib + * @build Util jtreg.SkippedException + * @run main/othervm -Dsun.awt.disableGtkFileDialogs=true TimeUnsignedConversionTest + */ + +import java.awt.Button; +import java.awt.EventQueue; +import java.awt.FileDialog; +import java.awt.FlowLayout; +import java.awt.Frame; +import java.awt.Robot; +import java.awt.Toolkit; +import java.awt.event.KeyEvent; +import java.util.concurrent.CountDownLatch; +import java.util.concurrent.TimeUnit; + +import jtreg.SkippedException; +import test.java.awt.regtesthelpers.Util; + +public class TimeUnsignedConversionTest { + static Robot robot; + static Frame frame; + static volatile Button button; + static volatile FileDialog dialog; + static volatile boolean dialogShown = false; + + static final CountDownLatch passedLatch = new CountDownLatch(1); + + public static void main(String[] args) throws Exception { + if (!Toolkit.getDefaultToolkit().getClass().getName().equals("sun.awt.X11.XToolkit")) { + throw new SkippedException("XAWT test only! Skipped."); + } + + try { + EventQueue.invokeAndWait(TimeUnsignedConversionTest::createAndShowGUI); + test(); + } finally { + EventQueue.invokeAndWait(() -> { + if (frame != null) { + frame.dispose(); + } + }); + } + } + + private static void createAndShowGUI() { + frame = new Frame("TimeUnsignedConversionTest frame"); + button = new Button("Show Dialog"); + dialog = new FileDialog(frame, "TimeUnsignedConversionTest Dialog", FileDialog.LOAD); + + Toolkit.getDefaultToolkit().addAWTEventListener(e -> { + System.out.println(e); + if (dialogShown && ((KeyEvent)e).getKeyCode() == KeyEvent.VK_K) { + passedLatch.countDown(); + } + }, KeyEvent.KEY_EVENT_MASK); + + frame.setLayout(new FlowLayout()); + frame.add(button); + + button.addActionListener(ae -> { + if (ae.getActionCommand().equals("Show Dialog")) { + dialog.setSize(200, 200); + dialog.setLocationRelativeTo(frame); + dialog.setVisible(true); + } + }); + + frame.setSize(100, 100); + frame.setLocationRelativeTo(null); + frame.setVisible(true); + } + + private static void test() throws Exception { + robot = new Robot(); + robot.waitForIdle(); + + Util.waitTillShown(button); + + robot.waitForIdle(); + robot.keyPress(KeyEvent.VK_SPACE); + robot.delay(50); + robot.keyRelease(KeyEvent.VK_SPACE); + + Util.waitTillShown(dialog); + dialogShown = true; + + robot.waitForIdle(); + robot.keyPress(KeyEvent.VK_K); + robot.delay(50); + robot.keyRelease(KeyEvent.VK_K); + + if (!passedLatch.await(2, TimeUnit.SECONDS)) { + throw new RuntimeException("Test failed!"); + } + + System.out.println("Test passed."); + } +} diff -Nru openjdk-17-17.0.17+10/test/jdk/java/awt/color/ICC_Profile/SerializedFormSize.java openjdk-17-17.0.18+8/test/jdk/java/awt/color/ICC_Profile/SerializedFormSize.java --- openjdk-17-17.0.17+10/test/jdk/java/awt/color/ICC_Profile/SerializedFormSize.java 1970-01-01 00:00:00.000000000 +0000 +++ openjdk-17-17.0.18+8/test/jdk/java/awt/color/ICC_Profile/SerializedFormSize.java 2026-01-15 15:23:06.000000000 +0000 @@ -0,0 +1,72 @@ +/* + * Copyright Amazon.com Inc. or its affiliates. All Rights Reserved. + * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. + * + * This code is free software; you can redistribute it and/or modify it + * under the terms of the GNU General Public License version 2 only, as + * published by the Free Software Foundation. + * + * This code is distributed in the hope that it will be useful, but WITHOUT + * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or + * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License + * version 2 for more details (a copy is included in the LICENSE file that + * accompanied this code). + * + * You should have received a copy of the GNU General Public License version + * 2 along with this work; if not, write to the Free Software Foundation, + * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. + * + * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA + * or visit www.oracle.com if you need additional information or have any + * questions. + */ + +import java.awt.color.ColorSpace; +import java.awt.color.ICC_Profile; +import java.io.ByteArrayOutputStream; +import java.io.ObjectOutputStream; + +/** + * @test + * @bug 8369032 + * @summary Checks the size of the serialized ICC_Profile for standard and + * non-standard profiles. + */ +public final class SerializedFormSize { + + private static final ICC_Profile[] PROFILES = { + ICC_Profile.getInstance(ColorSpace.CS_sRGB), + ICC_Profile.getInstance(ColorSpace.CS_LINEAR_RGB), + ICC_Profile.getInstance(ColorSpace.CS_CIEXYZ), + ICC_Profile.getInstance(ColorSpace.CS_PYCC), + ICC_Profile.getInstance(ColorSpace.CS_GRAY) + }; + + public static void main(String[] args) throws Exception { + for (ICC_Profile profile : PROFILES) { + byte[] data = profile.getData(); + int dataSize = data.length; + int min = 3; // At least version, name and data fields + int max = 200; // Small enough to confirm no data saved + + // Standard profile: should serialize to a small size, no data + test(profile, min, max); + // Non-standard profile: includes full data, but only once + test(ICC_Profile.getInstance(data), dataSize, dataSize + max); + } + } + + private static void test(ICC_Profile p, int min, int max) throws Exception { + try (var bos = new ByteArrayOutputStream(); + var oos = new ObjectOutputStream(bos)) + { + oos.writeObject(p); + int size = bos.size(); + if (size < min || size > max) { + System.err.println("Expected: >= " + min + " and <= " + max); + System.err.println("Actual: " + size); + throw new RuntimeException("Wrong size"); + } + } + } +} diff -Nru openjdk-17-17.0.17+10/test/jdk/java/awt/color/ICC_Profile/ValidateICCHeaderData/ValidateICCHeaderData.java openjdk-17-17.0.18+8/test/jdk/java/awt/color/ICC_Profile/ValidateICCHeaderData/ValidateICCHeaderData.java --- openjdk-17-17.0.17+10/test/jdk/java/awt/color/ICC_Profile/ValidateICCHeaderData/ValidateICCHeaderData.java 1970-01-01 00:00:00.000000000 +0000 +++ openjdk-17-17.0.18+8/test/jdk/java/awt/color/ICC_Profile/ValidateICCHeaderData/ValidateICCHeaderData.java 2026-01-15 15:23:06.000000000 +0000 @@ -0,0 +1,261 @@ +/* + * 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 8337703 + * @summary To verify if ICC_Profile's setData() and getInstance() methods + * validate header data and throw IAE for invalid values. + * @run main ValidateICCHeaderData + */ + +import java.awt.color.ColorSpace; +import java.awt.color.ICC_Profile; +import java.awt.image.BufferedImage; +import java.io.IOException; +import java.math.BigInteger; +import java.nio.ByteBuffer; + +public class ValidateICCHeaderData { + private static ICC_Profile profile; + + private static final boolean DEBUG = false; + private static final int VALID_HEADER_SIZE = 128; + private static final int HEADER_TAG = ICC_Profile.icSigHead; + private static final int PROFILE_CLASS_START_INDEX = ICC_Profile.icHdrDeviceClass; + private static final int COLOR_SPACE_START_INDEX = ICC_Profile.icHdrColorSpace; + private static final int RENDER_INTENT_START_INDEX = ICC_Profile.icHdrRenderingIntent; + private static final int PCS_START_INDEX = ICC_Profile.icHdrPcs; + + private static final int[] VALID_PROFILE_CLASS = new int[] { + ICC_Profile.icSigInputClass, ICC_Profile.icSigDisplayClass, + ICC_Profile.icSigOutputClass, ICC_Profile.icSigLinkClass, + ICC_Profile.icSigAbstractClass, ICC_Profile.icSigColorSpaceClass, + ICC_Profile.icSigNamedColorClass + }; + + private static final int[] VALID_COLOR_SPACE = new int[] { + ICC_Profile.icSigXYZData, ICC_Profile.icSigLabData, + ICC_Profile.icSigLuvData, ICC_Profile.icSigYCbCrData, + ICC_Profile.icSigYxyData, ICC_Profile.icSigRgbData, + ICC_Profile.icSigGrayData, ICC_Profile.icSigHsvData, + ICC_Profile.icSigHlsData, ICC_Profile.icSigCmykData, + ICC_Profile.icSigSpace2CLR, ICC_Profile.icSigSpace3CLR, + ICC_Profile.icSigSpace4CLR, ICC_Profile.icSigSpace5CLR, + ICC_Profile.icSigSpace6CLR, ICC_Profile.icSigSpace7CLR, + ICC_Profile.icSigSpace8CLR, ICC_Profile.icSigSpace9CLR, + ICC_Profile.icSigSpaceACLR, ICC_Profile.icSigSpaceBCLR, + ICC_Profile.icSigSpaceCCLR, ICC_Profile.icSigSpaceDCLR, + ICC_Profile.icSigSpaceECLR, ICC_Profile.icSigSpaceFCLR, + ICC_Profile.icSigCmyData + }; + + private static final int[] VALID_RENDER_INTENT = new int[] { + ICC_Profile.icPerceptual, ICC_Profile.icMediaRelativeColorimetric, + ICC_Profile.icSaturation, ICC_Profile.icAbsoluteColorimetric + }; + + private static void createCopyOfBuiltInProfile() { + ICC_Profile builtInProfile = ICC_Profile.getInstance(ColorSpace.CS_sRGB); + //copy of SRGB BuiltIn Profile that can be modified + //using ICC_Profile.setData() + profile = ICC_Profile.getInstance(builtInProfile.getData()); + } + + public static void main(String[] args) throws Exception { + createCopyOfBuiltInProfile(); + + System.out.println("CASE 1: Testing VALID Profile Classes ..."); + testValidHeaderData(VALID_PROFILE_CLASS, PROFILE_CLASS_START_INDEX, 4); + System.out.println("CASE 1: Passed \n"); + + // PCS field validation for Profile class != DEVICE_LINK + System.out.println("CASE 2: Testing VALID PCS Type" + + " for Profile class != DEVICE_LINK ..."); + testValidHeaderData(new int[] {ICC_Profile.icSigXYZData, ICC_Profile.icSigLabData}, + PCS_START_INDEX, 4); + System.out.println("CASE 2: Passed \n"); + + System.out.println("CASE 3: Testing INVALID PCS Type" + + " for Profile class != DEVICE_LINK ..."); + testInvalidHeaderData(ICC_Profile.icSigCmykData, PCS_START_INDEX, 4); + System.out.println("CASE 3: Passed \n"); + + System.out.println("CASE 4: Testing DEVICE LINK PROFILE CLASS ..."); + testValidHeaderData(new int[] {ICC_Profile.icSigLinkClass}, + PROFILE_CLASS_START_INDEX, 4); + //to check if instantiating BufferedImage with + //ICC_Profile device class = CLASS_DEVICELINK does not throw IAE. + BufferedImage img = new BufferedImage(100, 100, + BufferedImage.TYPE_3BYTE_BGR); + System.out.println("CASE 4: Passed \n"); + + // PCS field validation for Profile class == DEVICE_LINK + System.out.println("CASE 5: Testing VALID PCS Type" + + " for Profile class == DEVICE_LINK ..."); + testValidHeaderData(VALID_COLOR_SPACE, PCS_START_INDEX, 4); + System.out.println("CASE 5: Passed \n"); + + System.out.println("CASE 6: Testing INVALID PCS Type" + + " for Profile class == DEVICE_LINK ..."); + //original icSigLabData = 0x4C616220 + int invalidSigLabData = 0x4C616221; + testInvalidHeaderData(invalidSigLabData, PCS_START_INDEX, 4); + System.out.println("CASE 6: Passed \n"); + + System.out.println("CASE 7: Testing VALID Color Spaces ..."); + testValidHeaderData(VALID_COLOR_SPACE, COLOR_SPACE_START_INDEX, 4); + System.out.println("CASE 7: Passed \n"); + + System.out.println("CASE 8: Testing VALID Rendering Intent ..."); + testValidHeaderData(VALID_RENDER_INTENT, RENDER_INTENT_START_INDEX, 4); + System.out.println("CASE 8: Passed \n"); + + System.out.println("CASE 9: Testing INVALID Profile Class ..."); + //original icSigInputClass = 0x73636E72 + int invalidSigInputClass = 0x73636E70; + testInvalidHeaderData(invalidSigInputClass, PROFILE_CLASS_START_INDEX, 4); + System.out.println("CASE 9: Passed \n"); + + System.out.println("CASE 10: Testing INVALID Color Space ..."); + //original icSigXYZData = 0x58595A20 + int invalidSigXYZData = 0x58595A21; + testInvalidHeaderData(invalidSigXYZData, COLOR_SPACE_START_INDEX, 4); + System.out.println("CASE 10: Passed \n"); + + System.out.println("CASE 11: Testing INVALID Rendering Intent ..."); + //valid rendering intent values are 0-3 + int invalidRenderIntent = 5; + testInvalidHeaderData(invalidRenderIntent, RENDER_INTENT_START_INDEX, 4); + System.out.println("CASE 11: Passed \n"); + + System.out.println("CASE 12: Testing INVALID Header Size ..."); + testInvalidHeaderSize(); + System.out.println("CASE 12: Passed \n"); + + System.out.println("CASE 13: Testing ICC_Profile.getInstance(..)" + + " with VALID profile data ..."); + testProfileCreation(true); + System.out.println("CASE 13: Passed \n"); + + System.out.println("CASE 14: Testing ICC_Profile.getInstance(..)" + + " with INVALID profile data ..."); + testProfileCreation(false); + System.out.println("CASE 14: Passed \n"); + + System.out.println("CASE 15: Testing Deserialization of ICC_Profile ..."); + testDeserialization(); + System.out.println("CASE 15: Passed \n"); + + System.out.println("Successfully completed testing all 15 cases. Test Passed !!"); + } + + private static void testValidHeaderData(int[] validData, int startIndex, + int fieldLength) { + for (int value : validData) { + setTag(value, startIndex, fieldLength); + } + } + + private static void testInvalidHeaderData(int invalidData, int startIndex, + int fieldLength) { + try { + setTag(invalidData, startIndex, fieldLength); + throw new RuntimeException("Test Failed ! Expected IAE NOT thrown"); + } catch (IllegalArgumentException iae) { + System.out.println("Expected IAE thrown: " + iae.getMessage()); + } + } + + private static void setTag(int value, int startIndex, int fieldLength) { + byte[] byteArray; + if (startIndex == RENDER_INTENT_START_INDEX) { + byteArray = ByteBuffer.allocate(4).putInt(value).array(); + } else { + BigInteger big = BigInteger.valueOf(value); + byteArray = (big.toByteArray()); + } + + if (DEBUG) { + System.out.print("Byte Array : "); + for (int i = 0; i < byteArray.length; i++) { + System.out.print(byteArray[i] + " "); + } + System.out.println("\n"); + } + + byte[] iccProfileHeaderData = profile.getData(HEADER_TAG); + System.arraycopy(byteArray, 0, iccProfileHeaderData, startIndex, fieldLength); + profile.setData(HEADER_TAG, iccProfileHeaderData); + } + + private static void testProfileCreation(boolean validCase) { + ICC_Profile builtInProfile = ICC_Profile.getInstance(ColorSpace.CS_GRAY); + byte[] profileData = builtInProfile.getData(); + + int validDeviceClass = ICC_Profile.icSigInputClass; + BigInteger big = BigInteger.valueOf(validDeviceClass); + //valid case set device class to 0x73636E72 (icSigInputClass) + //invalid case set device class to 0x00000000 + byte[] field = validCase ? big.toByteArray() + : ByteBuffer.allocate(4).putInt(0).array(); + System.arraycopy(field, 0, profileData, PROFILE_CLASS_START_INDEX, 4); + + try { + ICC_Profile.getInstance(profileData); + if (!validCase) { + throw new RuntimeException("Test Failed ! Expected IAE NOT thrown"); + } + } catch (IllegalArgumentException iae) { + if (!validCase) { + System.out.println("Expected IAE thrown: " + iae.getMessage()); + } else { + throw new RuntimeException("Unexpected IAE thrown"); + } + } + } + + private static void testInvalidHeaderSize() { + byte[] iccProfileHeaderData = profile.getData(HEADER_TAG); + byte[] invalidHeaderSize = new byte[VALID_HEADER_SIZE - 1]; + System.arraycopy(iccProfileHeaderData, 0, + invalidHeaderSize, 0, invalidHeaderSize.length); + try { + profile.setData(HEADER_TAG, invalidHeaderSize); + throw new RuntimeException("Test Failed ! Expected IAE NOT thrown"); + } catch (IllegalArgumentException iae) { + System.out.println("Expected IAE thrown: " + iae.getMessage()); + } + } + + private static void testDeserialization() throws IOException { + //invalidSRGB.icc is serialized on older version of JDK + //Upon deserialization, the invalid profile is expected to throw IAE + try { + ICC_Profile.getInstance("./invalidSRGB.icc"); + throw new RuntimeException("Test Failed ! Expected IAE NOT thrown"); + } catch (IllegalArgumentException iae) { + System.out.println("Expected IAE thrown: " + iae.getMessage()); + } + } +} Binary files /srv/release.debian.org/tmp/uPhuv2pZsD/openjdk-17-17.0.17+10/test/jdk/java/awt/color/ICC_Profile/ValidateICCHeaderData/invalidSRGB.icc and /srv/release.debian.org/tmp/x_MuUtmaH2/openjdk-17-17.0.18+8/test/jdk/java/awt/color/ICC_Profile/ValidateICCHeaderData/invalidSRGB.icc differ diff -Nru openjdk-17-17.0.17+10/test/jdk/java/awt/datatransfer/ClipboardPerformanceTest.java openjdk-17-17.0.18+8/test/jdk/java/awt/datatransfer/ClipboardPerformanceTest.java --- openjdk-17-17.0.17+10/test/jdk/java/awt/datatransfer/ClipboardPerformanceTest.java 1970-01-01 00:00:00.000000000 +0000 +++ openjdk-17-17.0.18+8/test/jdk/java/awt/datatransfer/ClipboardPerformanceTest.java 2026-01-15 15:23:06.000000000 +0000 @@ -0,0 +1,133 @@ +/* + * Copyright (c) 2001, 2025, Oracle and/or its affiliates. All rights reserved. + * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. + * + * This code is free software; you can redistribute it and/or modify it + * under the terms of the GNU General Public License version 2 only, as + * published by the Free Software Foundation. + * + * This code is distributed in the hope that it will be useful, but WITHOUT + * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or + * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License + * version 2 for more details (a copy is included in the LICENSE file that + * accompanied this code). + * + * You should have received a copy of the GNU General Public License version + * 2 along with this work; if not, write to the Free Software Foundation, + * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. + * + * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA + * or visit www.oracle.com if you need additional information or have any + * questions. + */ + +/* + * @test + * @bug 4463560 + * @requires (os.family == "windows") + * @summary Tests that datatransfer doesn't take too much time to complete + * @key headful + * @library /test/lib + * @run main/timeout=300 ClipboardPerformanceTest + */ + +import java.awt.Toolkit; +import java.awt.datatransfer.Clipboard; +import java.awt.datatransfer.DataFlavor; +import java.awt.datatransfer.StringSelection; +import java.awt.datatransfer.Transferable; +import java.util.concurrent.TimeUnit; +import java.util.concurrent.TimeoutException; + +import jdk.test.lib.process.OutputAnalyzer; +import jdk.test.lib.process.ProcessTools; + +public class ClipboardPerformanceTest { + public static final int CODE_FAILURE = 1; + public static final int CODE_OTHER_FAILURE = 2; + static String eoln; + static char[] text; + public static final int ARRAY_SIZE = 100000; + public static final int RATIO_THRESHOLD = 10; + + public static void main(String[] args) throws Exception { + if (args.length == 0) { + ClipboardPerformanceTest clipboardPerformanceTest = new ClipboardPerformanceTest(); + clipboardPerformanceTest.initialize(); + return; + } + + long before, after, oldTime, newTime; + float ratio; + + try { + Transferable t = Toolkit.getDefaultToolkit().getSystemClipboard().getContents(null); + before = System.currentTimeMillis(); + String ss = (String) t.getTransferData(new DataFlavor("text/plain; class=java.lang.String")); + after = System.currentTimeMillis(); + + System.err.println("Size: " + ss.length()); + newTime = after - before; + System.err.println("Time consumed: " + newTime); + + initArray(); + + StringBuffer buf = new StringBuffer(new String(text)); + int eoln_len = eoln.length(); + before = System.currentTimeMillis(); + + for (int i = 0; i + eoln_len <= buf.length(); i++) { + if (eoln.equals(buf.substring(i, i + eoln_len))) { + buf.replace(i, i + eoln_len, "\n"); + } + } + + after = System.currentTimeMillis(); + oldTime = after - before; + System.err.println("Old algorithm: " + oldTime); + ratio = oldTime / newTime; + System.err.println("Ratio: " + ratio); + + if (ratio < RATIO_THRESHOLD) { + System.out.println("Time ratio failure!!"); + System.exit(CODE_FAILURE); + } + } catch (Throwable e) { + e.printStackTrace(); + System.exit(CODE_OTHER_FAILURE); + } + System.out.println("Test Pass!"); + } + + public static void initArray() { + text = new char[ARRAY_SIZE + 2]; + + for (int i = 0; i < ARRAY_SIZE; i += 3) { + text[i] = '\r'; + text[i + 1] = '\n'; + text[i + 2] = 'a'; + } + eoln = "\r\n"; + } + + public void initialize() throws Exception { + initArray(); + Clipboard cb = Toolkit.getDefaultToolkit().getSystemClipboard(); + cb.setContents(new StringSelection(new String(text)), null); + + ProcessBuilder pb = ProcessTools.createTestJavaProcessBuilder( + ClipboardPerformanceTest.class.getName(), + "child" + ); + + Process process = ProcessTools.startProcess("Child", pb); + OutputAnalyzer outputAnalyzer = new OutputAnalyzer(process); + + if (!process.waitFor(15, TimeUnit.SECONDS)) { + process.destroyForcibly(); + throw new TimeoutException("Timed out waiting for Child"); + } + + outputAnalyzer.shouldHaveExitValue(0); + } +} diff -Nru openjdk-17-17.0.17+10/test/jdk/java/awt/datatransfer/HTMLTransferConsoleOutputTest.java openjdk-17-17.0.18+8/test/jdk/java/awt/datatransfer/HTMLTransferConsoleOutputTest.java --- openjdk-17-17.0.17+10/test/jdk/java/awt/datatransfer/HTMLTransferConsoleOutputTest.java 1970-01-01 00:00:00.000000000 +0000 +++ openjdk-17-17.0.18+8/test/jdk/java/awt/datatransfer/HTMLTransferConsoleOutputTest.java 2026-01-15 15:23:06.000000000 +0000 @@ -0,0 +1,182 @@ +/* + * Copyright (c) 2002, 2025, Oracle and/or its affiliates. All rights reserved. + * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. + * + * This code is free software; you can redistribute it and/or modify it + * under the terms of the GNU General Public License version 2 only, as + * published by the Free Software Foundation. + * + * This code is distributed in the hope that it will be useful, but WITHOUT + * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or + * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License + * version 2 for more details (a copy is included in the LICENSE file that + * accompanied this code). + * + * You should have received a copy of the GNU General Public License version + * 2 along with this work; if not, write to the Free Software Foundation, + * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. + * + * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA + * or visit www.oracle.com if you need additional information or have any + * questions. + */ + +/* + * @test + * @bug 4638351 + * @summary tests that HTML transfer doesn't cause console output + * @key headful + * @library /test/lib + * @run main HTMLTransferConsoleOutputTest + */ + +import java.awt.Toolkit; +import java.awt.datatransfer.Clipboard; +import java.awt.datatransfer.ClipboardOwner; +import java.awt.datatransfer.DataFlavor; +import java.awt.datatransfer.Transferable; +import java.awt.datatransfer.UnsupportedFlavorException; +import java.io.ByteArrayOutputStream; +import java.io.IOException; +import java.io.OutputStream; +import java.io.PrintStream; +import java.io.UnsupportedEncodingException; +import java.util.concurrent.TimeUnit; +import java.util.concurrent.TimeoutException; + +import jdk.test.lib.process.OutputAnalyzer; +import jdk.test.lib.process.ProcessTools; + +public class HTMLTransferConsoleOutputTest implements ClipboardOwner { + static final Clipboard clipboard = + Toolkit.getDefaultToolkit().getSystemClipboard(); + static final DataFlavor dataFlavor = + new DataFlavor("text/html; class=java.lang.String", null); + static final String magic = "TESTMAGICSTRING"; + static final Transferable transferable = new Transferable() { + final DataFlavor[] flavors = new DataFlavor[]{dataFlavor}; + final String data = "" + magic + ""; + + public DataFlavor[] getTransferDataFlavors() { + return flavors; + } + + public boolean isDataFlavorSupported(DataFlavor df) { + return dataFlavor.equals(df); + } + + public Object getTransferData(DataFlavor df) + throws UnsupportedFlavorException { + if (!isDataFlavorSupported(df)) { + throw new UnsupportedFlavorException(df); + } + return data; + } + }; + final ByteArrayOutputStream baos = new ByteArrayOutputStream(); + public static final int CLIPBOARD_DELAY = 1000; + + public static void main(String[] args) throws Exception { + if (args.length == 0) { + HTMLTransferConsoleOutputTest htmlTransferConsoleOutputTest = new HTMLTransferConsoleOutputTest(); + htmlTransferConsoleOutputTest.initialize(); + return; + } + final ClipboardOwner clipboardOwner = new ClipboardOwner() { + public void lostOwnership(Clipboard clip, + Transferable contents) { + System.exit(0); + } + }; + clipboard.setContents(transferable, clipboardOwner); + final Object o = new Object(); + synchronized (o) { + try { + o.wait(); + } catch (InterruptedException ie) { + ie.printStackTrace(); + } + } + System.out.println("Test Pass!"); + } + + public void initialize() throws Exception { + clipboard.setContents(transferable, this); + ProcessBuilder pb = ProcessTools.createTestJavaProcessBuilder( + HTMLTransferConsoleOutputTest.class.getName(), + "child" + ); + + Process process = ProcessTools.startProcess("Child", pb); + OutputAnalyzer outputAnalyzer = new OutputAnalyzer(process); + + if (!process.waitFor(15, TimeUnit.SECONDS)) { + process.destroyForcibly(); + throw new TimeoutException("Timed out waiting for Child"); + } + + byte[] bytes = baos.toByteArray(); + String string = null; + try { + string = new String(bytes, "ASCII"); + } catch (UnsupportedEncodingException uee) { + uee.printStackTrace(); + } + if (string.lastIndexOf(magic) != -1) { + throw new RuntimeException("Test failed. Output contains:" + + string); + } + + outputAnalyzer.shouldHaveExitValue(0); + } + + + static class ForkOutputStream extends OutputStream { + final OutputStream outputStream1; + final OutputStream outputStream2; + + public ForkOutputStream(OutputStream os1, OutputStream os2) { + outputStream1 = os1; + outputStream2 = os2; + } + + public void write(int b) throws IOException { + outputStream1.write(b); + outputStream2.write(b); + } + + public void flush() throws IOException { + outputStream1.flush(); + outputStream2.flush(); + } + + public void close() throws IOException { + outputStream1.close(); + outputStream2.close(); + } + } + + public void lostOwnership(Clipboard clip, Transferable contents) { + final Runnable r = () -> { + try { + Thread.sleep(CLIPBOARD_DELAY); + } catch (InterruptedException e) { + e.printStackTrace(); + } + final PrintStream oldOut = System.out; + final PrintStream newOut = + new PrintStream(new ForkOutputStream(oldOut, baos)); + Transferable t = clipboard.getContents(null); + try { + System.setOut(newOut); + t.getTransferData(dataFlavor); + System.setOut(oldOut); + } catch (IOException | UnsupportedFlavorException ioe) { + ioe.printStackTrace(); + } + clipboard.setContents(transferable, null); + }; + final Thread t = new Thread(r); + t.start(); + } +} diff -Nru openjdk-17-17.0.17+10/test/jdk/java/awt/datatransfer/ImageTransferCrashTest.java openjdk-17-17.0.18+8/test/jdk/java/awt/datatransfer/ImageTransferCrashTest.java --- openjdk-17-17.0.17+10/test/jdk/java/awt/datatransfer/ImageTransferCrashTest.java 1970-01-01 00:00:00.000000000 +0000 +++ openjdk-17-17.0.18+8/test/jdk/java/awt/datatransfer/ImageTransferCrashTest.java 2026-01-15 15:23:06.000000000 +0000 @@ -0,0 +1,147 @@ +/* + * Copyright (c) 2002, 2025, Oracle and/or its affiliates. All rights reserved. + * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. + * + * This code is free software; you can redistribute it and/or modify it + * under the terms of the GNU General Public License version 2 only, as + * published by the Free Software Foundation. + * + * This code is distributed in the hope that it will be useful, but WITHOUT + * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or + * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License + * version 2 for more details (a copy is included in the LICENSE file that + * accompanied this code). + * + * You should have received a copy of the GNU General Public License version + * 2 along with this work; if not, write to the Free Software Foundation, + * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. + * + * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA + * or visit www.oracle.com if you need additional information or have any + * questions. + */ + +/* + * @test + * @bug 4513976 + * @summary tests that inter-JVM image transfer doesn't cause crash + * @key headful + * @library /test/lib + * @run main ImageTransferCrashTest + */ + +import java.awt.Toolkit; +import java.awt.datatransfer.Clipboard; +import java.awt.datatransfer.ClipboardOwner; +import java.awt.datatransfer.DataFlavor; +import java.awt.datatransfer.StringSelection; +import java.awt.datatransfer.Transferable; +import java.awt.datatransfer.UnsupportedFlavorException; +import java.awt.image.BufferedImage; +import java.awt.image.WritableRaster; +import java.io.IOException; +import java.util.concurrent.TimeUnit; +import java.util.concurrent.TimeoutException; + +import jdk.test.lib.process.OutputAnalyzer; +import jdk.test.lib.process.ProcessTools; + +public class ImageTransferCrashTest implements ClipboardOwner { + static final Clipboard clipboard = + Toolkit.getDefaultToolkit().getSystemClipboard(); + final Transferable textTransferable = new StringSelection("TEXT"); + public static final int CLIPBOARD_DELAY = 10; + + public static void main(String[] args) throws Exception { + if (args.length == 0) { + ImageTransferCrashTest imageTransferCrashTest = new ImageTransferCrashTest(); + imageTransferCrashTest.initialize(); + return; + } + final ClipboardOwner clipboardOwner = (clip, contents) -> System.exit(0); + final int width = 100; + final int height = 100; + final BufferedImage bufferedImage = + new BufferedImage(width, height, BufferedImage.TYPE_INT_RGB); + final WritableRaster writableRaster = + bufferedImage.getWritableTile(0, 0); + final int[] color = new int[]{0x80, 0x80, 0x80}; + for (int i = 0; i < width; i++) { + for (int j = 0; j < height; j++) { + writableRaster.setPixel(i, j, color); + } + } + bufferedImage.releaseWritableTile(0, 0); + + final Transferable imageTransferable = new Transferable() { + final DataFlavor[] flavors = new DataFlavor[]{ + DataFlavor.imageFlavor}; + + public DataFlavor[] getTransferDataFlavors() { + return flavors; + } + + public boolean isDataFlavorSupported(DataFlavor df) { + return DataFlavor.imageFlavor.equals(df); + } + + public Object getTransferData(DataFlavor df) + throws UnsupportedFlavorException { + if (!isDataFlavorSupported(df)) { + throw new UnsupportedFlavorException(df); + } + return bufferedImage; + } + }; + clipboard.setContents(imageTransferable, clipboardOwner); + final Object o = new Object(); + synchronized (o) { + try { + o.wait(); + } catch (InterruptedException ie) { + ie.printStackTrace(); + } + } + System.out.println("Test Pass!"); + } + + public void initialize() throws Exception { + clipboard.setContents(textTransferable, this); + ProcessBuilder pb = ProcessTools.createTestJavaProcessBuilder( + ImageTransferCrashTest.class.getName(), + "child" + ); + + Process process = ProcessTools.startProcess("Child", pb); + OutputAnalyzer outputAnalyzer = new OutputAnalyzer(process); + + if (!process.waitFor(15, TimeUnit.SECONDS)) { + process.destroyForcibly(); + throw new TimeoutException("Timed out waiting for Child"); + } + + outputAnalyzer.shouldHaveExitValue(0); + } + + public void lostOwnership(Clipboard clip, Transferable contents) { + final Runnable r = () -> { + while (true) { + try { + Thread.sleep(CLIPBOARD_DELAY); + Transferable t = clipboard.getContents(null); + t.getTransferData(DataFlavor.imageFlavor); + } catch (IllegalStateException e) { + e.printStackTrace(); + System.err.println("clipboard is not prepared yet"); + continue; + } catch (Exception e) { + e.printStackTrace(); + } + break; + } + clipboard.setContents(textTransferable, null); + }; + final Thread t = new Thread(r); + t.start(); + } +} diff -Nru openjdk-17-17.0.17+10/test/jdk/java/awt/dnd/DnDFileGroupDescriptor/DnDFileGroupDescriptor.html openjdk-17-17.0.18+8/test/jdk/java/awt/dnd/DnDFileGroupDescriptor/DnDFileGroupDescriptor.html --- openjdk-17-17.0.17+10/test/jdk/java/awt/dnd/DnDFileGroupDescriptor/DnDFileGroupDescriptor.html 2025-10-13 07:48:04.000000000 +0000 +++ openjdk-17-17.0.18+8/test/jdk/java/awt/dnd/DnDFileGroupDescriptor/DnDFileGroupDescriptor.html 1970-01-01 00:00:00.000000000 +0000 @@ -1,43 +0,0 @@ - - - - - - DnDToWordpadTest - - - -

DnDFileGroupDescriptor
Bug ID: 6242241

- -

See the dialog box (usually in upper left corner) for instructions

- - - - diff -Nru openjdk-17-17.0.17+10/test/jdk/java/awt/dnd/DnDFileGroupDescriptor/DnDFileGroupDescriptor.java openjdk-17-17.0.18+8/test/jdk/java/awt/dnd/DnDFileGroupDescriptor/DnDFileGroupDescriptor.java --- openjdk-17-17.0.17+10/test/jdk/java/awt/dnd/DnDFileGroupDescriptor/DnDFileGroupDescriptor.java 2025-10-13 07:48:04.000000000 +0000 +++ openjdk-17-17.0.18+8/test/jdk/java/awt/dnd/DnDFileGroupDescriptor/DnDFileGroupDescriptor.java 2026-01-15 15:23:06.000000000 +0000 @@ -1,188 +1,80 @@ - /* - * Copyright (c) 2009, 2013, Oracle and/or its affiliates. All rights reserved. - * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. - * - * This code is free software; you can redistribute 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 6242241 - @summary Tests basic DnD functionality in an applet - @requires (os.family == "windows") - @author Your Name: Alexey Utkin area=dnd - @run applet/manual=yesno DnDFileGroupDescriptor.html -*/ - -import java.applet.Applet; -import java.awt.*; - -public class DnDFileGroupDescriptor extends Applet { - public void init() { - setLayout(new BorderLayout()); - - String[] instructions = { - "The applet window contains a red field.", - "1. Start MS Outlook program. Find and open ", - " the mail form with attachments.", - "2. Select attachments from the mail and drag into a red field of applet.", - " When the mouse enters the field during the drag, the application ", - " should change the cursor form to OLE-copy and field color to yellow.", - "3. Release the mouse button (drop attachments) over the field.", - "", - "File paths in temporary folder should appear.", - "", - "You should be able to repeat this operation multiple times.", - "Please, select \"Pass\" just in case of success or \"Fail\" for another." - }; - Sysout.createDialogWithInstructions( instructions ); - } - - public void start() { - Panel mainPanel; - Component dropTarget; + * Copyright (c) 2009, 2024, Oracle and/or its affiliates. All rights reserved. + * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. + * + * This code is free software; you can redistribute it and/or modify it + * under the terms of the GNU General Public License version 2 only, as + * published by the Free Software Foundation. + * + * This code is distributed in the hope that it will be useful, but WITHOUT + * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or + * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License + * version 2 for more details (a copy is included in the LICENSE file that + * accompanied this code). + * + * You should have received a copy of the GNU General Public License version + * 2 along with this work; if not, write to the Free Software Foundation, + * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. + * + * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA + * or visit www.oracle.com if you need additional information or have any + * questions. + */ + +import java.awt.BorderLayout; +import java.awt.Color; +import java.awt.Component; +import java.awt.Frame; +import java.awt.Panel; - mainPanel = new Panel(); +/* + * @test + * @bug 6242241 + * @summary Tests TransferFlavor that supports DnD of MS Outlook attachments. + * @requires (os.family == "windows") + * @library /java/awt/regtesthelpers + * @build PassFailJFrame + * @run main/manual DnDFileGroupDescriptor + */ + +public class DnDFileGroupDescriptor { + private static final String INSTRUCTIONS = """ + When the test starts, a RED panel appears. + 1. Start MS Outlook program. Find and open the mail form with attachments. + + 2. Select attachments from the mail and drag into a red field of applet. + When the mouse enters the field during the process of drag, the application + should change the cursor form to OLE-copy and field color to yellow. + + 3. Release the mouse button (drop attachments) over the field. + File paths in temporary folder should appear. + You should be able to repeat this operation multiple times. + + If the above is the case then press PASS, else FAIL. + """; + + public static void main(String[] args) throws Exception { + PassFailJFrame.builder() + .title("Test Instructions") + .instructions(INSTRUCTIONS) + .rows((int) INSTRUCTIONS.lines().count() + 2) + .columns(40) + .testUI(DnDFileGroupDescriptor::createUI) + .build() + .awaitAndCheck(); + } + + private static Frame createUI() { + Frame frame = new Frame("Test MS Outlook Mail Attachments DnD"); + Panel mainPanel = new Panel(); mainPanel.setLayout(new BorderLayout()); - mainPanel.setBackground(Color.blue); - dropTarget = new DnDTarget(Color.red, Color.yellow); - + Component dropTarget = new DnDTarget(Color.RED, Color.YELLOW); mainPanel.add(dropTarget, "Center"); - add(mainPanel); - setSize(200,200); + frame.add(mainPanel); + frame.setSize(400, 200); + frame.setAlwaysOnTop(true); + return frame; } } - -/**************************************************** - Standard Test Machinery - DO NOT modify anything below -- it's a standard - chunk of code whose purpose is to make user - interaction uniform, and thereby make it simpler - to read and understand someone else's test. - ****************************************************/ - -class Sysout - { - private static TestDialog dialog; - - public static void createDialogWithInstructions( String[] instructions ) - { - dialog = new TestDialog( new Frame(), "Instructions" ); - dialog.printInstructions( instructions ); - dialog.show(); - println( "Any messages for the tester will display here." ); - } - - public static void createDialog( ) - { - dialog = new TestDialog( new Frame(), "Instructions" ); - String[] defInstr = { "Instructions will appear here. ", "" } ; - dialog.printInstructions( defInstr ); - dialog.show(); - println( "Any messages for the tester will display here." ); - } - - - public static void printInstructions( String[] instructions ) - { - dialog.printInstructions( instructions ); - } - - - public static void println( String messageIn ) - { - dialog.displayMessage( messageIn ); - } - - }// Sysout class - -class TestDialog extends Dialog - { - - TextArea instructionsText; - TextArea messageText; - int maxStringLength = 80; - - //DO NOT call this directly, go through Sysout - public TestDialog( Frame frame, String name ) - { - super( frame, name ); - int scrollBoth = TextArea.SCROLLBARS_BOTH; - instructionsText = new TextArea( "", 15, maxStringLength, scrollBoth ); - add( "North", instructionsText ); - - messageText = new TextArea( "", 5, maxStringLength, scrollBoth ); - add("South", messageText); - - pack(); - - show(); - }// TestDialog() - - //DO NOT call this directly, go through Sysout - public void printInstructions( String[] instructions ) - { - //Clear out any current instructions - instructionsText.setText( "" ); - - //Go down array of instruction strings - - String printStr, remainingStr; - for( int i=0; i < instructions.length; i++ ) - { - //chop up each into pieces maxSringLength long - remainingStr = instructions[ i ]; - while( remainingStr.length() > 0 ) - { - //if longer than max then chop off first max chars to print - if( remainingStr.length() >= maxStringLength ) - { - //Try to chop on a word boundary - int posOfSpace = remainingStr. - lastIndexOf( ' ', maxStringLength - 1 ); - - if( posOfSpace <= 0 ) posOfSpace = maxStringLength - 1; - - printStr = remainingStr.substring( 0, posOfSpace + 1 ); - remainingStr = remainingStr.substring( posOfSpace + 1 ); - } - //else just print - else - { - printStr = remainingStr; - remainingStr = ""; - } - - instructionsText.append( printStr + "\n" ); - - }// while - - }// for - - }//printInstructions() - - //DO NOT call this directly, go through Sysout - public void displayMessage( String messageIn ) - { - messageText.append( messageIn + "\n" ); - } - - }// TestDialog class diff -Nru openjdk-17-17.0.17+10/test/jdk/java/awt/event/InputEvent/InputEventTimeTest.java openjdk-17-17.0.18+8/test/jdk/java/awt/event/InputEvent/InputEventTimeTest.java --- openjdk-17-17.0.17+10/test/jdk/java/awt/event/InputEvent/InputEventTimeTest.java 1970-01-01 00:00:00.000000000 +0000 +++ openjdk-17-17.0.18+8/test/jdk/java/awt/event/InputEvent/InputEventTimeTest.java 2026-01-15 15:23:06.000000000 +0000 @@ -0,0 +1,115 @@ +/* + * Copyright (c) 1999, 2025, Oracle and/or its affiliates. All rights reserved. + * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. + * + * This code is free software; you can redistribute 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 4176525 + * @summary InputEvent.getWhen() returns the wrong event time. + * @key headful + * @run main InputEventTimeTest + */ + +import java.awt.AWTEvent; +import java.awt.AWTException; +import java.awt.Dimension; +import java.awt.EventQueue; +import java.awt.Frame; +import java.awt.Point; +import java.awt.Robot; +import java.awt.event.InputEvent; +import java.awt.event.KeyEvent; +import java.lang.reflect.InvocationTargetException; +import java.util.Date; + +public class InputEventTimeTest extends Frame { + public void initUI() { + setTitle("Input Event Time Test"); + enableEvents(AWTEvent.MOUSE_EVENT_MASK); + enableEvents(AWTEvent.KEY_EVENT_MASK); + setSize(200, 200); + setLocationRelativeTo(null); + setVisible(true); + } + + public void center(Point point) { + Point loc = getLocationOnScreen(); + Dimension size = getSize(); + point.setLocation(loc.x + (size.width / 2), loc.y + (size.height / 2)); + } + + public void processEvent(AWTEvent e) { + long currentTime; + long eventTime; + long difference; + + if (!(e instanceof InputEvent)) { + return; + } + + currentTime = (new Date()).getTime(); + eventTime = ((InputEvent) e).getWhen(); + difference = currentTime - eventTime; + + if ((difference > 5000) || (difference < -5000)) { + throw new RuntimeException("The difference between current time" + + " and event creation time is " + difference + "ms"); + } + } + + public static void main(String[] args) throws InterruptedException, + InvocationTargetException, AWTException { + InputEventTimeTest test = new InputEventTimeTest(); + try { + EventQueue.invokeAndWait(test::initUI); + Robot robot = new Robot(); + robot.setAutoDelay(50); + robot.waitForIdle(); + robot.delay(1000); + Point center = new Point(); + EventQueue.invokeAndWait(() -> test.center(center)); + robot.mouseMove(center.x, center.y); + robot.mousePress(InputEvent.BUTTON1_DOWN_MASK); + robot.mouseRelease(InputEvent.BUTTON1_DOWN_MASK); + robot.waitForIdle(); + robot.mousePress(InputEvent.BUTTON2_DOWN_MASK); + robot.mouseRelease(InputEvent.BUTTON2_DOWN_MASK); + robot.waitForIdle(); + robot.mousePress(InputEvent.BUTTON1_DOWN_MASK); + robot.mouseRelease(InputEvent.BUTTON1_DOWN_MASK); + robot.waitForIdle(); + for (int i = 0; i < 6; i++) { + robot.keyPress(KeyEvent.VK_A + i); + robot.keyRelease(KeyEvent.VK_A + i); + robot.waitForIdle(); + } + for (int i = 0; i < 150; i += 5) { + robot.mouseMove(center.x - i, center.y - i); + } + for (int i = 150; i > 0; i -= 5) { + robot.mouseMove(center.x - i, center.y - i); + } + } finally { + EventQueue.invokeAndWait(test::dispose); + } + } +} diff -Nru openjdk-17-17.0.17+10/test/jdk/java/awt/event/KeyEvent/AltGrTest.java openjdk-17-17.0.18+8/test/jdk/java/awt/event/KeyEvent/AltGrTest.java --- openjdk-17-17.0.17+10/test/jdk/java/awt/event/KeyEvent/AltGrTest.java 1970-01-01 00:00:00.000000000 +0000 +++ openjdk-17-17.0.18+8/test/jdk/java/awt/event/KeyEvent/AltGrTest.java 2026-01-15 15:23:06.000000000 +0000 @@ -0,0 +1,90 @@ +/* + * Copyright (c) 1999, 2025, Oracle and/or its affiliates. All rights reserved. + * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. + * + * This code is free software; you can redistribute 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 4122687 4209844 + * @summary Characters typed with AltGr have Alt bit set on + * KEY_TYPED events + * @requires (os.family == "windows") + * @library /java/awt/regtesthelpers + * @build PassFailJFrame + * @run main/manual AltGrTest + */ + +import java.awt.BorderLayout; +import java.awt.Frame; +import java.awt.TextField; +import java.awt.event.KeyEvent; +import java.awt.event.KeyListener; +import java.lang.reflect.InvocationTargetException; + +public class AltGrTest extends Frame implements KeyListener { + static String INSTRUCTIONS = """ + Switch to German (Germany) keyboard layout and type + few characters using key. + Note: on windows keyboards without an AltGr key, + you should use Ctrl-Alt to synthesize AltGr. + For example, on German keyboards, `@' is AltGr-Q + `{' is AltGr-7 and '[' is AltGr-8 + If you see the corresponding symbols appear in the text field + and there are no entries in log area starting with word "FAIL:" + press "Pass", otherwise press "Fail". + """; + + public AltGrTest() { + setLayout(new BorderLayout()); + TextField entry = new TextField(); + entry.addKeyListener(this); + add(entry, BorderLayout.CENTER); + pack(); + } + + public void keyTyped(KeyEvent e) { + PassFailJFrame.log("----"); + PassFailJFrame.log("Got " + e); + + if (e.isControlDown() || e.isAltDown()) { + PassFailJFrame.log("FAIL: character typed has following modifiers bits set:"); + PassFailJFrame.log((e.isControlDown() ? " Control" : "") + + (e.isAltDown() ? " Alt" : "")); + } + + if (!(e.isAltGraphDown())) { + PassFailJFrame.log("FAIL: AltGraph modifier is missing"); + } + } + + public void keyPressed(KeyEvent ignore) {} + public void keyReleased(KeyEvent ignore) {} + + public static void main(String[] args) throws InterruptedException, + InvocationTargetException { + PassFailJFrame.builder() + .instructions(INSTRUCTIONS) + .logArea(10) + .testUI(AltGrTest::new) + .build() + .awaitAndCheck(); + } +} diff -Nru openjdk-17-17.0.17+10/test/jdk/java/awt/event/KeyEvent/CRTest.java openjdk-17-17.0.18+8/test/jdk/java/awt/event/KeyEvent/CRTest.java --- openjdk-17-17.0.17+10/test/jdk/java/awt/event/KeyEvent/CRTest.java 1970-01-01 00:00:00.000000000 +0000 +++ openjdk-17-17.0.18+8/test/jdk/java/awt/event/KeyEvent/CRTest.java 2026-01-15 15:23:06.000000000 +0000 @@ -0,0 +1,124 @@ +/* + * Copyright (c) 1999, 2025, Oracle and/or its affiliates. All rights reserved. + * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. + * + * This code is free software; you can redistribute 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 4257434 + * @summary Ensures that the right results are produced by the + * carriage return keys. + * @library /java/awt/regtesthelpers + * @build PassFailJFrame + * @run main/manual CRTest + */ + +import java.awt.BorderLayout; +import java.awt.Button; +import java.awt.Frame; +import java.awt.TextField; +import java.awt.event.ActionEvent; +import java.awt.event.ActionListener; +import java.awt.event.KeyEvent; +import java.awt.event.KeyListener; +import java.lang.reflect.InvocationTargetException; +import java.util.concurrent.atomic.AtomicBoolean; + +public class CRTest extends Frame implements KeyListener, ActionListener { + StringBuilder error = new StringBuilder(); + AtomicBoolean actionCompleted = new AtomicBoolean(false); + static String INSTRUCTIONS = """ + This test requires keyboard with the numeric keypad (numpad). + If your keyboard does not have numpad press "Pass" to skip testing. + Click on the text field in window named "Check KeyChar values". + Press Enter on keypad. Then press Return key on a standard keyboard. + Then click on "Done" button. Test will pass or fail automatically. + """; + + public CRTest() { + super("Check KeyChar values"); + setLayout(new BorderLayout()); + TextField tf = new TextField(30); + + tf.addKeyListener(this); + tf.addActionListener(this); + + add(tf, BorderLayout.CENTER); + + Button done = new Button("Done"); + done.addActionListener((event) -> { + checkAndComplete(); + }); + add(done, BorderLayout.SOUTH); + pack(); + } + + public void checkAndComplete() { + if (!actionCompleted.get()) { + error.append("\nNo action received!"); + } + + if (!error.isEmpty()) { + PassFailJFrame.forceFail(error.toString()); + } else { + PassFailJFrame.forcePass(); + } + } + + public void keyPressed(KeyEvent evt) { + if ((evt.getKeyChar() != '\n') || (evt.getKeyCode() != KeyEvent.VK_ENTER)) { + error.append("\nKeyPressed: Unexpected code " + evt.getKeyCode()); + } else { + PassFailJFrame.log("KeyPressed Test PASSED"); + } + } + + public void keyTyped(KeyEvent evt) { + if ((evt.getKeyChar() != '\n') || (evt.getKeyCode() != KeyEvent.VK_UNDEFINED)) { + error.append("\nKeyTyped: Unexpected code " + evt.getKeyCode()); + } else { + PassFailJFrame.log("KeyTyped Test PASSED"); + } + } + + public void keyReleased(KeyEvent evt) { + if ((evt.getKeyChar() != '\n') || (evt.getKeyCode() != KeyEvent.VK_ENTER)) { + error.append("\nKeyReleased: Unexpected code " + evt.getKeyCode()); + } else { + PassFailJFrame.log("KeyReleased Test PASSED"); + } + } + + public void actionPerformed(ActionEvent evt) { + PassFailJFrame.log("ActionPerformed Test PASSED"); + actionCompleted.set(true); + } + + public static void main(String[] args) throws InterruptedException, + InvocationTargetException { + PassFailJFrame.builder() + .instructions(INSTRUCTIONS) + .logArea(10) + .testUI(CRTest::new) + .build() + .awaitAndCheck(); + } +} diff -Nru openjdk-17-17.0.17+10/test/jdk/java/awt/event/KeyEvent/CharUndefinedTest.java openjdk-17-17.0.18+8/test/jdk/java/awt/event/KeyEvent/CharUndefinedTest.java --- openjdk-17-17.0.17+10/test/jdk/java/awt/event/KeyEvent/CharUndefinedTest.java 1970-01-01 00:00:00.000000000 +0000 +++ openjdk-17-17.0.18+8/test/jdk/java/awt/event/KeyEvent/CharUndefinedTest.java 2026-01-15 15:23:06.000000000 +0000 @@ -0,0 +1,95 @@ +/* + * Copyright (c) 1999, 2025, Oracle and/or its affiliates. All rights reserved. + * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. + * + * This code is free software; you can redistribute 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 4115484 4164672 4167893 + * @summary Ensures that KeyEvent has right keyChar for modifier and action keys. + * @library /java/awt/regtesthelpers + * @build PassFailJFrame + * @run main/manual CharUndefinedTest + */ + +import java.awt.BorderLayout; +import java.awt.Frame; +import java.awt.TextField; +import java.awt.event.KeyEvent; +import java.awt.event.KeyListener; +import java.lang.reflect.InvocationTargetException; + +public class CharUndefinedTest extends Frame implements KeyListener { + + static String INSTRUCTIONS = """ + Click on the text field inside the window named "Check KeyChar values". + Of any of the keys mentioned in this list that exist on your keyboard + press each of the listed keys once and also press them in two-key combinations such as + Control-Shift or Alt-Control. + The list of keys is: "Control, Shift, Meta, Alt, Command, Option". + After that press all function keys from F1 to F12 once, + Insert, Home, End, PageUp, PageDown and four arrow keys. + Check the log area below. If there are no messages starting with word "ERROR" + press "Pass" otherwise press "Fail". + """; + + public CharUndefinedTest() { + super("Check KeyChar values"); + setLayout(new BorderLayout()); + TextField tf = new TextField(30); + tf.addKeyListener(this); + add(tf, BorderLayout.CENTER); + pack(); + tf.requestFocus(); + } + + public void keyPressed(KeyEvent e) { + if (e.getKeyChar() != KeyEvent.CHAR_UNDEFINED) { + PassFailJFrame.log("ERROR: KeyPressed: keyChar = " + e.getKeyChar() + + " keyCode = " + e.getKeyCode() + " " + e.getKeyText(e.getKeyCode())); + } + } + + public void keyTyped(KeyEvent e) { + if (e.getKeyChar() != KeyEvent.CHAR_UNDEFINED) { + PassFailJFrame.log("ERROR: KeyTyped: keyChar = " + e.getKeyChar() + + " keyCode = " + e.getKeyCode() + " " + e.getKeyText(e.getKeyCode())); + } + } + + public void keyReleased(KeyEvent e) { + if (e.getKeyChar() != KeyEvent.CHAR_UNDEFINED) { + PassFailJFrame.log("ERROR: KeyReleased: keyChar = " + e.getKeyChar() + + " keyCode = " + e.getKeyCode() + " " + e.getKeyText(e.getKeyCode())); + } + } + + public static void main(String[] args) throws InterruptedException, + InvocationTargetException { + PassFailJFrame.builder() + .instructions(INSTRUCTIONS) + .columns(45) + .logArea(10) + .testUI(CharUndefinedTest::new) + .build() + .awaitAndCheck(); + } +} diff -Nru openjdk-17-17.0.17+10/test/jdk/java/awt/event/KeyEvent/ExtendedKeysTest.java openjdk-17-17.0.18+8/test/jdk/java/awt/event/KeyEvent/ExtendedKeysTest.java --- openjdk-17-17.0.17+10/test/jdk/java/awt/event/KeyEvent/ExtendedKeysTest.java 1970-01-01 00:00:00.000000000 +0000 +++ openjdk-17-17.0.18+8/test/jdk/java/awt/event/KeyEvent/ExtendedKeysTest.java 2026-01-15 15:23:06.000000000 +0000 @@ -0,0 +1,66 @@ +/* + * Copyright (c) 1999, 2025, Oracle and/or its affiliates. All rights reserved. + * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. + * + * This code is free software; you can redistribute 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 4218892 4191924 4199284 + * @summary Unable to enter some chars via european keyboard layout(s) + * @library /java/awt/regtesthelpers + * @build PassFailJFrame + * @run main/manual ExtendedKeysTest + */ + +import java.awt.BorderLayout; +import java.awt.Frame; +import java.awt.TextArea; +import java.lang.reflect.InvocationTargetException; + +public class ExtendedKeysTest extends Frame { + static String INSTRUCTIONS = """ + This test requires Swiss German input. If the Swiss German input + can not be installed or configured press "Pass" to skip testing. + Click on the text area inside the window named "Check input". + Switch to Swiss German input and press key with "\\" on it + (usually this key is above or to the left of the main "Enter" key). + If you see a dollar sign press "Pass". + If you see any other character or question mark press "Fail". + """; + + public ExtendedKeysTest() { + super("Check input"); + setLayout(new BorderLayout()); + add(new TextArea(20, 20), "Center"); + pack(); + } + + public static void main(String[] args) throws InterruptedException, + InvocationTargetException { + PassFailJFrame.builder() + .instructions(INSTRUCTIONS) + .columns(45) + .logArea(10) + .testUI(ExtendedKeysTest::new) + .build() + .awaitAndCheck(); + } +} diff -Nru openjdk-17-17.0.17+10/test/jdk/java/awt/event/KeyEvent/KeyDownCaptureTest.java openjdk-17-17.0.18+8/test/jdk/java/awt/event/KeyEvent/KeyDownCaptureTest.java --- openjdk-17-17.0.17+10/test/jdk/java/awt/event/KeyEvent/KeyDownCaptureTest.java 1970-01-01 00:00:00.000000000 +0000 +++ openjdk-17-17.0.18+8/test/jdk/java/awt/event/KeyEvent/KeyDownCaptureTest.java 2026-01-15 15:23:06.000000000 +0000 @@ -0,0 +1,111 @@ +/* + * Copyright (c) 2001, 2025, Oracle and/or its affiliates. All rights reserved. + * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. + * + * This code is free software; you can redistribute it and/or modify it + * under the terms of the GNU General Public License version 2 only, as + * published by the Free Software Foundation. + * + * This code is distributed in the hope that it will be useful, but WITHOUT + * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or + * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License + * version 2 for more details (a copy is included in the LICENSE file that + * accompanied this code). + * + * You should have received a copy of the GNU General Public License version + * 2 along with this work; if not, write to the Free Software Foundation, + * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. + * + * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA + * or visit www.oracle.com if you need additional information or have any + * questions. + */ + +/* + * @test + * @bug 4093998 + * @summary keyDown not called on subclasses of Component + * @key headful + * @run main KeyDownCaptureTest + */ + +import java.awt.AWTException; +import java.awt.BorderLayout; +import java.awt.Canvas; +import java.awt.Color; +import java.awt.Dimension; +import java.awt.EventQueue; +import java.awt.Frame; +import java.awt.Point; +import java.awt.Robot; +import java.awt.event.InputEvent; +import java.awt.event.KeyEvent; +import java.awt.event.KeyListener; +import java.lang.reflect.InvocationTargetException; +import java.util.concurrent.atomic.AtomicBoolean; + +public class KeyDownCaptureTest extends Frame implements KeyListener { + static AtomicBoolean passed = new AtomicBoolean(false); + + public KeyDownCaptureTest() { + super("Key Down Capture Test"); + } + + public void initUI() { + setLayout (new BorderLayout()); + setSize(200, 200); + setLocationRelativeTo(null); + Canvas canvas = new Canvas(); + canvas.setBackground(Color.RED); + canvas.addKeyListener(this); + add(canvas, BorderLayout.CENTER); + setVisible(true); + } + + public void middle(Point p) { + Point loc = getLocationOnScreen(); + Dimension size = getSize(); + p.setLocation(loc.x + (size.width / 2), loc.y + (size.height / 2)); + } + + @Override + public void keyTyped(KeyEvent ignore) {} + + @Override + public void keyPressed(KeyEvent e) { + passed.set(true); + } + + @Override + public void keyReleased(KeyEvent ignore) {} + + public static void main(String[] args) throws InterruptedException, + InvocationTargetException, AWTException { + KeyDownCaptureTest test = new KeyDownCaptureTest(); + try { + EventQueue.invokeAndWait((test::initUI)); + Robot robot = new Robot(); + robot.setAutoDelay(50); + robot.delay(500); + robot.waitForIdle(); + Point target = new Point(); + EventQueue.invokeAndWait(() -> { + test.middle(target); + }); + robot.mouseMove(target.x, target.y); + robot.mousePress(InputEvent.BUTTON1_DOWN_MASK); + robot.mouseRelease(InputEvent.BUTTON1_DOWN_MASK); + robot.keyPress(KeyEvent.VK_SPACE); + robot.keyRelease(KeyEvent.VK_SPACE); + robot.delay(100); + robot.waitForIdle(); + if (!passed.get()) { + throw new RuntimeException("KeyPressed has not arrived to canvas"); + } + } finally { + if (test != null) { + EventQueue.invokeAndWait(test::dispose); + } + } + } +} diff -Nru openjdk-17-17.0.17+10/test/jdk/java/awt/event/KeyEvent/KeyEventToLightweight.java openjdk-17-17.0.18+8/test/jdk/java/awt/event/KeyEvent/KeyEventToLightweight.java --- openjdk-17-17.0.17+10/test/jdk/java/awt/event/KeyEvent/KeyEventToLightweight.java 1970-01-01 00:00:00.000000000 +0000 +++ openjdk-17-17.0.18+8/test/jdk/java/awt/event/KeyEvent/KeyEventToLightweight.java 2026-01-15 15:23:06.000000000 +0000 @@ -0,0 +1,125 @@ +/* + * Copyright (c) 2001, 2025, Oracle and/or its affiliates. All rights reserved. + * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. + * + * This code is free software; you can redistribute it and/or modify it + * under the terms of the GNU General Public License version 2 only, as + * published by the Free Software Foundation. + * + * This code is distributed in the hope that it will be useful, but WITHOUT + * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or + * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License + * version 2 for more details (a copy is included in the LICENSE file that + * accompanied this code). + * + * You should have received a copy of the GNU General Public License version + * 2 along with this work; if not, write to the Free Software Foundation, + * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. + * + * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA + * or visit www.oracle.com if you need additional information or have any + * questions. + */ + +/* + * @test + * @bug 4397557 + * @summary Check that focused lightweight component gets key events + * even if mouse is outside of it or on top of heavyweight component + * @key headful + * @run main KeyEventToLightweight + */ + +import java.awt.AWTException; +import java.awt.Button; +import java.awt.Component; +import java.awt.Dimension; +import java.awt.EventQueue; +import java.awt.FlowLayout; +import java.awt.Frame; +import java.awt.Point; +import java.awt.Robot; +import java.awt.event.InputEvent; +import java.awt.event.KeyAdapter; +import java.awt.event.KeyEvent; +import java.lang.reflect.InvocationTargetException; +import java.util.concurrent.atomic.AtomicBoolean; +import javax.swing.JButton; + +public class KeyEventToLightweight extends Frame { + JButton lwbutton = new JButton("Select Me"); + Button hwbutton = new Button("Heavyweight"); + + AtomicBoolean aTyped = new AtomicBoolean(false); + AtomicBoolean bTyped = new AtomicBoolean(false); + AtomicBoolean cTyped = new AtomicBoolean(false); + + public static void main(String[] args) throws InterruptedException, + InvocationTargetException, AWTException { + KeyEventToLightweight test = new KeyEventToLightweight(); + try { + EventQueue.invokeAndWait(test::initUI); + test.performTest(); + } finally { + EventQueue.invokeAndWait(test::dispose); + } + } + + public void initUI() { + this.setLayout(new FlowLayout()); + add(lwbutton); + add(hwbutton); + setSize(200, 200); + setLocationRelativeTo(null); + lwbutton.addKeyListener(new KeyAdapter() { + public void keyPressed(KeyEvent e) { + if (e.getKeyCode() == KeyEvent.VK_A) { + aTyped.set(true); + } else if (e.getKeyCode() == KeyEvent.VK_B) { + bTyped.set(true); + } else if (e.getKeyCode() == KeyEvent.VK_C) { + cTyped.set(true); + } + } + }); + setVisible(true); + } + + public void middleOf(Component c, Point p) { + Point loc = c.getLocationOnScreen(); + Dimension size = c.getSize(); + p.setLocation(loc.x + (size.width / 2), loc.y + (size.height / 2)); + } + + public void performTest() throws AWTException, InterruptedException, + InvocationTargetException { + Robot robot = new Robot(); + robot.setAutoDelay(50); + robot.delay(500); + robot.waitForIdle(); + Point target = new Point(); + EventQueue.invokeAndWait(() -> middleOf(lwbutton, target)); + robot.mouseMove(target.x, target.y); + robot.mousePress(InputEvent.BUTTON1_DOWN_MASK); + robot.mouseRelease(InputEvent.BUTTON1_DOWN_MASK); + robot.waitForIdle(); + robot.delay(500); + robot.keyPress(KeyEvent.VK_A); + robot.keyRelease(KeyEvent.VK_A); + robot.waitForIdle(); + robot.mouseMove(target.x - 200, target.y); + robot.keyPress(KeyEvent.VK_B); + robot.keyRelease(KeyEvent.VK_B); + robot.waitForIdle(); + robot.delay(500); + EventQueue.invokeAndWait(() -> middleOf(hwbutton, target)); + robot.mouseMove(target.x, target.y); + robot.keyPress(KeyEvent.VK_C); + robot.keyRelease(KeyEvent.VK_C); + if (!aTyped.get() || !bTyped.get() || !cTyped.get()) { + throw new RuntimeException("Key event was not delivered, case 1: " + + aTyped.get() + ", case 2: " + bTyped.get() + ", case 3: " + + cTyped.get()); + } + } +} diff -Nru openjdk-17-17.0.17+10/test/jdk/java/awt/event/KeyEvent/KeyModifiers.java openjdk-17-17.0.18+8/test/jdk/java/awt/event/KeyEvent/KeyModifiers.java --- openjdk-17-17.0.17+10/test/jdk/java/awt/event/KeyEvent/KeyModifiers.java 1970-01-01 00:00:00.000000000 +0000 +++ openjdk-17-17.0.18+8/test/jdk/java/awt/event/KeyEvent/KeyModifiers.java 2026-01-15 15:23:06.000000000 +0000 @@ -0,0 +1,134 @@ +/* + * Copyright (c) 1999, 2025, Oracle and/or its affiliates. All rights reserved. + * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. + * + * This code is free software; you can redistribute 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 4193779 4174399 + * @summary Ensures that KeyEvents have the right modifiers set + * @library /java/awt/regtesthelpers /test/lib + * @build PassFailJFrame jdk.test.lib.Platform + * @run main/manual KeyModifiers + */ + +import java.awt.BorderLayout; +import java.awt.Frame; +import java.awt.TextField; +import java.awt.event.InputEvent; +import java.awt.event.KeyEvent; +import java.awt.event.KeyListener; +import java.lang.reflect.InvocationTargetException; + +import jdk.test.lib.Platform; + + +public class KeyModifiers extends Frame implements KeyListener { + public KeyModifiers() { + super("Check KeyChar values"); + setLayout(new BorderLayout()); + TextField tf = new TextField(30); + tf.addKeyListener(this); + add(tf, BorderLayout.CENTER); + pack(); + } + + public static void main(String[] args) throws InterruptedException, + InvocationTargetException { + + String keys; + if (Platform.isWindows()) { + keys = "\"Shift-n\", \"Alt-n\"\n"; + } else if (Platform.isOSX()) { + keys = "\"Shift-n\", \"Alt-n\", \"Command-n\"\n"; + } else { + keys = "\"Shift-n\", \"Alt-n\", \"Meta-n\"\n"; + } + + String INSTRUCTIONS1 = """ + Click on the text field in the window named "Check KeyChar values" + and type the following key combinations: + """; + String INSTRUCTIONS2 = """ + After each combination check that the KeyPressed and KeyTyped modifiers + are correctly displayed. If modifiers are correct press "Pass", + otherwise press "Fail". + """; + PassFailJFrame.builder() + .title("KeyModifiers Test Instructions") + .instructions(INSTRUCTIONS1 + keys + INSTRUCTIONS2) + .columns(45) + .logArea(10) + .testUI(KeyModifiers::new) + .build() + .awaitAndCheck(); + } + + public void keyPressed(KeyEvent evt) { + int kc = evt.getKeyCode(); + + if (kc == KeyEvent.VK_CONTROL) { + return; + } + + if ((kc == KeyEvent.VK_SHIFT) || (kc == KeyEvent.VK_META) || + (kc == KeyEvent.VK_ALT) || (kc == KeyEvent.VK_ALT_GRAPH)) { + PassFailJFrame.log("Key pressed= " + KeyEvent.getKeyText(kc) + + " modifiers = " + InputEvent.getModifiersExText(evt.getModifiersEx())); + } else { + PassFailJFrame.log("Key pressed = " + evt.getKeyChar() + + " modifiers = " + InputEvent.getModifiersExText(evt.getModifiersEx())); + } + } + + public void keyTyped(KeyEvent evt) { + int kc = evt.getKeyCode(); + + if (kc == KeyEvent.VK_CONTROL) { + return; + } + + if ((kc == KeyEvent.VK_SHIFT) || (kc == KeyEvent.VK_META) || + (kc == KeyEvent.VK_ALT) || (kc == KeyEvent.VK_ALT_GRAPH)) { + PassFailJFrame.log("Key typed = " + KeyEvent.getKeyText(kc) + + " modifiers = " + InputEvent.getModifiersExText(evt.getModifiersEx())); + } else { + PassFailJFrame.log("Key typed = " + evt.getKeyChar() + + " modifiers = " + InputEvent.getModifiersExText(evt.getModifiersEx())); + } + } + + public void keyReleased(KeyEvent evt) { + int kc = evt.getKeyCode(); + + if (kc == KeyEvent.VK_CONTROL) + return; + + if ((kc == KeyEvent.VK_SHIFT) || (kc == KeyEvent.VK_META) || + (kc == KeyEvent.VK_ALT) || (kc == KeyEvent.VK_ALT_GRAPH)) { + PassFailJFrame.log("Key = released " + KeyEvent.getKeyText(kc) + + " modifiers = " + InputEvent.getModifiersExText(evt.getModifiersEx())); + } else { + PassFailJFrame.log("Key released = " + evt.getKeyChar() + + " modifiers = " + InputEvent.getModifiersExText(evt.getModifiersEx())); + } + } +} diff -Nru openjdk-17-17.0.17+10/test/jdk/java/awt/event/KeyEvent/KeyPressedModifiers.java openjdk-17-17.0.18+8/test/jdk/java/awt/event/KeyEvent/KeyPressedModifiers.java --- openjdk-17-17.0.17+10/test/jdk/java/awt/event/KeyEvent/KeyPressedModifiers.java 1970-01-01 00:00:00.000000000 +0000 +++ openjdk-17-17.0.18+8/test/jdk/java/awt/event/KeyEvent/KeyPressedModifiers.java 2026-01-15 15:23:06.000000000 +0000 @@ -0,0 +1,108 @@ +/* + * Copyright (c) 1998, 2025, Oracle and/or its affiliates. All rights reserved. + * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. + * + * This code is free software; you can redistribute 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 4174399 + * @summary Check that modifier values are set on a KeyPressed event + * when a modifier key is pressed. + * @key headful + * @run main KeyPressedModifiers + */ + +import java.awt.AWTException; +import java.awt.BorderLayout; +import java.awt.EventQueue; +import java.awt.Frame; +import java.awt.Robot; +import java.awt.TextField; +import java.awt.event.KeyEvent; +import java.awt.event.KeyListener; +import java.lang.reflect.InvocationTargetException; +import java.util.concurrent.atomic.AtomicBoolean; + +public class KeyPressedModifiers extends Frame implements KeyListener { + static AtomicBoolean shiftDown = new AtomicBoolean(false); + static AtomicBoolean controlDown = new AtomicBoolean(false); + static AtomicBoolean altDown = new AtomicBoolean(false); + + public static void main(String[] args) throws InterruptedException, + InvocationTargetException, AWTException { + KeyPressedModifiers test = new KeyPressedModifiers(); + try { + EventQueue.invokeAndWait(test::initUI); + Robot robot = new Robot(); + robot.setAutoDelay(100); + robot.delay(500); + robot.waitForIdle(); + robot.keyPress(KeyEvent.VK_SHIFT); + robot.keyRelease(KeyEvent.VK_SHIFT); + robot.keyPress(KeyEvent.VK_CONTROL); + robot.keyRelease(KeyEvent.VK_CONTROL); + robot.keyPress(KeyEvent.VK_ALT); + robot.keyRelease(KeyEvent.VK_ALT); + robot.delay(500); + robot.waitForIdle(); + if (!shiftDown.get() || !controlDown.get() || !altDown.get()) { + String error = "Following key modifiers were not registered:" + + (shiftDown.get() ? "" : " SHIFT") + + (controlDown.get() ? "" : " CONTROL") + + (altDown.get() ? "" : " ALT"); + throw new RuntimeException(error); + } + } finally { + EventQueue.invokeAndWait(test::dispose); + } + } + + public void initUI() { + setLayout(new BorderLayout()); + TextField tf = new TextField(30); + tf.addKeyListener(this); + add(tf, BorderLayout.CENTER); + setSize(350, 100); + setVisible(true); + tf.requestFocus(); + } + + public void keyTyped(KeyEvent ignore) { + } + + public void keyReleased(KeyEvent ignore) { + } + + public void keyPressed(KeyEvent e) { + System.out.println(e); + switch (e.getKeyCode()) { + case KeyEvent.VK_SHIFT: + shiftDown.set(e.isShiftDown()); + break; + case KeyEvent.VK_CONTROL: + controlDown.set(e.isControlDown()); + break; + case KeyEvent.VK_ALT: + altDown.set(e.isAltDown()); + break; + } + } +} diff -Nru openjdk-17-17.0.17+10/test/jdk/java/awt/event/KeyEvent/KeyTest.java openjdk-17-17.0.18+8/test/jdk/java/awt/event/KeyEvent/KeyTest.java --- openjdk-17-17.0.17+10/test/jdk/java/awt/event/KeyEvent/KeyTest.java 1970-01-01 00:00:00.000000000 +0000 +++ openjdk-17-17.0.18+8/test/jdk/java/awt/event/KeyEvent/KeyTest.java 2026-01-15 15:23:06.000000000 +0000 @@ -0,0 +1,104 @@ +/* + * Copyright (c) 1999, 2025, Oracle and/or its affiliates. All rights reserved. + * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. + * + * This code is free software; you can redistribute 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 4151419 4090870 4169733 + * @summary Ensures that KeyEvent has right results for the following + * keys -=\[];,./ + * @library /java/awt/regtesthelpers + * @build PassFailJFrame + * @run main/manual KeyTest + */ + +import java.awt.BorderLayout; +import java.awt.Frame; +import java.awt.TextField; +import java.awt.event.KeyEvent; +import java.awt.event.KeyListener; +import java.lang.reflect.InvocationTargetException; + +public class KeyTest extends Frame implements KeyListener { + + static String INSTRUCTIONS = """ + Click on the text field in window named "Check KeyChar values" + Type the following keys/characters in the TextField: + - = \\ [ ] ; , . / + Verify that the keyChar and keyCode is correct for each key pressed. + Remember that the keyCode for the KEY_TYPED event should be zero. + Also verify that the character you typed appears in the TextField. + + Key Name keyChar Keycode + ------------------------------------- + - Minus - 45 45 + = Equals = 61 61 + \\ Slash \\ 92 92 + [ Left Brace [ 91 91 + ] Right Brace ] 93 93 + ; Semicolon ; 59 59 + , Comma , 44 44 + . Period . 46 46 + / Front Slash / 47 47 + """; + public KeyTest() { + super("Check KeyChar values"); + setLayout(new BorderLayout()); + TextField tf = new TextField(30); + tf.addKeyListener(this); + add(tf, BorderLayout.CENTER); + pack(); + + } + + public void keyPressed(KeyEvent evt) { + printKey(evt); + } + + public void keyTyped(KeyEvent evt) { + printKey(evt); + } + + public void keyReleased(KeyEvent evt) { + printKey(evt); + } + + protected void printKey(KeyEvent evt) { + if (evt.isActionKey()) { + PassFailJFrame.log("params= " + evt.paramString() + " KeyChar: " + + (int) evt.getKeyChar() + " Action Key"); + } else { + PassFailJFrame.log("params= " + evt.paramString() + " KeyChar: " + + (int) evt.getKeyChar()); + } + } + + public static void main(String[] args) throws InterruptedException, InvocationTargetException { + PassFailJFrame.builder() + .title("KeyTest Instructions") + .instructions(INSTRUCTIONS) + .logArea(20) + .testUI(KeyTest::new) + .build() + .awaitAndCheck(); + } +} diff -Nru openjdk-17-17.0.17+10/test/jdk/java/awt/event/KeyEvent/NumpadTest2.java openjdk-17-17.0.18+8/test/jdk/java/awt/event/KeyEvent/NumpadTest2.java --- openjdk-17-17.0.17+10/test/jdk/java/awt/event/KeyEvent/NumpadTest2.java 1970-01-01 00:00:00.000000000 +0000 +++ openjdk-17-17.0.18+8/test/jdk/java/awt/event/KeyEvent/NumpadTest2.java 2026-01-15 15:23:06.000000000 +0000 @@ -0,0 +1,108 @@ +/* + * Copyright (c) 1999, 2025, Oracle and/or its affiliates. All rights reserved. + * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. + * + * This code is free software; you can redistribute 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 4279566 + * @summary Tests that numpad keys produce the correct key codes and + * key chars when both the NumLock and CapsLock are on. + * @library /java/awt/regtesthelpers + * @build PassFailJFrame + * @run main/manual NumpadTest2 +*/ + +import java.awt.BorderLayout; +import java.awt.Frame; +import java.awt.TextField; +import java.awt.event.KeyEvent; +import java.awt.event.KeyListener; +import java.lang.reflect.InvocationTargetException; + +public class NumpadTest2 extends Frame implements KeyListener { + static String INSTRUCTIONS = """ + Make sure that the NumLock and CapsLock are both ON. + Click on the text field inside the window named "Check KeyChar values" + Then, type the NumPad 7 key (not the regular 7 key). + Verify that the keyChar and keyCode is correct for each key pressed. + Remember that the keyCode for the KEY_TYPED event should be zero. + If 7 appears in the text field and the key code printed is correct + press "Pass", otherwise press "Fail". + + Key Name keyChar Keycode + ------------------------------------------------- + Numpad-7 Numpad-7 55 103 + """; + + public NumpadTest2() { + super("Check KeyChar values"); + setLayout(new BorderLayout()); + TextField tf = new TextField(30); + tf.addKeyListener(this); + add(tf, BorderLayout.CENTER); + pack(); + } + + public void keyPressed(KeyEvent evt) { + printKey(evt); + } + + public void keyTyped(KeyEvent evt) { + printKey(evt); + } + + public void keyReleased(KeyEvent evt) { + printKey(evt); + } + + protected void printKey(KeyEvent evt) { + switch (evt.getID()) { + case KeyEvent.KEY_TYPED: + break; + case KeyEvent.KEY_PRESSED: + break; + case KeyEvent.KEY_RELEASED: + break; + default: + System.out.println("Other Event "); + return; + } + + if (evt.isActionKey()) { + PassFailJFrame.log("params= " + evt.paramString() + " KeyChar: " + + (int) evt.getKeyChar() + " Action Key"); + } else { + PassFailJFrame.log("params= " + evt.paramString() + " KeyChar: " + + (int) evt.getKeyChar()); + } + } + + public static void main(String[] args) throws InterruptedException, + InvocationTargetException { + PassFailJFrame.builder() + .instructions(INSTRUCTIONS) + .logArea(10) + .testUI(NumpadTest2::new) + .build() + .awaitAndCheck(); + } +} diff -Nru openjdk-17-17.0.17+10/test/jdk/java/awt/event/KeyEvent/TestDoubleKeyEvent.java openjdk-17-17.0.18+8/test/jdk/java/awt/event/KeyEvent/TestDoubleKeyEvent.java --- openjdk-17-17.0.17+10/test/jdk/java/awt/event/KeyEvent/TestDoubleKeyEvent.java 1970-01-01 00:00:00.000000000 +0000 +++ openjdk-17-17.0.18+8/test/jdk/java/awt/event/KeyEvent/TestDoubleKeyEvent.java 2026-01-15 15:23:06.000000000 +0000 @@ -0,0 +1,87 @@ +/* + * Copyright (c) 1999, 2025, Oracle and/or its affiliates. All rights reserved. + * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. + * + * This code is free software; you can redistribute 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 4495473 + * @summary Tests that when you press key on canvas-type heavyweight only one key event arrives + * @key headful + * @run main TestDoubleKeyEvent + */ + +import java.awt.AWTException; +import java.awt.BorderLayout; +import java.awt.EventQueue; +import java.awt.FlowLayout; +import java.awt.Robot; +import java.awt.event.KeyEvent; +import java.lang.reflect.InvocationTargetException; +import javax.swing.JFrame; +import javax.swing.JWindow; +import javax.swing.JTextField; + +public class TestDoubleKeyEvent extends JFrame { + JWindow w; + JTextField tf; + + public void initUI() { + setLayout(new BorderLayout()); + setTitle("Double Key Event Test"); + setLocationRelativeTo(null); + setVisible(true); + w = new JWindow(this); + w.setLayout(new FlowLayout()); + tf = new JTextField(20); + w.add(tf); + w.pack(); + w.setLocationRelativeTo(null); + w.setVisible(true); + tf.requestFocus(); + } + + public void testAndClean() { + String str = tf.getText(); + w.dispose(); + dispose(); + if (str.length() != str.chars().distinct().count()) { + throw new RuntimeException("Duplicate characters found!"); + } + } + + public static void main(String[] args) throws InterruptedException, + InvocationTargetException, AWTException { + TestDoubleKeyEvent test = new TestDoubleKeyEvent(); + EventQueue.invokeAndWait(test::initUI); + Robot robot = new Robot(); + robot.setAutoDelay(50); + robot.waitForIdle(); + robot.delay(1000); + for (int i = 0; i < 15; i++) { + robot.keyPress(KeyEvent.VK_A + i); + robot.keyRelease(KeyEvent.VK_A + i); + robot.waitForIdle(); + } + robot.delay(1000); + EventQueue.invokeAndWait(test::testAndClean); + } +} diff -Nru openjdk-17-17.0.17+10/test/jdk/java/awt/event/MouseWheelEvent/HWWheelScroll.java openjdk-17-17.0.18+8/test/jdk/java/awt/event/MouseWheelEvent/HWWheelScroll.java --- openjdk-17-17.0.17+10/test/jdk/java/awt/event/MouseWheelEvent/HWWheelScroll.java 1970-01-01 00:00:00.000000000 +0000 +++ openjdk-17-17.0.18+8/test/jdk/java/awt/event/MouseWheelEvent/HWWheelScroll.java 2026-01-15 15:23:06.000000000 +0000 @@ -0,0 +1,160 @@ +/* + * Copyright (c) 2001, 2025, Oracle and/or its affiliates. All rights reserved. + * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. + * + * This code is free software; you can redistribute it and/or modify it + * under the terms of the GNU General Public License version 2 only, as + * published by the Free Software Foundation. + * + * This code is distributed in the hope that it will be useful, but WITHOUT + * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or + * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License + * version 2 for more details (a copy is included in the LICENSE file that + * accompanied this code). + * + * You should have received a copy of the GNU General Public License version + * 2 along with this work; if not, write to the Free Software Foundation, + * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. + * + * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA + * or visit www.oracle.com if you need additional information or have any + * questions. + */ + +/* + * @test + * @bug 4425654 + * @summary Test wheel scrolling of heavyweight components + * @library /java/awt/regtesthelpers + * @build PassFailJFrame + * @run main/manual HWWheelScroll + */ + +import java.awt.Choice; +import java.awt.FileDialog; +import java.awt.Frame; +import java.awt.List; +import java.awt.TextArea; +import java.awt.Window; +import java.lang.reflect.InvocationTargetException; +import java.util.ArrayList; + +public class HWWheelScroll { + public static final int TEXT_TALL = 0; + public static final int TEXT_WIDE = 1; + public static final int TEXT_SMALL = 2; + public static final int TEXT_BIG = 3; + static String INSTRUCTIONS = """ + Test for mouse wheel scrolling of heavyweight components with built-in + scrollbars or similar functionality that is controlled by guestures + such as Apple Magic Mouse or trackpad scrolling guesture. + Several windows containing either a TextArea, List, Choice, or a + FileDialog will appear. For each window, use the mouse wheel to + scroll its content, and then minimize it or move away + and continue with the next window. + Do not close any of the opened windows except the FileDialog. + For the FileDialog, first change to a directory with enough items that a + scrollbar appears. + Some of the other windows don't have enough text to warrant scrollbars, + but should be tested anyway to make sure no crash or hang occurs. + If all scrollbars scroll correctly, press "Pass", otherwise press "Fail". + """; + + public static ArrayList initUI() { + ArrayList retValue = new ArrayList<>(); + retValue.add(makeTextFrame(TextArea.SCROLLBARS_BOTH, TEXT_BIG)); + retValue.add(makeTextFrame(TextArea.SCROLLBARS_BOTH, TEXT_TALL)); + retValue.add(makeTextFrame(TextArea.SCROLLBARS_BOTH, TEXT_SMALL)); + retValue.add(makeTextFrame(TextArea.SCROLLBARS_BOTH, TEXT_WIDE)); + retValue.add(makeTextFrame(TextArea.SCROLLBARS_VERTICAL_ONLY, TEXT_TALL)); + retValue.add(makeTextFrame(TextArea.SCROLLBARS_VERTICAL_ONLY, TEXT_SMALL)); + retValue.add(makeTextFrame(TextArea.SCROLLBARS_HORIZONTAL_ONLY, TEXT_SMALL)); + retValue.add(makeTextFrame(TextArea.SCROLLBARS_HORIZONTAL_ONLY, TEXT_WIDE)); + retValue.add(makeListFrame(TEXT_TALL)); + retValue.add(makeListFrame(TEXT_WIDE)); + retValue.add(makeListFrame(TEXT_SMALL)); + Frame f = new Frame("File Dialog Owner"); + f.setSize(150, 150); + f.setLocationRelativeTo(null); + FileDialog fd = new FileDialog(f, "FileDialog"); + fd.setDirectory("."); + retValue.add(fd); + retValue.add(f); + Frame choiceFrame = new Frame("Choice"); + Choice c = new Choice(); + for (int i = 0; i < 50; i++) { + c.add(i + " choice item"); + } + choiceFrame.add(c); + choiceFrame.setSize(150, 150); + choiceFrame.setLocationRelativeTo(null); + retValue.add(choiceFrame); + return retValue; + } + + public static Frame makeTextFrame(int policy, int textShape) { + Frame f = new Frame("TextArea"); + f.add(makeTextArea(policy, textShape)); + f.setSize(150, 150); + f.setLocationRelativeTo(null); + return f; + } + + public static Frame makeListFrame(int textShape) { + Frame f = new Frame("List"); + f.add(makeList(textShape)); + f.setSize(150, 150); + f.setLocationRelativeTo(null); + return f; + } + + public static TextArea makeTextArea(int policy, int textShape) { + TextArea ta = new TextArea("", 0, 0, policy); + if (textShape == TEXT_TALL) { + for (int i = 0; i < 50 ; i++) { + ta.append(i + "\n"); + } + } else if (textShape == TEXT_WIDE) { + for (int i = 0; i < 2; i++) { + ta.append(i + "very, very, very, very, very, very, very, long line of text number\n"); + } + } else if (textShape == TEXT_SMALL) { + ta.append("text"); + } else if (textShape == TEXT_BIG) { + for (int i = 0; i < 50 ; i++) { + ta.append(i + "very, very, very, very, very, very, very, long line of text number\n"); + } + } + return ta; + } + + public static List makeList(int textShape) { + java.awt.List l = new java.awt.List(); + if (textShape == TEXT_TALL) { + for (int i = 0; i < 50 ; i++) { + l.add(" " + i + " "); + } + } else if (textShape == TEXT_WIDE) { + for (int i = 0; i < 2 ; i++) { + l.add(i + "very, very, very, very, very, very, very, long line of text number"); + } + } else if (textShape == TEXT_SMALL) { + l.add("text"); + } else if (textShape == TEXT_BIG) { + for (int i = 0; i < 50 ; i++) { + l.add(i + "very, very, very, very, very, very, very, long line of text number"); + } + } + return l; + } + + public static void main(String[] args) throws InterruptedException, + InvocationTargetException { + PassFailJFrame.builder() + .instructions(INSTRUCTIONS) + .logArea(10) + .testUI(HWWheelScroll::initUI) + .build() + .awaitAndCheck(); + } +} diff -Nru openjdk-17-17.0.17+10/test/jdk/java/awt/event/MouseWheelEvent/WheelEventCoord.java openjdk-17-17.0.18+8/test/jdk/java/awt/event/MouseWheelEvent/WheelEventCoord.java --- openjdk-17-17.0.17+10/test/jdk/java/awt/event/MouseWheelEvent/WheelEventCoord.java 1970-01-01 00:00:00.000000000 +0000 +++ openjdk-17-17.0.18+8/test/jdk/java/awt/event/MouseWheelEvent/WheelEventCoord.java 2026-01-15 15:23:06.000000000 +0000 @@ -0,0 +1,95 @@ +/* + * Copyright (c) 2001, 2025, Oracle and/or its affiliates. All rights reserved. + * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. + * + * This code is free software; you can redistribute it and/or modify it + * under the terms of the GNU General Public License version 2 only, as + * published by the Free Software Foundation. + * + * This code is distributed in the hope that it will be useful, but WITHOUT + * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or + * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License + * version 2 for more details (a copy is included in the LICENSE file that + * accompanied this code). + * + * You should have received a copy of the GNU General Public License version + * 2 along with this work; if not, write to the Free Software Foundation, + * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. + * + * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA + * or visit www.oracle.com if you need additional information or have any + * questions. + */ + +/* + * @test + * @bug 4492456 + * @summary MouseWheelEvent coordinates are wrong + * @library /java/awt/regtesthelpers + * @build PassFailJFrame + * @run main/manual WheelEventCoord + */ + +import java.awt.Button; +import java.awt.Dimension; +import java.awt.Frame; +import java.awt.GridLayout; +import java.lang.reflect.InvocationTargetException; + +public class WheelEventCoord extends Frame { + static String INSTRUCTIONS = """ + This test requires mouse with scrolling wheel or device, + that has capability to simulate scrolling wheel with gestures + such as Apple mouse or a trackpad with gesture control. + If you do not have such device press "Pass". + Move mouse to the top of the button named "Button 1". + While constantly turning mouse wheel up and down slowly move + mouse cursor until it reaches bottom of the button named "Button 3". + While doing so look at the log area. + If despite the wheel direction y coordinate is steadily increases + as you move the mouse down press "Pass". + If y coordinate decreases when cursor is moving down or suddenly jumps + by more than 50 points when crossing to another button press "Fail". + """; + + public WheelEventCoord() { + super("Wheel Event Coordinates"); + setLayout(new GridLayout(3, 1)); + + add(new BigButton("Button 1")); + add(new BigButton("Button 2")); + add(new BigButton("Button 3")); + + addMouseWheelListener(e -> PassFailJFrame.log("Mouse y coordinate = " + e.getY())); + pack(); + } + + public static void main(String[] args) throws InterruptedException, + InvocationTargetException { + PassFailJFrame.builder() + .title("Wheel Event Coordinates Instructions") + .instructions(INSTRUCTIONS) + .logArea(10) + .testUI(WheelEventCoord::new) + .build() + .awaitAndCheck(); + } +} + +class BigButton extends Button { + public BigButton(String label) { + super(label); + } + + public Dimension getPreferredSize() { + return new Dimension(300, 100); + } + + public Dimension getMinimumSize() { + return getPreferredSize(); + } + + public Dimension getMaximumSize() { + return getPreferredSize(); + } +} diff -Nru openjdk-17-17.0.17+10/test/jdk/java/awt/event/MouseWheelEvent/WheelScrollEnabled.java openjdk-17-17.0.18+8/test/jdk/java/awt/event/MouseWheelEvent/WheelScrollEnabled.java --- openjdk-17-17.0.17+10/test/jdk/java/awt/event/MouseWheelEvent/WheelScrollEnabled.java 1970-01-01 00:00:00.000000000 +0000 +++ openjdk-17-17.0.18+8/test/jdk/java/awt/event/MouseWheelEvent/WheelScrollEnabled.java 2026-01-15 15:23:06.000000000 +0000 @@ -0,0 +1,129 @@ +/* + * 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 + * 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 4372477 + * @summary Test disabling of wheel scrolling + * @library /java/awt/regtesthelpers + * @build PassFailJFrame + * @run main/manual WheelScrollEnabled + */ + +import java.awt.BorderLayout; +import java.awt.Checkbox; +import java.awt.Frame; +import java.awt.GridLayout; +import java.awt.Label; +import java.awt.Panel; +import java.awt.ScrollPane; +import java.awt.event.ItemEvent; +import java.awt.event.ItemListener; +import java.awt.event.MouseWheelEvent; +import java.awt.event.MouseWheelListener; +import java.lang.reflect.InvocationTargetException; + +public class WheelScrollEnabled extends Frame { + static String INSTRUCTIONS = """ + This test requires mouse with a scrolling wheel or + device that is able to simulate scrolling using gestures. + If you do not have such device press "Pass" to skip testing. + You should see a ScrollPane with some labels in it and two checkboxes. + For each of the four combinations of the two checkboxes, + move the cursor over the ScrollPane and rotate the mouse wheel. + When (and ONLY when) the 'WheelListener added' checkbox is checked, + scrolling the mouse wheel should produce a text message in the log area. + When (and ONLY when) the 'Wheel scrolling enabled' checkbox is checked, + the ScrollPane should scroll when mouse wheel is scrolled on top of it. + If all four checkbox combinations work properly press "Pass", + otherwise press "Fail". + """; + MouseWheelListener mwl; + Checkbox cb; + Checkbox cb2; + ScrollPane sp; + + public WheelScrollEnabled() { + setLayout(new BorderLayout()); + Panel pnl = new Panel(); + pnl.setLayout(new GridLayout(10, 10)); + for (int i = 0; i < 100; i++) { + pnl.add(new Label("Label " + i)); + } + sp = new ScrollPane(); + sp.add(pnl); + sp.setWheelScrollingEnabled(false); + mwl = new MouseWheelListener() { + int i; + @Override + public void mouseWheelMoved(MouseWheelEvent e) { + PassFailJFrame.log("mouseWheelMoved " + i++); + } + }; + sp.addMouseWheelListener(mwl); + add(sp, BorderLayout.CENTER); + + Panel pl2 = new Panel(); + ItemListener il = new ControlListener(); + + cb = new Checkbox("WheelListener added", true); + cb.addItemListener(il); + pl2.add(cb); + + cb2 = new Checkbox("Wheel scrolling enabled", false); + cb2.addItemListener(il); + pl2.add(cb2); + + add(pl2, BorderLayout.SOUTH); + setSize(400, 200); + } + + class ControlListener implements ItemListener { + public void itemStateChanged(ItemEvent e) { + if (e.getSource() == cb) { + boolean state = cb.getState(); + if (state) { + sp.addMouseWheelListener(mwl); + } + else { + sp.removeMouseWheelListener(mwl); + } + } + if (e.getSource() == cb2) { + sp.setWheelScrollingEnabled(cb2.getState()); + } + } + } + + public static void main(String[] args) throws InterruptedException, + InvocationTargetException { + PassFailJFrame.builder() + .title("Wheel Scroll Enabled Instructions") + .instructions(INSTRUCTIONS) + .logArea(10) + .testUI(WheelScrollEnabled::new) + .build() + .awaitAndCheck(); + } +} + diff -Nru openjdk-17-17.0.17+10/test/jdk/java/awt/event/StressTest/LargeAWTEventMulticasterTest.java openjdk-17-17.0.18+8/test/jdk/java/awt/event/StressTest/LargeAWTEventMulticasterTest.java --- openjdk-17-17.0.17+10/test/jdk/java/awt/event/StressTest/LargeAWTEventMulticasterTest.java 1970-01-01 00:00:00.000000000 +0000 +++ openjdk-17-17.0.18+8/test/jdk/java/awt/event/StressTest/LargeAWTEventMulticasterTest.java 2026-01-15 15:23:06.000000000 +0000 @@ -0,0 +1,96 @@ +/* + * Copyright (c) 2024, Oracle and/or its affiliates. All rights reserved. + * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. + * + * This code is free software; you can redistribute it and/or modify it + * under the terms of the GNU General Public License version 2 only, as + * published by the Free Software Foundation. + * + * This code is distributed in the hope that it will be useful, but WITHOUT + * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or + * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License + * version 2 for more details (a copy is included in the LICENSE file that + * accompanied this code). + * + * You should have received a copy of the GNU General Public License version + * 2 along with this work; if not, write to the Free Software Foundation, + * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. + * + * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA + * or visit www.oracle.com if you need additional information or have any + * questions. + */ + +import java.awt.event.ActionListener; +import java.awt.event.ActionEvent; +import java.awt.AWTEventMulticaster; + +/* + * @test + * @bug 8342782 + * @summary Tests large AWTEventMulticasters for StackOverflowErrors + * @run main LargeAWTEventMulticasterTest + */ +public class LargeAWTEventMulticasterTest { + + /** + * This is an empty ActionListener that also has a numeric index. + */ + static class IndexedActionListener implements ActionListener { + private final int index; + + public IndexedActionListener(int index) { + this.index = index; + } + + @Override + public void actionPerformed(ActionEvent e) { + + } + + public int getIndex() { + return index; + } + + @Override + public String toString() { + return Integer.toString(index); + } + } + + public static void main(String[] args) { + int maxA = 0; + try { + for (int a = 1; a < 200_000; a *= 2) { + maxA = a; + testAddingActionListener(a); + } + } finally { + System.out.println("maximum a = " + maxA); + } + } + + private static void testAddingActionListener(int numberOfListeners) { + // step 1: create the large AWTEventMulticaster + ActionListener l = null; + for (int a = 0; a < numberOfListeners; a++) { + l = AWTEventMulticaster.add(l, new IndexedActionListener(a)); + } + + // Prior to 8342782 we could CREATE a large AWTEventMulticaster, but we couldn't + // always interact with it. + + // step 2: dispatch an event + // Here we're making sure we don't get a StackOverflowError when we traverse the tree: + l.actionPerformed(null); + + // step 3: make sure getListeners() returns elements in the correct order + // The resolution for 8342782 introduced a `rebalance` method; we want to + // double-check that the rebalanced tree preserves the appropriate order. + IndexedActionListener[] array = AWTEventMulticaster.getListeners(l, IndexedActionListener.class); + for (int b = 0; b < array.length; b++) { + if (b != array[b].getIndex()) + throw new Error("the listeners are in the wrong order. " + b + " != " + array[b].getIndex()); + } + } +} diff -Nru openjdk-17-17.0.17+10/test/jdk/java/awt/font/FontNames/LocaleFamilyNames.java openjdk-17-17.0.18+8/test/jdk/java/awt/font/FontNames/LocaleFamilyNames.java --- openjdk-17-17.0.17+10/test/jdk/java/awt/font/FontNames/LocaleFamilyNames.java 2025-10-13 07:48:04.000000000 +0000 +++ openjdk-17-17.0.18+8/test/jdk/java/awt/font/FontNames/LocaleFamilyNames.java 2026-01-15 15:23:06.000000000 +0000 @@ -1,5 +1,5 @@ /* - * Copyright (c) 2003, 2011, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2003, 2025, Oracle and/or its affiliates. All rights reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * * This code is free software; you can redistribute it and/or modify it @@ -26,29 +26,32 @@ * @bug 4935798 6521210 6901159 * @summary Tests that all family names that are reported in all locales * correspond to some font returned from getAllFonts(). - * @run main LocaleFamilyNames + * @run main/othervm/timeout=360 LocaleFamilyNames */ import java.awt.*; import java.util.*; public class LocaleFamilyNames { public static void main(String[] args) throws Exception { + System.out.println("Start time: " + java.time.LocalDateTime.now()); GraphicsEnvironment ge = GraphicsEnvironment.getLocalGraphicsEnvironment(); - Font[] all_fonts = ge.getAllFonts(); - Locale[] all_locales = Locale.getAvailableLocales(); + System.out.println("Number of fonts: " + all_fonts.length); + System.out.println("Number of locales: " + all_locales.length); + HashSet all_families = new HashSet(); for (int i=0; i map = new HashMap<>(); + map.put(TextAttribute.FONT, font); + layouts[0][0] = new TextLayout(text, map, frc); + AttributedCharacterIterator iter = new AttributedString(text, map).getIterator(); + layouts[0][1] = new LineBreakMeasurer(iter, frc).nextLayout(Float.MAX_VALUE); + + NumericShaper arabic = NumericShaper.getShaper(NumericShaper.ARABIC); + map.put(TextAttribute.NUMERIC_SHAPING, arabic); + layouts[1][0] = new TextLayout(text, map, frc); + iter = new AttributedString(text, map).getIterator(); + layouts[1][1] = new LineBreakMeasurer(iter, frc).nextLayout(Float.MAX_VALUE); + + NumericShaper contextualArabic = NumericShaper.getContextualShaper(NumericShaper.ARABIC, NumericShaper.ARABIC); + map.put(TextAttribute.NUMERIC_SHAPING, contextualArabic); + layouts[2][0] = new TextLayout(text, map, frc); + iter = new AttributedString(text, map).getIterator(); + layouts[2][1] = new LineBreakMeasurer(iter, frc).nextLayout(Float.MAX_VALUE); + + NumericShaper contextualArabicASCII = NumericShaper.getContextualShaper(NumericShaper.ARABIC); + map.put(TextAttribute.NUMERIC_SHAPING, contextualArabicASCII); + layouts[3][0] = new TextLayout(text, map, frc); + iter = new AttributedString(text, map).getIterator(); + layouts[3][1] = new LineBreakMeasurer(iter, frc).nextLayout(Float.MAX_VALUE); + + NumericShaper contextualAll = NumericShaper.getContextualShaper(NumericShaper.ALL_RANGES); + map.put(TextAttribute.NUMERIC_SHAPING, contextualAll); + layouts[4][0] = new TextLayout(text, map, frc); + iter = new AttributedString(text, map).getIterator(); + layouts[4][1] = new LineBreakMeasurer(iter, frc).nextLayout(Float.MAX_VALUE); + + titles = new String[]{ + "plain -- all digits ASCII", + "Arabic -- all digits Arabic", + "contextual Arabic default Arabic -- only leading digits and digits following Arabic text are Arabic", + "contextual Arabic default ASCII -- only digits following Arabic text are Arabic", + "contextual all default ASCII -- leading digits english, others correspond to context" + }; + } + + @Override + public void paint(Graphics g) { + Graphics2D g2d = (Graphics2D) g; + + float x = 5; + float y = 5; + + for (int i = 0; i < layouts.length; ++i) { + y += 18; + g2d.drawString(titles[i], x, y); + y += 4; + + for (int j = 0; j < 2; ++j) { + y += layouts[i][j].getAscent(); + layouts[i][j].draw(g2d, x, y); + y += layouts[i][j].getDescent() + layouts[i][j].getLeading(); + } + } + } +} diff -Nru openjdk-17-17.0.17+10/test/jdk/java/awt/font/TextLayout/TestGASPHint.java openjdk-17-17.0.18+8/test/jdk/java/awt/font/TextLayout/TestGASPHint.java --- openjdk-17-17.0.17+10/test/jdk/java/awt/font/TextLayout/TestGASPHint.java 1970-01-01 00:00:00.000000000 +0000 +++ openjdk-17-17.0.18+8/test/jdk/java/awt/font/TextLayout/TestGASPHint.java 2026-01-15 15:23:06.000000000 +0000 @@ -0,0 +1,113 @@ +/* + * Copyright (c) 2006, 2025, Oracle and/or its affiliates. All rights reserved. + * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. + * + * This code is free software; you can redistribute it and/or modify it + * under the terms of the GNU General Public License version 2 only, as + * published by the Free Software Foundation. + * + * This code is distributed in the hope that it will be useful, but WITHOUT + * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or + * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License + * version 2 for more details (a copy is included in the LICENSE file that + * accompanied this code). + * + * You should have received a copy of the GNU General Public License version + * 2 along with this work; if not, write to the Free Software Foundation, + * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. + * + * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA + * or visit www.oracle.com if you need additional information or have any + * questions. + */ + +import java.awt.Color; +import java.awt.Dimension; +import java.awt.Font; +import java.awt.Graphics; +import java.awt.Graphics2D; +import java.awt.GraphicsEnvironment; +import java.awt.RenderingHints; + +import javax.swing.JPanel; + +/* + * @test + * @bug 6320502 + * @summary Display laid out text which substitutes invisible glyphs correctly. + * @library /java/awt/regtesthelpers /test/lib + * @build PassFailJFrame jtreg.SkippedException + * @run main/manual TestGASPHint + */ + +public class TestGASPHint extends JPanel { + private static final String text = "\u0905\u0901\u0917\u094d\u0930\u0947\u091c\u093c\u0940"; + private static final Font font = getPhysicalFontForText(text, Font.PLAIN, 36); + + public static void main(String[] args) throws Exception { + if (font == null) { + throw new jtreg.SkippedException("No Devanagari font found. Test Skipped"); + } + + final String INSTRUCTIONS = """ + A short piece of Devanagari text should appear without any + artifacts. In particular there should be no "empty rectangles" + representing the missing glyph. + + If the above condition is true, press Pass, else Fail."""; + + PassFailJFrame.builder() + .title("TestGASPHint Instruction") + .instructions(INSTRUCTIONS) + .columns(32) + .splitUI(TestGASPHint::new) + .build() + .awaitAndCheck(); + } + + @Override + public Dimension getPreferredSize() { + return new Dimension(200, 200); + } + + @Override + public void paint(Graphics g) { + Graphics2D g2d = (Graphics2D) g; + + g2d.setColor(Color.WHITE); + g2d.fillRect(0, 0, getWidth(), getHeight()); + + g2d.setRenderingHint(RenderingHints.KEY_TEXT_ANTIALIASING, + RenderingHints.VALUE_TEXT_ANTIALIAS_GASP); + + g2d.setFont(font); + g2d.setColor(Color.BLACK); + g2d.drawString(text, 10, 50); + } + + /* + * Searches the available system fonts for a font which can display all the + * glyphs in the input text correctly. Returns null, if not found. + */ + private static Font getPhysicalFontForText(String text, int style, int size) { + GraphicsEnvironment ge = GraphicsEnvironment.getLocalGraphicsEnvironment(); + String[] names = ge.getAvailableFontFamilyNames(); + + for (String n : names) { + switch (n.toLowerCase()) { + case "dialog": + case "dialoginput": + case "serif": + case "sansserif": + case "monospaced": + break; + default: + Font f = new Font(n, style, size); + if (f.canDisplayUpTo(text) == -1) { + return f; + } + } + } + return null; + } +} diff -Nru openjdk-17-17.0.17+10/test/jdk/java/awt/font/TextLayout/TestSelection.java openjdk-17-17.0.18+8/test/jdk/java/awt/font/TextLayout/TestSelection.java --- openjdk-17-17.0.17+10/test/jdk/java/awt/font/TextLayout/TestSelection.java 1970-01-01 00:00:00.000000000 +0000 +++ openjdk-17-17.0.18+8/test/jdk/java/awt/font/TextLayout/TestSelection.java 2026-01-15 15:23:06.000000000 +0000 @@ -0,0 +1,134 @@ +/* + * Copyright (c) 1999, 2025, Oracle and/or its affiliates. All rights reserved. + * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. + * + * This code is free software; you can redistribute it and/or modify it + * under the terms of the GNU General Public License version 2 only, as + * published by the Free Software Foundation. + * + * This code is distributed in the hope that it will be useful, but WITHOUT + * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or + * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License + * version 2 for more details (a copy is included in the LICENSE file that + * accompanied this code). + * + * You should have received a copy of the GNU General Public License version + * 2 along with this work; if not, write to the Free Software Foundation, + * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. + * + * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA + * or visit www.oracle.com if you need additional information or have any + * questions. + */ + +import java.awt.Color; +import java.awt.Dimension; +import java.awt.Font; +import java.awt.Graphics; +import java.awt.Graphics2D; +import java.awt.Shape; +import java.awt.font.FontRenderContext; +import java.awt.font.TextAttribute; +import java.awt.font.TextLayout; +import java.text.AttributedString; + +import javax.swing.JPanel; + +/* + * @test + * @bug 4221422 + * @summary Display several TextLayouts with various selections. + * All the selections should be between non-italic and italic text, + * and the top and bottom of the selection region should be horizontal. + * @library /java/awt/regtesthelpers + * @build PassFailJFrame + * @run main/manual TestSelection + */ + +public final class TestSelection extends JPanel { + private static final float MARGIN = 20; + + public static void main(String[] args) throws Exception { + final String INSTRUCTIONS = """ + Several TextLayouts are displayed along with selections. + The selection regions should have horizontal top and bottom segments. + + If above condition is true, press Pass else Fail."""; + + PassFailJFrame.builder() + .title("TestSelection Instruction") + .instructions(INSTRUCTIONS) + .columns(40) + .splitUI(TestSelection::new) + .build() + .awaitAndCheck(); + } + + @Override + public Dimension getPreferredSize() { + return new Dimension(300, 300); + } + + private float drawSelectionAndLayout(Graphics2D g2d, + TextLayout layout, + float y, + int selStart, + int selLimit) { + Color selectionColor = Color.PINK; + Color textColor = Color.BLACK; + + y += layout.getAscent(); + + g2d.translate(MARGIN, y); + Shape hl = layout.getLogicalHighlightShape(selStart, selLimit); + g2d.setColor(selectionColor); + g2d.fill(hl); + g2d.setColor(textColor); + layout.draw(g2d, 0, 0); + g2d.translate(-MARGIN, -y); + + y += layout.getDescent() + layout.getLeading() + 10; + return y; + } + + @Override + public void paint(Graphics g) { + String text = "Hello world"; + + Graphics2D g2d = (Graphics2D) g; + g2d.setColor(Color.WHITE); + g2d.fillRect(0, 0, getWidth(), getHeight()); + + AttributedString attrStr = new AttributedString(text); + + FontRenderContext frc = g2d.getFontRenderContext(); + + final int midPoint = text.indexOf('w'); + final int selStart = midPoint / 2; + final int selLimit = text.length() - selStart; + final Font italic = new Font(Font.SANS_SERIF, Font.ITALIC, 24); + + float y = MARGIN; + + attrStr.addAttribute(TextAttribute.FONT, italic, 0, midPoint); + TextLayout layout = new TextLayout(attrStr.getIterator(), frc); + + y = drawSelectionAndLayout(g2d, layout, y, selStart - 1, selLimit); + y = drawSelectionAndLayout(g2d, layout, y, selStart, selLimit); + y = drawSelectionAndLayout(g2d, layout, y, selStart + 1, selLimit); + + attrStr = new AttributedString(text); + attrStr.addAttribute(TextAttribute.FONT, + italic, midPoint, text.length()); + layout = new TextLayout(attrStr.getIterator(), frc); + + y = drawSelectionAndLayout(g2d, layout, y, selStart, selLimit); + + attrStr = new AttributedString(text); + attrStr.addAttribute(TextAttribute.FONT, italic, 0, midPoint); + attrStr.addAttribute(TextAttribute.SIZE, 48f, midPoint, text.length()); + layout = new TextLayout(attrStr.getIterator(), frc); + + y = drawSelectionAndLayout(g2d, layout, y, selStart, selLimit); + } +} diff -Nru openjdk-17-17.0.17+10/test/jdk/java/awt/font/TextLayout/TestStrikethrough.java openjdk-17-17.0.18+8/test/jdk/java/awt/font/TextLayout/TestStrikethrough.java --- openjdk-17-17.0.17+10/test/jdk/java/awt/font/TextLayout/TestStrikethrough.java 1970-01-01 00:00:00.000000000 +0000 +++ openjdk-17-17.0.18+8/test/jdk/java/awt/font/TextLayout/TestStrikethrough.java 2026-01-15 15:23:06.000000000 +0000 @@ -0,0 +1,92 @@ +/* + * 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 + * under the terms of the GNU General Public License version 2 only, as + * published by the Free Software Foundation. + * + * This code is distributed in the hope that it will be useful, but WITHOUT + * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or + * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License + * version 2 for more details (a copy is included in the LICENSE file that + * accompanied this code). + * + * You should have received a copy of the GNU General Public License version + * 2 along with this work; if not, write to the Free Software Foundation, + * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. + * + * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA + * or visit www.oracle.com if you need additional information or have any + * questions. + */ + +import java.awt.Color; +import java.awt.Dimension; +import java.awt.Font; +import java.awt.Graphics; +import java.awt.Graphics2D; +import java.awt.font.FontRenderContext; +import java.awt.font.TextAttribute; +import java.awt.font.TextLayout; +import java.text.AttributedCharacterIterator; +import java.text.AttributedString; + +import javax.swing.JPanel; + +/* + * @test + * @bug 6426360 + * @summary Display a TextLayout with strikethrough at a number of + * different offsets relative to the pixel grid. + * @library /java/awt/regtesthelpers + * @build PassFailJFrame + * @run main/manual TestStrikethrough + */ + +public class TestStrikethrough extends JPanel { + + public static void main(String[] args) throws Exception { + final String INSTRUCTIONS = """ + Display text with strikethrough at a number of different positions. + + Press Fail if any line is missing a strikethrough else press Pass."""; + + PassFailJFrame.builder() + .title("TestStrikethrough Instruction") + .instructions(INSTRUCTIONS) + .columns(35) + .splitUI(TestStrikethrough::new) + .build() + .awaitAndCheck(); + } + + @Override + public Dimension getPreferredSize() { + return new Dimension(200, 120); + } + + @Override + public void paint(Graphics aContext) { + Graphics2D g2d = (Graphics2D) aContext; + + g2d.setColor(Color.WHITE); + g2d.fillRect(0, 0, getWidth(), getHeight()); + + Font font = new Font(Font.DIALOG, Font.PLAIN, 9); + FontRenderContext frc = g2d.getFontRenderContext(); + String str = "Where is the strikethrough?"; + AttributedString as = new AttributedString(str); + as.addAttribute(TextAttribute.FONT, font); + as.addAttribute(TextAttribute.STRIKETHROUGH, TextAttribute.STRIKETHROUGH_ON); + AttributedCharacterIterator aci = as.getIterator(); + TextLayout tl = new TextLayout(aci, frc); + float delta = (float) (Math.ceil(tl.getAscent() + tl.getDescent() + tl.getLeading()) + .1); + float y = delta - .1f; + g2d.setColor(Color.BLACK); + for (int i = 0; i < 11; ++i) { + tl.draw(g2d, 10f, y); + y += delta; + } + } +} diff -Nru openjdk-17-17.0.17+10/test/jdk/java/awt/print/Dialog/DialogType.java openjdk-17-17.0.18+8/test/jdk/java/awt/print/Dialog/DialogType.java --- openjdk-17-17.0.17+10/test/jdk/java/awt/print/Dialog/DialogType.java 2025-10-13 07:48:04.000000000 +0000 +++ openjdk-17-17.0.18+8/test/jdk/java/awt/print/Dialog/DialogType.java 2026-01-15 15:23:06.000000000 +0000 @@ -1,5 +1,5 @@ /* - * Copyright (c) 2007, 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 @@ -26,49 +26,63 @@ * @bug 6568874 * @key printer * @summary Verify the native dialog works with attribute sets. - * @run main/manual=yesno DialogType + * @library /java/awt/regtesthelpers /test/lib + * @build PassFailJFrame + * @run main/manual DialogType */ -import java.awt.print.*; -import javax.print.attribute.*; -import javax.print.attribute.standard.*; +import java.awt.print.PrinterJob; + +import javax.print.attribute.Attribute; +import javax.print.attribute.HashPrintRequestAttributeSet; +import javax.print.attribute.PrintRequestAttributeSet; +import javax.print.attribute.standard.DialogTypeSelection; + +import jtreg.SkippedException; public class DialogType { + private static PrinterJob job; - static String[] instructions = { - "This test assumes and requires that you have a printer installed", - "It verifies that the dialogs behave properly when using new API", - "to optionally select a native dialog where one is present.", - "Two dialogs are shown in succession.", - "The test passes as long as no exceptions are thrown, *AND*", - "if running on Windows only, the first dialog is a native windows", - "control which differs in appearance from the second dialog", - "" - }; - - public static void main(String[] args) { - - for (int i=0;i"}, the * instructions are displayed as HTML, as supported by Swing, which - * provides richer formatting options. + * provides richer formatting options. To handle navigating links in the + * instructions, call {@link Builder#hyperlinkListener} to install a listener. *

* The instructions are displayed in a text component with word-wrapping * so that there's no horizontal scroll bar. If the text doesn't fit, a @@ -592,6 +594,7 @@ frame.add(createInstructionUIPanel(instructions, testTimeOut, rows, columns, + null, false, false, 0), BorderLayout.CENTER); @@ -610,6 +613,7 @@ createInstructionUIPanel(builder.instructions, builder.testTimeOut, builder.rows, builder.columns, + builder.hyperlinkListener, builder.screenCapture, builder.addLogArea, builder.logAreaRows); @@ -631,6 +635,7 @@ private static JComponent createInstructionUIPanel(String instructions, long testTimeOut, int rows, int columns, + HyperlinkListener hyperlinkListener, boolean enableScreenCapture, boolean addLogArea, int logAreaRows) { @@ -643,6 +648,9 @@ JTextComponent text = instructions.startsWith("") ? configureHTML(instructions, rows, columns) : configurePlainText(instructions, rows, columns); + if (hyperlinkListener != null && text instanceof JEditorPane ep) { + ep.addHyperlinkListener(hyperlinkListener); + } text.setEditable(false); text.setBorder(createTextBorder()); text.setCaretPosition(0); @@ -716,7 +724,7 @@ // Reduce the list default margins styles.addRule("ol, ul { margin-left-ltr: 30; margin-left-rtl: 30 }"); // Make the size of code (and other elements) the same as other text - styles.addRule("code, kbd, samp, pre { font-size: inherit }"); + styles.addRule("code, kbd, samp, pre { font-size: inherit; background: #DDD; }"); return text; } @@ -1398,6 +1406,7 @@ private int rows; private int columns; private boolean screenCapture; + private HyperlinkListener hyperlinkListener; private boolean addLogArea; private int logAreaRows = 10; @@ -1478,6 +1487,18 @@ return this; } + /** + * Sets a {@link HyperlinkListener} for navigating links inside + * the instructions pane. + * + * @param hyperlinkListener the listener + * @return this builder + */ + public Builder hyperlinkListener(HyperlinkListener hyperlinkListener) { + this.hyperlinkListener = hyperlinkListener; + return this; + } + public Builder screenCapture() { this.screenCapture = true; return this; diff -Nru openjdk-17-17.0.17+10/test/jdk/java/beans/Introspector/DefaultMethodBeanPropertyTest.java openjdk-17-17.0.18+8/test/jdk/java/beans/Introspector/DefaultMethodBeanPropertyTest.java --- openjdk-17-17.0.17+10/test/jdk/java/beans/Introspector/DefaultMethodBeanPropertyTest.java 2025-10-13 07:48:04.000000000 +0000 +++ openjdk-17-17.0.18+8/test/jdk/java/beans/Introspector/DefaultMethodBeanPropertyTest.java 2026-01-15 15:23:06.000000000 +0000 @@ -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 @@ -23,20 +23,26 @@ /* * @test - * @bug 8071693 + * @bug 8071693 8347826 * @summary Verify that the Introspector finds default methods inherited * from interfaces */ +import java.beans.BeanInfo; import java.beans.IntrospectionException; import java.beans.Introspector; +import java.beans.MethodDescriptor; import java.beans.PropertyDescriptor; +import java.beans.SimpleBeanInfo; import java.lang.reflect.Method; +import java.util.Arrays; import java.util.Collection; import java.util.HashSet; import java.util.NavigableSet; +import java.util.Objects; import java.util.Set; import java.util.stream.Collectors; +import java.util.stream.Stream; public class DefaultMethodBeanPropertyTest { @@ -78,11 +84,17 @@ } public static void testScenario1() { + verifyMethods(D1.class, + "public static int DefaultMethodBeanPropertyTest$A1.getStaticValue()", + "public default int DefaultMethodBeanPropertyTest$A1.getValue()", + "public java.lang.Integer DefaultMethodBeanPropertyTest$D1.getFoo()", + "public java.lang.Float DefaultMethodBeanPropertyTest$D1.getObj()" + ); verifyProperties(D1.class, - "getClass", // inherited method - "getValue", // inherited default method - "getFoo", // overridden interface method - "getObj" // overridden default method + "public final native java.lang.Class java.lang.Object.getClass()", + "public default int DefaultMethodBeanPropertyTest$A1.getValue()", + "public java.lang.Integer DefaultMethodBeanPropertyTest$D1.getFoo()", + "public java.lang.Float DefaultMethodBeanPropertyTest$D1.getObj()" ); } @@ -108,9 +120,12 @@ } public static void testScenario2() { + verifyMethods(D2.class, + "public default java.lang.Object DefaultMethodBeanPropertyTest$A2.getFoo()" + ); verifyProperties(D2.class, - "getClass", - "getFoo" + "public final native java.lang.Class java.lang.Object.getClass()", + "public default java.lang.Object DefaultMethodBeanPropertyTest$A2.getFoo()" ); } @@ -144,60 +159,404 @@ } public static void testScenario3() { + verifyMethods(D3.class, + "public java.util.NavigableSet DefaultMethodBeanPropertyTest$D3.getFoo()" + ); verifyProperties(D3.class, - "getClass", - "getFoo" + "public final native java.lang.Class java.lang.Object.getClass()", + "public java.util.NavigableSet DefaultMethodBeanPropertyTest$D3.getFoo()" ); } -// Helper methods +////////////////////////////////////// +// // +// SCENARIO 4 // +// // +////////////////////////////////////// - public static void verifyProperties(Class type, String... getterNames) { + public interface A4 { + default Object getDefault0() { + return null; + } + default Object getDefault1() { + return null; + } + default Object getDefault2() { + return null; + } + default Object getDefault3() { + return null; + } + Object getNonDefault(); + } - // Gather expected properties - final HashSet expected = new HashSet<>(); - for (String methodName : getterNames) { - final String suffix = methodName.substring(3); - final String propName = Introspector.decapitalize(suffix); - final Method getter; + public class B4 implements A4 { + @Override + public Object getDefault1() { + return new B4(); + } + @Override + public String getDefault2() { + return null; + } + @Override + public Float getDefault3() { + return null; + } + public Long getNonDefault() { + return null; + } + } + + public static void testScenario4() { + verifyMethods(B4.class, + "public default java.lang.Object DefaultMethodBeanPropertyTest$A4.getDefault0()", + "public java.lang.Object DefaultMethodBeanPropertyTest$B4.getDefault1()", + "public java.lang.String DefaultMethodBeanPropertyTest$B4.getDefault2()", + "public java.lang.Float DefaultMethodBeanPropertyTest$B4.getDefault3()", + "public java.lang.Long DefaultMethodBeanPropertyTest$B4.getNonDefault()" + ); + verifyProperties(B4.class, + "public final native java.lang.Class java.lang.Object.getClass()", + "public default java.lang.Object DefaultMethodBeanPropertyTest$A4.getDefault0()", + "public java.lang.Object DefaultMethodBeanPropertyTest$B4.getDefault1()", + "public java.lang.String DefaultMethodBeanPropertyTest$B4.getDefault2()", + "public java.lang.Float DefaultMethodBeanPropertyTest$B4.getDefault3()", + "public java.lang.Long DefaultMethodBeanPropertyTest$B4.getNonDefault()" + ); + } + +////////////////////////////////////// +// // +// SCENARIO 5 // +// // +////////////////////////////////////// + + public interface A5 { + public default void setParentFoo(Integer num) { + } + public default void setFoo(String num) { + } + public static int getStaticValue() { + return 0; + } + private int getPrivateValue() { + return 0; + } + } + + public class B5 implements A5 { + public void setFoo(Number num) { + } + public void setLocalFoo(Long num) { + } + public static int getStaticValue() { + return 0; + } + } + + public static void testScenario5() { + verifyMethods(B5.class, + "public static int DefaultMethodBeanPropertyTest$B5.getStaticValue()", + "public default void DefaultMethodBeanPropertyTest$A5.setFoo(java.lang.String)", + "public default void DefaultMethodBeanPropertyTest$A5.setParentFoo(java.lang.Integer)", + "public void DefaultMethodBeanPropertyTest$B5.setFoo(java.lang.Number)", + "public void DefaultMethodBeanPropertyTest$B5.setLocalFoo(java.lang.Long)" + ); + verifyProperties(B5.class, + "public final native java.lang.Class java.lang.Object.getClass()", + "public default void DefaultMethodBeanPropertyTest$A5.setParentFoo(java.lang.Integer)", + "public void DefaultMethodBeanPropertyTest$B5.setFoo(java.lang.Number)", + "public void DefaultMethodBeanPropertyTest$B5.setLocalFoo(java.lang.Long)" + ); + } + +////////////////////////////////////// +// // +// SCENARIO 6 // +// // +////////////////////////////////////// + + public class A6 { + public void setParentFoo(Integer num) { + } + public void setFoo(Integer num) { + } + public static int getStaticValue() { + return 0; + } + private int getPrivateValue() { + return 0; + } + } + + public class B6 extends A6 { + public void setFoo(String num) { + } + public void setLocalFoo(Long num) { + } + public static int getStaticValue() { + return 0; + } + } + + public static void testScenario6() { + verifyMethods(B6.class, + "public static int DefaultMethodBeanPropertyTest$B6.getStaticValue()", + "public void DefaultMethodBeanPropertyTest$A6.setFoo(java.lang.Integer)", + "public void DefaultMethodBeanPropertyTest$A6.setParentFoo(java.lang.Integer)", + "public void DefaultMethodBeanPropertyTest$B6.setFoo(java.lang.String)", + "public void DefaultMethodBeanPropertyTest$B6.setLocalFoo(java.lang.Long)" + ); + verifyProperties(B6.class, + "public final native java.lang.Class java.lang.Object.getClass()", + "public void DefaultMethodBeanPropertyTest$A6.setParentFoo(java.lang.Integer)", + "public void DefaultMethodBeanPropertyTest$B6.setFoo(java.lang.String)", + "public void DefaultMethodBeanPropertyTest$B6.setLocalFoo(java.lang.Long)" + ); + } + +////////////////////////////////////// +// // +// SCENARIO 7 // +// // +////////////////////////////////////// + + interface A7 { + T getValue(); + } + + interface B7 { + Runnable getValue(); + } + + interface AB7 extends B7, A7 { + Runnable getValue(); + } + + abstract class D7 implements AB7 { + public void setValue(Runnable value) { + } + } + + public static void testScenario7() { + verifyMethods(D7.class, + "public void DefaultMethodBeanPropertyTest$D7.setValue(java.lang.Runnable)" + ); + verifyProperties(D7.class, + "public final native java.lang.Class java.lang.Object.getClass()", + "public void DefaultMethodBeanPropertyTest$D7.setValue(java.lang.Runnable)" + ); + } + +////////////////////////////////////// +// // +// SCENARIO 8 // +// // +////////////////////////////////////// + + public interface A8 { + public default void setFoo(Float num) { + } + public default void setFoo2(Integer num) { + } + } + public interface B8 extends A8 { + public default void setFoo(Integer num) { + } + public default void setFoo2(Float num) { + } + } + + public class C8 implements B8 { + } + + public static void testScenario8() { + verifyMethods(C8.class, + "public default void DefaultMethodBeanPropertyTest$A8.setFoo(java.lang.Float)", + "public default void DefaultMethodBeanPropertyTest$A8.setFoo2(java.lang.Integer)", + "public default void DefaultMethodBeanPropertyTest$B8.setFoo(java.lang.Integer)", + "public default void DefaultMethodBeanPropertyTest$B8.setFoo2(java.lang.Float)" + ); + verifyProperties(C8.class, + "public final native java.lang.Class java.lang.Object.getClass()", + "public default void DefaultMethodBeanPropertyTest$B8.setFoo(java.lang.Integer)", + "public default void DefaultMethodBeanPropertyTest$B8.setFoo2(java.lang.Float)" + ); + } + +////////////////////////////////////// +// // +// SCENARIO 9 // +// // +////////////////////////////////////// + + public class A9 { + public void setFoo(Object value) { + } + public void setFoo(String value) { + } + public void setFoo2(Object value) { + } + public void setFoo2(Integer value) { + } + // For the same setters with inconvertible arg types PropertyInfo behavior is undefined. + // public void setLocalFoo3(Long num) { } + // public void setLocalFoo3(Float num) { } + } + + public static void testScenario9() { + verifyMethods(A9.class, + "public void DefaultMethodBeanPropertyTest$A9.setFoo(java.lang.String)", + "public void DefaultMethodBeanPropertyTest$A9.setFoo(java.lang.Object)", + "public void DefaultMethodBeanPropertyTest$A9.setFoo2(java.lang.Integer)", + "public void DefaultMethodBeanPropertyTest$A9.setFoo2(java.lang.Object)" + ); + verifyProperties(A9.class, + "public final native java.lang.Class java.lang.Object.getClass()", + "public void DefaultMethodBeanPropertyTest$A9.setFoo(java.lang.String)", + "public void DefaultMethodBeanPropertyTest$A9.setFoo2(java.lang.Integer)" + ); + } + +////////////////////////////////////// +// // +// SCENARIO 10 // +// // +////////////////////////////////////// + + public static class A10 { + public Object getProp() { + return null; + } + } + + public static interface B10 { + Object getProp(); + } + + public static class C10_1 extends A10 implements B10 { + } + + public static class C10_2 extends A10 implements B10 { + } + + public static class A10BeanInfo extends SimpleBeanInfo { + public MethodDescriptor[] getMethodDescriptors() { try { - getter = type.getMethod(methodName); - } catch (NoSuchMethodException e) { - throw new Error("unexpected error", e); + Class params[] = {}; + MethodDescriptor md = new MethodDescriptor(A10.class.getDeclaredMethod("getProp", params)); + md.setDisplayName("display name"); + MethodDescriptor res[] = { md }; + return res; + } catch (Exception exception) { + throw new Error("unexpected exception", exception); } - final PropertyDescriptor propDesc; + } + } + + public static class C10_1BeanInfo extends SimpleBeanInfo { + public BeanInfo[] getAdditionalBeanInfo() { + try { + BeanInfo res[] = { + Introspector.getBeanInfo(A10.class), + Introspector.getBeanInfo(B10.class) + }; + return res; + } catch (IntrospectionException exception) { + throw new Error("unexpected exception", exception); + } + } + } + + public static class C10_2BeanInfo extends SimpleBeanInfo { + public BeanInfo[] getAdditionalBeanInfo() { try { - propDesc = new PropertyDescriptor(propName, getter, null); - } catch (IntrospectionException e) { - throw new Error("unexpected error", e); + BeanInfo res[] = { + Introspector.getBeanInfo(B10.class), + Introspector.getBeanInfo(A10.class) + }; + return res; + } catch (IntrospectionException exception) { + throw new Error("unexpected exception", exception); } - expected.add(propDesc); } + } - // Verify properties can be found directly - expected.stream() - .map(PropertyDescriptor::getName) - .filter(name -> BeanUtils.getPropertyDescriptor(type, name) == null) - .findFirst() - .ifPresent(name -> { - throw new Error("property \"" + name + "\" not found in " + type); - }); - - // Gather actual properties - final Set actual = - Set.of(BeanUtils.getPropertyDescriptors(type)); + public static void testScenario10() { + { + var md = getMethodDescriptor(C10_1.class, A10.class, "getProp"); + assertEquals("display name", md.getDisplayName(), "getDisplayName()"); + } + { + var md = getMethodDescriptor(C10_2.class, A10.class, "getProp"); + assertEquals("display name", md.getDisplayName(), "getDisplayName()"); + } + } - // Verify the two sets are the same +// Helper methods + + private static void verifyEquality(String title, Set expected, Set actual) { if (!actual.equals(expected)) { - throw new Error("mismatch: " + type - + "\nACTUAL:\n " - + actual.stream() - .map(Object::toString) - .collect(Collectors.joining("\n ")) - + "\nEXPECTED:\n " - + expected.stream() - .map(Object::toString) - .collect(Collectors.joining("\n "))); + throw new Error(title + " mismatch: " + + "\nACTUAL:\n " + + actual.stream() + .map(Object::toString) + .collect(Collectors.joining("\n ")) + + "\nEXPECTED:\n " + + expected.stream() + .map(Object::toString) + .collect(Collectors.joining("\n "))); + } + } + + public static void verifyProperties(Class type, String... methodNames) { + try { + final Set expected = new HashSet<>(Arrays.asList(methodNames)); + final Set actual = Arrays + .stream(Introspector.getBeanInfo(type) + .getPropertyDescriptors()) + .flatMap(pd -> Stream.of(pd.getReadMethod(), pd.getWriteMethod())) + .filter(Objects::nonNull) + .map((Method m) -> m.toString()) + .collect(Collectors.toSet()); + verifyEquality("properties", expected, actual); + } catch (IntrospectionException exception) { + throw new Error("unexpected exception", exception); + } + } + + public static void verifyMethods(Class type, String... methodNames) { + try { + final Set expected = new HashSet<>(Arrays.asList(methodNames)); + final Set actual = Arrays + .stream(Introspector.getBeanInfo(type, Object.class) + .getMethodDescriptors()) + .map(MethodDescriptor::getMethod) + .map(Method::toString) + .collect(Collectors.toSet()); + verifyEquality("methods", expected, actual); + } catch (IntrospectionException exception) { + throw new Error("unexpected exception", exception); + } + } + + private static MethodDescriptor getMethodDescriptor(Class cls, Class stop, String name) { + try { + for (var md : Introspector.getBeanInfo(cls, stop).getMethodDescriptors()) { + if (md.getName().equals(name)) { + return md; + } + } + return null; + } catch (IntrospectionException exception) { + throw new Error("unexpected exception", exception); + } + } + + private static void assertEquals(Object expected, Object actual, String msg) { + if (!expected.equals(actual)) { + throw new Error(msg + ":\nACTUAL: " + actual + "\nEXPECTED: " + expected); } } @@ -207,5 +566,12 @@ testScenario1(); testScenario2(); testScenario3(); + testScenario4(); + testScenario5(); + testScenario6(); + testScenario7(); + testScenario8(); + testScenario9(); + testScenario10(); } } diff -Nru openjdk-17-17.0.17+10/test/jdk/java/io/File/MacPathTest.java openjdk-17-17.0.18+8/test/jdk/java/io/File/MacPathTest.java --- openjdk-17-17.0.17+10/test/jdk/java/io/File/MacPathTest.java 2025-10-13 07:48:04.000000000 +0000 +++ openjdk-17-17.0.18+8/test/jdk/java/io/File/MacPathTest.java 2026-01-15 15:23:06.000000000 +0000 @@ -1,5 +1,5 @@ /* - * Copyright (c) 2008, 2017, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2008, 2025, Oracle and/or its affiliates. All rights reserved. * 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,11 @@ * questions. */ +/* + * This test is launched via a ProcessBuilder in the main test MacPath which + * includes a @requires (os.family == "mac") tag so no operating system + * conditional is applied here. + */ import java.io.File; import java.io.FileInputStream; import java.io.FileOutputStream; @@ -29,10 +34,6 @@ public class MacPathTest { public static void main(String args[]) throws Throwable { - String osname = System.getProperty("os.name"); - if (!osname.contains("OS X") && !osname.contains("Darwin")) - return; - // English test("TestDir_apple", // test dir "dir_macosx", // dir diff -Nru openjdk-17-17.0.17+10/test/jdk/java/io/File/MaxPath.java openjdk-17-17.0.18+8/test/jdk/java/io/File/MaxPath.java --- openjdk-17-17.0.17+10/test/jdk/java/io/File/MaxPath.java 2025-10-13 07:48:04.000000000 +0000 +++ openjdk-17-17.0.18+8/test/jdk/java/io/File/MaxPath.java 2026-01-15 15:23:06.000000000 +0000 @@ -1,5 +1,5 @@ /* - * Copyright (c) 2008, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2008, 2025, Oracle and/or its affiliates. All rights reserved. * 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,16 +24,14 @@ /* @test @bug 6481955 @summary Path length less than MAX_PATH (260) works on Windows + @requires (os.family == "windows") */ -import java.io.*; +import java.io.File; +import java.io.IOException; public class MaxPath { public static void main(String[] args) throws Exception { - String osName = System.getProperty("os.name"); - if (!osName.startsWith("Windows")) { - return; - } int MAX_PATH = 260; String dir = new File(".").getAbsolutePath() + "\\"; String padding = "1234567890123456789012345678901234567890012345678900123456789001234567890012345678900123456789001234567890012345678900123456789001234567890012345678900123456789001234567890012345678900123456789001234567890012345678900123456789001234567890012345678900123456789001234567890012345678900123456789001234567890012345678900123456789001234567890"; diff -Nru openjdk-17-17.0.17+10/test/jdk/java/io/File/MaxPathLength.java openjdk-17-17.0.18+8/test/jdk/java/io/File/MaxPathLength.java --- openjdk-17-17.0.17+10/test/jdk/java/io/File/MaxPathLength.java 2025-10-13 07:48:04.000000000 +0000 +++ openjdk-17-17.0.18+8/test/jdk/java/io/File/MaxPathLength.java 2026-01-15 15:23:06.000000000 +0000 @@ -1,5 +1,5 @@ /* - * Copyright (c) 2002, 2013, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2002, 2025, Oracle and/or its affiliates. All rights reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * * This code is free software; you can redistribute it and/or modify it @@ -24,30 +24,31 @@ /* @test @bug 4759207 4403166 4165006 4403166 6182812 6274272 7160013 @summary Test to see if win32 path length can be greater than 260 + @library .. /test/lib */ import java.io.*; import java.nio.file.Files; import java.nio.file.Path; import java.nio.file.DirectoryNotEmptyException; +import jdk.test.lib.Platform; public class MaxPathLength { private static String sep = File.separator; private static String pathComponent = sep + "aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa"; private static String fileName = - "areallylongfilenamethatsforsur"; - private static boolean isWindows = false; + "areallylongfilenamethatsforsur"; private static final int MAX_LENGTH = 256; + private static final int FILE_EXISTS_SLEEP = 100; + + private static final int MAX_PATH_COMPONENTS_WINDOWS = 20; + private static int counter = 0; public static void main(String[] args) throws Exception { - String osName = System.getProperty("os.name"); - if (osName.startsWith("Windows")) { - isWindows = true; - } for (int i = 4; i < 7; i++) { String name = fileName; @@ -59,14 +60,9 @@ } // test long paths on windows - // And these long pathes cannot be handled on Solaris and Mac platforms - if (isWindows) { - String name = fileName; - while (name.length() < MAX_LENGTH) { - testLongPath (20, name, false); - testLongPath (20, name, true); - name = getNextName(name); - } + // And these long paths cannot be handled on Linux and Mac platforms + if (Platform.isWindows()) { + testLongPath(); } } @@ -146,7 +142,7 @@ if (flist == null || !fn.equals(flist[0].getName())) throw new RuntimeException ("File.listFiles() failed"); - if (isWindows && + if (Platform.isWindows() && !fu.getCanonicalPath().equals(f.getCanonicalPath())) throw new RuntimeException ("getCanonicalPath() failed"); @@ -162,7 +158,7 @@ String abPath = f.getAbsolutePath(); if (!abPath.startsWith("\\\\") || abPath.length() < 1093) { - throw new RuntimeException ("File.renameTo() failed for lenth=" + throw new RuntimeException ("File.renameTo() failed for length=" + abPath.length()); } } else { @@ -189,7 +185,7 @@ Files.deleteIfExists(p); // Test if the file is really deleted and wait for 1 second at most for (int j = 0; j < 10 && Files.exists(p); j++) { - Thread.sleep(100); + Thread.sleep(FILE_EXISTS_SLEEP); } } catch (DirectoryNotEmptyException ex) { // Give up the clean-up, let jtreg handle it. @@ -199,4 +195,13 @@ } } } -} + + private static void testLongPath () throws Exception { + String name = fileName; + while (name.length() < MAX_LENGTH) { + testLongPath(MAX_PATH_COMPONENTS_WINDOWS, name, false); + testLongPath(MAX_PATH_COMPONENTS_WINDOWS, name, true); + name = getNextName(name); + } + } +} \ No newline at end of file diff -Nru openjdk-17-17.0.17+10/test/jdk/java/io/File/SymLinks.java openjdk-17-17.0.18+8/test/jdk/java/io/File/SymLinks.java --- openjdk-17-17.0.17+10/test/jdk/java/io/File/SymLinks.java 2025-10-13 07:48:04.000000000 +0000 +++ openjdk-17-17.0.18+8/test/jdk/java/io/File/SymLinks.java 2026-01-15 15:23:06.000000000 +0000 @@ -1,5 +1,5 @@ /* - * Copyright (c) 2009, 2012, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2009, 2025, Oracle and/or its affiliates. All rights reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * * This code is free software; you can redistribute it and/or modify it @@ -281,22 +281,7 @@ assertTrue(link2dir.isDirectory()); assertTrue(link2link2dir.isDirectory()); - // on Windows we test with the DOS hidden attribute set - if (System.getProperty("os.name").startsWith("Windows")) { - DosFileAttributeView view = Files - .getFileAttributeView(file.toPath(), DosFileAttributeView.class); - view.setHidden(true); - try { - assertTrue(file.isHidden()); - assertTrue(link2file.isHidden()); - assertTrue(link2link2file.isHidden()); - } finally { - view.setHidden(false); - } - assertFalse(file.isHidden()); - assertFalse(link2file.isHidden()); - assertFalse(link2link2file.isHidden()); - } + testDOSHiddenAttributes(); header("length"); @@ -362,6 +347,26 @@ } } + static void testDOSHiddenAttributes() throws IOException { + // on Windows we test with the DOS hidden attribute set + if (System.getProperty("os.name").startsWith("Windows")) { + header("testDOSHiddenAttributes"); + DosFileAttributeView view = Files + .getFileAttributeView(file.toPath(), DosFileAttributeView.class); + view.setHidden(true); + try { + assertTrue(file.isHidden()); + assertTrue(link2file.isHidden()); + assertTrue(link2link2file.isHidden()); + } finally { + view.setHidden(false); + } + assertFalse(file.isHidden()); + assertFalse(link2file.isHidden()); + assertFalse(link2link2file.isHidden()); + } + } + public static void main(String[] args) throws IOException { if (supportsSymLinks(top)) { try { diff -Nru openjdk-17-17.0.17+10/test/jdk/java/io/File/TimeZoneLastModified.java openjdk-17-17.0.18+8/test/jdk/java/io/File/TimeZoneLastModified.java --- openjdk-17-17.0.17+10/test/jdk/java/io/File/TimeZoneLastModified.java 2025-10-13 07:48:04.000000000 +0000 +++ openjdk-17-17.0.18+8/test/jdk/java/io/File/TimeZoneLastModified.java 2026-01-15 15:23:06.000000000 +0000 @@ -1,5 +1,5 @@ /* - * Copyright (c) 2017, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2017, 2025, Oracle and/or its affiliates. All rights reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * * This code is free software; you can redistribute it and/or modify it @@ -23,15 +23,14 @@ /* * @test - * @bug 6212869 + * @bug 6212869 8347841 * @summary Determine if lastModified() works after TimeZone.setDefault() * @run main/othervm TimeZoneLastModified */ import java.io.File; -import java.util.Date; +import java.time.ZoneId; import java.util.TimeZone; -import java.text.SimpleDateFormat; public class TimeZoneLastModified { // Tue, 04 Jun 2002 13:56:50.002 GMT @@ -40,6 +39,9 @@ public static void main(String[] args) throws Throwable { int failures = test(null); for (String timeZoneID : TimeZone.getAvailableIDs()) { + if (ZoneId.SHORT_IDS.containsKey(timeZoneID)) { + continue; + } failures += test(timeZoneID); } if (failures != 0) { diff -Nru openjdk-17-17.0.17+10/test/jdk/java/io/File/WinDeviceName.java openjdk-17-17.0.18+8/test/jdk/java/io/File/WinDeviceName.java --- openjdk-17-17.0.17+10/test/jdk/java/io/File/WinDeviceName.java 2025-10-13 07:48:04.000000000 +0000 +++ openjdk-17-17.0.18+8/test/jdk/java/io/File/WinDeviceName.java 2026-01-15 15:23:06.000000000 +0000 @@ -1,5 +1,5 @@ /* - * Copyright (c) 2006, 2013, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2006, 2025, Oracle and/or its affiliates. All rights reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * * This code is free software; you can redistribute it and/or modify it @@ -24,6 +24,7 @@ /* @test @bug 6176051 4858457 @summary Check whether reserved names are handled correctly on Windows + @requires (os.family == "windows") */ import java.io.File; @@ -38,10 +39,6 @@ }; public static void main(String[] args) { String osName = System.getProperty("os.name"); - if (!osName.startsWith("Windows")) { - return; - } - for (int i = 0; i < devnames.length; i++) { String names[] = { devnames[i], devnames[i] + ".TXT", devnames[i].toLowerCase(), diff -Nru openjdk-17-17.0.17+10/test/jdk/java/io/File/WinMaxPath.java openjdk-17-17.0.18+8/test/jdk/java/io/File/WinMaxPath.java --- openjdk-17-17.0.17+10/test/jdk/java/io/File/WinMaxPath.java 2025-10-13 07:48:04.000000000 +0000 +++ openjdk-17-17.0.18+8/test/jdk/java/io/File/WinMaxPath.java 2026-01-15 15:23:06.000000000 +0000 @@ -1,5 +1,5 @@ /* - * Copyright (c) 2006, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2006, 2025, Oracle and/or its affiliates. All rights reserved. * 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,12 @@ @bug 6384833 @summary Check if appropriate exception FileNotFoundException gets thrown when the pathlengh exceeds the limit. + @requires (os.family == "windows") */ import java.io.*; public class WinMaxPath { public static void main(String[] args) throws Exception { - String osName = System.getProperty("os.name"); - if (!osName.startsWith("Windows")) { - return; - } try { char[] as = new char[65000]; java.util.Arrays.fill(as, 'a'); diff -Nru openjdk-17-17.0.17+10/test/jdk/java/io/File/WinSpecialFiles.java openjdk-17-17.0.18+8/test/jdk/java/io/File/WinSpecialFiles.java --- openjdk-17-17.0.17+10/test/jdk/java/io/File/WinSpecialFiles.java 2025-10-13 07:48:04.000000000 +0000 +++ openjdk-17-17.0.18+8/test/jdk/java/io/File/WinSpecialFiles.java 2026-01-15 15:23:06.000000000 +0000 @@ -1,5 +1,5 @@ /* - * Copyright (c) 2006, 2018, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2006, 2025, Oracle and/or its affiliates. All rights reserved. * 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,12 @@ @bug 6192331 6348207 8202076 @summary Check if File.exists()/length() works correctly on Windows special files hiberfil.sys and pagefile.sys + @requires (os.family == "windows") */ import java.io.File; public class WinSpecialFiles { public static void main(String[] args) throws Exception { - String osName = System.getProperty("os.name"); - if (!osName.startsWith("Windows")) { - return; - } File root = new File("C:\\"); File[] dir = root.listFiles(); for (int i = 0; i < dir.length; i++) { diff -Nru openjdk-17-17.0.17+10/test/jdk/java/io/FileDescriptor/Sync.java openjdk-17-17.0.18+8/test/jdk/java/io/FileDescriptor/Sync.java --- openjdk-17-17.0.17+10/test/jdk/java/io/FileDescriptor/Sync.java 2025-10-13 07:48:04.000000000 +0000 +++ openjdk-17-17.0.18+8/test/jdk/java/io/FileDescriptor/Sync.java 2026-01-15 15:23:06.000000000 +0000 @@ -38,7 +38,7 @@ public class Sync { static final String TEST_DIR = System.getProperty("test.dir", "."); - static final int TRIES = 10_000; + static final int TRIES = 1_000; public static void testWith(File file) throws Exception { try (FileOutputStream fos = new FileOutputStream(file)) { diff -Nru openjdk-17-17.0.17+10/test/jdk/java/io/FileOutputStream/ManyFiles.java openjdk-17-17.0.18+8/test/jdk/java/io/FileOutputStream/ManyFiles.java --- openjdk-17-17.0.17+10/test/jdk/java/io/FileOutputStream/ManyFiles.java 2025-10-13 07:48:04.000000000 +0000 +++ openjdk-17-17.0.18+8/test/jdk/java/io/FileOutputStream/ManyFiles.java 2026-01-15 15:23:06.000000000 +0000 @@ -1,5 +1,5 @@ /* - * Copyright (c) 2003, 2020, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2003, 2025, Oracle and/or its affiliates. All rights reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * * This code is free software; you can redistribute it and/or modify it @@ -37,15 +37,6 @@ static int NUM_FILES = 2050; public static void main(String args[]) throws Exception { - // Linux does not yet allow opening this many files; Solaris - // 8 requires an explicit allocation of more file descriptors - // to succeed. Since this test is written to check for a - // Windows capability it is much simpler to only run it - // on that platform. - String osName = System.getProperty("os.name"); - if (osName.startsWith("Linux")) - return; - for (int n = 0; n < NUM_FILES; n++) { File f = new File("file" + count++); files.add(f); diff -Nru openjdk-17-17.0.17+10/test/jdk/java/io/InputStreamReader/StatefulDecoderNearEOF.java openjdk-17-17.0.18+8/test/jdk/java/io/InputStreamReader/StatefulDecoderNearEOF.java --- openjdk-17-17.0.17+10/test/jdk/java/io/InputStreamReader/StatefulDecoderNearEOF.java 1970-01-01 00:00:00.000000000 +0000 +++ openjdk-17-17.0.18+8/test/jdk/java/io/InputStreamReader/StatefulDecoderNearEOF.java 2026-01-15 15:23:06.000000000 +0000 @@ -0,0 +1,79 @@ +/* + * Copyright (c) 2022, Oracle and/or its affiliates. All rights reserved. + * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. + * + * This code is free software; you can redistribute it and/or modify it + * under the terms of the GNU General Public License version 2 only, as + * published by the Free Software Foundation. + * + * This code is distributed in the hope that it will be useful, but WITHOUT + * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or + * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License + * version 2 for more details (a copy is included in the LICENSE file that + * accompanied this code). + * + * You should have received a copy of the GNU General Public License version + * 2 along with this work; if not, write to the Free Software Foundation, + * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. + * + * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA + * or visit www.oracle.com if you need additional information or have any + * questions. + */ + +/* @test + * @bug 8292043 + * @run testng StatefulDecoderNearEOF + * @summary Check MalformedInputException is thrown with stateful decoders + * with malformed input before EOF + */ + +import java.io.ByteArrayInputStream; +import java.io.IOException; +import java.io.InputStreamReader; +import java.io.UncheckedIOException; +import java.nio.charset.CodingErrorAction; +import java.nio.charset.MalformedInputException; +import java.nio.charset.StandardCharsets; +import java.util.stream.IntStream; + +import org.testng.annotations.DataProvider; +import org.testng.annotations.Test; +import static org.testng.Assert.assertEquals; +import static org.testng.Assert.assertThrows; + +@Test +public class StatefulDecoderNearEOF { + + @DataProvider + public Object[][] inputs() { + return new Object[][] { + // BOM, followed by High surrogate (in UTF-16LE). + // First read() should throw an exception. + {new byte[] {(byte)0xff, (byte)0xfe, 0, (byte)0xd8}, 0}, + + // BOM, followed by 'A', 'B', 'C', then by High surrogate (in UTF-16LE). + // Fourth read() should throw an exception. + {new byte[] {(byte)0xff, (byte)0xfe, (byte)0x41, 0, (byte)0x42, 0, (byte)0x43, 0, 0, (byte)0xd8}, 3}, + }; + } + + @Test (dataProvider = "inputs") + public void testStatefulDecoderNearEOF(byte[] ba, int numSucessReads) throws IOException { + try (var r = new InputStreamReader( + new ByteArrayInputStream(ba), + StandardCharsets.UTF_16.newDecoder().onMalformedInput(CodingErrorAction.REPORT))) { + // Issue read() as many as numSucessReads which should not fail + IntStream.rangeClosed(1, numSucessReads).forEach(i -> { + try { + assertEquals(r.read(), (int)ba[i * 2]); + } catch (IOException e) { + throw new UncheckedIOException(e); + } + }); + + // Final dangling high surrogate should throw an exception + assertThrows(MalformedInputException.class, () -> r.read()); + } + } +} diff -Nru openjdk-17-17.0.17+10/test/jdk/java/io/ObjectStreamClass/ObjectStreamClassCaching.java openjdk-17-17.0.18+8/test/jdk/java/io/ObjectStreamClass/ObjectStreamClassCaching.java --- openjdk-17-17.0.17+10/test/jdk/java/io/ObjectStreamClass/ObjectStreamClassCaching.java 2025-10-13 07:48:04.000000000 +0000 +++ openjdk-17-17.0.18+8/test/jdk/java/io/ObjectStreamClass/ObjectStreamClassCaching.java 2026-01-15 15:23:06.000000000 +0000 @@ -1,5 +1,5 @@ /* - * Copyright (c) 2021, 2022, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2021, 2024, Oracle and/or its affiliates. All rights reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * * This code is free software; you can redistribute it and/or modify it @@ -69,41 +69,13 @@ /* * @test id=Serial * @requires vm.gc.Serial - * @bug 8277072 + * @bug 8277072 8327180 * @library /test/lib/ * @summary ObjectStreamClass caches keep ClassLoaders alive (Serial GC) * @run testng/othervm -Xmx64m -XX:+UseSerialGC ObjectStreamClassCaching */ public class ObjectStreamClassCaching { - /** - * Test methods execute in same VM and are ordered by name. - * We test effectiveness 1st which is sensitive to previous allocations when ZGC is used. - */ - @Test - public void test1CacheEffectiveness() throws Exception { - var list = new ArrayList<>(); - var ref1 = lookupObjectStreamClass(TestClass1.class); - var ref2 = newWeakRef(); - boolean oome = false; - try { - while (!ref2.refersTo(null)) { - list.add(new byte[1024 * 1024 * 1]); // 1 MiB chunks - System.out.println("1MiB allocated..."); - Thread.sleep(5L); - } - } catch (OutOfMemoryError e) { - // release - list = null; - oome = true; - } - assertFalse(oome, "WeakReference was not cleared although memory was pressed hard"); - assertFalse(ref1.refersTo(null), - "Cache lost entry together with WeakReference being cleared although memory was not under pressure"); - System.gc(); - Thread.sleep(100L); - } - @Test public void test2CacheReleaseUnderMemoryPressure() throws Exception { var list = new ArrayList<>(); diff -Nru openjdk-17-17.0.17+10/test/jdk/java/io/pathNames/win32/SJIS.java openjdk-17-17.0.18+8/test/jdk/java/io/pathNames/win32/SJIS.java --- openjdk-17-17.0.17+10/test/jdk/java/io/pathNames/win32/SJIS.java 2025-10-13 07:48:04.000000000 +0000 +++ openjdk-17-17.0.18+8/test/jdk/java/io/pathNames/win32/SJIS.java 2026-01-15 15:23:06.000000000 +0000 @@ -1,5 +1,5 @@ /* - * Copyright (c) 1998, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 1998, 2025, Oracle and/or its affiliates. All rights reserved. * 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,15 @@ @summary Check that pathnames containing double-byte characters are not corrupted by win32 path processing @author Mark Reinhold + @library /test/lib */ -import java.io.*; +import java.io.File; +import java.io.FileOutputStream; +import java.io.IOException; +import java.io.OutputStream; + +import jtreg.SkippedException; public class SJIS { @@ -47,8 +53,11 @@ /* This test is only valid on win32 systems that use the SJIS encoding */ if (File.separatorChar != '\\') return; - String enc = System.getProperty("file.encoding"); - if ((enc == null) || !enc.equals("SJIS")) return; + String enc = System.getProperty("native.encoding"); + if ((enc == null) || !enc.equals("MS932")) { + throw new SkippedException( + "native.encoding(%s) is not MS932".formatted(enc)); + } File f = new File("\u30BD"); if (f.exists()) rm(f); diff -Nru openjdk-17-17.0.17+10/test/jdk/java/lang/ClassLoader/securityManager/ClassLoaderTest.java openjdk-17-17.0.18+8/test/jdk/java/lang/ClassLoader/securityManager/ClassLoaderTest.java --- openjdk-17-17.0.17+10/test/jdk/java/lang/ClassLoader/securityManager/ClassLoaderTest.java 2025-10-13 07:48:04.000000000 +0000 +++ openjdk-17-17.0.18+8/test/jdk/java/lang/ClassLoader/securityManager/ClassLoaderTest.java 2026-01-15 15:23:06.000000000 +0000 @@ -1,5 +1,5 @@ /* - * Copyright (c) 2017, 2018, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2017, 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 @@ -26,9 +26,12 @@ * @bug 8168423 * @summary Different types of ClassLoader running with(out) SecurityManager and * (in)valid security policy file. + * @modules java.base/jdk.internal.org.objectweb.asm + * java.base/jdk.internal.org.objectweb.asm.commons + * java.base/jdk.internal.module * @library /test/lib - * @modules java.base/jdk.internal.module * @build jdk.test.lib.util.JarUtils + * jdk.test.lib.util.ModuleInfoWriter * @build TestClassLoader TestClient * @run main ClassLoaderTest -noPolicy * @run main ClassLoaderTest -validPolicy @@ -48,9 +51,9 @@ import java.util.Collections; import java.util.LinkedList; import java.util.List; -import jdk.internal.module.ModuleInfoWriter; import jdk.test.lib.process.ProcessTools; import jdk.test.lib.util.JarUtils; +import jdk.test.lib.util.ModuleInfoWriter; public class ClassLoaderTest { diff -Nru openjdk-17-17.0.17+10/test/jdk/java/lang/Math/FusedMultiplyAddTests.java openjdk-17-17.0.18+8/test/jdk/java/lang/Math/FusedMultiplyAddTests.java --- openjdk-17-17.0.17+10/test/jdk/java/lang/Math/FusedMultiplyAddTests.java 2025-10-13 07:48:04.000000000 +0000 +++ openjdk-17-17.0.18+8/test/jdk/java/lang/Math/FusedMultiplyAddTests.java 2026-01-15 15:23:06.000000000 +0000 @@ -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 @@ -23,7 +23,7 @@ /* * @test - * @bug 4851642 8253409 + * @bug 4851642 8253409 8362207 * @summary Tests for Math.fusedMac and StrictMath.fusedMac. * @build Tests * @build FusedMultiplyAddTests @@ -352,8 +352,9 @@ {1.0f+Math.ulp(1.0f), 1.0f+Math.ulp(1.0f), -1.0f-2.0f*Math.ulp(1.0f), Math.ulp(1.0f)*Math.ulp(1.0f)}, - // Double-rounding if done in double precision - {0x1.fffffep23f, 0x1.000004p28f, 0x1.fep5f, 0x1.000002p52f} + // Double-rounding if done in double precision and/or double fma + {0x1.fffffep23f, 0x1.000004p28f, 0x1.fep5f, 0x1.000002p52f}, + {0x1.001p0f, 0x1.001p0f, 0x1p-100f, 0x1.002002p0f}, }; for (float[] testCase: testCases) diff -Nru openjdk-17-17.0.17+10/test/jdk/java/lang/ModuleTests/AnnotationsTest.java openjdk-17-17.0.18+8/test/jdk/java/lang/ModuleTests/AnnotationsTest.java --- openjdk-17-17.0.17+10/test/jdk/java/lang/ModuleTests/AnnotationsTest.java 2025-10-13 07:48:04.000000000 +0000 +++ openjdk-17-17.0.18+8/test/jdk/java/lang/ModuleTests/AnnotationsTest.java 2026-01-15 15:23:06.000000000 +0000 @@ -1,5 +1,5 @@ /* - * Copyright (c) 2016, 2020, 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 @@ -36,7 +36,6 @@ import java.util.List; import java.util.Set; -import jdk.internal.module.ModuleInfoWriter; import jdk.internal.org.objectweb.asm.AnnotationVisitor; import jdk.internal.org.objectweb.asm.Attribute; import jdk.internal.org.objectweb.asm.ClassReader; @@ -44,6 +43,7 @@ import jdk.internal.org.objectweb.asm.ClassWriter; import jdk.internal.org.objectweb.asm.Opcodes; import jdk.internal.org.objectweb.asm.commons.ModuleTargetAttribute; +import jdk.test.lib.util.ModuleInfoWriter; import org.testng.annotations.Test; import static org.testng.Assert.*; @@ -53,6 +53,8 @@ * @modules java.base/jdk.internal.org.objectweb.asm * java.base/jdk.internal.org.objectweb.asm.commons * java.base/jdk.internal.module + * @library /test/lib + * @build jdk.test.lib.util.ModuleInfoWriter * @run testng AnnotationsTest * @summary Basic test of annotations on modules */ diff -Nru openjdk-17-17.0.17+10/test/jdk/java/lang/ProcessBuilder/Basic.java openjdk-17-17.0.18+8/test/jdk/java/lang/ProcessBuilder/Basic.java --- openjdk-17-17.0.17+10/test/jdk/java/lang/ProcessBuilder/Basic.java 2025-10-13 07:48:04.000000000 +0000 +++ openjdk-17-17.0.18+8/test/jdk/java/lang/ProcessBuilder/Basic.java 2026-01-15 15:23:06.000000000 +0000 @@ -27,7 +27,7 @@ * 5026830 5023243 5070673 4052517 4811767 6192449 6397034 6413313 * 6464154 6523983 6206031 4960438 6631352 6631966 6850957 6850958 * 4947220 7018606 7034570 4244896 5049299 8003488 8054494 8058464 - * 8067796 8224905 8263729 8265173 8272600 8231297 8282219 + * 8067796 8224905 8263729 8265173 8272600 8231297 8282219 8368192 * @key intermittent * @summary Basic tests for Process and Environment Variable code * @modules java.base/java.lang:open @@ -762,30 +762,29 @@ return Pattern.compile(regex).matcher(str).find(); } - private static String matchAndExtract(String str, String regex) { - Matcher matcher = Pattern.compile(regex).matcher(str); - if (matcher.find()) { - return matcher.group(); - } else { - return ""; - } + // Return the string with the matching regex removed + private static String matchAndRemove(String str, String regex) { + return Pattern.compile(regex) + .matcher(str) + .replaceAll(""); } /* Only used for Mac OS X -- - * Mac OS X (may) add the variable __CF_USER_TEXT_ENCODING to an empty - * environment. The environment variable JAVA_MAIN_CLASS_ may also - * be set in Mac OS X. - * Remove them both from the list of env variables + * Mac OS X (may) add the variables: __CF_USER_TEXT_ENCODING, JAVA_MAIN_CLASS_, + * and TMPDIR. + * Remove them from the list of env variables */ private static String removeMacExpectedVars(String vars) { // Check for __CF_USER_TEXT_ENCODING - String cleanedVars = vars.replace("__CF_USER_TEXT_ENCODING=" - +cfUserTextEncoding+",",""); + String cleanedVars = matchAndRemove(vars, + "__CF_USER_TEXT_ENCODING=" + cfUserTextEncoding + ","); // Check for JAVA_MAIN_CLASS_ - String javaMainClassStr - = matchAndExtract(cleanedVars, - "JAVA_MAIN_CLASS_\\d+=Basic.JavaChild,"); - return cleanedVars.replace(javaMainClassStr,""); + cleanedVars = matchAndRemove(cleanedVars, + "JAVA_MAIN_CLASS_\\d+=Basic.JavaChild,"); + // Check and remove TMPDIR + cleanedVars = matchAndRemove(cleanedVars, + "TMPDIR=[^,]*,"); + return cleanedVars; } /* Only used for AIX -- diff -Nru openjdk-17-17.0.17+10/test/jdk/java/lang/System/LoggerFinder/internal/BootstrapLogger/BootstrapLoggerTest.java openjdk-17-17.0.18+8/test/jdk/java/lang/System/LoggerFinder/internal/BootstrapLogger/BootstrapLoggerTest.java --- openjdk-17-17.0.17+10/test/jdk/java/lang/System/LoggerFinder/internal/BootstrapLogger/BootstrapLoggerTest.java 2025-10-13 07:48:04.000000000 +0000 +++ openjdk-17-17.0.18+8/test/jdk/java/lang/System/LoggerFinder/internal/BootstrapLogger/BootstrapLoggerTest.java 2026-01-15 15:23:06.000000000 +0000 @@ -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 @@ -39,6 +39,7 @@ import java.security.ProtectionDomain; import java.util.concurrent.atomic.AtomicBoolean; import java.util.List; +import java.util.Locale; import java.util.Optional; import java.util.Set; import java.util.stream.Collectors; @@ -88,6 +89,8 @@ } public static void main(String[] args) throws Exception { + Locale savedLocale = Locale.getDefault(); + Locale.setDefault(Locale.US); if (args == null || args.length == 0) { args = new String[] { TestCase.SECURE_AND_WAIT.name() }; } @@ -373,6 +376,7 @@ LogStream.err.println("Not checking executor termination for " + test); } } finally { + Locale.setDefault(savedLocale); SimplePolicy.allowAll.set(Boolean.FALSE); } LogStream.err.println(test.name() + ": PASSED"); diff -Nru openjdk-17-17.0.17+10/test/jdk/java/lang/module/ClassFileVersionsTest.java openjdk-17-17.0.18+8/test/jdk/java/lang/module/ClassFileVersionsTest.java --- openjdk-17-17.0.17+10/test/jdk/java/lang/module/ClassFileVersionsTest.java 2025-10-13 07:48:04.000000000 +0000 +++ openjdk-17-17.0.18+8/test/jdk/java/lang/module/ClassFileVersionsTest.java 2026-01-15 15:23:06.000000000 +0000 @@ -1,5 +1,5 @@ /* - * Copyright (c) 2017, 2021, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2017, 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 @@ -23,7 +23,11 @@ /** * @test - * @modules java.base/jdk.internal.module + * @modules java.base/jdk.internal.org.objectweb.asm + * java.base/jdk.internal.org.objectweb.asm.commons + * java.base/jdk.internal.module + * @library /test/lib + * @build jdk.test.lib.util.ModuleInfoWriter * @run testng ClassFileVersionsTest * @summary Test parsing of module-info.class with different class file versions */ @@ -36,7 +40,7 @@ import static java.lang.module.ModuleDescriptor.Requires.Modifier.*; -import jdk.internal.module.ModuleInfoWriter; +import jdk.test.lib.util.ModuleInfoWriter; import org.testng.annotations.DataProvider; import org.testng.annotations.Test; diff -Nru openjdk-17-17.0.17+10/test/jdk/java/lang/module/ConfigurationTest.java openjdk-17-17.0.18+8/test/jdk/java/lang/module/ConfigurationTest.java --- openjdk-17-17.0.17+10/test/jdk/java/lang/module/ConfigurationTest.java 2025-10-13 07:48:04.000000000 +0000 +++ openjdk-17-17.0.18+8/test/jdk/java/lang/module/ConfigurationTest.java 2026-01-15 15:23:06.000000000 +0000 @@ -1,5 +1,5 @@ /* - * Copyright (c) 2014, 2020, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2014, 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 @@ -23,10 +23,13 @@ /** * @test - * @library /test/lib * @modules java.base/jdk.internal.access + * java.base/jdk.internal.org.objectweb.asm + * java.base/jdk.internal.org.objectweb.asm.commons * java.base/jdk.internal.module + * @library /test/lib * @build ConfigurationTest + * jdk.test.lib.util.ModuleInfoWriter * jdk.test.lib.util.ModuleUtils * @run testng ConfigurationTest * @summary Basic tests for java.lang.module.Configuration @@ -47,10 +50,10 @@ import java.util.List; import java.util.Set; +import jdk.test.lib.util.ModuleInfoWriter; import jdk.test.lib.util.ModuleUtils; import jdk.internal.access.SharedSecrets; -import jdk.internal.module.ModuleInfoWriter; import jdk.internal.module.ModuleTarget; import org.testng.annotations.DataProvider; import org.testng.annotations.Test; diff -Nru openjdk-17-17.0.17+10/test/jdk/java/lang/module/ModuleDescriptorTest.java openjdk-17-17.0.18+8/test/jdk/java/lang/module/ModuleDescriptorTest.java --- openjdk-17-17.0.17+10/test/jdk/java/lang/module/ModuleDescriptorTest.java 2025-10-13 07:48:04.000000000 +0000 +++ openjdk-17-17.0.18+8/test/jdk/java/lang/module/ModuleDescriptorTest.java 2026-01-15 15:23:06.000000000 +0000 @@ -1,5 +1,5 @@ /* - * Copyright (c) 2013, 2018, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2013, 2023, Oracle and/or its affiliates. All rights reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * * This code is free software; you can redistribute it and/or modify it @@ -24,7 +24,11 @@ /** * @test * @modules java.base/jdk.internal.access + * java.base/jdk.internal.org.objectweb.asm + * java.base/jdk.internal.org.objectweb.asm.commons * java.base/jdk.internal.module + * @library /test/lib + * @build jdk.test.lib.util.ModuleInfoWriter * @run testng ModuleDescriptorTest * @summary Basic test for java.lang.module.ModuleDescriptor and its builder */ @@ -56,7 +60,7 @@ import jdk.internal.access.JavaLangModuleAccess; import jdk.internal.access.SharedSecrets; -import jdk.internal.module.ModuleInfoWriter; +import jdk.test.lib.util.ModuleInfoWriter; import org.testng.annotations.DataProvider; import org.testng.annotations.Test; import static org.testng.Assert.*; diff -Nru openjdk-17-17.0.17+10/test/jdk/java/lang/module/ModuleFinderTest.java openjdk-17-17.0.18+8/test/jdk/java/lang/module/ModuleFinderTest.java --- openjdk-17-17.0.17+10/test/jdk/java/lang/module/ModuleFinderTest.java 2025-10-13 07:48:04.000000000 +0000 +++ openjdk-17-17.0.18+8/test/jdk/java/lang/module/ModuleFinderTest.java 2026-01-15 15:23:06.000000000 +0000 @@ -1,5 +1,5 @@ /* - * Copyright (c) 2015, 2016, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2015, 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 @@ -23,8 +23,11 @@ /** * @test - * @modules java.base/jdk.internal.module - * @build ModuleFinderTest + * @modules java.base/jdk.internal.org.objectweb.asm + * java.base/jdk.internal.org.objectweb.asm.commons + * java.base/jdk.internal.module + * @library /test/lib + * @build ModuleFinderTest jdk.test.lib.util.ModuleInfoWriter * @run testng ModuleFinderTest * @summary Basic tests for java.lang.module.ModuleFinder */ @@ -45,7 +48,7 @@ import java.util.jar.JarOutputStream; import java.util.stream.Collectors; -import jdk.internal.module.ModuleInfoWriter; +import jdk.test.lib.util.ModuleInfoWriter; import org.testng.annotations.Test; import static org.testng.Assert.*; diff -Nru openjdk-17-17.0.17+10/test/jdk/java/lang/module/ModuleNamesTest.java openjdk-17-17.0.18+8/test/jdk/java/lang/module/ModuleNamesTest.java --- openjdk-17-17.0.17+10/test/jdk/java/lang/module/ModuleNamesTest.java 2025-10-13 07:48:04.000000000 +0000 +++ openjdk-17-17.0.18+8/test/jdk/java/lang/module/ModuleNamesTest.java 2026-01-15 15:23:06.000000000 +0000 @@ -1,5 +1,5 @@ /* - * Copyright (c) 2016, 2018, 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 @@ -24,7 +24,11 @@ /** * @test * @modules java.base/jdk.internal.access + * java.base/jdk.internal.org.objectweb.asm + * java.base/jdk.internal.org.objectweb.asm.commons * java.base/jdk.internal.module + * @library /test/lib + * @build jdk.test.lib.util.ModuleInfoWriter * @run testng ModuleNamesTest * @summary Basic test of reading a module-info.class with module names that * are legal in class files but not legal in the Java Language @@ -42,7 +46,8 @@ import java.util.Set; import jdk.internal.access.SharedSecrets; -import jdk.internal.module.ModuleInfoWriter; + +import jdk.test.lib.util.ModuleInfoWriter; import org.testng.annotations.DataProvider; import org.testng.annotations.Test; diff -Nru openjdk-17-17.0.17+10/test/jdk/java/lang/module/MultiReleaseJarTest.java openjdk-17-17.0.18+8/test/jdk/java/lang/module/MultiReleaseJarTest.java --- openjdk-17-17.0.17+10/test/jdk/java/lang/module/MultiReleaseJarTest.java 2025-10-13 07:48:04.000000000 +0000 +++ openjdk-17-17.0.18+8/test/jdk/java/lang/module/MultiReleaseJarTest.java 2026-01-15 15:23:06.000000000 +0000 @@ -1,5 +1,5 @@ /* - * Copyright (c) 2016, 2017, 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 @@ -23,9 +23,13 @@ /** * @test + * @modules java.base/jdk.internal.org.objectweb.asm + * java.base/jdk.internal.org.objectweb.asm.commons + * java.base/jdk.internal.module * @library /test/lib - * @modules java.base/jdk.internal.module - * @build MultiReleaseJarTest jdk.test.lib.util.JarUtils + * @build MultiReleaseJarTest + * jdk.test.lib.util.JarUtils + * jdk.test.lib.util.ModuleInfoWriter * @run testng MultiReleaseJarTest * @run testng/othervm -Djdk.util.jar.enableMultiRelease=false MultiReleaseJarTest * @summary Basic test of modular JARs as multi-release JARs @@ -54,7 +58,7 @@ import java.util.jar.Attributes; import java.util.jar.Manifest; -import jdk.internal.module.ModuleInfoWriter; +import jdk.test.lib.util.ModuleInfoWriter; import jdk.test.lib.util.JarUtils; import org.testng.annotations.Test; diff -Nru openjdk-17-17.0.17+10/test/jdk/java/net/CookieStoreTest.java openjdk-17-17.0.18+8/test/jdk/java/net/CookieStoreTest.java --- openjdk-17-17.0.17+10/test/jdk/java/net/CookieStoreTest.java 1970-01-01 00:00:00.000000000 +0000 +++ openjdk-17-17.0.18+8/test/jdk/java/net/CookieStoreTest.java 2026-01-15 15:23:06.000000000 +0000 @@ -0,0 +1,113 @@ +/* + * 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. + */ + +import java.net.CookieManager; +import java.net.CookieStore; +import java.net.HttpCookie; +import java.net.URI; +import java.util.ArrayList; +import java.util.List; + +import org.junit.jupiter.params.ParameterizedTest; +import org.junit.jupiter.params.provider.Arguments; +import org.junit.jupiter.params.provider.MethodSource; +import static org.junit.jupiter.api.Assertions.assertEquals; +import static org.junit.jupiter.api.Assertions.assertNotNull; +import static org.junit.jupiter.api.Assertions.assertThrows; + +/* + * @test + * @bug 8365086 + * @summary verify that the implementation of java.net.CookieStore works + * as expected + * @run junit CookieStoreTest + */ +class CookieStoreTest { + + // neither the scheme, host nor the port matters in this test + private static final URI COOKIE_TEST_URI = URI.create("https://127.0.0.1:12345"); + + static List cookieStores() { + final List params = new ArrayList<>(); + // empty CookieStore + params.add(Arguments.of(new CookieManager().getCookieStore(), true)); + + final CookieStore cookieStore = new CookieManager().getCookieStore(); + cookieStore.add(COOKIE_TEST_URI, new HttpCookie("foo", "bar")); + // non-empty CookieStore + params.add(Arguments.of(cookieStore, false)); + + return params; + } + + /* + * Verify that the List returned by CookieStore.getURIs() is immutable. + */ + @ParameterizedTest + @MethodSource("cookieStores") + void testImmutableGetURIs(final CookieStore cookieStore, final boolean expectEmpty) { + final List uris = cookieStore.getURIs(); + assertNotNull(uris, "CookieStore.getURIs() returned null"); + assertEquals(expectEmpty, uris.isEmpty(), "CookieStore.getURIs() returned: " + uris); + assertImmutableList(uris, COOKIE_TEST_URI); + } + + /* + * Verify that the List returned by CookieStore.getCookies() is immutable. + */ + @ParameterizedTest + @MethodSource("cookieStores") + void testImmutableGetCookies(final CookieStore cookieStore, final boolean expectEmpty) { + final List cookies = cookieStore.getCookies(); + assertNotNull(cookies, "CookieStore.getCookies() returned null"); + assertEquals(expectEmpty, cookies.isEmpty(), "CookieStore.getCookies() returned: " + cookies); + assertImmutableList(cookies, new HttpCookie("hello", "world")); + } + + /* + * Verify that the List returned by CookieStore.get(URI) is immutable. + */ + @ParameterizedTest + @MethodSource("cookieStores") + void testImmutableGetCookiesForURI(final CookieStore cookieStore, final boolean expectEmpty) { + final List cookies = cookieStore.get(COOKIE_TEST_URI); + assertNotNull(cookies, "CookieStore.get(URI) returned null"); + assertEquals(expectEmpty, cookies.isEmpty(), "CookieStore.get(URI) returned: " + cookies); + assertImmutableList(cookies, new HttpCookie("hello", "world")); + } + + /* + * Verifies that the attempt to modify the contents of the list will fail + * due to the list being immutable. + */ + private static void assertImmutableList(final List list, T elementToAddOrRemove) { + // the list is expected to be immutable, so each of these operations must fail + assertThrows(UnsupportedOperationException.class, () -> list.add(elementToAddOrRemove)); + assertThrows(UnsupportedOperationException.class, () -> list.remove(elementToAddOrRemove)); + assertThrows(UnsupportedOperationException.class, list::clear); + // even try the replace operation when the list isn't empty + if (!list.isEmpty()) { + assertThrows(UnsupportedOperationException.class, () -> list.set(0, elementToAddOrRemove)); + } + } +} diff -Nru openjdk-17-17.0.17+10/test/jdk/java/net/NetworkInterface/IPv4Only.java openjdk-17-17.0.18+8/test/jdk/java/net/NetworkInterface/IPv4Only.java --- openjdk-17-17.0.17+10/test/jdk/java/net/NetworkInterface/IPv4Only.java 2025-10-13 07:48:04.000000000 +0000 +++ openjdk-17-17.0.18+8/test/jdk/java/net/NetworkInterface/IPv4Only.java 2026-01-15 15:23:06.000000000 +0000 @@ -1,5 +1,5 @@ /* - * Copyright (c) 2010, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2010, 2025, Oracle and/or its affiliates. All rights reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * * This code is free software; you can redistribute it and/or modify it @@ -29,12 +29,18 @@ */ -import java.net.*; -import java.util.*; + import jdk.test.lib.net.IPSupport; +import java.net.Inet6Address; +import java.net.InetAddress; +import java.net.NetworkInterface; +import java.net.SocketException; +import java.util.Enumeration; + public class IPv4Only { public static void main(String[] args) throws Exception { + IPSupport.printPlatformSupport(System.out); if (IPSupport.hasIPv4()) { System.out.println("Testing IPv4"); Enumeration nifs = NetworkInterface.getNetworkInterfaces(); @@ -43,7 +49,7 @@ Enumeration addrs = nif.getInetAddresses(); while (addrs.hasMoreElements()) { InetAddress hostAddr = addrs.nextElement(); - if ( hostAddr instanceof Inet6Address ){ + if (hostAddr instanceof Inet6Address){ throw new RuntimeException( "NetworkInterfaceV6List failed - found v6 address " + hostAddr.getHostAddress() ); } } diff -Nru openjdk-17-17.0.17+10/test/jdk/java/net/httpclient/CancelRequestTest.java openjdk-17-17.0.18+8/test/jdk/java/net/httpclient/CancelRequestTest.java --- openjdk-17-17.0.17+10/test/jdk/java/net/httpclient/CancelRequestTest.java 2025-10-13 07:48:04.000000000 +0000 +++ openjdk-17-17.0.18+8/test/jdk/java/net/httpclient/CancelRequestTest.java 2026-01-15 15:23:06.000000000 +0000 @@ -35,9 +35,7 @@ */ // * -Dseed=3582896013206826205L // * -Dseed=5784221742235559231L -import com.sun.net.httpserver.HttpServer; -import com.sun.net.httpserver.HttpsConfigurator; -import com.sun.net.httpserver.HttpsServer; +import jdk.internal.net.http.common.OperationTrackers.Tracker; import jdk.test.lib.RandomFactory; import jdk.test.lib.net.SimpleSSLContext; import org.testng.ITestContext; @@ -55,8 +53,6 @@ import java.io.InputStream; import java.io.OutputStream; import java.lang.ref.Reference; -import java.net.InetAddress; -import java.net.InetSocketAddress; import java.net.URI; import java.net.http.HttpClient; import java.net.http.HttpConnectTimeoutException; @@ -79,16 +75,15 @@ import java.util.concurrent.atomic.AtomicLong; import java.util.concurrent.atomic.AtomicReference; import java.util.stream.Collectors; -import java.util.stream.Stream; import jdk.httpclient.test.lib.common.HttpServerAdapters; -import jdk.httpclient.test.lib.http2.Http2TestServer; -import static java.lang.System.arraycopy; import static java.lang.System.out; +import static java.lang.System.err; import static java.net.http.HttpClient.Version.HTTP_1_1; import static java.net.http.HttpClient.Version.HTTP_2; import static java.nio.charset.StandardCharsets.UTF_8; import static org.testng.Assert.assertEquals; +import static org.testng.Assert.assertFalse; import static org.testng.Assert.assertTrue; public class CancelRequestTest implements HttpServerAdapters { @@ -177,19 +172,19 @@ } @AfterClass - static final void printFailedTests(ITestContext context) { + static void printFailedTests(ITestContext context) { out.println("\n========================="); var failed = context.getFailedTests().getAllResults().stream() - .collect(Collectors.toMap(r -> name(r), ITestResult::getThrowable)); + .collect(Collectors.toMap(CancelRequestTest::name, ITestResult::getThrowable)); FAILURES.putAll(failed); try { out.printf("%n%sCreated %d servers and %d clients%n", now(), serverCount.get(), clientCount.get()); if (FAILURES.isEmpty()) return; out.println("Failed tests: "); - FAILURES.entrySet().forEach((e) -> { - out.printf("\t%s: %s%n", e.getKey(), e.getValue()); - e.getValue().printStackTrace(out); + FAILURES.forEach((key, value) -> { + out.printf("\t%s: %s%n", key, value); + value.printStackTrace(out); }); if (tasksFailed) { System.out.println("WARNING: Some tasks failed"); @@ -305,6 +300,7 @@ for (int i=0; i< ITERATION_COUNT; i++) { if (!sameClient || client == null) client = newHttpClient(sameClient); + Tracker tracker = TRACKER.getTracker(client); HttpRequest req = HttpRequest.newBuilder(URI.create(uri)) .GET() @@ -324,7 +320,7 @@ out.println("cf2 after cancel: " + cf2); try { String body = cf2.get().body(); - assertEquals(body, Stream.of(BODY.split("\\|")).collect(Collectors.joining())); + assertEquals(body, String.join("", BODY.split("\\|"))); throw new AssertionError("Expected CancellationException not received"); } catch (ExecutionException x) { out.println("Got expected exception: " + x); @@ -345,23 +341,31 @@ // completed yet - so wait for it here... try { String body = response.get().body(); - assertEquals(body, Stream.of(BODY.split("\\|")).collect(Collectors.joining())); + assertEquals(body, String.join("", BODY.split("\\|"))); if (mayInterruptIfRunning) { // well actually - this could happen... In which case we'll need to // increase the latency in the server handler... throw new AssertionError("Expected Exception not received"); } } catch (ExecutionException x) { - assertEquals(response.isDone(), true); + assertTrue(response.isDone()); Throwable wrapped = x.getCause(); - assertTrue(CancellationException.class.isAssignableFrom(wrapped.getClass())); - Throwable cause = wrapped.getCause(); - out.println("CancellationException cause: " + x); - assertTrue(IOException.class.isAssignableFrom(cause.getClass())); - if (cause instanceof HttpConnectTimeoutException) { + Throwable cause = wrapped; + if (mayInterruptIfRunning) { + assertTrue(CancellationException.class.isAssignableFrom(wrapped.getClass()), + "Unexpected exception: " + wrapped); + cause = wrapped.getCause(); + out.println("CancellationException cause: " + x); + if (cause instanceof HttpConnectTimeoutException) { + cause.printStackTrace(out); + throw new RuntimeException("Unexpected timeout exception", cause); + } + } + if (!IOException.class.isInstance(cause)) { + out.println("Unexpected cause: " + cause.getClass()); cause.printStackTrace(out); - throw new RuntimeException("Unexpected timeout exception", cause); } + assertTrue(IOException.class.isAssignableFrom(cause.getClass())); if (mayInterruptIfRunning) { out.println("Got expected exception: " + wrapped); out.println("\tcause: " + cause); @@ -372,20 +376,22 @@ } } - assertEquals(response.isDone(), true); - assertEquals(response.isCancelled(), false); + assertTrue(response.isDone()); + assertFalse(response.isCancelled()); assertEquals(cf1.isCancelled(), hasCancellationException); - assertEquals(cf2.isDone(), true); - assertEquals(cf2.isCancelled(), false); + assertTrue(cf2.isDone()); + assertFalse(cf2.isCancelled()); assertEquals(latch.getCount(), 0); - var error = TRACKER.check(1, + var error = TRACKER.check(tracker, 1000, (t) -> t.getOutstandingOperations() > 0 || t.getOutstandingSubscribers() > 0, "subscribers for testGetSendAsync(%s)\n\t step [%s]".formatted(req.uri(), i), false); Reference.reachabilityFence(client); if (error != null) throw error; } + assert client != null; + //if (!sameClient) client.close(); } @Test(dataProvider = "asyncurls") @@ -398,10 +404,11 @@ for (int i=0; i< ITERATION_COUNT; i++) { if (!sameClient || client == null) client = newHttpClient(sameClient); + Tracker tracker = TRACKER.getTracker(client); CompletableFuture> cancelFuture = new CompletableFuture<>(); - Iterable iterable = new Iterable() { + Iterable iterable = new Iterable<>() { @Override public Iterator iterator() { // this is dangerous @@ -436,7 +443,7 @@ out.println("cf2 after cancel: " + cf2); try { String body = cf2.get().body(); - assertEquals(body, Stream.of(BODY.split("\\|")).collect(Collectors.joining())); + assertEquals(body, String.join("", BODY.split("\\|"))); throw new AssertionError("Expected CancellationException not received"); } catch (ExecutionException x) { out.println("Got expected exception: " + x); @@ -457,14 +464,14 @@ // completed yet - so wait for it here... try { String body = response.get().body(); - assertEquals(body, Stream.of(BODY.split("\\|")).collect(Collectors.joining())); + assertEquals(body, String.join("", BODY.split("\\|"))); if (mayInterruptIfRunning) { // well actually - this could happen... In which case we'll need to // increase the latency in the server handler... throw new AssertionError("Expected Exception not received"); } } catch (ExecutionException x) { - assertEquals(response.isDone(), true); + assertTrue(response.isDone()); Throwable wrapped = x.getCause(); assertTrue(CancellationException.class.isAssignableFrom(wrapped.getClass())); Throwable cause = wrapped.getCause(); @@ -483,20 +490,22 @@ } } - assertEquals(response.isDone(), true); - assertEquals(response.isCancelled(), false); + assertTrue(response.isDone()); + assertFalse(response.isCancelled()); assertEquals(cf1.isCancelled(), hasCancellationException); - assertEquals(cf2.isDone(), true); - assertEquals(cf2.isCancelled(), false); + assertTrue(cf2.isDone()); + assertFalse(cf2.isCancelled()); assertEquals(latch.getCount(), 0); - var error = TRACKER.check(1, + var error = TRACKER.check(tracker, 1000, (t) -> t.getOutstandingOperations() > 0 || t.getOutstandingSubscribers() > 0, "subscribers for testPostSendAsync(%s)\n\t step [%s]".formatted(req.uri(), i), false); Reference.reachabilityFence(client); if (error != null) throw error; } + assert client != null; + //if (!sameClient) client.close(); } @Test(dataProvider = "urls") @@ -508,11 +517,15 @@ for (int i=0; i< ITERATION_COUNT; i++) { if (!sameClient || client == null) client = newHttpClient(sameClient); + Tracker tracker = TRACKER.getTracker(client); + Thread main = Thread.currentThread(); CompletableFuture interruptingThread = new CompletableFuture<>(); + var uriStr = uri + "/post/req=" + i; Runnable interrupt = () -> { Thread current = Thread.currentThread(); - out.printf("%s Interrupting main from: %s (%s)", now(), current, uri); + out.printf("%s Interrupting main from: %s (%s)%n", now(), current, uriStr); + err.printf("%s Interrupting main from: %s (%s)%n", now(), current, uriStr); interruptingThread.complete(current); main.interrupt(); }; @@ -523,42 +536,52 @@ return List.of(BODY.getBytes(UTF_8)).iterator(); }; - HttpRequest req = HttpRequest.newBuilder(URI.create(uri)) + HttpRequest req = HttpRequest.newBuilder(URI.create(uriStr)) .POST(HttpRequest.BodyPublishers.ofByteArrays(iterable)) .build(); String body = null; Exception failed = null; try { + out.println("Sending: " + uriStr); body = client.send(req, BodyHandlers.ofString()).body(); } catch (Exception x) { failed = x; } - + out.println(uriStr + ": got result or exception"); if (failed instanceof InterruptedException) { - out.println("Got expected exception: " + failed); + out.println(uriStr + ": Got expected exception: " + failed); } else if (failed instanceof IOException) { + out.println(uriStr + ": got IOException: " + failed); // that could be OK if the main thread was interrupted // from the main thread: the interrupt status could have // been caught by writing to the socket from the main // thread. - if (interruptingThread.get() == main) { - out.println("Accepting IOException: " + failed); + if (interruptingThread.isDone() && interruptingThread.get() == main) { + out.println(uriStr + ": Accepting IOException: " + failed); failed.printStackTrace(out); } else { + out.println(uriStr + ": unexpected exception: " + failed); throw failed; } } else if (failed != null) { - assertEquals(body, Stream.of(BODY.split("\\|")).collect(Collectors.joining())); + out.println(uriStr + ": unexpected exception: " + failed); throw failed; + } else { + assert failed == null; + out.println(uriStr + ": got body: " + body); + assertEquals(body, String.join("", BODY.split("\\|"))); } + out.println("next iteration"); - var error = TRACKER.check(1, + var error = TRACKER.check(tracker, 2000, (t) -> t.getOutstandingOperations() > 0 || t.getOutstandingSubscribers() > 0, "subscribers for testPostInterrupt(%s)\n\t step [%s]".formatted(req.uri(), i), false); Reference.reachabilityFence(client); if (error != null) throw error; } + assert client != null; + //if (!sameClient) client.close(); } diff -Nru openjdk-17-17.0.17+10/test/jdk/java/net/httpclient/ContentLengthHeaderTest.java openjdk-17-17.0.18+8/test/jdk/java/net/httpclient/ContentLengthHeaderTest.java --- openjdk-17-17.0.17+10/test/jdk/java/net/httpclient/ContentLengthHeaderTest.java 1970-01-01 00:00:00.000000000 +0000 +++ openjdk-17-17.0.18+8/test/jdk/java/net/httpclient/ContentLengthHeaderTest.java 2026-01-15 15:23:06.000000000 +0000 @@ -0,0 +1,232 @@ +/* + * Copyright (c) 2022, Oracle and/or its affiliates. All rights reserved. + * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. + * + * This code is free software; you can redistribute it and/or modify it + * under the terms of the GNU General Public License version 2 only, as + * published by the Free Software Foundation. + * + * This code is distributed in the hope that it will be useful, but WITHOUT + * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or + * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License + * version 2 for more details (a copy is included in the LICENSE file that + * accompanied this code). + * + * You should have received a copy of the GNU General Public License version + * 2 along with this work; if not, write to the Free Software Foundation, + * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. + * + * Please contact Oracle, 500 Oracle Pa6a7709320d28d8e1593b113fdf39ab583fca3687rkway, Redwood Shores, CA 94065 USA + * or visit www.oracle.com if you need additional information or have any + * questions. + */ + +/* + * @test + * @summary Tests that a Content-length header is not sent for GET requests + * that do not have a body. Also checks that the header is sent when + * a body is present on the GET request. + * @library /test/lib + * @bug 8283544 + * @run testng/othervm ContentLengthHeaderTest + */ + + +import com.sun.net.httpserver.HttpExchange; +import com.sun.net.httpserver.HttpHandler; +import com.sun.net.httpserver.HttpServer; +import org.testng.annotations.AfterTest; +import org.testng.annotations.BeforeTest; +import org.testng.annotations.Test; + +import java.io.IOException; +import java.io.InputStream; +import java.io.OutputStream; +import java.io.PrintStream; +import java.net.InetAddress; +import java.net.InetSocketAddress; +import java.net.ProxySelector; +import java.net.URI; +import java.net.URISyntaxException; +import java.net.http.HttpClient; +import java.net.http.HttpRequest; +import java.net.http.HttpResponse; +import jdk.test.lib.net.URIBuilder; + + +import static java.net.http.HttpClient.Version.HTTP_1_1; +import static java.nio.charset.StandardCharsets.UTF_8; +import static org.testng.Assert.assertEquals; + + +public class ContentLengthHeaderTest { + + final String NO_BODY_PATH = "/no_body"; + final String BODY_PATH = "/body"; + + static HttpServer testContentLengthServer; + static PrintStream testLog = System.err; + + HttpClient hc; + URI testContentLengthURI; + + @BeforeTest + public void setup() throws IOException, URISyntaxException { + InetSocketAddress sa = new InetSocketAddress(InetAddress.getLoopbackAddress(), 0); + testContentLengthServer = HttpServer.create(sa, 0); + + // Create handlers for tests that check for the presence of a Content-length header + testContentLengthServer.createContext(NO_BODY_PATH, new NoContentLengthHandler()); + testContentLengthServer.createContext(BODY_PATH, new ContentLengthHandler()); + testContentLengthURI = URIBuilder.newBuilder() + .scheme("http") + .loopback() + .port(testContentLengthServer.getAddress().getPort()) + .build(); + + testContentLengthServer.start(); + testLog.println("Server up at address: " + testContentLengthServer.getAddress()); + testLog.println("Request URI for Client: " + testContentLengthURI); + + hc = HttpClient.newBuilder() + .proxy(HttpClient.Builder.NO_PROXY) + .version(HTTP_1_1) + .build(); + } + + @AfterTest + public void teardown() { + if (testContentLengthServer != null) + testContentLengthServer.stop(0); + } + + @Test + // A GET request with no request body should have no Content-length header + public void getWithNoBody() throws IOException, InterruptedException { + testLog.println("Checking GET with no request body"); + HttpRequest req = HttpRequest.newBuilder() + .version(HTTP_1_1) + .GET() + .uri(URI.create(testContentLengthURI + NO_BODY_PATH)) + .build(); + HttpResponse resp = hc.send(req, HttpResponse.BodyHandlers.ofString(UTF_8)); + assertEquals(resp.statusCode(), 200, resp.body()); + } + + @Test + // A GET request with a request body should have a Content-length header + public void getWithBody() throws IOException, InterruptedException { + testLog.println("Checking GET with request body"); + HttpRequest req = HttpRequest.newBuilder() + .version(HTTP_1_1) + .method("GET", HttpRequest.BodyPublishers.ofString("GET Body")) + .uri(URI.create(testContentLengthURI + BODY_PATH)) + .build(); + HttpResponse resp = hc.send(req, HttpResponse.BodyHandlers.ofString(UTF_8)); + assertEquals(resp.statusCode(), 200, resp.body()); + } + + @Test + // A DELETE request with no request body should have no Content-length header + public void deleteWithNoBody() throws IOException, InterruptedException { + testLog.println("Checking DELETE with no request body"); + HttpRequest req = HttpRequest.newBuilder() + .version(HTTP_1_1) + .DELETE() + .uri(URI.create(testContentLengthURI + NO_BODY_PATH)) + .build(); + HttpResponse resp = hc.send(req, HttpResponse.BodyHandlers.ofString(UTF_8)); + assertEquals(resp.statusCode(), 200, resp.body()); + } + + @Test + // A DELETE request with a request body should have a Content-length header + public void deleteWithBody() throws IOException, InterruptedException { + testLog.println("Checking DELETE with request body"); + HttpRequest req = HttpRequest.newBuilder() + .version(HTTP_1_1) + .method("DELETE", HttpRequest.BodyPublishers.ofString("DELETE Body")) + .uri(URI.create(testContentLengthURI + BODY_PATH)) + .build(); + HttpResponse resp = hc.send(req, HttpResponse.BodyHandlers.ofString(UTF_8)); + assertEquals(resp.statusCode(), 200, resp.body()); + } + + /* + @Test + // A HEAD request with no request body should have no Content-length header + public void headWithNoBody() throws IOException, InterruptedException { + testLog.println("Checking HEAD with no request body"); + HttpRequest req = HttpRequest.newBuilder() + .version(HTTP_1_1) + .HEAD() + .uri(URI.create(testContentLengthURI + NO_BODY_PATH)) + .build(); + HttpResponse resp = hc.send(req, HttpResponse.BodyHandlers.ofString(UTF_8)); + assertEquals(resp.statusCode(), 200, resp.body()); + } + */ + + @Test + // A HEAD request with a request body should have a Content-length header + public void headWithBody() throws IOException, InterruptedException { + testLog.println("Checking HEAD with request body"); + HttpRequest req = HttpRequest.newBuilder() + .version(HTTP_1_1) + .method("HEAD", HttpRequest.BodyPublishers.ofString("HEAD Body")) + .uri(URI.create(testContentLengthURI + BODY_PATH)) + .build(); + // Sending this request invokes sendResponseHeaders which emits a warning about including + // a Content-length header with a HEAD request + HttpResponse resp = hc.send(req, HttpResponse.BodyHandlers.ofString(UTF_8)); + assertEquals(resp.statusCode(), 200, resp.body()); + } + + public static void handleResponse(HttpExchange ex, String body, int rCode) throws IOException { + try (InputStream is = ex.getRequestBody(); + OutputStream os = ex.getResponseBody()) { + is.readAllBytes(); + byte[] bytes = body.getBytes(UTF_8); + ex.sendResponseHeaders(rCode, bytes.length); + os.write(bytes); + } + } + + static class NoContentLengthHandler implements HttpHandler { + + @Override + public void handle(HttpExchange exchange) throws IOException { + testLog.println("NoContentLengthHandler: Received Headers " + exchange.getRequestHeaders().entrySet() + + " from " + exchange.getRequestMethod() + " request."); + String contentLength = exchange.getRequestHeaders().getFirst("Content-length"); + + // Check Content-length header was not set + if (contentLength == null) { + handleResponse(exchange, "Request completed",200); + } else { + String responseBody = exchange.getRequestMethod() + " request contained an unexpected " + + "Content-length header of value: " + exchange.getRequestHeaders().getFirst("Content-length"); + handleResponse(exchange, responseBody, 400); + } + } + } + + static class ContentLengthHandler implements HttpHandler { + + @Override + public void handle(HttpExchange exchange) throws IOException { + testLog.println("ContentLengthHandler: Received Headers " + exchange.getRequestHeaders().entrySet() + + " from " + exchange.getRequestMethod() + " request."); + String contentLength = exchange.getRequestHeaders().getFirst("Content-length"); + + // Check Content-length header was set + if (contentLength != null) { + handleResponse(exchange, "Request completed",200); + } else { + String responseBody = "Expected a Content-length header in " + + exchange.getRequestMethod() + " request but was not present."; + handleResponse(exchange, responseBody, 400); + } + } + } +} diff -Nru openjdk-17-17.0.17+10/test/jdk/java/net/httpclient/HttpsTunnelAuthTest.java openjdk-17-17.0.18+8/test/jdk/java/net/httpclient/HttpsTunnelAuthTest.java --- openjdk-17-17.0.17+10/test/jdk/java/net/httpclient/HttpsTunnelAuthTest.java 2025-10-13 07:48:04.000000000 +0000 +++ openjdk-17-17.0.18+8/test/jdk/java/net/httpclient/HttpsTunnelAuthTest.java 2026-01-15 15:23:06.000000000 +0000 @@ -37,12 +37,11 @@ import java.util.stream.Stream; import javax.net.ssl.SSLContext; import jdk.httpclient.test.lib.common.HttpServerAdapters; -import jdk.httpclient.test.lib.http2.Http2TestServer; import jdk.test.lib.net.SimpleSSLContext; import static java.lang.System.out; -/** +/* * @test * @bug 8262027 * @summary Verify that it's possible to handle proxy authentication manually @@ -62,7 +61,7 @@ //-Djdk.internal.httpclient.debug=true -Dtest.debug=true public class HttpsTunnelAuthTest implements HttpServerAdapters, AutoCloseable { - static final String data[] = { + static final String[] data = { "Lorem ipsum", "dolor sit amet", "consectetur adipiscing elit, sed do eiusmod tempor", @@ -150,7 +149,7 @@ @Override public void close() throws Exception { - if (proxy != null) close(proxy::stop); + if (proxy != null) close(proxy); if (http1Server != null) close(http1Server::stop); if (https1Server != null) close(https1Server::stop); if (https2Server != null) close(https2Server::stop); @@ -160,7 +159,8 @@ try { closeable.close(); } catch (Exception x) { - // OK. + // OK to ignore and just log + System.err.println("ignoring failure during close() of " + closeable + " due to: " + x); } } diff -Nru openjdk-17-17.0.17+10/test/jdk/java/net/httpclient/ManyRequests.java openjdk-17-17.0.18+8/test/jdk/java/net/httpclient/ManyRequests.java --- openjdk-17-17.0.17+10/test/jdk/java/net/httpclient/ManyRequests.java 2025-10-13 07:48:04.000000000 +0000 +++ openjdk-17-17.0.18+8/test/jdk/java/net/httpclient/ManyRequests.java 2026-01-15 15:23:06.000000000 +0000 @@ -24,6 +24,7 @@ /* * @test * @bug 8087112 8180044 8256459 + * @key intermittent * @modules java.net.http * java.logging * jdk.httpserver diff -Nru openjdk-17-17.0.17+10/test/jdk/java/net/httpclient/ProxyServer.java openjdk-17-17.0.18+8/test/jdk/java/net/httpclient/ProxyServer.java --- openjdk-17-17.0.17+10/test/jdk/java/net/httpclient/ProxyServer.java 2025-10-13 07:48:04.000000000 +0000 +++ openjdk-17-17.0.18+8/test/jdk/java/net/httpclient/ProxyServer.java 2026-01-15 15:23:06.000000000 +0000 @@ -1,5 +1,5 @@ /* - * Copyright (c) 2015, 2022, 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 @@ -42,7 +42,7 @@ * Two threads are created per client connection. So, it's not * intended for large numbers of parallel connections. */ -public class ProxyServer extends Thread implements Closeable { +public final class ProxyServer implements Closeable { // could use the test library here - Platform.isWindows(), // but it would force all tests that use ProxyServer to @@ -99,9 +99,7 @@ this(port, debug, null); } - public ProxyServer(Integer port, - Boolean debug, - Credentials credentials) + private ProxyServer(Integer port, Boolean debug, Credentials credentials) throws IOException { this.debug = debug; @@ -110,15 +108,11 @@ listener.bind(new InetSocketAddress(InetAddress.getLoopbackAddress(), port)); this.port = ((InetSocketAddress)listener.getLocalAddress()).getPort(); this.credentials = credentials; - setName("ProxyListener"); - setDaemon(true); - connections = new CopyOnWriteArrayList(); - start(); - } - - public ProxyServer(String s) { - credentials = null; connections = new CopyOnWriteArrayList(); + Thread d = new Thread(() -> run()); + d.setName("ProxyListener"); + d.setDaemon(true); + d.start(); } /** @@ -150,7 +144,7 @@ volatile boolean done; - public void run() { + private void run() { if (System.getSecurityManager() == null) { execute(); } else { @@ -195,6 +189,9 @@ volatile InputStream clientIn, serverIn; volatile OutputStream clientOut, serverOut; + boolean proxyInClosed; // only accessed from synchronized block + boolean proxyOutClosed; // only accessed from synchronized block + final static int CR = 13; final static int LF = 10; @@ -594,9 +591,7 @@ if (log) System.out.printf("Proxy Forwarding [request body]: total %d%n", body); } - closing = true; - serverSocket.close(); - clientSocket.close(); + closeClientIn(); } catch (IOException e) { if (!closing && debug) { System.out.println("Proxy: " + e); @@ -615,9 +610,7 @@ if (log) System.out.printf("Proxy Forwarding [response]: %s%n", new String(bb, 0, n, UTF_8)); if (log) System.out.printf("Proxy Forwarding [response]: total %d%n", resp); } - closing = true; - serverSocket.close(); - clientSocket.close(); + closeClientOut(); } catch (IOException e) { if (!closing && debug) { System.out.println("Proxy: " + e); @@ -641,6 +634,28 @@ proxyCommon(false); } + synchronized void closeClientIn() throws IOException { + closing = true; + proxyInClosed = true; + clientSocket.shutdownInput(); + serverSocket.shutdownOutput(); + if (proxyOutClosed) { + serverSocket.close(); + clientSocket.close(); + } + } + + synchronized void closeClientOut() throws IOException { + closing = true; + proxyOutClosed = true; + serverSocket.shutdownInput(); + clientSocket.shutdownOutput(); + if (proxyInClosed) { + serverSocket.close(); + clientSocket.close(); + } + } + @Override public String toString() { return "Proxy connection " + id + ", client sock:" + clientSocket; @@ -651,10 +666,11 @@ int port = Integer.parseInt(args[0]); boolean debug = args.length > 1 && args[1].equals("-debug"); System.out.println("Debugging : " + debug); - ProxyServer ps = new ProxyServer(port, debug); - System.out.println("Proxy server listening on port " + ps.getPort()); - while (true) { - Thread.sleep(5000); + try (ProxyServer ps = new ProxyServer(port, debug)) { + System.out.println("Proxy server listening on port " + ps.getPort()); + while (true) { + Thread.sleep(5000); + } } } } diff -Nru openjdk-17-17.0.17+10/test/jdk/java/net/ipv6tests/TcpTest.java openjdk-17-17.0.18+8/test/jdk/java/net/ipv6tests/TcpTest.java --- openjdk-17-17.0.17+10/test/jdk/java/net/ipv6tests/TcpTest.java 2025-10-13 07:48:04.000000000 +0000 +++ openjdk-17-17.0.18+8/test/jdk/java/net/ipv6tests/TcpTest.java 2026-01-15 15:23:06.000000000 +0000 @@ -31,6 +31,7 @@ * @library /test/lib * @build jdk.test.lib.NetworkConfiguration * jdk.test.lib.Platform + * jtreg.SkippedException * @run main TcpTest -d * @run main/othervm -Djdk.net.usePlainSocketImpl TcpTest -d */ @@ -39,6 +40,8 @@ import java.io.*; import java.util.concurrent.TimeUnit; +import jtreg.SkippedException; + public class TcpTest extends Tests { static ServerSocket server, server1, server2; static Socket c1, c2, c3, s1, s2, s3; @@ -63,12 +66,10 @@ public static void main (String[] args) throws Exception { checkDebug(args); if (ia4addr == null) { - System.out.println ("No IPV4 addresses: exiting test"); - return; + throw new SkippedException("No IPV4 addresses: exiting test"); } if (ia6addr == null) { - System.out.println ("No IPV6 addresses: exiting test"); - return; + throw new SkippedException("No IPV6 addresses: exiting test"); } dprintln ("Local Addresses"); dprintln (ia4addr.toString()); diff -Nru openjdk-17-17.0.17+10/test/jdk/java/nio/channels/DatagramChannel/StressNativeSignal.java openjdk-17-17.0.18+8/test/jdk/java/nio/channels/DatagramChannel/StressNativeSignal.java --- openjdk-17-17.0.17+10/test/jdk/java/nio/channels/DatagramChannel/StressNativeSignal.java 2025-10-13 07:48:04.000000000 +0000 +++ openjdk-17-17.0.18+8/test/jdk/java/nio/channels/DatagramChannel/StressNativeSignal.java 2026-01-15 15:23:06.000000000 +0000 @@ -1,5 +1,5 @@ /* - * Copyright (c) 2016, 2024, 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 @@ -36,42 +36,23 @@ import java.util.concurrent.CountDownLatch; public class StressNativeSignal { - private UDPThread udpThread; - private ServerSocketThread serverSocketThread; + private final UDPThread udpThread; + private final ServerSocketThread serverSocketThread; - StressNativeSignal() { + StressNativeSignal() throws IOException { serverSocketThread = initServerSocketThread(); - if (serverSocketThread != null) { - serverSocketThread.start(); - } + serverSocketThread.start(); udpThread = initUDPThread(); - if (udpThread != null) { - udpThread.start(); - } + udpThread.start(); } - private UDPThread initUDPThread() { - UDPThread aUDPThread = null; - try { - aUDPThread = new UDPThread(); - } catch (Exception z) { - System.err.println("failed to create and start a UDPThread"); - z.printStackTrace(); - } - return aUDPThread; + private UDPThread initUDPThread() throws IOException { + return new UDPThread(); } - private ServerSocketThread initServerSocketThread() { - ServerSocketThread aServerSocketThread = null; - try { - aServerSocketThread = new ServerSocketThread(); - - } catch (Exception z) { - System.err.println("failed to create and start a ServerSocketThread"); - z.printStackTrace(); - } - return aServerSocketThread; + private ServerSocketThread initServerSocketThread() throws IOException { + return new ServerSocketThread(); } public static void main(String[] args) throws Throwable { @@ -80,46 +61,39 @@ test.shutdown(); } - public void shutdown() { - if ((udpThread != null) && udpThread.isAlive()) { + public void shutdown() throws InterruptedException, IOException { + if (udpThread != null && udpThread.isAlive()) { udpThread.terminate(); - try { - udpThread.join(); - } catch (Exception z) { - z.printStackTrace(System.err); - } + udpThread.join(); + } else { System.out.println("UDPThread test scenario was not run"); } - if ((serverSocketThread != null) && (serverSocketThread.isAlive())) { + if (serverSocketThread != null && serverSocketThread.isAlive()) { serverSocketThread.terminate(); - try { - serverSocketThread.join(); - } catch (Exception z) { - z.printStackTrace(System.err); - } + serverSocketThread.join(); } else { System.out.println("ServerSocketThread test scenario was not run"); } } - public void waitForTestThreadsToStart() { - if ((udpThread != null) && udpThread.isAlive()) { + public void waitForTestThreadsToStart() throws InterruptedException { + if (udpThread != null && udpThread.isAlive()) { udpThread.waitTestThreadStart(); } - if ((serverSocketThread != null) && (serverSocketThread.isAlive())) { + if (serverSocketThread != null && serverSocketThread.isAlive()) { serverSocketThread.waitTestThreadStart(); } } public class ServerSocketThread extends Thread { private volatile boolean shouldTerminate; - private ServerSocket socket; + private final ServerSocket socket; private final CountDownLatch threadStarted = new CountDownLatch(1); - public ServerSocketThread () throws Exception { - socket = new ServerSocket(1122); + public ServerSocketThread() throws IOException { + socket = new ServerSocket(0); } public void run() { @@ -129,7 +103,7 @@ Socket client = socket.accept(); client.close(); throw new RuntimeException("Unexpected return from accept call"); - } catch (Exception z) { + } catch (IOException z) { System.err.println("ServerSocketThread: caught exception " + z.getClass().getName()); if (!shouldTerminate) { z.printStackTrace(System.err); @@ -141,7 +115,7 @@ shouldTerminate = true; try { socket.close(); - } catch (Exception z) { + } catch (IOException z) { z.printStackTrace(System.err); // ignore } @@ -150,7 +124,7 @@ public void waitTestThreadStart() { try { threadStarted.await(); - } catch (Exception z) { + } catch (InterruptedException z) { z.printStackTrace(System.err); // ignore } @@ -158,15 +132,14 @@ } public class UDPThread extends Thread { - private DatagramChannel channel; + private final DatagramChannel channel; private volatile boolean shouldTerminate; private final CountDownLatch threadStarted = new CountDownLatch(1); - public UDPThread () throws Exception { - + public UDPThread() throws IOException { channel = DatagramChannel.open(); channel.setOption(StandardSocketOptions.SO_RCVBUF, 6553600); - channel.bind(new InetSocketAddress(19870)); + channel.bind(new InetSocketAddress(0)); } @Override @@ -191,7 +164,7 @@ shouldTerminate = true; try { channel.close(); - } catch (Exception z) { + } catch (IOException z) { System.err.println("UDPThread: caught exception " + z.getClass().getName()); z.printStackTrace(System.err); // ignore @@ -201,7 +174,7 @@ public void waitTestThreadStart() { try { threadStarted.await(); - } catch (Exception z) { + } catch (InterruptedException z) { z.printStackTrace(System.err); // ignore } diff -Nru openjdk-17-17.0.17+10/test/jdk/java/nio/channels/FileChannel/directio/DirectIOTest.java openjdk-17-17.0.18+8/test/jdk/java/nio/channels/FileChannel/directio/DirectIOTest.java --- openjdk-17-17.0.17+10/test/jdk/java/nio/channels/FileChannel/directio/DirectIOTest.java 2025-10-13 07:48:04.000000000 +0000 +++ openjdk-17-17.0.18+8/test/jdk/java/nio/channels/FileChannel/directio/DirectIOTest.java 2026-01-15 15:23:06.000000000 +0000 @@ -27,11 +27,13 @@ * @summary Test for ExtendedOpenOption.DIRECT flag * @requires (os.family == "linux" | os.family == "aix") * @library /test/lib + * @modules java.base/sun.nio.ch:+open java.base/java.io:+open * @build jdk.test.lib.Platform * @run main/native DirectIOTest */ import java.io.*; +import java.lang.reflect.Field; import java.nio.ByteBuffer; import java.nio.CharBuffer; import java.nio.channels.*; @@ -47,10 +49,25 @@ public class DirectIOTest { private static final int BASE_SIZE = 4096; + private static final int TRIES = 3; + + public static int getFD(FileChannel channel) throws Exception { + Field fFdFd = channel.getClass().getDeclaredField("fd"); + fFdFd.setAccessible(true); + FileDescriptor fd = (FileDescriptor) fFdFd.get(channel); + + Field fFd = FileDescriptor.class.getDeclaredField("fd"); + fFd.setAccessible(true); + return fFd.getInt(fd); + } + + private static void testWrite(Path p, long blockSize) throws Exception { + try (FileChannel fc = FileChannel.open(p, + StandardOpenOption.READ, + StandardOpenOption.WRITE, + ExtendedOpenOption.DIRECT)) { + int fd = getFD(fc); - private static int testWrite(Path p, long blockSize) throws Exception { - try (FileChannel fc = FileChannel.open(p, StandardOpenOption.WRITE, - ExtendedOpenOption.DIRECT)) { int bs = (int)blockSize; int size = Math.max(BASE_SIZE, bs); int alignment = bs; @@ -60,22 +77,55 @@ for (int j = 0; j < size; j++) { src.put((byte)0); } - src.flip(); - fc.write(src); - return size; + + // If there is AV or other FS tracing software, it may cache the file + // contents on first access, even though we have asked for DIRECT here. + // Do several attempts to make test more resilient. + + for (int t = 0; t < TRIES; t++) { + flushFileCache(size, fd); + src.flip(); + fc.position(0); + fc.write(src); + if (!isFileInCache(size, fd)) { + return; + } + } + + throw new RuntimeException("DirectIO is not working properly with " + + "write. File still exists in cache!"); } } - private static int testRead(Path p, long blockSize) throws Exception { - try (FileChannel fc = FileChannel.open(p, ExtendedOpenOption.DIRECT)) { + private static void testRead(Path p, long blockSize) throws Exception { + try (FileChannel fc = FileChannel.open(p, + StandardOpenOption.READ, + ExtendedOpenOption.DIRECT)) { + int fd = getFD(fc); + int bs = (int)blockSize; int size = Math.max(BASE_SIZE, bs); int alignment = bs; ByteBuffer dest = ByteBuffer.allocateDirect(size + alignment - 1) .alignedSlice(alignment); assert dest.capacity() != 0; - fc.read(dest); - return size; + + // If there is AV or other FS tracing software, it may cache the file + // contents on first access, even though we have asked for DIRECT here. + // Do several attempts to make test more resilient. + + for (int t = 0; t < TRIES; t++) { + flushFileCache(size, fd); + dest.clear(); + fc.position(0); + fc.read(dest); + if (!isFileInCache(size, fd)) { + return; + } + } + + throw new RuntimeException("DirectIO is not working properly with " + + "read. File still exists in cache!"); } } @@ -84,12 +134,8 @@ Paths.get(System.getProperty("test.dir", ".")), "test", null); } - private static boolean isFileInCache(int size, Path p) { - String path = p.toString(); - return isFileInCache0(size, path); - } - - private static native boolean isFileInCache0(int size, String path); + private static native boolean flushFileCache(int size, int fd); + private static native boolean isFileInCache(int size, int fd); public static void main(String[] args) throws Exception { Path p = createTempFile(); @@ -98,16 +144,8 @@ System.loadLibrary("DirectIO"); try { - int size = testWrite(p, blockSize); - if (isFileInCache(size, p)) { - throw new RuntimeException("DirectIO is not working properly with " - + "write. File still exists in cache!"); - } - size = testRead(p, blockSize); - if (isFileInCache(size, p)) { - throw new RuntimeException("DirectIO is not working properly with " - + "read. File still exists in cache!"); - } + testWrite(p, blockSize); + testRead(p, blockSize); } finally { Files.delete(p); } diff -Nru openjdk-17-17.0.17+10/test/jdk/java/nio/channels/FileChannel/directio/libDirectIO.c openjdk-17-17.0.18+8/test/jdk/java/nio/channels/FileChannel/directio/libDirectIO.c --- openjdk-17-17.0.17+10/test/jdk/java/nio/channels/FileChannel/directio/libDirectIO.c 2025-10-13 07:48:04.000000000 +0000 +++ openjdk-17-17.0.18+8/test/jdk/java/nio/channels/FileChannel/directio/libDirectIO.c 2026-01-15 15:23:06.000000000 +0000 @@ -45,13 +45,27 @@ /* * Class: DirectIO - * Method: isFileInCache0 - * Signature: (ILjava/lang/String;)Z + * Method: flushFileCache + * Signature: (II;)V */ -JNIEXPORT jboolean Java_DirectIOTest_isFileInCache0(JNIEnv *env, +JNIEXPORT void Java_DirectIOTest_flushFileCache(JNIEnv *env, jclass cls, jint file_size, - jstring file_path) { + jint fd) { +#ifdef __linux__ + posix_fadvise(fd, 0, file_size, POSIX_FADV_DONTNEED); +#endif +} + +/* + * Class: DirectIO + * Method: isFileInCache + * Signature: (II;)Z + */ +JNIEXPORT jboolean Java_DirectIOTest_isFileInCache(JNIEnv *env, + jclass cls, + jint file_size, + jint fd) { void *f_mmap; #ifdef __linux__ unsigned char *f_seg; @@ -69,17 +83,10 @@ size_t index = (file_size + page_size - 1) /page_size; jboolean result = JNI_FALSE; - const char* path = (*env)->GetStringUTFChars(env, file_path, JNI_FALSE); - - int fd = open(path, O_RDWR); - - (*env)->ReleaseStringUTFChars(env, file_path, path); - f_mmap = mmap(0, file_size, PROT_NONE, MAP_SHARED, fd, 0); if (f_mmap == MAP_FAILED) { - close(fd); ThrowException(env, "java/io/IOException", - "test of whether file exists in cache failed"); + "test of whether file exists in cache failed: mmap failed"); } f_seg = malloc(index); if (f_seg != NULL) { @@ -95,9 +102,8 @@ free(f_seg); } else { ThrowException(env, "java/io/IOException", - "test of whether file exists in cache failed"); + "test of whether file exists in cache failed: malloc failed"); } - close(fd); munmap(f_mmap, file_size); return result; } diff -Nru openjdk-17-17.0.17+10/test/jdk/java/nio/channels/SocketChannel/PeerReadsAfterAsyncClose.java openjdk-17-17.0.18+8/test/jdk/java/nio/channels/SocketChannel/PeerReadsAfterAsyncClose.java --- openjdk-17-17.0.17+10/test/jdk/java/nio/channels/SocketChannel/PeerReadsAfterAsyncClose.java 1970-01-01 00:00:00.000000000 +0000 +++ openjdk-17-17.0.18+8/test/jdk/java/nio/channels/SocketChannel/PeerReadsAfterAsyncClose.java 2026-01-15 15:23:06.000000000 +0000 @@ -0,0 +1,198 @@ +/* + * 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 8358764 + * @summary Test closing a socket while a thread is blocked in read. The connection + * should be closed gracefuly so that the peer reads EOF. + * @run junit PeerReadsAfterAsyncClose + */ + +import java.io.IOException; +import java.net.InetAddress; +import java.net.InetSocketAddress; +import java.net.ServerSocket; +import java.net.Socket; +import java.net.SocketException; +import java.nio.ByteBuffer; +import java.nio.channels.ClosedChannelException; +import java.nio.channels.SocketChannel; +import java.util.Arrays; +import java.util.Objects; +import java.util.concurrent.Executors; +import java.util.concurrent.ThreadFactory; +import java.util.concurrent.atomic.AtomicBoolean; +import java.util.stream.Stream; + +import org.junit.jupiter.params.ParameterizedTest; +import org.junit.jupiter.params.provider.MethodSource; +import static org.junit.jupiter.api.Assertions.*; + +class PeerReadsAfterAsyncClose { + + static Stream factories() { + return Stream.of(Executors.defaultThreadFactory()); + } + + /** + * Close SocketChannel while a thread is blocked reading from the channel's socket. + */ + @ParameterizedTest + @MethodSource("factories") + void testCloseDuringSocketChannelRead(ThreadFactory factory) throws Exception { + var loopback = InetAddress.getLoopbackAddress(); + try (var listener = new ServerSocket()) { + listener.bind(new InetSocketAddress(loopback, 0)); + + try (SocketChannel sc = SocketChannel.open(listener.getLocalSocketAddress()); + Socket peer = listener.accept()) { + + // start thread to read from channel + var cceThrown = new AtomicBoolean(); + Thread thread = factory.newThread(() -> { + try { + sc.read(ByteBuffer.allocate(1)); + fail(); + } catch (ClosedChannelException e) { + cceThrown.set(true); + } catch (Throwable e) { + e.printStackTrace(); + } + }); + thread.start(); + try { + // close SocketChannel when thread sampled in read() + onReach(thread, "sun.nio.ch.SocketChannelImpl.read", () -> { + try { + sc.close(); + } catch (IOException ignore) { } + }); + + // peer should read EOF + int n = peer.getInputStream().read(); + assertEquals(-1, n); + } finally { + thread.join(); + } + assertEquals(true, cceThrown.get(), "ClosedChannelException not thrown"); + } + } + } + + /** + * Close Socket while a thread is blocked reading from the socket. + */ + @ParameterizedTest + @MethodSource("factories") + void testCloseDuringSocketUntimedRead(ThreadFactory factory) throws Exception { + testCloseDuringSocketRead(factory, 0); + } + + /** + * Close Socket while a thread is blocked reading from the socket with a timeout. + */ + @ParameterizedTest + @MethodSource("factories") + void testCloseDuringSockeTimedRead(ThreadFactory factory) throws Exception { + testCloseDuringSocketRead(factory, 60_000); + } + + private void testCloseDuringSocketRead(ThreadFactory factory, int timeout) throws Exception { + var loopback = InetAddress.getLoopbackAddress(); + try (var listener = new ServerSocket()) { + listener.bind(new InetSocketAddress(loopback, 0)); + + try (Socket s = new Socket(loopback, listener.getLocalPort()); + Socket peer = listener.accept()) { + + // start thread to read from socket + var seThrown = new AtomicBoolean(); + Thread thread = factory.newThread(() -> { + try { + s.setSoTimeout(timeout); + s.getInputStream().read(); + fail(); + } catch (SocketException e) { + seThrown.set(true); + } catch (Throwable e) { + e.printStackTrace(); + } + }); + thread.start(); + try { + // close Socket when thread sampled in implRead + onReach(thread, "sun.nio.ch.NioSocketImpl.implRead", () -> { + try { + s.close(); + } catch (IOException ignore) { } + }); + + // peer should read EOF + int n = peer.getInputStream().read(); + assertEquals(-1, n); + } finally { + thread.join(); + } + assertEquals(true, seThrown.get(), "SocketException not thrown"); + } + } + } + + /** + * Runs the given action when the given target thread is sampled at the given + * location. The location takes the form "{@code c.m}" where + * {@code c} is the fully qualified class name and {@code m} is the method name. + */ + private void onReach(Thread target, String location, Runnable action) { + int index = location.lastIndexOf('.'); + String className = location.substring(0, index); + String methodName = location.substring(index + 1); + Thread tDaemon = new Thread(() -> { + try { + boolean found = false; + while (!found) { + found = contains(target.getStackTrace(), className, methodName); + if (!found) { + Thread.sleep(20); + } + } + action.run(); + } catch (Exception e) { + e.printStackTrace(); + } + }); + tDaemon.setDaemon(true); + tDaemon.start(); + } + + /** + * Returns true if the given stack trace contains an element for the given class + * and method name. + */ + private boolean contains(StackTraceElement[] stack, String className, String methodName) { + return Arrays.stream(stack) + .anyMatch(e -> className.equals(e.getClassName()) + && methodName.equals(e.getMethodName())); + } +} diff -Nru openjdk-17-17.0.17+10/test/jdk/java/nio/charset/Charset/AvailableCharsetNames.java openjdk-17-17.0.18+8/test/jdk/java/nio/charset/Charset/AvailableCharsetNames.java --- openjdk-17-17.0.17+10/test/jdk/java/nio/charset/Charset/AvailableCharsetNames.java 2025-10-13 07:48:04.000000000 +0000 +++ openjdk-17-17.0.18+8/test/jdk/java/nio/charset/Charset/AvailableCharsetNames.java 2026-01-15 15:23:06.000000000 +0000 @@ -1,5 +1,5 @@ /* - * Copyright (c) 2010, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2010, 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 @@ -25,27 +25,26 @@ * @bug 4422044 * @summary Ensure that keys in available-charset map * are identical to canonical names + * @run junit AvailableCharsetNames */ -import java.io.*; -import java.nio.*; -import java.nio.charset.*; -import java.util.*; +import java.nio.charset.Charset; +import org.junit.jupiter.api.Test; + +import static org.junit.jupiter.api.Assertions.assertEquals; public class AvailableCharsetNames { - public static void main(String[] args) throws Exception { - Iterator charsetIterator = Charset.availableCharsets().keySet().iterator(); - while (charsetIterator.hasNext()) { - String charsetName = (String) charsetIterator.next(); + /** + * Test that the keys in Charset.availableCharsets() + * are equal to the associated Charset.name() value. + */ + @Test + public void canonicalNamesTest() { + for (String charsetName : Charset.availableCharsets().keySet()) { Charset charset = Charset.forName(charsetName); - if (!charset.name().equals(charsetName)) { - throw new Exception("Error: Charset name mismatch - expected " - + charsetName + ", got " + charset.name()); - } + assertEquals(charset.name(), charsetName, "Charset name mismatch"); } - } - } diff -Nru openjdk-17-17.0.17+10/test/jdk/java/nio/charset/Charset/CharsetContainmentTest.java openjdk-17-17.0.18+8/test/jdk/java/nio/charset/Charset/CharsetContainmentTest.java --- openjdk-17-17.0.17+10/test/jdk/java/nio/charset/Charset/CharsetContainmentTest.java 2025-10-13 07:48:04.000000000 +0000 +++ openjdk-17-17.0.18+8/test/jdk/java/nio/charset/Charset/CharsetContainmentTest.java 2026-01-15 15:23:06.000000000 +0000 @@ -1,5 +1,5 @@ /* - * Copyright (c) 2010, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2010, 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 @@ -25,93 +25,116 @@ * @bug 4626545 4696726 * @summary Checks the inter containment relationships between NIO charsets * @modules jdk.charsets + * @run junit CharsetContainmentTest */ -import java.nio.charset.*; +import java.nio.charset.Charset; +import java.util.ArrayList; +import java.util.List; +import java.util.stream.Stream; + +import org.junit.jupiter.params.ParameterizedTest; +import org.junit.jupiter.params.provider.Arguments; +import org.junit.jupiter.params.provider.MethodSource; + +import static org.junit.jupiter.api.Assertions.assertTrue; public class CharsetContainmentTest { - static String[] encodings = - { "US-ASCII", "UTF-16", "UTF-16BE", "UTF-16LE", "UTF-8", - "windows-1252", "ISO-8859-1", "ISO-8859-2", "ISO-8859-3", - "ISO-8859-4", "ISO-8859-5", "ISO-8859-6", "ISO-8859-7", - "ISO-8859-8", "ISO-8859-9", "ISO-8859-13", "ISO-8859-15", "ISO-8859-16", - "ISO-2022-JP", "ISO-2022-KR", - - // Temporarily remove ISO-2022-CN-* charsets until full encoder/decoder - // support is added (4673614) - // "x-ISO-2022-CN-CNS", "x-ISO-2022-CN-GB", - - "x-ISCII91", "GBK", "GB18030", "Big5", - "x-EUC-TW", "GB2312", "EUC-KR", "x-Johab", "Big5-HKSCS", - "x-MS950-HKSCS", "windows-1251", "windows-1253", "windows-1254", - "windows-1255", "windows-1256", "windows-1257", "windows-1258", - "x-mswin-936", "x-windows-949", "x-windows-950", "windows-31j", - "Shift_JIS", "EUC-JP", "KOI8-R", "TIS-620" - }; - - static String[][] contains = { - { "US-ASCII"}, - encodings, - encodings, - encodings, - encodings, - {"US-ASCII", "windows-1252"}, - {"US-ASCII", "ISO-8859-1"}, - {"US-ASCII", "ISO-8859-2"}, - {"US-ASCII", "ISO-8859-3"}, - {"US-ASCII", "ISO-8859-4"}, - {"US-ASCII", "ISO-8859-5"}, - {"US-ASCII", "ISO-8859-6"}, - {"US-ASCII", "ISO-8859-7"}, - {"US-ASCII", "ISO-8859-8"}, - {"US-ASCII", "ISO-8859-9"}, - {"US-ASCII", "ISO-8859-13"}, - {"US-ASCII", "ISO-8859-15"}, - {"US-ASCII", "ISO-8859-16"}, - {"ISO-2022-JP"}, - {"ISO-2022-KR"}, - // Temporarily remove ISO-2022-CN-* charsets until full encoder/decoder - // support is added (4673614) - //{"x-ISO-2022-CN-CNS"}, - //{"x-ISO-2022-CN-GB"}, - {"US-ASCII", "x-ISCII91"}, - {"US-ASCII", "GBK"}, - encodings, - {"US-ASCII", "Big5"}, - {"US-ASCII", "x-EUC-TW"}, - {"US-ASCII", "GB2312"}, - {"US-ASCII", "EUC-KR"}, - {"US-ASCII", "x-Johab"}, - {"US-ASCII", "Big5-HKSCS", "Big5"}, - {"US-ASCII", "x-MS950-HKSCS", "x-windows-950"}, - {"US-ASCII", "windows-1251"}, - {"US-ASCII", "windows-1253"}, - {"US-ASCII", "windows-1254"}, - {"US-ASCII", "windows-1255"}, - {"US-ASCII", "windows-1256"}, - {"US-ASCII", "windows-1257"}, - {"US-ASCII", "windows-1258"}, - {"US-ASCII", "x-mswin-936"}, - {"US-ASCII", "x-windows-949"}, - {"US-ASCII", "x-windows-950"}, - {"US-ASCII", "windows-31j" }, - {"US-ASCII", "Shift_JIS"}, - {"US-ASCII", "EUC-JP"}, - {"US-ASCII", "KOI8-R"}, - {"US-ASCII", "TIS-620"}}; + /** + * Test that the charsets in 'encodings' contain the charsets + * inside 'contains'. Each value in 'encodings' is mapped to a String + * array in 'contains'. For example, the value, "TIS-620" in 'encodings' + * should contain "US-ASCII", "TIS-620". + */ + @ParameterizedTest + @MethodSource("charsets") + public void interContainmentTest(String containerName, String containedName) { + Charset container = Charset.forName(containerName); + Charset contained = Charset.forName(containedName); + assertTrue(container.contains(contained), + String.format("Charset: %s does not contain: %s", containerName, containedName)); + } - public static void main(String[] args) throws Exception { + private static Stream charsets() { + String[] encodings = { + "US-ASCII", "UTF-16", "UTF-16BE", "UTF-16LE", "UTF-8", + "windows-1252", "ISO-8859-1", "ISO-8859-2", "ISO-8859-3", + "ISO-8859-4", "ISO-8859-5", "ISO-8859-6", "ISO-8859-7", + "ISO-8859-8", "ISO-8859-9", "ISO-8859-13", "ISO-8859-15", "ISO-8859-16", + "ISO-2022-JP", "ISO-2022-KR", + // Temporarily remove ISO-2022-CN-* charsets until full encoder/decoder + // support is added (4673614) + // "x-ISO-2022-CN-CNS", "x-ISO-2022-CN-GB", + "x-ISCII91", "GBK", "GB18030", "Big5", + "x-EUC-TW", "GB2312", "EUC-KR", "x-Johab", "Big5-HKSCS", + "x-MS950-HKSCS", "windows-1251", "windows-1253", "windows-1254", + "windows-1255", "windows-1256", "windows-1257", "windows-1258", + "x-mswin-936", "x-windows-949", "x-windows-950", "windows-31j", + "Shift_JIS", "EUC-JP", "KOI8-R", "TIS-620" + }; + + String[][] contains = { + {"US-ASCII"}, + encodings, + encodings, + encodings, + encodings, + {"US-ASCII", "windows-1252"}, + {"US-ASCII", "ISO-8859-1"}, + {"US-ASCII", "ISO-8859-2"}, + {"US-ASCII", "ISO-8859-3"}, + {"US-ASCII", "ISO-8859-4"}, + {"US-ASCII", "ISO-8859-5"}, + {"US-ASCII", "ISO-8859-6"}, + {"US-ASCII", "ISO-8859-7"}, + {"US-ASCII", "ISO-8859-8"}, + {"US-ASCII", "ISO-8859-9"}, + {"US-ASCII", "ISO-8859-13"}, + {"US-ASCII", "ISO-8859-15"}, + {"US-ASCII", "ISO-8859-16"}, + {"ISO-2022-JP"}, + {"ISO-2022-KR"}, + // Temporarily remove ISO-2022-CN-* charsets until full encoder/decoder + // support is added (4673614) + //{"x-ISO-2022-CN-CNS"}, + //{"x-ISO-2022-CN-GB"}, + {"US-ASCII", "x-ISCII91"}, + {"US-ASCII", "GBK"}, + encodings, + {"US-ASCII", "Big5"}, + {"US-ASCII", "x-EUC-TW"}, + {"US-ASCII", "GB2312"}, + {"US-ASCII", "EUC-KR"}, + {"US-ASCII", "x-Johab"}, + {"US-ASCII", "Big5-HKSCS", "Big5"}, + {"US-ASCII", "x-MS950-HKSCS", "x-windows-950"}, + {"US-ASCII", "windows-1251"}, + {"US-ASCII", "windows-1253"}, + {"US-ASCII", "windows-1254"}, + {"US-ASCII", "windows-1255"}, + {"US-ASCII", "windows-1256"}, + {"US-ASCII", "windows-1257"}, + {"US-ASCII", "windows-1258"}, + {"US-ASCII", "x-mswin-936"}, + {"US-ASCII", "x-windows-949"}, + {"US-ASCII", "x-windows-950"}, + {"US-ASCII", "windows-31j"}, + {"US-ASCII", "Shift_JIS"}, + {"US-ASCII", "EUC-JP"}, + {"US-ASCII", "KOI8-R"}, + {"US-ASCII", "TIS-620"}}; + + // Length of encodings and contains should always be equal + if (encodings.length != contains.length) { + throw new RuntimeException("Testing data is not set up correctly"); + } + List charsetList = new ArrayList(); for (int i = 0; i < encodings.length; i++) { - Charset c = Charset.forName(encodings[i]); - for (int j = 0 ; j < contains[i].length; j++) { - if (c.contains(Charset.forName(contains[i][j]))) - continue; - else { - throw new Exception ("Error: charset " + encodings[i] + - "doesn't contain " + contains[i][j]); - } - } + for (int j = 0 ; j < contains[i].length; j++) { + charsetList.add(Arguments.of(encodings[i], contains[i][j])); + } } + return charsetList.stream(); } } diff -Nru openjdk-17-17.0.17+10/test/jdk/java/nio/charset/Charset/Contains.java openjdk-17-17.0.18+8/test/jdk/java/nio/charset/Charset/Contains.java --- openjdk-17-17.0.17+10/test/jdk/java/nio/charset/Charset/Contains.java 2025-10-13 07:48:04.000000000 +0000 +++ openjdk-17-17.0.18+8/test/jdk/java/nio/charset/Charset/Contains.java 2026-01-15 15:23:06.000000000 +0000 @@ -25,166 +25,186 @@ * @summary Unit test for charset containment * @bug 6798572 8167252 * @modules jdk.charsets + * @run junit Contains */ -import java.nio.charset.*; +import java.nio.charset.Charset; +import java.util.Arrays; +import java.util.stream.Stream; + +import org.junit.jupiter.api.Test; +import org.junit.jupiter.params.ParameterizedTest; +import org.junit.jupiter.params.provider.Arguments; +import org.junit.jupiter.params.provider.MethodSource; +import static org.junit.jupiter.api.Assertions.assertEquals; +import static org.junit.jupiter.api.Assertions.assertTrue; public class Contains { - static void ck(Charset cs1, Charset cs2, boolean cont) throws Exception { - if ((cs1.contains(cs2)) != cont) - throw new Exception("Wrong answer: " - + cs1.name() + " contains " + cs2.name()); - System.err.println(cs1.name() - + (cont ? " contains " : " does not contain ") - + cs2.name()); + /** + * Tests the containment of some charsets against themselves. + * This test takes both true and false for 'cont'. + */ + @ParameterizedTest + @MethodSource("charsets") + public void charsetsTest(Charset containerCs, Charset cs, boolean cont){ + shouldContain(containerCs, cs, cont); } - public static void main(String[] args) throws Exception { - - Charset us_ascii = Charset.forName("US-ASCII"); - Charset iso_8859_1 = Charset.forName("ISO-8859-1"); - Charset iso_8859_15 = Charset.forName("ISO-8859-15"); - Charset utf_8 = Charset.forName("UTF-8"); - Charset utf_16be = Charset.forName("UTF-16BE"); - Charset cp1252 = Charset.forName("CP1252"); - - ck(us_ascii, us_ascii, true); - ck(us_ascii, iso_8859_1, false); - ck(us_ascii, iso_8859_15, false); - ck(us_ascii, utf_8, false); - ck(us_ascii, utf_16be, false); - ck(us_ascii, cp1252, false); - - ck(iso_8859_1, us_ascii, true); - ck(iso_8859_1, iso_8859_1, true); - ck(iso_8859_1, iso_8859_15, false); - ck(iso_8859_1, utf_8, false); - ck(iso_8859_1, utf_16be, false); - ck(iso_8859_1, cp1252, false); - - ck(iso_8859_15, us_ascii, true); - ck(iso_8859_15, iso_8859_1, false); - ck(iso_8859_15, iso_8859_15, true); - ck(iso_8859_15, utf_8, false); - ck(iso_8859_15, utf_16be, false); - ck(iso_8859_15, cp1252, false); - - ck(utf_8, us_ascii, true); - ck(utf_8, iso_8859_1, true); - ck(utf_8, iso_8859_15, true); - ck(utf_8, utf_8, true); - ck(utf_8, utf_16be, true); - ck(utf_8, cp1252, true); - - ck(utf_16be, us_ascii, true); - ck(utf_16be, iso_8859_1, true); - ck(utf_16be, iso_8859_15, true); - ck(utf_16be, utf_8, true); - ck(utf_16be, utf_16be, true); - ck(utf_16be, cp1252, true); - - ck(cp1252, us_ascii, true); - ck(cp1252, iso_8859_1, false); - ck(cp1252, iso_8859_15, false); - ck(cp1252, utf_8, false); - ck(cp1252, utf_16be, false); - ck(cp1252, cp1252, true); - - checkUTF(); - - containsSelfTest(); - } - - static void checkUTF() throws Exception { - for (String utfName : utfNames) - for (String csName : charsetNames) - ck(Charset.forName(utfName), - Charset.forName(csName), - true); + /** + * Tests UTF charsets with other charsets. In this case, each UTF charset + * should contain every single charset they are tested against. 'cont' is + * always true. + */ + @ParameterizedTest + @MethodSource("utfCharsets") + public void UTFCharsetsTest(Charset containerCs, Charset cs, boolean cont){ + shouldContain(containerCs, cs, cont); } /** * Tests the assertion in the contains() method: "Every charset contains itself." */ - static void containsSelfTest() { - boolean failed = false; - + @Test + public void containsSelfTest() { for (var entry : Charset.availableCharsets().entrySet()) { Charset charset = entry.getValue(); boolean contains = charset.contains(charset); - - System.out.println("Charset(" + charset.name() + ").contains(Charset(" + charset.name() - + ")) returns " + contains); - if (!contains) { - failed = true; - } - } - if (failed) { - throw new RuntimeException("Charset.contains(itself) returns false for some charsets"); + assertTrue(contains, String.format("Charset(%s).contains(Charset(%s)) returns %s", + charset.name(), charset.name(), contains)); } } - static String[] utfNames = {"utf-16", - "utf-8", - "utf-16le", - "utf-16be", - "x-utf-16le-bom"}; - - static String[] charsetNames = { - "US-ASCII", - "UTF-8", - "UTF-16", - "UTF-16BE", - "UTF-16LE", - "x-UTF-16LE-BOM", - "GBK", - "GB18030", - "ISO-8859-1", - "ISO-8859-15", - "ISO-8859-2", - "ISO-8859-3", - "ISO-8859-4", - "ISO-8859-5", - "ISO-8859-6", - "ISO-8859-7", - "ISO-8859-8", - "ISO-8859-9", - "ISO-8859-13", - "JIS_X0201", - "x-JIS0208", - "JIS_X0212-1990", - "GB2312", - "EUC-KR", - "x-EUC-TW", - "EUC-JP", - "x-euc-jp-linux", - "KOI8-R", - "TIS-620", - "x-ISCII91", - "windows-1251", - "windows-1252", - "windows-1253", - "windows-1254", - "windows-1255", - "windows-1256", - "windows-1257", - "windows-1258", - "windows-932", - "x-mswin-936", - "x-windows-949", - "x-windows-950", - "windows-31j", - "Big5", - "Big5-HKSCS", - "x-MS950-HKSCS", - "ISO-2022-JP", - "ISO-2022-KR", - "x-ISO-2022-CN-CNS", - "x-ISO-2022-CN-GB", - "Big5-HKSCS", - "x-Johab", - "Shift_JIS" - }; + /** + * Helper method that checks if a charset should contain another charset. + */ + static void shouldContain(Charset containerCs, Charset cs, boolean cont){ + assertEquals((containerCs.contains(cs)), cont, String.format("%s %s %s", + containerCs.name(), (cont ? " contains " : " does not contain "), cs.name())); + } + + private static Stream utfCharsets() { + String[] utfNames = { + "utf-16", + "utf-8", + "utf-16le", + "utf-16be", + "x-utf-16le-bom" + }; + + String[] charsetNames = { + "US-ASCII", + "UTF-8", + "UTF-16", + "UTF-16BE", + "UTF-16LE", + "x-UTF-16LE-BOM", + "GBK", + "GB18030", + "ISO-8859-1", + "ISO-8859-15", + "ISO-8859-2", + "ISO-8859-3", + "ISO-8859-4", + "ISO-8859-5", + "ISO-8859-6", + "ISO-8859-7", + "ISO-8859-8", + "ISO-8859-9", + "ISO-8859-13", + "JIS_X0201", + "x-JIS0208", + "JIS_X0212-1990", + "GB2312", + "EUC-KR", + "x-EUC-TW", + "EUC-JP", + "x-euc-jp-linux", + "KOI8-R", + "TIS-620", + "x-ISCII91", + "windows-1251", + "windows-1252", + "windows-1253", + "windows-1254", + "windows-1255", + "windows-1256", + "windows-1257", + "windows-1258", + "windows-932", + "x-mswin-936", + "x-windows-949", + "x-windows-950", + "windows-31j", + "Big5", + "Big5-HKSCS", + "x-MS950-HKSCS", + "ISO-2022-JP", + "ISO-2022-KR", + "x-ISO-2022-CN-CNS", + "x-ISO-2022-CN-GB", + "Big5-HKSCS", + "x-Johab", + "Shift_JIS" + }; + + // All charsets in utfNames should contain + // all charsets in charsetNames + return Arrays.stream(utfNames).flatMap(cs1 -> Arrays.stream(charsetNames) + .map(cs2 -> Arguments.of(Charset.forName(cs1), Charset.forName(cs2), true))); + } + + private static Stream charsets() { + Charset us_ascii = Charset.forName("US-ASCII"); + Charset iso_8859_1 = Charset.forName("ISO-8859-1"); + Charset iso_8859_15 = Charset.forName("ISO-8859-15"); + Charset utf_8 = Charset.forName("UTF-8"); + Charset utf_16be = Charset.forName("UTF-16BE"); + Charset cp1252 = Charset.forName("CP1252"); + + return Stream.of( + Arguments.of(us_ascii, us_ascii, true), + Arguments.of(us_ascii, iso_8859_1, false), + Arguments.of(us_ascii, iso_8859_15, false), + Arguments.of(us_ascii, utf_8, false), + Arguments.of(us_ascii, utf_16be, false), + Arguments.of(us_ascii, cp1252, false), + + Arguments.of(iso_8859_1, us_ascii, true), + Arguments.of(iso_8859_1, iso_8859_1, true), + Arguments.of(iso_8859_1, iso_8859_15, false), + Arguments.of(iso_8859_1, utf_8, false), + Arguments.of(iso_8859_1, utf_16be, false), + Arguments.of(iso_8859_1, cp1252, false), + + Arguments.of(iso_8859_15, us_ascii, true), + Arguments.of(iso_8859_15, iso_8859_1, false), + Arguments.of(iso_8859_15, iso_8859_15, true), + Arguments.of(iso_8859_15, utf_8, false), + Arguments.of(iso_8859_15, utf_16be, false), + Arguments.of(iso_8859_15, cp1252, false), + + Arguments.of(utf_8, us_ascii, true), + Arguments.of(utf_8, iso_8859_1, true), + Arguments.of(utf_8, iso_8859_15, true), + Arguments.of(utf_8, utf_8, true), + Arguments.of(utf_8, utf_16be, true), + Arguments.of(utf_8, cp1252, true), + + Arguments.of(utf_16be, us_ascii, true), + Arguments.of(utf_16be, iso_8859_1, true), + Arguments.of(utf_16be, iso_8859_15, true), + Arguments.of(utf_16be, utf_8, true), + Arguments.of(utf_16be, utf_16be, true), + Arguments.of(utf_16be, cp1252, true), + + Arguments.of(cp1252, us_ascii, true), + Arguments.of(cp1252, iso_8859_1, false), + Arguments.of(cp1252, iso_8859_15, false), + Arguments.of(cp1252, utf_8, false), + Arguments.of(cp1252, utf_16be, false), + Arguments.of(cp1252, cp1252, true) + ); + } } diff -Nru openjdk-17-17.0.17+10/test/jdk/java/nio/charset/Charset/EmptyCharsetName.java openjdk-17-17.0.18+8/test/jdk/java/nio/charset/Charset/EmptyCharsetName.java --- openjdk-17-17.0.17+10/test/jdk/java/nio/charset/Charset/EmptyCharsetName.java 2025-10-13 07:48:04.000000000 +0000 +++ openjdk-17-17.0.18+8/test/jdk/java/nio/charset/Charset/EmptyCharsetName.java 1970-01-01 00:00:00.000000000 +0000 @@ -1,84 +0,0 @@ -/* - * Copyright (c) 2010, 2017, Oracle and/or its affiliates. All rights reserved. - * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. - * - * This code is free software; you can redistribute it and/or modify it - * 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 4786884 - * @summary Ensure that passing the empty string to Charset methods and - * constructors causes an IllegalArgumentException to be thrown - */ - -import java.io.*; -import java.nio.*; -import java.nio.charset.*; - - -public class EmptyCharsetName { - - static abstract class Test { - - public abstract void go() throws Exception; - - Test() throws Exception { - try { - go(); - } catch (Exception x) { - if (x instanceof IllegalCharsetNameException) { - System.err.println("Thrown as expected: " + x); - return; - } - throw new Exception("Incorrect exception: " - + x.getClass().getName(), - x); - } - throw new Exception("No exception thrown"); - } - - } - - public static void main(String[] args) throws Exception { - - new Test() { - public void go() throws Exception { - Charset.forName(""); - }}; - new Test() { - public void go() throws Exception { - Charset.isSupported(""); - }}; - new Test() { - public void go() throws Exception { - new Charset("", new String[] { }) { - public CharsetDecoder newDecoder() { - return null; - } - public CharsetEncoder newEncoder() { - return null; - } - public boolean contains(Charset cs) { - return false; - } - }; - }}; - } - -} diff -Nru openjdk-17-17.0.17+10/test/jdk/java/nio/charset/Charset/EncDec.java openjdk-17-17.0.18+8/test/jdk/java/nio/charset/Charset/EncDec.java --- openjdk-17-17.0.17+10/test/jdk/java/nio/charset/Charset/EncDec.java 2025-10-13 07:48:04.000000000 +0000 +++ openjdk-17-17.0.18+8/test/jdk/java/nio/charset/Charset/EncDec.java 2026-01-15 15:23:06.000000000 +0000 @@ -1,5 +1,5 @@ /* - * Copyright (c) 2010, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2010, 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 @@ -23,23 +23,42 @@ /* @test * @summary Unit test for encode/decode convenience methods + * @run junit EncDec */ +import java.nio.ByteBuffer; +import java.nio.charset.Charset; +import java.util.stream.Stream; -import java.nio.*; -import java.nio.charset.*; +import org.junit.jupiter.params.ParameterizedTest; +import org.junit.jupiter.params.provider.MethodSource; +import static org.junit.jupiter.api.Assertions.assertEquals; public class EncDec { - public static void main(String[] args) throws Exception { - String s = "Hello, world!"; + /** + * Test that the input String is the same after round tripping + * the Charset.encode() and Charset.decode() methods. + */ + @ParameterizedTest + @MethodSource("stringProvider") + public void roundTripTest(String pre) { ByteBuffer bb = ByteBuffer.allocate(100); - bb.put(Charset.forName("ISO-8859-15").encode(s)).flip(); - String t = Charset.forName("UTF-8").decode(bb).toString(); - System.err.println(t); - if (!t.equals(s)) - throw new Exception("Mismatch: " + s + " != " + t); + Charset preCs = Charset.forName("ISO-8859-15"); + if (!preCs.canEncode()) { + throw new RuntimeException("Error: Trying to test encode and " + + "decode methods on a charset that does not support encoding"); + } + bb.put(preCs.encode(pre)).flip(); + String post = Charset.forName("UTF-8").decode(bb).toString(); + assertEquals(pre, post, "Mismatch after encoding + decoding, :"); } + static Stream stringProvider() { + return Stream.of( + "Hello, world!", + "apple, banana, orange", + "car, truck, horse"); + } } diff -Nru openjdk-17-17.0.17+10/test/jdk/java/nio/charset/Charset/IllegalCharsetName.java openjdk-17-17.0.18+8/test/jdk/java/nio/charset/Charset/IllegalCharsetName.java --- openjdk-17-17.0.17+10/test/jdk/java/nio/charset/Charset/IllegalCharsetName.java 2025-10-13 07:48:04.000000000 +0000 +++ openjdk-17-17.0.18+8/test/jdk/java/nio/charset/Charset/IllegalCharsetName.java 2026-01-15 15:23:06.000000000 +0000 @@ -1,5 +1,5 @@ /* - * Copyright (c) 2010, 2017, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2010, 2025, Oracle and/or its affiliates. All rights reserved. * 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,46 +22,71 @@ */ /* @test - * @bug 6330020 8184665 + * @bug 4786884 6330020 8184665 * @summary Ensure Charset.forName/isSupport throws the correct exception * if the charset names passed in are illegal. + * @run junit IllegalCharsetName */ -import java.nio.charset.*; +import java.nio.charset.Charset; +import java.nio.charset.CharsetDecoder; +import java.nio.charset.CharsetEncoder; +import java.nio.charset.IllegalCharsetNameException; +import java.util.stream.Stream; + +import org.junit.jupiter.api.Test; +import org.junit.jupiter.params.ParameterizedTest; +import org.junit.jupiter.params.provider.MethodSource; + +import static org.junit.jupiter.api.Assertions.assertThrows; public class IllegalCharsetName { - public static void main(String[] args) throws Exception { - String[] illegalNames = { - ".", - "_", - ":", - "-", - ".name", - "_name", - ":name", - "-name", - "name*name", - "name?name" - }; - for (int i = 0; i < illegalNames.length; i++) { - try { - Charset.forName(illegalNames[i]); - throw new Exception("Charset.forName(): No exception thrown"); - } catch (IllegalCharsetNameException x) { //expected - } - - try { - Charset.isSupported(illegalNames[i]); - throw new Exception("Charset.isSupported(): No exception thrown"); - } catch (IllegalCharsetNameException x) { //expected - } - } - // Standard charsets may bypass alias checking during startup, test that - // they're all well-behaved as a sanity test - checkAliases(StandardCharsets.ISO_8859_1); - checkAliases(StandardCharsets.US_ASCII); - checkAliases(StandardCharsets.UTF_8); + // Charset.forName and Charset.isSupported should throw an + // IllegalCharsetNameException when passed an illegal name + @ParameterizedTest + @MethodSource("illegalNames") + public void illegalCharsetsTest(String name) { + assertThrows(IllegalCharsetNameException.class, + () -> Charset.forName(name)); + assertThrows(IllegalCharsetNameException.class, + () -> Charset.isSupported(name)); + } + + // Charset.forName, Charset.isSupported, and the Charset constructor should + // throw an IllegalCharsetNameException when passed an empty name + @Test + public void emptyCharsetsTest() { + assertThrows(IllegalCharsetNameException.class, + () -> Charset.forName("")); + assertThrows(IllegalCharsetNameException.class, + () -> Charset.isSupported("")); + assertThrows(IllegalCharsetNameException.class, + () -> new Charset("", new String[]{}) { + @Override + public boolean contains(Charset cs) { + return false; + } + + @Override + public CharsetDecoder newDecoder() { + return null; + } + + @Override + public CharsetEncoder newEncoder() { + return null; + } + }); + } + + // Standard charsets may bypass alias checking during startup, test that + // they're all well-behaved as a sanity test + @Test + public void aliasTest() { + for (Charset cs : Charset.availableCharsets().values()) { + checkAliases(cs); + } } private static void checkAliases(Charset cs) { @@ -70,4 +95,19 @@ Charset.isSupported(alias); } } + + static Stream illegalNames() { + return Stream.of( + ".", + "_", + ":", + "-", + ".name", + "_name", + ":name", + "-name", + "name*name", + "name?name" + ); + } } diff -Nru openjdk-17-17.0.17+10/test/jdk/java/nio/charset/Charset/NullCharsetName.java openjdk-17-17.0.18+8/test/jdk/java/nio/charset/Charset/NullCharsetName.java --- openjdk-17-17.0.17+10/test/jdk/java/nio/charset/Charset/NullCharsetName.java 2025-10-13 07:48:04.000000000 +0000 +++ openjdk-17-17.0.18+8/test/jdk/java/nio/charset/Charset/NullCharsetName.java 2026-01-15 15:23:06.000000000 +0000 @@ -1,5 +1,5 @@ /* - * Copyright (c) 2010, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2010, 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 @@ -24,29 +24,21 @@ /* @test * @bug 4448594 * @summary Ensure passing null to Charset.forName throws the correct exception + * @run junit NullCharsetName */ -import java.io.*; -import java.nio.*; -import java.nio.charset.*; -import java.util.*; +import java.nio.charset.Charset; +import org.junit.jupiter.api.Test; + +import static org.junit.jupiter.api.Assertions.assertThrows; public class NullCharsetName { - public static void main(String[] args) throws Exception { - try { - Charset.forName(null); - } catch (Exception x) { - if (x instanceof IllegalArgumentException) { - System.err.println("Thrown as expected: " + x); - return; - } - throw new Exception("Incorrect exception: " - + x.getClass().getName(), - x); - } - throw new Exception("No exception thrown"); + // Charset.forName should throw an exception when passed null + @Test + public void nullCharsetTest() { + assertThrows(IllegalArgumentException.class, + () -> Charset.forName(null)); } - } diff -Nru openjdk-17-17.0.17+10/test/jdk/java/nio/charset/Charset/RegisteredCharsets.java openjdk-17-17.0.18+8/test/jdk/java/nio/charset/Charset/RegisteredCharsets.java --- openjdk-17-17.0.17+10/test/jdk/java/nio/charset/Charset/RegisteredCharsets.java 2025-10-13 07:48:04.000000000 +0000 +++ openjdk-17-17.0.18+8/test/jdk/java/nio/charset/Charset/RegisteredCharsets.java 2026-01-15 15:23:06.000000000 +0000 @@ -26,1283 +26,1321 @@ 6911753 8071447 8186751 8242541 8301119 * @summary Check that registered charsets are actually registered * @modules jdk.charsets - * @run main RegisteredCharsets - * @run main/othervm -Djdk.charset.GB18030=2000 RegisteredCharsets + * @run junit RegisteredCharsets + * @run junit/othervm -Djdk.charset.GB18030=2000 RegisteredCharsets */ -import java.io.*; -import java.nio.*; -import java.nio.charset.*; -import java.util.*; +import java.nio.charset.Charset; +import java.nio.charset.UnsupportedCharsetException; +import java.util.stream.Stream; + +import org.junit.jupiter.api.Test; +import org.junit.jupiter.params.ParameterizedTest; +import org.junit.jupiter.params.provider.Arguments; +import org.junit.jupiter.params.provider.MethodSource; + +import static org.junit.jupiter.api.Assertions.assertEquals; +import static org.junit.jupiter.api.Assertions.assertThrows; public class RegisteredCharsets { - static String [] ianaRegistered = { - "US-ASCII", "UTF8", "Big5", "EUC-JP", - "GBK", "GB18030", "ISO-2022-KR", "ISO-2022-JP", - "GB2312", // IANA preferred name for "EUC-CN" - "ISO-8859-1", "ISO-8859-2", "ISO-8859-3", - "ISO-8859-4", "ISO-8859-5", "ISO-8859-6", - "ISO-8859-7", "ISO-8859-8", "ISO-8859-9", - "ISO-8859-13", "ISO-8859-15", "ISO-8859-16", - "windows-1251", - "windows-1252", "windows-1253", "windows-1254", - "windows-1255", "windows-1256", "windows-31j", - "Shift_JIS", "JIS_X0201", "JIS_X0212-1990", - "TIS-620", "Big5-HKSCS", - "ISO-2022-CN", - "IBM850", - "IBM852", - "IBM855", - "IBM857", - "IBM860", - "IBM861", - "IBM862", - "IBM863", - "IBM864", - "IBM865", - "IBM866", - "IBM868", - "IBM869", - "IBM437", - "IBM775", - "IBM037", - "IBM1026", - "IBM273", - "IBM277", - "IBM278", - "IBM280", - "IBM284", - "IBM285", - "IBM297", - "IBM420", - "IBM424", - "IBM500", - "IBM-Thai", - "IBM870", - "IBM871", - "IBM918", - "IBM1047", - "IBM01140", - "IBM01141", - "IBM01142", - "IBM01143", - "IBM01144", - "IBM01145", - "IBM01146", - "IBM01147", - "IBM01148", - "IBM01149", - "IBM00858" }; - - static String [] ianaUnRegistered = { - "x-EUC-TW", "x-ISCII91", - "x-windows-949", "x-windows-950", - "x-mswin-936", "x-JIS0208", - "x-ISO-8859-11", - "x-windows-874", - "x-PCK", "x-JISAutoDetect", "x-Johab", - "x-MS950-HKSCS", - "x-Big5-Solaris", - "x-ISO-2022-CN-CNS", - "x-ISO-2022-CN-GB", - "x-MacArabic", - "x-MacCentralEurope", - "x-MacCroatian", - "x-MacCyrillic", - "x-MacDingbat", - "x-MacGreek", - "x-MacHebrew", - "x-MacIceland", - "x-MacRoman", - "x-MacRomania", - "x-MacSymbol", - "x-MacThai", - "x-MacTurkish", - "x-MacUkraine", - "x-IBM942", - "x-IBM942C", - "x-IBM943", - "x-IBM943C", - "x-IBM948", - "x-IBM950", - "x-IBM930", - "x-IBM935", - "x-IBM937", - "x-IBM856", - "x-IBM874", - "x-IBM737", - "x-IBM1006", - "x-IBM1046", - "x-IBM1098", - "x-IBM1025", - "x-IBM1112", - "x-IBM1122", - "x-IBM1123", - "x-IBM1124", - "x-IBM1129", - "x-IBM1166", - "x-IBM875", - "x-IBM921", - "x-IBM922", - "x-IBM1097", - "x-IBM949", - "x-IBM949C", - "x-IBM939", - "x-IBM933", - "x-IBM1381", - "x-IBM1383", - "x-IBM970", - "x-IBM964", - "x-IBM33722", - "x-IBM1006", - "x-IBM1046", - "x-IBM1097", - "x-IBM1098", - "x-IBM1112", - "x-IBM1122", - "x-IBM1123", - "x-IBM1124", - "x-IBM33722", - "x-IBM737", - "x-IBM856", - "x-IBM874", - "x-IBM875", - "x-IBM922", - "x-IBM933", - "x-IBM964" }; + /** + * Tests that the aliases of the input String convert + * to the same Charset. This is validated by ensuring the input String + * and Charset.name() values are equal. + */ + @ParameterizedTest + @MethodSource("aliases") + public void testAliases(String canonicalName, String[] aliasNames) { + for (String aliasName : aliasNames) { + Charset cs = Charset.forName(aliasName); + assertEquals(cs.name(), canonicalName); + } + } - static void check(String csn, boolean testRegistered) throws Exception { - if (!Charset.forName(csn).isRegistered() && testRegistered) - throw new Exception("Not registered: " + csn); - else if (Charset.forName(csn).isRegistered() && !testRegistered) - throw new Exception("Registered: " + csn + "should be unregistered"); + /** + * Tests charsets to ensure that they are registered in the + * IANA Charset Registry. + */ + @ParameterizedTest + @MethodSource("ianaRegistered") + public void registeredTest(String cs) throws Exception { + check(cs, true); } - static void aliasCheck(String canonicalName, String[] aliasNames) throws Exception - { - for (int k = 0; k < aliasNames.length; k++ ) { - Charset cs = Charset.forName(aliasNames[k]); - if (!cs.name().equals(canonicalName)) { - throw new Exception("Unexpected Canonical name " + canonicalName); - } - } + /** + * Tests charsets to ensure that they are NOT registered in the + * IANA Charset Registry. + */ + @ParameterizedTest + @MethodSource("ianaUnregistered") + public void unregisteredTest(String cs) throws Exception { + check(cs, false); } - public static void main(String[] args) throws Exception { + /** + * Helper method which checks if a charset is registered and whether + * it should be. + */ + static void check(String csn, boolean testRegistered) throws Exception { + if (!Charset.forName(csn).isRegistered() && testRegistered) { + throw new Exception("Not registered: " + csn); + } + else if (Charset.forName(csn).isRegistered() && !testRegistered) { + throw new Exception("Registered: " + csn + "should be unregistered"); + } + } - for (int i = 0; i < ianaRegistered.length ; i++) - check(ianaRegistered[i], true); + // See https://www.iana.org/assignments/character-sets/character-sets.xhtml + private static Stream ianaRegistered() { + return Stream.of( + "US-ASCII", "UTF8", "Big5", "EUC-JP", + "GBK", "GB18030", "ISO-2022-KR", "ISO-2022-JP", + "GB2312", // IANA preferred name for "EUC-CN" + "ISO-8859-1", "ISO-8859-2", "ISO-8859-3", + "ISO-8859-4", "ISO-8859-5", "ISO-8859-6", + "ISO-8859-7", "ISO-8859-8", "ISO-8859-9", + "ISO-8859-13", "ISO-8859-15", "ISO-8859-16", + "windows-1251", + "windows-1252", "windows-1253", "windows-1254", + "windows-1255", "windows-1256", "windows-31j", + "Shift_JIS", "JIS_X0201", "JIS_X0212-1990", + "TIS-620", "Big5-HKSCS", + "ISO-2022-CN", + "IBM850", + "IBM852", + "IBM855", + "IBM857", + "IBM860", + "IBM861", + "IBM862", + "IBM863", + "IBM864", + "IBM865", + "IBM866", + "IBM868", + "IBM869", + "IBM437", + "IBM775", + "IBM037", + "IBM1026", + "IBM273", + "IBM277", + "IBM278", + "IBM280", + "IBM284", + "IBM285", + "IBM297", + "IBM420", + "IBM424", + "IBM500", + "IBM-Thai", + "IBM870", + "IBM871", + "IBM918", + "IBM1047", + "IBM01140", + "IBM01141", + "IBM01142", + "IBM01143", + "IBM01144", + "IBM01145", + "IBM01146", + "IBM01147", + "IBM01148", + "IBM01149", + "IBM00858" + ); + } - for (int i = 0; i < ianaUnRegistered.length ; i++) - check(ianaUnRegistered[i], false); + private static Stream ianaUnregistered() { + return Stream.of( + "x-EUC-TW", "x-ISCII91", + "x-windows-949", "x-windows-950", + "x-mswin-936", "x-JIS0208", + "x-ISO-8859-11", + "x-windows-874", + "x-PCK", "x-JISAutoDetect", "x-Johab", + "x-MS950-HKSCS", + "x-Big5-Solaris", + "x-ISO-2022-CN-CNS", + "x-ISO-2022-CN-GB", + "x-MacArabic", + "x-MacCentralEurope", + "x-MacCroatian", + "x-MacCyrillic", + "x-MacDingbat", + "x-MacGreek", + "x-MacHebrew", + "x-MacIceland", + "x-MacRoman", + "x-MacRomania", + "x-MacSymbol", + "x-MacThai", + "x-MacTurkish", + "x-MacUkraine", + "x-IBM942", + "x-IBM942C", + "x-IBM943", + "x-IBM943C", + "x-IBM948", + "x-IBM950", + "x-IBM930", + "x-IBM935", + "x-IBM937", + "x-IBM856", + "x-IBM874", + "x-IBM737", + "x-IBM1006", + "x-IBM1046", + "x-IBM1098", + "x-IBM1025", + "x-IBM1112", + "x-IBM1122", + "x-IBM1123", + "x-IBM1124", + "x-IBM1129", + "x-IBM1166", + "x-IBM875", + "x-IBM921", + "x-IBM922", + "x-IBM1097", + "x-IBM949", + "x-IBM949C", + "x-IBM939", + "x-IBM933", + "x-IBM1381", + "x-IBM1383", + "x-IBM970", + "x-IBM964", + "x-IBM33722", + "x-IBM1006", + "x-IBM1046", + "x-IBM1097", + "x-IBM1098", + "x-IBM1112", + "x-IBM1122", + "x-IBM1123", + "x-IBM1124", + "x-IBM33722", + "x-IBM737", + "x-IBM856", + "x-IBM874", + "x-IBM875", + "x-IBM922", + "x-IBM933", + "x-IBM964" + ); + } + private static Stream aliases() { // Check aliases registered with IANA for all NIO supported // Charset implementations. // // The aliases below are in sync with the IANA registered charset // document at: http://www.iana.org/assignments/character-sets // Last updated 7/25/2002 - - aliasCheck("US-ASCII", - new String[] {"ascii","ANSI_X3.4-1968", - "iso-ir-6","ANSI_X3.4-1986", "ISO_646.irv:1991", - "ASCII", "ISO646-US","us","IBM367","cp367", - "csASCII", "default"}); - - aliasCheck("UTF-8", - new String[] { - "UTF8", - "unicode-1-1-utf-8" - }); - - aliasCheck("UTF-16", - new String[] { - "UTF_16", - "utf16" - }); - - aliasCheck("UTF-16BE", - new String[] { - "UTF_16BE", - "ISO-10646-UCS-2", - "X-UTF-16BE", - "UnicodeBigUnmarked" - }); - - aliasCheck("UTF-16LE", - new String[] { - "UTF_16LE", - "X-UTF-16LE", - "UnicodeLittleUnmarked" - }); - - aliasCheck("Big5", - new String[] { - "csBig5" - }); - - aliasCheck("Big5-HKSCS", - new String[] { - "Big5_HKSCS", - "big5hk", - "big5-hkscs", - "big5hkscs" - }); - - aliasCheck("x-MS950-HKSCS", - new String[] { - "MS950_HKSCS" - }); - - aliasCheck("GB18030", - "2000".equals(System.getProperty("jdk.charset.GB18030")) ? - new String[] { - "gb18030-2000" - } : - new String[] { - "gb18030-2022" - }); - - aliasCheck("ISO-2022-KR", new String[] {"csISO2022KR"}); - aliasCheck("ISO-2022-JP", new String[] {"csISO2022JP"}); - aliasCheck("EUC-KR", new String[] { "csEUCKR"}); - aliasCheck("ISO-8859-1", - new String[] { - - // IANA aliases - "iso-ir-100", - "ISO_8859-1", - "latin1", - "l1", - "IBM819", - "cp819", - "csISOLatin1", - - // JDK historical aliases - "819", - "IBM-819", - "ISO8859_1", - "ISO_8859-1:1987", - "ISO_8859_1", - "8859_1", - "ISO8859-1", - - }); - - aliasCheck("ISO-8859-2", - new String[] { - "ISO_8859-2", - "ISO_8859-2:1987", - "iso-ir-101", - "latin2", - "l2", - "8859_2", - "iso_8859-2:1987", - "iso8859-2", - "ibm912", - "ibm-912", - "cp912", - "912", - "csISOLatin2"}); - - aliasCheck("ISO-8859-3", - new String[] {"latin3", - "ISO_8859-3:1988", - "iso-ir-109", - "l3", - "8859_3", - "iso_8859-3:1988", - "iso8859-3", - "ibm913", - "ibm-913", - "cp913", - "913", - "csISOLatin3"}); - - aliasCheck("ISO-8859-4", - new String[] {"csISOLatin4", - "ISO_8859-4:1988", - "iso-ir-110", - "latin4", - "8859_4", - "iso_8859-4:1988", - "iso8859-4", - "ibm914", - "ibm-914", - "cp914", - "914", - "l4"}); - - aliasCheck("ISO-8859-5", - new String[] { - "iso8859_5", // JDK historical - "8859_5", - "iso-ir-144", - "ISO_8859-5", - "ISO_8859-5:1988", - "ISO8859-5", - "cyrillic", - "ibm915", - "ibm-915", - "915", - "cp915", - "csISOLatinCyrillic" - }); - - aliasCheck("ISO-8859-6", - new String[] {"ISO_8859-6:1987", - "iso-ir-127", - "ISO_8859-6", - "ECMA-114", - "ASMO-708", - "arabic", - "8859_6", - "iso_8859-6:1987", - "iso8859-6", - "ibm1089", - "ibm-1089", - "cp1089", - "1089", - "csISOLatinArabic"}); - - aliasCheck("ISO-8859-7", - new String[] {"ISO_8859-7:1987", - "iso-ir-126", - "ISO_8859-7", - "ELOT_928", - "ECMA-118", - "greek", - "greek8", - "8859_7", - "iso_8859-7:1987", - "iso8859-7", - "ibm813", - "ibm-813", - "cp813", - "813", - "csISOLatinGreek"}); - - aliasCheck("ISO-8859-8", - new String[] { - "ISO_8859-8:1988", - "iso-ir-138", - "ISO_8859-8", - "hebrew", - "8859_8", - "iso_8859-8:1988", - "iso8859-8", - "ibm916", - "ibm-916", - "cp916", - "916", - "csISOLatinHebrew"}); - - aliasCheck("ISO-8859-9", - new String[] {"ISO_8859-9:1989", - "iso-ir-148", - "ISO_8859-9", - "latin5", - "l5", - "8859_9", - "iso8859-9", - "ibm920", - "ibm-920", - "cp920", - "920", - "csISOLatin5"}); - - aliasCheck("ISO-8859-13", - new String[] { - "iso8859_13", // JDK historical - "iso_8859-13", - "8859_13", - "ISO8859-13" - }); - - aliasCheck("ISO-8859-15", - new String[] { - // IANA alias - "ISO_8859-15", - "Latin-9", - "csISO885915", - // JDK historical aliases - "8859_15", - "ISO-8859-15", - "ISO_8859-15", - "ISO8859-15", - "ISO8859_15", - "IBM923", - "IBM-923", - "cp923", - "923", - "LATIN0", - "LATIN9", - "L9", - "csISOlatin0", - "csISOlatin9", - "ISO8859_15_FDIS" - }); - - aliasCheck("ISO-8859-16", - new String[] { - "iso-ir-226", - "ISO_8859-16:2001", - "ISO_8859-16", - "ISO8859_16", - "latin10", - "l10", - "csISO885916" - }); - - aliasCheck("JIS_X0212-1990", - new String[] { - "iso-ir-159", - "csISO159JISX02121990"}); - - aliasCheck("JIS_X0201", - new String[]{ - "X0201", - "csHalfWidthKatakana"}); - - aliasCheck("KOI8-R", - new String[] { - "KOI8_R", - "csKOI8R"}); - - aliasCheck("GBK", - new String[] { - "windows-936"}); - - aliasCheck("Shift_JIS", - new String[] { - "MS_Kanji", - "csShiftJIS"}); - - aliasCheck("EUC-JP", - new String[] { - "Extended_UNIX_Code_Packed_Format_for_Japanese", - "csEUCPkdFmtJapanese"}); - - aliasCheck("Big5", new String[] {"csBig5"}); - - aliasCheck("windows-31j", new String[] {"csWindows31J"}); - - aliasCheck("x-iso-8859-11", - new String[] { "iso-8859-11", "iso8859_11" }); - - aliasCheck("windows-1250", - new String[] { - "cp1250", - "cp5346" - }); - - aliasCheck("windows-1251", - new String[] { - "cp1251", - "cp5347", - "ansi-1251" - }); - - aliasCheck("windows-1252", - new String[] { - "cp1252", - "cp5348" - }); - - aliasCheck("windows-1253", - new String[] { - "cp1253", - "cp5349" - }); - - aliasCheck("windows-1254", - new String[] { - "cp1254", - "cp5350" - }); - - aliasCheck("windows-1255", - new String[] { - "cp1255" - }); - - aliasCheck("windows-1256", - new String[] { - "cp1256" - }); - - aliasCheck("windows-1257", - new String[] { - "cp1257", - "cp5353" - }); - - aliasCheck("windows-1258", - new String[] { - "cp1258" - }); - - aliasCheck("x-windows-874", - new String[] { - "ms874", "ms-874", "windows-874" }); - - aliasCheck("GB2312", - new String[] { - "x-EUC-CN", - "gb2312-80", - "gb2312-1980", - "euc-cn", - "euccn" }); - - aliasCheck("x-IBM942" , - new String[] { - "cp942", // JDK historical - "ibm942", - "ibm-942", - "942" - }); - - aliasCheck("x-IBM942C" , - new String[] { - "cp942C", // JDK historical - "ibm942C", - "ibm-942C", - "942C" - } ); - - aliasCheck("x-IBM943" , - new String[] { - "cp943", // JDK historical - "ibm943", - "ibm-943", - "943" - } ); - - aliasCheck("x-IBM943C" , - new String[] { - "cp943c", // JDK historical - "ibm943C", - "ibm-943C", - "943C" - } ); - - aliasCheck("x-IBM948" , - new String[] { - "cp948", // JDK historical - "ibm948", - "ibm-948", - "948" - } ); - - aliasCheck("x-IBM950" , - new String[] { - "cp950", // JDK historical - "ibm950", - "ibm-950", - "950" - } ); - - aliasCheck("x-IBM930" , - new String[] { - "cp930", // JDK historical - "ibm930", - "ibm-930", - "930" - } ); - - aliasCheck("x-IBM935" , - new String[] { - "cp935", // JDK historical - "ibm935", - "ibm-935", - "935" - } ); - - aliasCheck("x-IBM937" , - new String[] { - "cp937", // JDK historical - "ibm937", - "ibm-937", - "937" - } ); - - aliasCheck("IBM850" , - new String[] { - "cp850", // JDK historical - "ibm-850", - "ibm850", - "850", - "cspc850multilingual" - } ); - - aliasCheck("IBM852" , - new String[] { - "cp852", // JDK historical - "ibm852", - "ibm-852", - "852", - "csPCp852" - } ); - - aliasCheck("IBM855" , - new String[] { - "cp855", // JDK historical - "ibm-855", - "ibm855", - "855", - "cspcp855" - } ); - - aliasCheck("x-IBM856" , - new String[] { - "cp856", // JDK historical - "ibm-856", - "ibm856", - "856" - } ); - - aliasCheck("IBM857" , - new String[] { - "cp857", // JDK historical - "ibm857", - "ibm-857", - "857", - "csIBM857" - } ); - - aliasCheck("IBM860" , - new String[] { - "cp860", // JDK historical - "ibm860", - "ibm-860", - "860", - "csIBM860" - } ); - aliasCheck("IBM861" , - new String[] { - "cp861", // JDK historical - "ibm861", - "ibm-861", - "861", - "csIBM861" - } ); - - aliasCheck("IBM862" , - new String[] { - "cp862", // JDK historical - "ibm862", - "ibm-862", - "862", - "csIBM862" - } ); - - aliasCheck("IBM863" , - new String[] { - "cp863", // JDK historical - "ibm863", - "ibm-863", - "863", - "csIBM863" - } ); - - aliasCheck("IBM864" , - new String[] { - "cp864", // JDK historical - "ibm864", - "ibm-864", - "864", - "csIBM864" - } ); - - aliasCheck("IBM865" , - new String[] { - "cp865", // JDK historical - "ibm865", - "ibm-865", - "865", - "csIBM865" - } ); - - aliasCheck("IBM866" , new String[] { - "cp866", // JDK historical - "ibm866", - "ibm-866", - "866", - "csIBM866" - } ); - aliasCheck("IBM868" , - new String[] { - "cp868", // JDK historical - "ibm868", - "ibm-868", - "868", - "cp-ar", - "csIBM868" - } ); - - aliasCheck("IBM869" , - new String[] { - "cp869", // JDK historical - "ibm869", - "ibm-869", - "869", - "cp-gr", - "csIBM869" - } ); - - aliasCheck("IBM437" , - new String[] { - "cp437", // JDK historical - "ibm437", - "ibm-437", - "437", - "cspc8codepage437", - "windows-437" - } ); - - aliasCheck("x-IBM874" , - new String[] { - "cp874", // JDK historical - "ibm874", - "ibm-874", - "874" - } ); - aliasCheck("x-IBM737" , - new String[] { - "cp737", // JDK historical - "ibm737", - "ibm-737", - "737" - } ); - - aliasCheck("IBM775" , - new String[] { - "cp775", // JDK historical - "ibm775", - "ibm-775", - "775" - } ); - - aliasCheck("x-IBM921" , - new String[] { - "cp921", // JDK historical - "ibm921", - "ibm-921", - "921" - } ); - - aliasCheck("x-IBM1006" , - new String[] { - "cp1006", // JDK historical - "ibm1006", - "ibm-1006", - "1006" - } ); - - aliasCheck("x-IBM1046" , - new String[] { - "cp1046", // JDK historical - "ibm1046", - "ibm-1046", - "1046" - } ); - - aliasCheck("IBM1047" , - new String[] { - "cp1047", // JDK historical - "ibm-1047", - "1047" - } ); - - aliasCheck("x-IBM1098" , - new String[] { - "cp1098", // JDK historical - "ibm1098", - "ibm-1098", - "1098", - } ); - - aliasCheck("IBM037" , - new String[] { - "cp037", // JDK historical - "ibm037", - "csIBM037", - "cs-ebcdic-cp-us", - "cs-ebcdic-cp-ca", - "cs-ebcdic-cp-wt", - "cs-ebcdic-cp-nl", - "ibm-037", - "ibm-37", - "cpibm37", - "037" - } ); - - aliasCheck("x-IBM1025" , - new String[] { - "cp1025", // JDK historical - "ibm1025", - "ibm-1025", - "1025" - } ); - - aliasCheck("IBM1026" , - new String[] { - "cp1026", // JDK historical - "ibm1026", - "ibm-1026", - "1026" - } ); - - aliasCheck("x-IBM1112" , - new String[] { - "cp1112", // JDK historical - "ibm1112", - "ibm-1112", - "1112" - } ); - - aliasCheck("x-IBM1122" , - new String[] { - "cp1122", // JDK historical - "ibm1122", - "ibm-1122", - "1122" - } ); - - aliasCheck("x-IBM1123" , - new String[] { - "cp1123", // JDK historical - "ibm1123", - "ibm-1123", - "1123" - } ); - - aliasCheck("x-IBM1124" , - new String[] { - "cp1124", // JDK historical - "ibm1124", - "ibm-1124", - "1124" - } ); - - aliasCheck("x-IBM1129" , - new String[] { - "cp1129", // JDK historical - "ibm1129", - "ibm-1129", - "1129" - } ); - - aliasCheck("x-IBM1166" , - new String[] { - "cp1166", // JDK historical - "ibm1166", - "ibm-1166", - "1166" - } ); - - aliasCheck("IBM273" , - new String[] { - "cp273", // JDK historical - "ibm273", - "ibm-273", - "273" - } ); - - aliasCheck("IBM277" , - new String[] { - "cp277", // JDK historical - "ibm277", - "ibm-277", - "277" - } ); - - aliasCheck("IBM278" , - new String[] { - "cp278", // JDK historical - "ibm278", - "ibm-278", - "278", - "ebcdic-sv", - "ebcdic-cp-se", - "csIBM278" - } ); - - aliasCheck("IBM280" , - new String[] { - "cp280", // JDK historical - "ibm280", - "ibm-280", - "280" - } ); - - aliasCheck("IBM284" , - new String[] { - "cp284", // JDK historical - "ibm284", - "ibm-284", - "284", - "csIBM284", - "cpibm284" - } ); - - aliasCheck("IBM285" , - new String[] { - "cp285", // JDK historical - "ibm285", - "ibm-285", - "285", - "ebcdic-cp-gb", - "ebcdic-gb", - "csIBM285", - "cpibm285" - } ); - - aliasCheck("IBM297" , - new String[] { - "cp297", // JDK historical - "ibm297", - "ibm-297", - "297", - "ebcdic-cp-fr", - "cpibm297", - "csIBM297", - } ); - - aliasCheck("IBM420" , - new String[] { - "cp420", // JDK historical - "ibm420", - "ibm-420", - "ebcdic-cp-ar1", - "420", - "csIBM420" - } ); - - aliasCheck("IBM424" , - new String[] { - "cp424", // JDK historical - "ibm424", - "ibm-424", - "424", - "ebcdic-cp-he", - "csIBM424" - } ); - - aliasCheck("IBM500" , - new String[] { - "cp500", // JDK historical - "ibm500", - "ibm-500", - "500", - "ebcdic-cp-ch", - "ebcdic-cp-bh", - "csIBM500" - } ); - - aliasCheck("IBM-Thai" , - new String[] { - "cp838", // JDK historical - "ibm838", - "ibm-838", - "ibm838", - "838" - } ); - - aliasCheck("IBM870" , - new String[] { - "cp870", // JDK historical - "ibm870", - "ibm-870", - "870", - "ebcdic-cp-roece", - "ebcdic-cp-yu", - "csIBM870" - } ); - - aliasCheck("IBM871" , - new String[] { - "cp871", // JDK historical - "ibm871", - "ibm-871", - "871", - "ebcdic-cp-is", - "csIBM871" - } ); - - aliasCheck("x-IBM875" , - new String[] { - "cp875", // JDK historical - "ibm875", - "ibm-875", - "875" - } ); - - aliasCheck("IBM918" , - new String[] { - "cp918", // JDK historical - "ibm-918", - "918", - "ebcdic-cp-ar2" - } ); - - aliasCheck("x-IBM922" , - new String[] { - "cp922", // JDK historical - "ibm922", - "ibm-922", - "922" - } ); - - aliasCheck("x-IBM1097" , - new String[] { - "cp1097", // JDK historical - "ibm1097", - "ibm-1097", - "1097" - } ); - - aliasCheck("x-IBM949" , - new String[] { - "cp949", // JDK historical - "ibm949", - "ibm-949", - "949" - } ); - - aliasCheck("x-IBM949C" , - new String[] { - "cp949C", // JDK historical - "ibm949C", - "ibm-949C", - "949C" - } ); - - aliasCheck("x-IBM939" , - new String[] { - "cp939", // JDK historical - "ibm939", - "ibm-939", - "939" - } ); - - aliasCheck("x-IBM933" , - new String[] { - "cp933", // JDK historical - "ibm933", - "ibm-933", - "933" - } ); - - aliasCheck("x-IBM1381" , - new String[] { - "cp1381", // JDK historical - "ibm1381", - "ibm-1381", - "1381" - } ); - - aliasCheck("x-IBM1383" , - new String[] { - "cp1383", // JDK historical - "ibm1383", - "ibm-1383", - "1383" - } ); - - aliasCheck("x-IBM970" , - new String[] { - "cp970", // JDK historical - "ibm970", - "ibm-970", - "ibm-eucKR", - "970" - } ); - - aliasCheck("x-IBM964" , - new String[] { - "cp964", // JDK historical - "ibm964", - "ibm-964", - "964" - } ); - - aliasCheck("x-IBM33722" , - new String[] { - "cp33722", // JDK historical - "ibm33722", - "ibm-33722", - "ibm-5050", // from IBM alias list - "ibm-33722_vascii_vpua", // from IBM alias list - "33722" - } ); - - aliasCheck("IBM01140" , - new String[] { - "cp1140", // JDK historical - "ccsid01140", - "cp01140", - // "ebcdic-us-037+euro" - } ); - - aliasCheck("IBM01141" , - new String[] { - "cp1141", // JDK historical - "ccsid01141", - "cp01141", - // "ebcdic-de-273+euro" - } ); - - aliasCheck("IBM01142" , - new String[] { - "cp1142", // JDK historical - "ccsid01142", - "cp01142", - // "ebcdic-no-277+euro", - // "ebcdic-dk-277+euro" - } ); - - aliasCheck("IBM01143" , - new String[] { - "cp1143", // JDK historical - "ccsid01143", - "cp01143", - // "ebcdic-fi-278+euro", - // "ebcdic-se-278+euro" - } ); - - aliasCheck("IBM01144" , - new String[] { - "cp1144", // JDK historical - "ccsid01144", - "cp01144", - // "ebcdic-it-280+euro" - } ); - - aliasCheck("IBM01145" , - new String[] { - "cp1145", // JDK historical - "ccsid01145", - "cp01145", - // "ebcdic-es-284+euro" - } ); - - aliasCheck("IBM01146" , - new String[] { - "cp1146", // JDK historical - "ccsid01146", - "cp01146", - // "ebcdic-gb-285+euro" - } ); - - aliasCheck("IBM01147" , - new String[] { - "cp1147", // JDK historical - "ccsid01147", - "cp01147", - // "ebcdic-fr-277+euro" - } ); - - aliasCheck("IBM01148" , - new String[] { - "cp1148", // JDK historical - "ccsid01148", - "cp01148", - // "ebcdic-international-500+euro" - } ); - - aliasCheck("IBM01149" , - new String[] { - "cp1149", // JDK historical - "ccsid01149", - "cp01149", - // "ebcdic-s-871+euro" - } ); - - aliasCheck("IBM00858" , - new String[] { - "cp858", // JDK historical - "ccsid00858", - "cp00858", - // "PC-Multilingual-850+euro" - } ); - - aliasCheck("x-MacRoman", - new String[] { - "MacRoman" // JDK historical - }); - - aliasCheck("x-MacCentralEurope", - new String[] { - "MacCentralEurope" // JDK historical - }); - - aliasCheck("x-MacCroatian", - new String[] { - "MacCroatian" // JDK historical - }); - - - aliasCheck("x-MacCroatian", - new String[] { - "MacCroatian" // JDK historical - }); - - - aliasCheck("x-MacGreek", - new String[] { - "MacGreek" // JDK historical - }); - - aliasCheck("x-MacCyrillic", - new String[] { - "MacCyrillic" // JDK historical - }); - - aliasCheck("x-MacUkraine", - new String[] { - "MacUkraine" // JDK historical - }); - - aliasCheck("x-MacTurkish", - new String[] { - "MacTurkish" // JDK historical - }); - - aliasCheck("x-MacArabic", - new String[] { - "MacArabic" // JDK historical - }); - - aliasCheck("x-MacHebrew", - new String[] { - "MacHebrew" // JDK historical - }); - - aliasCheck("x-MacIceland", - new String[] { - "MacIceland" // JDK historical - }); - - aliasCheck("x-MacRomania", - new String[] { - "MacRomania" // JDK historical - }); - - aliasCheck("x-MacThai", - new String[] { - "MacThai" // JDK historical - }); - - aliasCheck("x-MacSymbol", - new String[] { - "MacSymbol" // JDK historical - }); - - aliasCheck("x-MacDingbat", - new String[] { - "MacDingbat" // JDK historical - }); + return Stream.of( + Arguments.of("US-ASCII", + new String[] {"ascii","ANSI_X3.4-1968", + "iso-ir-6","ANSI_X3.4-1986", "ISO_646.irv:1991", + "ASCII", "ISO646-US","us","IBM367","cp367", + "csASCII", "default"}), + + Arguments.of("UTF-8", + new String[] { + "UTF8", + "unicode-1-1-utf-8" + }), + + Arguments.of("UTF-16", + new String[] { + "UTF_16", + "utf16" + }), + + Arguments.of("UTF-16BE", + new String[] { + "UTF_16BE", + "ISO-10646-UCS-2", + "X-UTF-16BE", + "UnicodeBigUnmarked" + }), + + Arguments.of("UTF-16LE", + new String[] { + "UTF_16LE", + "X-UTF-16LE", + "UnicodeLittleUnmarked" + }), + + Arguments.of("Big5", + new String[] { + "csBig5" + }), + + Arguments.of("Big5-HKSCS", + new String[] { + "Big5_HKSCS", + "big5hk", + "big5-hkscs", + "big5hkscs" + }), + + Arguments.of("x-MS950-HKSCS", + new String[] { + "MS950_HKSCS" + }), + + Arguments.of("GB18030", + "2000".equals(System.getProperty("jdk.charset.GB18030")) ? + new String[] { + "gb18030-2000" + } : + new String[] { + "gb18030-2022" + }), + + Arguments.of("ISO-2022-KR", new String[] {"csISO2022KR"}), + Arguments.of("ISO-2022-JP", new String[] {"csISO2022JP"}), + Arguments.of("EUC-KR", new String[] { "csEUCKR"}), + Arguments.of("ISO-8859-1", + new String[] { + + // IANA aliases + "iso-ir-100", + "ISO_8859-1", + "latin1", + "l1", + "IBM819", + "cp819", + "csISOLatin1", + + // JDK historical aliases + "819", + "IBM-819", + "ISO8859_1", + "ISO_8859-1:1987", + "ISO_8859_1", + "8859_1", + "ISO8859-1", + + }), + + Arguments.of("ISO-8859-2", + new String[] { + "ISO_8859-2", + "ISO_8859-2:1987", + "iso-ir-101", + "latin2", + "l2", + "8859_2", + "iso_8859-2:1987", + "iso8859-2", + "ibm912", + "ibm-912", + "cp912", + "912", + "csISOLatin2"}), + + Arguments.of("ISO-8859-3", + new String[] {"latin3", + "ISO_8859-3:1988", + "iso-ir-109", + "l3", + "8859_3", + "iso_8859-3:1988", + "iso8859-3", + "ibm913", + "ibm-913", + "cp913", + "913", + "csISOLatin3"}), + + Arguments.of("ISO-8859-4", + new String[] {"csISOLatin4", + "ISO_8859-4:1988", + "iso-ir-110", + "latin4", + "8859_4", + "iso_8859-4:1988", + "iso8859-4", + "ibm914", + "ibm-914", + "cp914", + "914", + "l4"}), + + Arguments.of("ISO-8859-5", + new String[] { + "iso8859_5", // JDK historical + "8859_5", + "iso-ir-144", + "ISO_8859-5", + "ISO_8859-5:1988", + "ISO8859-5", + "cyrillic", + "ibm915", + "ibm-915", + "915", + "cp915", + "csISOLatinCyrillic" + }), + + Arguments.of("ISO-8859-6", + new String[] {"ISO_8859-6:1987", + "iso-ir-127", + "ISO_8859-6", + "ECMA-114", + "ASMO-708", + "arabic", + "8859_6", + "iso_8859-6:1987", + "iso8859-6", + "ibm1089", + "ibm-1089", + "cp1089", + "1089", + "csISOLatinArabic"}), + + Arguments.of("ISO-8859-7", + new String[] {"ISO_8859-7:1987", + "iso-ir-126", + "ISO_8859-7", + "ELOT_928", + "ECMA-118", + "greek", + "greek8", + "8859_7", + "iso_8859-7:1987", + "iso8859-7", + "ibm813", + "ibm-813", + "cp813", + "813", + "csISOLatinGreek"}), + + Arguments.of("ISO-8859-8", + new String[] { + "ISO_8859-8:1988", + "iso-ir-138", + "ISO_8859-8", + "hebrew", + "8859_8", + "iso_8859-8:1988", + "iso8859-8", + "ibm916", + "ibm-916", + "cp916", + "916", + "csISOLatinHebrew"}), + + Arguments.of("ISO-8859-9", + new String[] {"ISO_8859-9:1989", + "iso-ir-148", + "ISO_8859-9", + "latin5", + "l5", + "8859_9", + "iso8859-9", + "ibm920", + "ibm-920", + "cp920", + "920", + "csISOLatin5"}), + + Arguments.of("ISO-8859-13", + new String[] { + "iso8859_13", // JDK historical + "iso_8859-13", + "8859_13", + "ISO8859-13" + }), + + Arguments.of("ISO-8859-15", + new String[] { + // IANA alias + "ISO_8859-15", + "Latin-9", + "csISO885915", + // JDK historical aliases + "8859_15", + "ISO-8859-15", + "ISO_8859-15", + "ISO8859-15", + "ISO8859_15", + "IBM923", + "IBM-923", + "cp923", + "923", + "LATIN0", + "LATIN9", + "L9", + "csISOlatin0", + "csISOlatin9", + "ISO8859_15_FDIS" + }), + + Arguments.of("ISO-8859-16", + new String[] { + "iso-ir-226", + "ISO_8859-16:2001", + "ISO_8859-16", + "ISO8859_16", + "latin10", + "l10", + "csISO885916" + }), + + Arguments.of("JIS_X0212-1990", + new String[] { + "iso-ir-159", + "csISO159JISX02121990"}), + + Arguments.of("JIS_X0201", + new String[]{ + "X0201", + "csHalfWidthKatakana"}), + + Arguments.of("KOI8-R", + new String[] { + "KOI8_R", + "csKOI8R"}), + + Arguments.of("GBK", + new String[] { + "windows-936"}), + + Arguments.of("Shift_JIS", + new String[] { + "MS_Kanji", + "csShiftJIS"}), + + Arguments.of("EUC-JP", + new String[] { + "Extended_UNIX_Code_Packed_Format_for_Japanese", + "csEUCPkdFmtJapanese"}), + + Arguments.of("Big5", new String[] {"csBig5"}), + + Arguments.of("windows-31j", new String[] {"csWindows31J"}), + + Arguments.of("x-iso-8859-11", + new String[] { "iso-8859-11", "iso8859_11" }), + + Arguments.of("windows-1250", + new String[] { + "cp1250", + "cp5346" + }), + + Arguments.of("windows-1251", + new String[] { + "cp1251", + "cp5347", + "ansi-1251" + }), + + Arguments.of("windows-1252", + new String[] { + "cp1252", + "cp5348" + }), + + Arguments.of("windows-1253", + new String[] { + "cp1253", + "cp5349" + }), + + Arguments.of("windows-1254", + new String[] { + "cp1254", + "cp5350" + }), + + Arguments.of("windows-1255", + new String[] { + "cp1255" + }), + + Arguments.of("windows-1256", + new String[] { + "cp1256" + }), + + Arguments.of("windows-1257", + new String[] { + "cp1257", + "cp5353" + }), + + Arguments.of("windows-1258", + new String[] { + "cp1258" + }), + + Arguments.of("x-windows-874", + new String[] { + "ms874", "ms-874", "windows-874" }), + + Arguments.of("GB2312", + new String[] { + "x-EUC-CN", + "gb2312-80", + "gb2312-1980", + "euc-cn", + "euccn" }), + + Arguments.of("x-IBM942" , + new String[] { + "cp942", // JDK historical + "ibm942", + "ibm-942", + "942" + }), + + Arguments.of("x-IBM942C" , + new String[] { + "cp942C", // JDK historical + "ibm942C", + "ibm-942C", + "942C" + } ), + + Arguments.of("x-IBM943" , + new String[] { + "cp943", // JDK historical + "ibm943", + "ibm-943", + "943" + } ), + + Arguments.of("x-IBM943C" , + new String[] { + "cp943c", // JDK historical + "ibm943C", + "ibm-943C", + "943C" + } ), + + Arguments.of("x-IBM948" , + new String[] { + "cp948", // JDK historical + "ibm948", + "ibm-948", + "948" + } ), + + Arguments.of("x-IBM950" , + new String[] { + "cp950", // JDK historical + "ibm950", + "ibm-950", + "950" + } ), + + Arguments.of("x-IBM930" , + new String[] { + "cp930", // JDK historical + "ibm930", + "ibm-930", + "930" + } ), + + Arguments.of("x-IBM935" , + new String[] { + "cp935", // JDK historical + "ibm935", + "ibm-935", + "935" + } ), + + Arguments.of("x-IBM937" , + new String[] { + "cp937", // JDK historical + "ibm937", + "ibm-937", + "937" + } ), + + Arguments.of("IBM850" , + new String[] { + "cp850", // JDK historical + "ibm-850", + "ibm850", + "850", + "cspc850multilingual" + } ), + + Arguments.of("IBM852" , + new String[] { + "cp852", // JDK historical + "ibm852", + "ibm-852", + "852", + "csPCp852" + } ), + + Arguments.of("IBM855" , + new String[] { + "cp855", // JDK historical + "ibm-855", + "ibm855", + "855", + "cspcp855" + } ), + + Arguments.of("x-IBM856" , + new String[] { + "cp856", // JDK historical + "ibm-856", + "ibm856", + "856" + } ), + + Arguments.of("IBM857" , + new String[] { + "cp857", // JDK historical + "ibm857", + "ibm-857", + "857", + "csIBM857" + } ), + + Arguments.of("IBM860" , + new String[] { + "cp860", // JDK historical + "ibm860", + "ibm-860", + "860", + "csIBM860" + } ), + Arguments.of("IBM861" , + new String[] { + "cp861", // JDK historical + "ibm861", + "ibm-861", + "861", + "csIBM861" + } ), + + Arguments.of("IBM862" , + new String[] { + "cp862", // JDK historical + "ibm862", + "ibm-862", + "862", + "csIBM862" + } ), + + Arguments.of("IBM863" , + new String[] { + "cp863", // JDK historical + "ibm863", + "ibm-863", + "863", + "csIBM863" + } ), + + Arguments.of("IBM864" , + new String[] { + "cp864", // JDK historical + "ibm864", + "ibm-864", + "864", + "csIBM864" + } ), + + Arguments.of("IBM865" , + new String[] { + "cp865", // JDK historical + "ibm865", + "ibm-865", + "865", + "csIBM865" + } ), + + Arguments.of("IBM866" , new String[] { + "cp866", // JDK historical + "ibm866", + "ibm-866", + "866", + "csIBM866" + } ), + Arguments.of("IBM868" , + new String[] { + "cp868", // JDK historical + "ibm868", + "ibm-868", + "868", + "cp-ar", + "csIBM868" + } ), + + Arguments.of("IBM869" , + new String[] { + "cp869", // JDK historical + "ibm869", + "ibm-869", + "869", + "cp-gr", + "csIBM869" + } ), + + Arguments.of("IBM437" , + new String[] { + "cp437", // JDK historical + "ibm437", + "ibm-437", + "437", + "cspc8codepage437", + "windows-437" + } ), + + Arguments.of("x-IBM874" , + new String[] { + "cp874", // JDK historical + "ibm874", + "ibm-874", + "874" + } ), + Arguments.of("x-IBM737" , + new String[] { + "cp737", // JDK historical + "ibm737", + "ibm-737", + "737" + } ), + + Arguments.of("IBM775" , + new String[] { + "cp775", // JDK historical + "ibm775", + "ibm-775", + "775" + } ), + + Arguments.of("x-IBM921" , + new String[] { + "cp921", // JDK historical + "ibm921", + "ibm-921", + "921" + } ), + + Arguments.of("x-IBM1006" , + new String[] { + "cp1006", // JDK historical + "ibm1006", + "ibm-1006", + "1006" + } ), + + Arguments.of("x-IBM1046" , + new String[] { + "cp1046", // JDK historical + "ibm1046", + "ibm-1046", + "1046" + } ), + + Arguments.of("IBM1047" , + new String[] { + "cp1047", // JDK historical + "ibm-1047", + "1047" + } ), + + Arguments.of("x-IBM1098" , + new String[] { + "cp1098", // JDK historical + "ibm1098", + "ibm-1098", + "1098", + } ), + + Arguments.of("IBM037" , + new String[] { + "cp037", // JDK historical + "ibm037", + "csIBM037", + "cs-ebcdic-cp-us", + "cs-ebcdic-cp-ca", + "cs-ebcdic-cp-wt", + "cs-ebcdic-cp-nl", + "ibm-037", + "ibm-37", + "cpibm37", + "037" + } ), + + Arguments.of("x-IBM1025" , + new String[] { + "cp1025", // JDK historical + "ibm1025", + "ibm-1025", + "1025" + } ), + + Arguments.of("IBM1026" , + new String[] { + "cp1026", // JDK historical + "ibm1026", + "ibm-1026", + "1026" + } ), + + Arguments.of("x-IBM1112" , + new String[] { + "cp1112", // JDK historical + "ibm1112", + "ibm-1112", + "1112" + } ), + + Arguments.of("x-IBM1122" , + new String[] { + "cp1122", // JDK historical + "ibm1122", + "ibm-1122", + "1122" + } ), + + Arguments.of("x-IBM1123" , + new String[] { + "cp1123", // JDK historical + "ibm1123", + "ibm-1123", + "1123" + } ), + + Arguments.of("x-IBM1124" , + new String[] { + "cp1124", // JDK historical + "ibm1124", + "ibm-1124", + "1124" + } ), + + Arguments.of("x-IBM1129" , + new String[] { + "cp1129", // JDK historical + "ibm1129", + "ibm-1129", + "1129" + } ), + + Arguments.of("x-IBM1166" , + new String[] { + "cp1166", // JDK historical + "ibm1166", + "ibm-1166", + "1166" + } ), + + Arguments.of("IBM273" , + new String[] { + "cp273", // JDK historical + "ibm273", + "ibm-273", + "273" + } ), + + Arguments.of("IBM277" , + new String[] { + "cp277", // JDK historical + "ibm277", + "ibm-277", + "277" + } ), + + Arguments.of("IBM278" , + new String[] { + "cp278", // JDK historical + "ibm278", + "ibm-278", + "278", + "ebcdic-sv", + "ebcdic-cp-se", + "csIBM278" + } ), + + Arguments.of("IBM280" , + new String[] { + "cp280", // JDK historical + "ibm280", + "ibm-280", + "280" + } ), + + Arguments.of("IBM284" , + new String[] { + "cp284", // JDK historical + "ibm284", + "ibm-284", + "284", + "csIBM284", + "cpibm284" + } ), + + Arguments.of("IBM285" , + new String[] { + "cp285", // JDK historical + "ibm285", + "ibm-285", + "285", + "ebcdic-cp-gb", + "ebcdic-gb", + "csIBM285", + "cpibm285" + } ), + + Arguments.of("IBM297" , + new String[] { + "cp297", // JDK historical + "ibm297", + "ibm-297", + "297", + "ebcdic-cp-fr", + "cpibm297", + "csIBM297", + } ), + + Arguments.of("IBM420" , + new String[] { + "cp420", // JDK historical + "ibm420", + "ibm-420", + "ebcdic-cp-ar1", + "420", + "csIBM420" + } ), + + Arguments.of("IBM424" , + new String[] { + "cp424", // JDK historical + "ibm424", + "ibm-424", + "424", + "ebcdic-cp-he", + "csIBM424" + } ), + + Arguments.of("IBM500" , + new String[] { + "cp500", // JDK historical + "ibm500", + "ibm-500", + "500", + "ebcdic-cp-ch", + "ebcdic-cp-bh", + "csIBM500" + } ), + + Arguments.of("IBM-Thai" , + new String[] { + "cp838", // JDK historical + "ibm838", + "ibm-838", + "ibm838", + "838" + } ), + + Arguments.of("IBM870" , + new String[] { + "cp870", // JDK historical + "ibm870", + "ibm-870", + "870", + "ebcdic-cp-roece", + "ebcdic-cp-yu", + "csIBM870" + } ), + + Arguments.of("IBM871" , + new String[] { + "cp871", // JDK historical + "ibm871", + "ibm-871", + "871", + "ebcdic-cp-is", + "csIBM871" + } ), + + Arguments.of("x-IBM875" , + new String[] { + "cp875", // JDK historical + "ibm875", + "ibm-875", + "875" + } ), + + Arguments.of("IBM918" , + new String[] { + "cp918", // JDK historical + "ibm-918", + "918", + "ebcdic-cp-ar2" + } ), + + Arguments.of("x-IBM922" , + new String[] { + "cp922", // JDK historical + "ibm922", + "ibm-922", + "922" + } ), + + Arguments.of("x-IBM1097" , + new String[] { + "cp1097", // JDK historical + "ibm1097", + "ibm-1097", + "1097" + } ), + + Arguments.of("x-IBM949" , + new String[] { + "cp949", // JDK historical + "ibm949", + "ibm-949", + "949" + } ), + + Arguments.of("x-IBM949C" , + new String[] { + "cp949C", // JDK historical + "ibm949C", + "ibm-949C", + "949C" + } ), + + Arguments.of("x-IBM939" , + new String[] { + "cp939", // JDK historical + "ibm939", + "ibm-939", + "939" + } ), + + Arguments.of("x-IBM933" , + new String[] { + "cp933", // JDK historical + "ibm933", + "ibm-933", + "933" + } ), + + Arguments.of("x-IBM1381" , + new String[] { + "cp1381", // JDK historical + "ibm1381", + "ibm-1381", + "1381" + } ), + + Arguments.of("x-IBM1383" , + new String[] { + "cp1383", // JDK historical + "ibm1383", + "ibm-1383", + "1383" + } ), + + Arguments.of("x-IBM970" , + new String[] { + "cp970", // JDK historical + "ibm970", + "ibm-970", + "ibm-eucKR", + "970" + } ), + + Arguments.of("x-IBM964" , + new String[] { + "cp964", // JDK historical + "ibm964", + "ibm-964", + "964" + } ), + + Arguments.of("x-IBM33722" , + new String[] { + "cp33722", // JDK historical + "ibm33722", + "ibm-33722", + "ibm-5050", // from IBM alias list + "ibm-33722_vascii_vpua", // from IBM alias list + "33722" + } ), + + Arguments.of("IBM01140" , + new String[] { + "cp1140", // JDK historical + "ccsid01140", + "cp01140", + // "ebcdic-us-037+euro" + } ), + + Arguments.of("IBM01141" , + new String[] { + "cp1141", // JDK historical + "ccsid01141", + "cp01141", + // "ebcdic-de-273+euro" + } ), + + Arguments.of("IBM01142" , + new String[] { + "cp1142", // JDK historical + "ccsid01142", + "cp01142", + // "ebcdic-no-277+euro", + // "ebcdic-dk-277+euro" + } ), + + Arguments.of("IBM01143" , + new String[] { + "cp1143", // JDK historical + "ccsid01143", + "cp01143", + // "ebcdic-fi-278+euro", + // "ebcdic-se-278+euro" + } ), + + Arguments.of("IBM01144" , + new String[] { + "cp1144", // JDK historical + "ccsid01144", + "cp01144", + // "ebcdic-it-280+euro" + } ), + + Arguments.of("IBM01145" , + new String[] { + "cp1145", // JDK historical + "ccsid01145", + "cp01145", + // "ebcdic-es-284+euro" + } ), + + Arguments.of("IBM01146" , + new String[] { + "cp1146", // JDK historical + "ccsid01146", + "cp01146", + // "ebcdic-gb-285+euro" + } ), + + Arguments.of("IBM01147" , + new String[] { + "cp1147", // JDK historical + "ccsid01147", + "cp01147", + // "ebcdic-fr-277+euro" + } ), + + Arguments.of("IBM01148" , + new String[] { + "cp1148", // JDK historical + "ccsid01148", + "cp01148", + // "ebcdic-international-500+euro" + } ), + + Arguments.of("IBM01149" , + new String[] { + "cp1149", // JDK historical + "ccsid01149", + "cp01149", + // "ebcdic-s-871+euro" + } ), + + Arguments.of("IBM00858" , + new String[] { + "cp858", // JDK historical + "ccsid00858", + "cp00858", + // "PC-Multilingual-850+euro" + } ), + + Arguments.of("x-MacRoman", + new String[] { + "MacRoman" // JDK historical + }), + + Arguments.of("x-MacCentralEurope", + new String[] { + "MacCentralEurope" // JDK historical + }), + + Arguments.of("x-MacCroatian", + new String[] { + "MacCroatian" // JDK historical + }), + + + Arguments.of("x-MacCroatian", + new String[] { + "MacCroatian" // JDK historical + }), + + + Arguments.of("x-MacGreek", + new String[] { + "MacGreek" // JDK historical + }), + + Arguments.of("x-MacCyrillic", + new String[] { + "MacCyrillic" // JDK historical + }), + + Arguments.of("x-MacUkraine", + new String[] { + "MacUkraine" // JDK historical + }), + + Arguments.of("x-MacTurkish", + new String[] { + "MacTurkish" // JDK historical + }), + + Arguments.of("x-MacArabic", + new String[] { + "MacArabic" // JDK historical + }), + + Arguments.of("x-MacHebrew", + new String[] { + "MacHebrew" // JDK historical + }), + + Arguments.of("x-MacIceland", + new String[] { + "MacIceland" // JDK historical + }), + + Arguments.of("x-MacRomania", + new String[] { + "MacRomania" // JDK historical + }), + + Arguments.of("x-MacThai", + new String[] { + "MacThai" // JDK historical + }), + + Arguments.of("x-MacSymbol", + new String[] { + "MacSymbol" // JDK historical + }), + + Arguments.of("x-MacDingbat", + new String[] { + "MacDingbat" // JDK historical + }) + ); } } diff -Nru openjdk-17-17.0.17+10/test/jdk/java/rmi/transport/checkLeaseInfoLeak/CheckLeaseLeak.java openjdk-17-17.0.18+8/test/jdk/java/rmi/transport/checkLeaseInfoLeak/CheckLeaseLeak.java --- openjdk-17-17.0.17+10/test/jdk/java/rmi/transport/checkLeaseInfoLeak/CheckLeaseLeak.java 2025-10-13 07:48:04.000000000 +0000 +++ openjdk-17-17.0.18+8/test/jdk/java/rmi/transport/checkLeaseInfoLeak/CheckLeaseLeak.java 2026-01-15 15:23:06.000000000 +0000 @@ -1,5 +1,5 @@ /* - * Copyright (c) 1998, 2017, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 1998, 2025, Oracle and/or its affiliates. All rights reserved. * 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,12 +54,11 @@ import java.rmi.*; import java.rmi.server.*; -import sun.rmi.transport.*; -import sun.rmi.*; import java.util.Map; import java.io.*; import java.lang.reflect.*; import java.rmi.registry.*; +import sun.rmi.transport.*; public class CheckLeaseLeak extends UnicastRemoteObject implements LeaseLeak { public CheckLeaseLeak() throws RemoteException { } @@ -102,8 +101,6 @@ System.err.println("Created client: " + i); JavaVM jvm = new JavaVM("LeaseLeakClient", - " -Djava.security.policy=" + - TestParams.defaultPolicy + " -Drmi.registry.port=" + registryPort, ""); @@ -128,8 +125,8 @@ } } - /* numLeft should be 2 - if 11 there is a problem. */ - if (numLeft > 2) { + /* numLeft should be 4 - if 11 there is a problem. */ + if (numLeft > 4) { TestLibrary.bomb("Too many objects in DGCImpl.leaseTable: "+ numLeft); } else { @@ -156,57 +153,51 @@ Field f; try { - f = (Field) java.security.AccessController.doPrivileged - (new java.security.PrivilegedExceptionAction() { - public Object run() throws Exception { - - ObjID dgcID = new ObjID(DGC_ID); - - /* - * Construct an ObjectEndpoint containing DGC's - * ObjID. - */ - Class oeClass = - Class.forName("sun.rmi.transport.ObjectEndpoint"); - Class[] constrParams = - new Class[]{ ObjID.class, Transport.class }; - Constructor oeConstructor = - oeClass.getDeclaredConstructor(constrParams); - oeConstructor.setAccessible(true); - Object oe = - oeConstructor.newInstance( - new Object[]{ dgcID, null }); - - /* - * Get Target that contains DGCImpl in ObjectTable - */ - Class objTableClass = - Class.forName("sun.rmi.transport.ObjectTable"); - Class getTargetParams[] = new Class[] { oeClass }; - Method objTableGetTarget = - objTableClass.getDeclaredMethod("getTarget", - getTargetParams); - objTableGetTarget.setAccessible(true); - Target dgcTarget = (Target) - objTableGetTarget.invoke(null, new Object[]{ oe }); - - /* get the DGCImpl from its Target */ - Method targetGetImpl = - dgcTarget.getClass().getDeclaredMethod + ObjID dgcID = new ObjID(DGC_ID); + /* + * Construct an ObjectEndpoint containing DGC's + * ObjID. + */ + Class oeClass = + Class.forName("sun.rmi.transport.ObjectEndpoint"); + Class[] constrParams = + new Class[]{ ObjID.class, Transport.class }; + Constructor oeConstructor = + oeClass.getDeclaredConstructor(constrParams); + oeConstructor.setAccessible(true); + Object oe = + oeConstructor.newInstance( + new Object[]{ dgcID, null }); + + /* + * Get Target that contains DGCImpl in ObjectTable + */ + Class objTableClass = + Class.forName("sun.rmi.transport.ObjectTable"); + Class getTargetParams[] = new Class[] { oeClass }; + Method objTableGetTarget = + objTableClass.getDeclaredMethod("getTarget", + getTargetParams); + objTableGetTarget.setAccessible(true); + Target dgcTarget = (Target) + objTableGetTarget.invoke(null, new Object[]{ oe }); + + /* get the DGCImpl from its Target */ + Method targetGetImpl = + dgcTarget.getClass().getDeclaredMethod ("getImpl", null); - targetGetImpl.setAccessible(true); - dgcImpl[0] = - (Remote) targetGetImpl.invoke(dgcTarget, null); - - /* Get the lease table from the DGCImpl. */ - Field reflectedLeaseTable = - dgcImpl[0].getClass().getDeclaredField + targetGetImpl.setAccessible(true); + dgcImpl[0] = + (Remote) targetGetImpl.invoke(dgcTarget, null); + + /* Get the lease table from the DGCImpl. */ + Field reflectedLeaseTable = + dgcImpl[0].getClass().getDeclaredField ("leaseTable"); - reflectedLeaseTable.setAccessible(true); + reflectedLeaseTable.setAccessible(true); + + f = reflectedLeaseTable; - return reflectedLeaseTable; - } - }); /** * This is the leaseTable that will fill up with LeaseInfo @@ -217,9 +208,6 @@ numLeaseInfosLeft = leaseTable.size(); } catch(Exception e) { - if (e instanceof java.security.PrivilegedActionException) - e = ((java.security.PrivilegedActionException) e). - getException(); TestLibrary.bomb(e); } diff -Nru openjdk-17-17.0.17+10/test/jdk/java/rmi/transport/checkLeaseInfoLeak/LeaseLeakClient.java openjdk-17-17.0.18+8/test/jdk/java/rmi/transport/checkLeaseInfoLeak/LeaseLeakClient.java --- openjdk-17-17.0.17+10/test/jdk/java/rmi/transport/checkLeaseInfoLeak/LeaseLeakClient.java 2025-10-13 07:48:04.000000000 +0000 +++ openjdk-17-17.0.18+8/test/jdk/java/rmi/transport/checkLeaseInfoLeak/LeaseLeakClient.java 2026-01-15 15:23:06.000000000 +0000 @@ -1,5 +1,5 @@ /* - * Copyright (c) 1998, 2012, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 1998, 2025, Oracle and/or its affiliates. All rights reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * * This code is free software; you can redistribute it and/or modify it @@ -27,7 +27,6 @@ public class LeaseLeakClient { public static void main(String args[]) { - TestLibrary.suggestSecurityManager("java.rmi.RMISecurityManager"); try { LeaseLeak leaseLeak = null; diff -Nru openjdk-17-17.0.17+10/test/jdk/java/security/Provider/SecurityProviderModularTest.java openjdk-17-17.0.18+8/test/jdk/java/security/Provider/SecurityProviderModularTest.java --- openjdk-17-17.0.17+10/test/jdk/java/security/Provider/SecurityProviderModularTest.java 2025-10-13 07:48:04.000000000 +0000 +++ openjdk-17-17.0.18+8/test/jdk/java/security/Provider/SecurityProviderModularTest.java 2026-01-15 15:23:06.000000000 +0000 @@ -1,5 +1,5 @@ /* - * Copyright (c) 2015, 2017, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2015, 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 @@ -38,19 +38,22 @@ import java.io.OutputStream; import java.lang.module.ModuleDescriptor; import java.lang.module.ModuleDescriptor.Builder; -import jdk.internal.module.ModuleInfoWriter; import jdk.test.lib.process.ProcessTools; import jdk.test.lib.util.JarUtils; - +import jdk.test.lib.util.ModuleInfoWriter; /* * @test * @bug 8130360 8183310 * @summary Test security provider in different combination of modular option * defined with(out) service description. + * @modules java.base/jdk.internal.org.objectweb.asm + * java.base/jdk.internal.org.objectweb.asm.commons + * java.base/jdk.internal.module * @library /test/lib - * @modules java.base/jdk.internal.module - * @build jdk.test.lib.util.JarUtils TestProvider TestClient + * @build jdk.test.lib.util.JarUtils + * jdk.test.lib.util.ModuleInfoWriter + * TestProvider TestClient * @run main SecurityProviderModularTest CL true * @run main SecurityProviderModularTest CL false * @run main SecurityProviderModularTest SL true diff -Nru openjdk-17-17.0.17+10/test/jdk/java/security/Security/SecurityPropFile/TEST.properties openjdk-17-17.0.18+8/test/jdk/java/security/Security/SecurityPropFile/TEST.properties --- openjdk-17-17.0.17+10/test/jdk/java/security/Security/SecurityPropFile/TEST.properties 2025-10-13 07:48:04.000000000 +0000 +++ openjdk-17-17.0.18+8/test/jdk/java/security/Security/SecurityPropFile/TEST.properties 1970-01-01 00:00:00.000000000 +0000 @@ -1,2 +0,0 @@ -# disabled till JDK-8219408 is fixed -allowSmartActionArgs=false diff -Nru openjdk-17-17.0.17+10/test/jdk/java/text/Format/ChoiceFormat/ParseTest.java openjdk-17-17.0.18+8/test/jdk/java/text/Format/ChoiceFormat/ParseTest.java --- openjdk-17-17.0.17+10/test/jdk/java/text/Format/ChoiceFormat/ParseTest.java 1970-01-01 00:00:00.000000000 +0000 +++ openjdk-17-17.0.18+8/test/jdk/java/text/Format/ChoiceFormat/ParseTest.java 2026-01-15 15:23:06.000000000 +0000 @@ -0,0 +1,76 @@ +/* + * 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 8353585 + * @summary Basic parse tests. Enforce regular behavior, no match, and multi match. + * @run junit ParseTest + */ + +import org.junit.jupiter.params.ParameterizedTest; +import org.junit.jupiter.params.provider.Arguments; +import org.junit.jupiter.params.provider.MethodSource; + +import java.text.ChoiceFormat; +import java.text.ParsePosition; +import java.util.stream.Stream; + +import static org.junit.jupiter.api.Assertions.assertEquals; + +public class ParseTest { + + // Ensure that the parsed text produces the expected number + // i.e. return limit corresponding to format matched + @ParameterizedTest + @MethodSource + void parseTest(String pattern, String text, Double expected, int index) { + var pp = new ParsePosition(index); + var fmt = new ChoiceFormat(pattern); + assertEquals(expected, fmt.parse(text, pp), "Incorrect limit returned"); + if (expected.equals(Double.NaN)) { // AKA failed parse + assertEquals(index, pp.getErrorIndex(), + "Failed parse produced incorrect error index"); + } else { + assertEquals(-1, pp.getErrorIndex(), + "Error index should remain -1 on match"); + } + } + + private static Stream parseTest() { + return Stream.of( + Arguments.of("1#foo", "foo", Double.NaN, -1), + Arguments.of("1#baz", "foo bar baz", Double.NaN, 20), + Arguments.of("1#baz", "foo bar baz", 1d, 8), + Arguments.of("1#baz", "foo baz quux", Double.NaN, 8), + Arguments.of("1#a", "", Double.NaN, 0), + Arguments.of("1#a", "a", 1d, 0), + Arguments.of("1# ", " ", 1d, 0), + Arguments.of("1#a|2#a", "a", 1d, 0), + Arguments.of("1#a|2#aa", "aa", 2d, 0), + Arguments.of("1#a|2#aa", "aabb", 2d, 0), + Arguments.of("1#a|2#aa", "bbaa", Double.NaN, 0), + Arguments.of("1#aa|2#aaa", "a", Double.NaN, 0) + ); + } +} diff -Nru openjdk-17-17.0.17+10/test/jdk/java/text/Format/ChoiceFormat/PatternsTest.java openjdk-17-17.0.18+8/test/jdk/java/text/Format/ChoiceFormat/PatternsTest.java --- openjdk-17-17.0.17+10/test/jdk/java/text/Format/ChoiceFormat/PatternsTest.java 1970-01-01 00:00:00.000000000 +0000 +++ openjdk-17-17.0.18+8/test/jdk/java/text/Format/ChoiceFormat/PatternsTest.java 2026-01-15 15:23:06.000000000 +0000 @@ -0,0 +1,153 @@ +/* + * Copyright (c) 2023, Oracle and/or its affiliates. All rights reserved. + * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. + * + * This code is free software; you can redistribute it and/or modify it + * under the terms of the GNU General Public License version 2 only, as + * published by the Free Software Foundation. + * + * This code is distributed in the hope that it will be useful, but WITHOUT + * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or + * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License + * version 2 for more details (a copy is included in the LICENSE file that + * accompanied this code). + * + * You should have received a copy of the GNU General Public License version + * 2 along with this work; if not, write to the Free Software Foundation, + * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. + * + * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA + * or visit www.oracle.com if you need additional information or have any + * questions. + */ + +/* + * @test + * @bug 6801704 + * @summary Test the expected behavior for a wide range of patterns (both + * correct and incorrect). This test documents the behavior of incorrect + * ChoiceFormat patterns either throwing an exception, or discarding + * the incorrect portion of a pattern. + * @run junit PatternsTest + */ + +import java.text.ChoiceFormat; + +import org.junit.jupiter.api.Test; +import org.junit.jupiter.params.ParameterizedTest; +import org.junit.jupiter.params.provider.Arguments; +import org.junit.jupiter.params.provider.MethodSource; + +import static org.junit.jupiter.api.Assertions.assertDoesNotThrow; +import static org.junit.jupiter.api.Assertions.assertEquals; +import static org.junit.jupiter.api.Assertions.assertThrows; +import static org.junit.jupiter.params.provider.Arguments.arguments; + +public class PatternsTest { + + private static final String ERR1 = + "Each interval must contain a number before a format"; + private static final String ERR2 = + "Incorrect order of intervals, must be in ascending order"; + + // Check that some valid patterns do not throw an exception. Check + // them against the expected values they should be formatted as. + @ParameterizedTest + @MethodSource + public void validPatternsTest(String pattern, String[] expectedValues) { + var fmt = new ChoiceFormat(pattern); + for (int i=1; i<=expectedValues.length; i++) { + assertEquals(expectedValues[i-1], fmt.format(i), + String.format("ChoiceFormat formatted %s incorrectly:", i)); + } + } + + // Valid patterns ranging from normal appearing to odd. These should not + // throw an exception or discard any portions of the pattern. + private static Arguments[] validPatternsTest() { + return new Arguments[] { + // Multi pattern with trailing empty string Format + arguments("1#foo|2#bar|3#", new String[]{"foo", "bar", ""}), + // Multi patten with trailing '|' + arguments("1#foo|2#bar|", new String[]{"foo", "bar"}), + // Using a '>' (not a Relation) within a Format + arguments("1#foo|2#bar>", new String[]{"foo", "bar>"}), + // Standard Multi Pattern + arguments("1#foo|2#bar", new String[]{"foo", "bar"}), + // Same numerical value Limits, different Relations + arguments("1#foo|1 new ChoiceFormat(pattern)); + assertEquals(errMsg, ex.getMessage()); + } + + // Variety of patterns that break the ChoiceFormat pattern syntax and throw + // an exception. + private static Arguments[] invalidPatternsThrowsTest() { + return new Arguments[] { + arguments("#foo", ERR1), // No Limit + arguments("0#foo|#|1#bar", ERR1), // Missing Relation in SubPattern + arguments("#|", ERR1), // Missing Limit + arguments("##|", ERR1), // Double Relations + arguments("0#foo1#", ERR1), // SubPattern not separated by '|' + arguments("0#foo#", ERR1), // Using a Relation in a format + arguments("0#test|#", ERR1), // SubPattern missing Limit + arguments("0#foo|3#bar|1#baz", ERR2), // Non-ascending Limits + }; + } + + // Check that the incorrect pattern discards the trailing incorrect portion. + // These incorrect patterns should ideally throw an exception, but for + // behavioral compatibility reasons do not. + @ParameterizedTest + @MethodSource + public void invalidPatternsDiscardedTest(String brokenPattern, String actualPattern) { + var cf1 = new ChoiceFormat(brokenPattern); + var cf2 = new ChoiceFormat(actualPattern); + assertEquals(cf2, cf1, + String.format("Expected %s, but got %s", cf2.toPattern(), cf1.toPattern())); + } + + // Variety of incorrect patterns with the actual expected pattern + // after discarding occurs. + private static Arguments[] invalidPatternsDiscardedTest() { + return new Arguments[] { + // Incomplete SubPattern at the end of the Pattern + arguments("0#foo|1#bar|baz", "0#foo|1#bar"), + + // --- These throw an ArrayIndexOutOfBoundsException + // when attempting to format with them --- + // SubPattern with only a Limit (which is interpreted as a Format) + arguments("0", ""), + // SubPattern with only a Format + arguments("foo", ""), + // empty string + arguments("", "") + }; + } + + // Calling format() with empty limits and formats + // throws an ArrayIndexOutOfBoundsException + @Test + public void emptyLimitsAndFormatsTest() { + var cf1 = new ChoiceFormat(""); + assertThrows(ArrayIndexOutOfBoundsException.class, + () -> cf1.format(1)); + + var cf2 = new ChoiceFormat(new double[]{}, new String[]{}); + assertThrows(ArrayIndexOutOfBoundsException.class, + () -> cf2.format(2)); + } +} diff -Nru openjdk-17-17.0.17+10/test/jdk/java/text/Format/DateFormat/DateFormatRegression.java openjdk-17-17.0.18+8/test/jdk/java/text/Format/DateFormat/DateFormatRegression.java --- openjdk-17-17.0.17+10/test/jdk/java/text/Format/DateFormat/DateFormatRegression.java 2025-10-13 07:48:04.000000000 +0000 +++ openjdk-17-17.0.18+8/test/jdk/java/text/Format/DateFormat/DateFormatRegression.java 2026-01-15 15:23:06.000000000 +0000 @@ -1,5 +1,5 @@ /* - * Copyright (c) 1998, 2023, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 1998, 2025, Oracle and/or its affiliates. All rights reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * * This code is free software; you can redistribute it and/or modify it @@ -34,7 +34,7 @@ * @bug 4029195 4052408 4056591 4059917 4060212 4061287 4065240 4071441 4073003 * 4089106 4100302 4101483 4103340 4103341 4104136 4104522 4106807 4108407 * 4134203 4138203 4148168 4151631 4151706 4153860 4162071 4182066 4209272 4210209 - * 4213086 4250359 4253490 4266432 4406615 4413980 8008577 8305853 + * 4213086 4250359 4253490 4266432 4406615 4413980 8008577 8305853 8347841 * @library /java/text/testlib * @run junit/othervm -Djava.locale.providers=COMPAT,SPI DateFormatRegression */ @@ -274,7 +274,7 @@ try { Locale curLocale = new Locale("de","DE"); Locale.setDefault(curLocale); - TimeZone.setDefault(TimeZone.getTimeZone("EST")); + TimeZone.setDefault(TimeZone.getTimeZone("America/Panama")); curDate = new Date(98, 0, 1); shortdate = DateFormat.getDateInstance(DateFormat.SHORT); fulldate = DateFormat.getDateTimeInstance(DateFormat.LONG, DateFormat.LONG @@ -453,7 +453,7 @@ TimeZone savedTimeZone = TimeZone.getDefault(); try { boolean pass = true; - String[] IDs = new String[] {"Undefined", "PST", "US/Pacific", + String[] IDs = new String[] {"Undefined", "America/Los_Angeles", "US/Pacific", "GMT+3:00", "GMT-01:30"}; for (int i = 0; i < IDs.length; i++) { TimeZone tz = TimeZone.getTimeZone(IDs[i]); @@ -543,7 +543,7 @@ public void Test4103341() { TimeZone saveZone =TimeZone.getDefault(); try { - TimeZone.setDefault(TimeZone.getTimeZone("CST")); + TimeZone.setDefault(TimeZone.getTimeZone("America/Chicago")); SimpleDateFormat simple = new SimpleDateFormat("MM/dd/yyyy HH:mm"); if (!simple.getTimeZone().equals(TimeZone.getDefault())) fail("Fail: SimpleDateFormat not using default zone"); @@ -794,7 +794,7 @@ Locale savedLocale = Locale.getDefault(); TimeZone savedTimeZone = TimeZone.getDefault(); Locale.setDefault(Locale.US); - TimeZone.setDefault(TimeZone.getTimeZone("PST")); + TimeZone.setDefault(TimeZone.getTimeZone("America/Los_Angeles")); Date d1, d2; String dt = "Mon, 1 Jan 2001 00:00:00"; @@ -1096,7 +1096,7 @@ // XXX: Test assumes "PST" is not TimeZoneNames_ja. Need to // pick up another time zone when L10N is done to that file. - TimeZone.setDefault(TimeZone.getTimeZone("PST")); + TimeZone.setDefault(TimeZone.getTimeZone("America/Los_Angeles")); SimpleDateFormat fmt = new SimpleDateFormat("yy/MM/dd hh:ss zzz", Locale.JAPAN); @SuppressWarnings("deprecation") String result = fmt.format(new Date(1999 - 1900, 0, 1)); diff -Nru openjdk-17-17.0.17+10/test/jdk/java/text/Format/DateFormat/DateFormatTest.java openjdk-17-17.0.18+8/test/jdk/java/text/Format/DateFormat/DateFormatTest.java --- openjdk-17-17.0.17+10/test/jdk/java/text/Format/DateFormat/DateFormatTest.java 2025-10-13 07:48:04.000000000 +0000 +++ openjdk-17-17.0.18+8/test/jdk/java/text/Format/DateFormat/DateFormatTest.java 2026-01-15 15:23:06.000000000 +0000 @@ -1,5 +1,5 @@ /* - * Copyright (c) 1997, 2023, 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 @@ -24,14 +24,16 @@ /** * @test * @bug 4052223 4089987 4469904 4326988 4486735 8008577 8045998 8140571 - * 8190748 8216969 + * 8190748 8216969 8347841 * @summary test DateFormat and SimpleDateFormat. * @modules jdk.localedata * @run junit/othervm -Djava.locale.providers=COMPAT,SPI DateFormatTest */ -import java.util.*; +import java.time.ZoneId; import java.text.*; +import java.util.*; +import java.util.function.Predicate; import static java.util.GregorianCalendar.*; import org.junit.jupiter.api.Test; @@ -89,7 +91,9 @@ /* * A String array for the time zone ids. */ - String[] ids = TimeZone.getAvailableIDs(); + String[] ids = Arrays.stream(TimeZone.getAvailableIDs()) + .filter(Predicate.not(ZoneId.SHORT_IDS::containsKey)) + .toArray(String[]::new); /* * How many ids do we have? */ @@ -179,7 +183,7 @@ //logln(fmt.format(date)); // This shows what the current locale format is //logln(((SimpleDateFormat)fmt).toPattern()); TimeZone save = TimeZone.getDefault(); - TimeZone PST = TimeZone.getTimeZone("PST"); + TimeZone PST = TimeZone.getTimeZone("America/Los_Angeles"); String s = "03-Apr-04 2:20:47 o'clock AM PST"; int hour = 2; try { @@ -271,7 +275,7 @@ "0034", "0012", "0513", "Pacific Daylight Time", }; Date someDate = new Date(871508052513L); - TimeZone PST = TimeZone.getTimeZone("PST"); + TimeZone PST = TimeZone.getTimeZone("America/Los_Angeles"); for (int j = 0, exp = 0; j < dateFormats.length; ++j) { DateFormat df = dateFormats[j]; if (!(df instanceof SimpleDateFormat)) { diff -Nru openjdk-17-17.0.17+10/test/jdk/java/text/Format/DateFormat/SDFTCKZoneNamesTest.java openjdk-17-17.0.18+8/test/jdk/java/text/Format/DateFormat/SDFTCKZoneNamesTest.java --- openjdk-17-17.0.17+10/test/jdk/java/text/Format/DateFormat/SDFTCKZoneNamesTest.java 2025-10-13 07:48:04.000000000 +0000 +++ openjdk-17-17.0.18+8/test/jdk/java/text/Format/DateFormat/SDFTCKZoneNamesTest.java 2026-01-15 15:23:06.000000000 +0000 @@ -1,5 +1,5 @@ /* - * Copyright (c) 2019, 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 @@ -23,12 +23,13 @@ /** * @test - * @bug 8218948 + * @bug 8218948 8347841 * @summary TCK tests that check the time zone names between DFS.getZoneStrings() * and SDF.format("z*") * @run main SDFTCKZoneNamesTest */ import java.text.*; +import java.time.ZoneId; import java.util.Calendar; import java.util.Date; import java.util.List; @@ -325,6 +326,9 @@ SimpleDateFormat sdf = new SimpleDateFormat(); Date date = new Date(1234567890); for (String[] tz : sdf.getDateFormatSymbols().getZoneStrings()) { + if (ZoneId.SHORT_IDS.containsKey(tz[0])) { + continue; + } sdf.setTimeZone(TimeZone.getTimeZone(tz[0])); for (int i = 0; i < patterns.length && passed; i++) { StringBuffer result = new StringBuffer("qwerty"); diff -Nru openjdk-17-17.0.17+10/test/jdk/java/text/Format/DateFormat/bug4358730.java openjdk-17-17.0.18+8/test/jdk/java/text/Format/DateFormat/bug4358730.java --- openjdk-17-17.0.17+10/test/jdk/java/text/Format/DateFormat/bug4358730.java 2025-10-13 07:48:04.000000000 +0000 +++ openjdk-17-17.0.18+8/test/jdk/java/text/Format/DateFormat/bug4358730.java 2026-01-15 15:23:06.000000000 +0000 @@ -1,5 +1,5 @@ /* - * Copyright (c) 2000, 2023, 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 @@ -31,7 +31,7 @@ /** * @test - * @bug 4358730 + * @bug 4358730 8347841 * @summary test that confirms Zero-Padding on year. * @run junit bug4358730 */ @@ -56,7 +56,7 @@ Locale saveLocale = Locale.getDefault(); try { - TimeZone.setDefault(TimeZone.getTimeZone("PST")); + TimeZone.setDefault(TimeZone.getTimeZone("America/Los_Angeles")); Locale.setDefault(new Locale("en", "US")); SimpleDateFormat sdf = new SimpleDateFormat(); diff -Nru openjdk-17-17.0.17+10/test/jdk/java/util/Calendar/CalendarRegression.java openjdk-17-17.0.18+8/test/jdk/java/util/Calendar/CalendarRegression.java --- openjdk-17-17.0.17+10/test/jdk/java/util/Calendar/CalendarRegression.java 2025-10-13 07:48:04.000000000 +0000 +++ openjdk-17-17.0.18+8/test/jdk/java/util/Calendar/CalendarRegression.java 2026-01-15 15:23:06.000000000 +0000 @@ -1,5 +1,5 @@ /* - * Copyright (c) 1998, 2023, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 1998, 2025, Oracle and/or its affiliates. All rights reserved. * 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 @@ * 4174361 4177484 4197699 4209071 4288792 4328747 4413980 4546637 4623997 * 4685354 4655637 4683492 4080631 4080631 4167995 4340146 4639407 * 4652815 4652830 4740554 4936355 4738710 4633646 4846659 4822110 4960642 - * 4973919 4980088 4965624 5013094 5006864 8152077 + * 4973919 4980088 4965624 5013094 5006864 8152077 8347841 * @library /java/text/testlib * @run junit CalendarRegression */ @@ -42,6 +42,8 @@ import java.text.DateFormat; import java.text.NumberFormat; import java.text.SimpleDateFormat; +import java.time.ZoneId; +import java.util.Arrays; import java.util.Calendar; import java.util.Date; import java.util.GregorianCalendar; @@ -50,6 +52,7 @@ import java.util.Map; import java.util.SimpleTimeZone; import java.util.TimeZone; +import java.util.function.Predicate; import static java.util.Calendar.*; @@ -75,7 +78,9 @@ public void Test4031502() { // This bug actually occurs on Windows NT as well, and doesn't // require the host zone to be set; it can be set in Java. - String[] ids = TimeZone.getAvailableIDs(); + String[] ids = Arrays.stream(TimeZone.getAvailableIDs()) + .filter(Predicate.not(ZoneId.SHORT_IDS::containsKey)) + .toArray(String[]::new); boolean bad = false; for (int i = 0; i < ids.length; ++i) { TimeZone zone = TimeZone.getTimeZone(ids[i]); @@ -489,7 +494,7 @@ @Test public void Test4096231() { TimeZone GMT = TimeZone.getTimeZone("GMT"); - TimeZone PST = TimeZone.getTimeZone("PST"); + TimeZone PST = TimeZone.getTimeZone("America/Los_Angeles"); int sec = 0, min = 0, hr = 0, day = 1, month = 10, year = 1997; Calendar cal1 = new GregorianCalendar(PST); @@ -838,7 +843,7 @@ TimeZone saveZone = TimeZone.getDefault(); boolean fail = false; try { - TimeZone.setDefault(TimeZone.getTimeZone("PST")); + TimeZone.setDefault(TimeZone.getTimeZone("America/Los_Angeles")); Calendar cal = Calendar.getInstance(); long onset = new Date(98, APRIL, 5, 1, 0).getTime() + ONE_HOUR; long cease = new Date(98, OCTOBER, 25, 0, 0).getTime() + 2 * ONE_HOUR; @@ -1163,8 +1168,8 @@ @Test public void Test4149677() { TimeZone[] zones = {TimeZone.getTimeZone("GMT"), - TimeZone.getTimeZone("PST"), - TimeZone.getTimeZone("EAT")}; + TimeZone.getTimeZone("America/Los_Angeles"), + TimeZone.getTimeZone("Africa/Addis_Ababa")}; for (int i = 0; i < zones.length; ++i) { GregorianCalendar calendar = new GregorianCalendar(zones[i]); @@ -1197,7 +1202,7 @@ @Test public void Test4162587() { TimeZone savedTz = TimeZone.getDefault(); - TimeZone tz = TimeZone.getTimeZone("PST"); + TimeZone tz = TimeZone.getTimeZone("America/Los_Angeles"); TimeZone.setDefault(tz); GregorianCalendar cal = new GregorianCalendar(tz); Date d; @@ -1511,8 +1516,8 @@ */ @Test public void Test4177484() { - TimeZone PST = TimeZone.getTimeZone("PST"); - TimeZone EST = TimeZone.getTimeZone("EST"); + TimeZone PST = TimeZone.getTimeZone("America/Los_Angeles"); + TimeZone EST = TimeZone.getTimeZone("America/Panama"); Calendar cal = Calendar.getInstance(PST, Locale.US); cal.clear(); @@ -1770,7 +1775,7 @@ TimeZone savedTimeZone = TimeZone.getDefault(); try { boolean pass = true; - String[] IDs = new String[]{"Undefined", "PST", "US/Pacific", + String[] IDs = new String[]{"Undefined", "America/Los_Angeles", "US/Pacific", "GMT+3:00", "GMT-01:30"}; for (int i = 0; i < IDs.length; i++) { TimeZone tz = TimeZone.getTimeZone(IDs[i]); diff -Nru openjdk-17-17.0.17+10/test/jdk/java/util/Calendar/JavatimeTest.java openjdk-17-17.0.18+8/test/jdk/java/util/Calendar/JavatimeTest.java --- openjdk-17-17.0.17+10/test/jdk/java/util/Calendar/JavatimeTest.java 2025-10-13 07:48:04.000000000 +0000 +++ openjdk-17-17.0.18+8/test/jdk/java/util/Calendar/JavatimeTest.java 2026-01-15 15:23:06.000000000 +0000 @@ -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 @@ -23,7 +23,7 @@ /* *@test - *@bug 8007520 8008254 + *@bug 8007520 8008254 8347841 *@summary Test those bridge methods to/from java.time date/time classes * @key randomness */ @@ -107,23 +107,22 @@ ///////////// java.util.TimeZone ///////////////////////// for (String zidStr : TimeZone.getAvailableIDs()) { - // TBD: tzdt intergration + if (ZoneId.SHORT_IDS.containsKey(zidStr)) { + continue; + } + // TBD: tzdt integration if (zidStr.startsWith("SystemV") || zidStr.contains("Riyadh8") - || zidStr.equals("US/Pacific-New") - || zidStr.equals("EST") - || zidStr.equals("HST") - || zidStr.equals("MST")) { + || zidStr.equals("US/Pacific-New")) { continue; } - ZoneId zid = ZoneId.of(zidStr, ZoneId.SHORT_IDS); + ZoneId zid = ZoneId.of(zidStr); if (!zid.equals(TimeZone.getTimeZone(zid).toZoneId())) { throw new RuntimeException("FAILED: zid -> tz -> zid :" + zidStr); } TimeZone tz = TimeZone.getTimeZone(zidStr); // no round-trip for alias and "GMT" if (!tz.equals(TimeZone.getTimeZone(tz.toZoneId())) - && !ZoneId.SHORT_IDS.containsKey(zidStr) && !zidStr.startsWith("GMT")) { throw new RuntimeException("FAILED: tz -> zid -> tz :" + zidStr); } diff -Nru openjdk-17-17.0.17+10/test/jdk/java/util/Calendar/bug4316678.java openjdk-17-17.0.18+8/test/jdk/java/util/Calendar/bug4316678.java --- openjdk-17-17.0.17+10/test/jdk/java/util/Calendar/bug4316678.java 2025-10-13 07:48:04.000000000 +0000 +++ openjdk-17-17.0.18+8/test/jdk/java/util/Calendar/bug4316678.java 2026-01-15 15:23:06.000000000 +0000 @@ -1,5 +1,5 @@ /* - * Copyright (c) 2000, 2023, 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 @@ -23,7 +23,7 @@ /* * @test - * @bug 4316678 + * @bug 4316678 8347841 * @summary test that Calendar's Serialization works correctly. * @run junit bug4316678 */ @@ -53,7 +53,7 @@ // Set custom JVM default TimeZone @BeforeAll static void initAll() { - TimeZone.setDefault(TimeZone.getTimeZone("PST")); + TimeZone.setDefault(TimeZone.getTimeZone("America/Los_Angeles")); } // Restore JVM default Locale and TimeZone diff -Nru openjdk-17-17.0.17+10/test/jdk/java/util/Calendar/bug4372743.java openjdk-17-17.0.18+8/test/jdk/java/util/Calendar/bug4372743.java --- openjdk-17-17.0.17+10/test/jdk/java/util/Calendar/bug4372743.java 2025-10-13 07:48:04.000000000 +0000 +++ openjdk-17-17.0.18+8/test/jdk/java/util/Calendar/bug4372743.java 2026-01-15 15:23:06.000000000 +0000 @@ -1,5 +1,5 @@ /* - * Copyright (c) 2000, 2023, 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 @@ -23,7 +23,7 @@ /* * @test - * @bug 4372743 + * @bug 4372743 8347841 * @summary test that checks transitions of ERA and YEAR which are caused by add(MONTH). * @run junit bug4372743 */ @@ -67,7 +67,7 @@ // Set custom JVM default timezone @BeforeAll static void initAll() { - TimeZone.setDefault(TimeZone.getTimeZone("PST")); + TimeZone.setDefault(TimeZone.getTimeZone("America/Los_Angeles")); } // Restore JVM default timezone diff -Nru openjdk-17-17.0.17+10/test/jdk/java/util/Date/Bug4955000.java openjdk-17-17.0.18+8/test/jdk/java/util/Date/Bug4955000.java --- openjdk-17-17.0.17+10/test/jdk/java/util/Date/Bug4955000.java 2025-10-13 07:48:04.000000000 +0000 +++ openjdk-17-17.0.18+8/test/jdk/java/util/Date/Bug4955000.java 2026-01-15 15:23:06.000000000 +0000 @@ -1,5 +1,5 @@ /* - * Copyright (c) 2005, 2016, 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 @@ -23,7 +23,7 @@ /* * @test - * @bug 4955000 + * @bug 4955000 8347841 * @summary Make sure that a Date and a GregorianCalendar produce the * same date/time. Both are new implementations in 1.5. */ @@ -42,7 +42,7 @@ public static void main(String[] args) { TimeZone defaultTZ = TimeZone.getDefault(); try { - TimeZone.setDefault(TimeZone.getTimeZone("NST")); + TimeZone.setDefault(TimeZone.getTimeZone("Pacific/Auckland")); GregorianCalendar gc = new GregorianCalendar(TimeZone.getTimeZone("UTC")); // Date1025 int[] years1 = { diff -Nru openjdk-17-17.0.17+10/test/jdk/java/util/Date/DateRegression.java openjdk-17-17.0.18+8/test/jdk/java/util/Date/DateRegression.java --- openjdk-17-17.0.17+10/test/jdk/java/util/Date/DateRegression.java 2025-10-13 07:48:04.000000000 +0000 +++ openjdk-17-17.0.18+8/test/jdk/java/util/Date/DateRegression.java 2026-01-15 15:23:06.000000000 +0000 @@ -1,5 +1,5 @@ /* - * Copyright (c) 1998, 2023, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 1998, 2025, Oracle and/or its affiliates. All rights reserved. * 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,8 @@ /* * @test - * @bug 4023247 4027685 4032037 4072029 4073003 4118010 4120606 4133833 4136916 6274757 6314387 + * @bug 4023247 4027685 4032037 4072029 4073003 4118010 4120606 4133833 + * 4136916 6274757 6314387 8347841 * @run junit DateRegression */ @@ -106,7 +107,7 @@ TimeZone saveZone = TimeZone.getDefault(); try { - TimeZone.setDefault(TimeZone.getTimeZone("PST")); + TimeZone.setDefault(TimeZone.getTimeZone("America/Los_Angeles")); Date now = new Date(); String s = now.toString(); Date now2 = new Date(now.toString()); diff -Nru openjdk-17-17.0.17+10/test/jdk/java/util/Date/DateTest.java openjdk-17-17.0.18+8/test/jdk/java/util/Date/DateTest.java --- openjdk-17-17.0.17+10/test/jdk/java/util/Date/DateTest.java 2025-10-13 07:48:04.000000000 +0000 +++ openjdk-17-17.0.18+8/test/jdk/java/util/Date/DateTest.java 2026-01-15 15:23:06.000000000 +0000 @@ -1,5 +1,5 @@ /* - * Copyright (c) 1997, 2023, 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 @@ -23,7 +23,7 @@ /* * @test - * @bug 4143459 + * @bug 4143459 8347841 * @summary test Date * @run junit DateTest */ @@ -56,7 +56,7 @@ d.setMonth(Calendar.JANUARY); d.setDate(1); d.setHours(6); - TimeZone.setDefault(TimeZone.getTimeZone("PST")); + TimeZone.setDefault(TimeZone.getTimeZone("America/Los_Angeles")); if (d.getHours() != 22) { fail("Fail: Date.setHours()/getHours() ignoring default zone"); } @@ -79,7 +79,7 @@ Date ref = new Date(883634400000L); // This is Thu Jan 1 1998 6:00 am GMT String refstr = "Jan 1 1998 6:00"; TimeZone GMT = TimeZone.getTimeZone("GMT"); - TimeZone PST = TimeZone.getTimeZone("PST"); + TimeZone PST = TimeZone.getTimeZone("America/Los_Angeles"); String[] names = { "year", "month", "date", "day of week", "hour", "offset" }; int[] GMT_EXP = { 98, Calendar.JANUARY, 1, Calendar.THURSDAY - Calendar.SUNDAY, 6, 0 }; @@ -207,7 +207,7 @@ { TimeZone save = TimeZone.getDefault(); try { - TimeZone.setDefault(TimeZone.getTimeZone("PST")); + TimeZone.setDefault(TimeZone.getTimeZone("America/Los_Angeles")); Date d1=new java.util.Date(97,8,13,10,8,13); System.out.println("d = "+d1); Date d2=new java.util.Date(97,8,13,30,8,13); // 20 hours later diff -Nru openjdk-17-17.0.17+10/test/jdk/java/util/PluggableLocale/LocaleNameProviderTest.java openjdk-17-17.0.18+8/test/jdk/java/util/PluggableLocale/LocaleNameProviderTest.java --- openjdk-17-17.0.17+10/test/jdk/java/util/PluggableLocale/LocaleNameProviderTest.java 2025-10-13 07:48:04.000000000 +0000 +++ openjdk-17-17.0.18+8/test/jdk/java/util/PluggableLocale/LocaleNameProviderTest.java 2026-01-15 15:23:06.000000000 +0000 @@ -1,5 +1,5 @@ /* - * Copyright (c) 2007, 2018, 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 @@ -23,7 +23,7 @@ /* * @test - * @bug 4052440 8000273 8062588 8210406 + * @bug 4052440 8000273 8062588 8210406 8356040 * @summary LocaleNameProvider tests * @library providersrc/foobarutils * providersrc/barprovider @@ -31,97 +31,112 @@ * java.base/sun.util.resources * @build com.foobar.Utils * com.bar.* - * @run main/othervm -Djava.locale.providers=JRE,SPI LocaleNameProviderTest + * @run junit/othervm -Djava.locale.providers=JRE,SPI LocaleNameProviderTest */ +import java.util.ArrayList; import java.util.Arrays; import java.util.List; import java.util.Locale; import java.util.MissingResourceException; +import java.util.ResourceBundle; import com.bar.LocaleNameProviderImpl; +import org.junit.jupiter.api.Test; +import org.junit.jupiter.params.ParameterizedTest; +import org.junit.jupiter.params.provider.Arguments; +import org.junit.jupiter.params.provider.MethodSource; import sun.util.locale.provider.LocaleProviderAdapter; import sun.util.locale.provider.ResourceBundleBasedAdapter; import sun.util.resources.OpenListResourceBundle; public class LocaleNameProviderTest extends ProviderTest { - public static void main(String[] s) { - new LocaleNameProviderTest(); - } + private static final LocaleNameProviderImpl LNP = new LocaleNameProviderImpl(); + + /* + * This is not an exhaustive test. Such a test would require iterating (1000x1000)+ + * inputs. Instead, we check against Japanese lang locales which guarantees + * we will run into cases where the CLDR is not the preferred provider as the + * SPI has defined variants of the Japanese locale (E.g. osaka). + * See LocaleNameProviderImpl and LocaleNames ResourceBundle. + */ + @ParameterizedTest + @MethodSource + void checkAvailLocValidityTest(Locale target, Locale test, ResourceBundle rb, + boolean jreSupports, boolean spiSupports) { + // codes + String lang = test.getLanguage(); + String ctry = test.getCountry(); + String vrnt = test.getVariant(); + + // the localized name + String langresult = test.getDisplayLanguage(target); + String ctryresult = test.getDisplayCountry(target); + String vrntresult = test.getDisplayVariant(target); + + // provider's name (if any) + String providerslang = null; + String providersctry = null; + String providersvrnt = null; + if (spiSupports) { + providerslang = LNP.getDisplayLanguage(lang, target); + providersctry = LNP.getDisplayCountry(ctry, target); + providersvrnt = LNP.getDisplayVariant(vrnt, target); + } + + // JRE's name + String jreslang = null; + String jresctry = null; + String jresvrnt = null; + if (!lang.isEmpty()) { + try { + jreslang = rb.getString(lang); + } catch (MissingResourceException mre) {} + } + if (!ctry.isEmpty()) { + try { + jresctry = rb.getString(ctry); + } catch (MissingResourceException mre) {} + } + if (!vrnt.isEmpty()) { + try { + jresvrnt = rb.getString("%%"+vrnt); + } catch (MissingResourceException mre) {} + } - LocaleNameProviderTest() { - checkAvailLocValidityTest(); - variantFallbackTest(); + checkValidity(target, jreslang, providerslang, langresult, + jreSupports && jreslang != null); + checkValidity(target, jresctry, providersctry, ctryresult, + jreSupports && jresctry != null); + checkValidity(target, jresvrnt, providersvrnt, vrntresult, + jreSupports && jresvrnt != null); } - void checkAvailLocValidityTest() { - LocaleNameProviderImpl lnp = new LocaleNameProviderImpl(); - Locale[] availloc = Locale.getAvailableLocales(); - Locale[] testloc = availloc.clone(); - List jreimplloc = Arrays.asList(LocaleProviderAdapter.forJRE().getLocaleNameProvider().getAvailableLocales()); - List providerloc = Arrays.asList(lnp.getAvailableLocales()); + public static List checkAvailLocValidityTest() { + var args = new ArrayList(); + Locale[] availloc = Arrays.stream(Locale.getAvailableLocales()) + .filter(l -> l.getLanguage().equals("ja")) + .toArray(Locale[]::new); + List jreimplloc = Arrays.stream(LocaleProviderAdapter.forJRE().getLocaleNameProvider().getAvailableLocales()) + .filter(l -> l.getLanguage().equals("ja")) + .toList(); + List providerloc = Arrays.asList(LNP.getAvailableLocales()); - for (Locale target: availloc) { + for (Locale target : availloc) { // pure JRE implementation - OpenListResourceBundle rb = ((ResourceBundleBasedAdapter)LocaleProviderAdapter.forJRE()).getLocaleData().getLocaleNames(target); + OpenListResourceBundle rb = ((ResourceBundleBasedAdapter) LocaleProviderAdapter.forJRE()).getLocaleData().getLocaleNames(target); boolean jreSupportsTarget = jreimplloc.contains(target); - - for (Locale test: testloc) { - // codes - String lang = test.getLanguage(); - String ctry = test.getCountry(); - String vrnt = test.getVariant(); - - // the localized name - String langresult = test.getDisplayLanguage(target); - String ctryresult = test.getDisplayCountry(target); - String vrntresult = test.getDisplayVariant(target); - - // provider's name (if any) - String providerslang = null; - String providersctry = null; - String providersvrnt = null; - if (providerloc.contains(target)) { - providerslang = lnp.getDisplayLanguage(lang, target); - providersctry = lnp.getDisplayCountry(ctry, target); - providersvrnt = lnp.getDisplayVariant(vrnt, target); - } - - // JRE's name - String jreslang = null; - String jresctry = null; - String jresvrnt = null; - if (!lang.equals("")) { - try { - jreslang = rb.getString(lang); - } catch (MissingResourceException mre) {} - } - if (!ctry.equals("")) { - try { - jresctry = rb.getString(ctry); - } catch (MissingResourceException mre) {} - } - if (!vrnt.equals("")) { - try { - jresvrnt = rb.getString("%%"+vrnt); - } catch (MissingResourceException mre) {} - } - - System.out.print("For key: "+lang+" "); - checkValidity(target, jreslang, providerslang, langresult, - jreSupportsTarget && jreslang != null); - System.out.print("For key: "+ctry+" "); - checkValidity(target, jresctry, providersctry, ctryresult, - jreSupportsTarget && jresctry != null); - System.out.print("For key: "+vrnt+" "); - checkValidity(target, jresvrnt, providersvrnt, vrntresult, - jreSupportsTarget && jresvrnt != null); + boolean providerSupportsTarget = providerloc.contains(target); + for (Locale test : availloc) { + args.add(Arguments.of(target, test, rb, jreSupportsTarget, providerSupportsTarget)); } } + return args; } + @Test void variantFallbackTest() { Locale YY = new Locale("yy", "YY", "YYYY"); Locale YY_suffix = new Locale("yy", "YY", "YYYY_suffix"); @@ -143,4 +158,4 @@ throw new RuntimeException(message); } -} \ No newline at end of file +} diff -Nru openjdk-17-17.0.17+10/test/jdk/java/util/PluggableLocale/TimeZoneNameProviderTest.java openjdk-17-17.0.18+8/test/jdk/java/util/PluggableLocale/TimeZoneNameProviderTest.java --- openjdk-17-17.0.17+10/test/jdk/java/util/PluggableLocale/TimeZoneNameProviderTest.java 2025-10-13 07:48:04.000000000 +0000 +++ openjdk-17-17.0.18+8/test/jdk/java/util/PluggableLocale/TimeZoneNameProviderTest.java 2026-01-15 15:23:06.000000000 +0000 @@ -1,5 +1,5 @@ /* - * Copyright (c) 2007, 2018, 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 @@ -23,7 +23,7 @@ /* * @test - * @bug 4052440 8003267 8062588 8210406 + * @bug 4052440 8003267 8062588 8210406 8327434 8347841 * @summary TimeZoneNameProvider tests * @library providersrc/foobarutils * providersrc/barprovider @@ -37,6 +37,7 @@ import java.text.DateFormatSymbols; import java.text.ParseException; import java.text.SimpleDateFormat; +import java.time.ZoneId; import java.time.format.TextStyle; import java.util.Arrays; import java.util.Calendar; @@ -45,6 +46,8 @@ import java.util.Locale; import java.util.MissingResourceException; import java.util.TimeZone; +import java.util.function.Predicate; +import java.util.stream.Stream; import com.bar.TimeZoneNameProviderImpl; @@ -69,12 +72,14 @@ } void test1() { - Locale[] available = Locale.getAvailableLocales(); List jreimplloc = Arrays.asList(LocaleProviderAdapter.forJRE().getTimeZoneNameProvider().getAvailableLocales()); List providerLocales = Arrays.asList(tznp.getAvailableLocales()); - String[] ids = TimeZone.getAvailableIDs(); + String[] ids = Arrays.stream(TimeZone.getAvailableIDs()) + .filter(Predicate.not(ZoneId.SHORT_IDS::containsKey)) + .toArray(String[]::new); - for (Locale target: available) { + // Sampling relevant locales + Stream.concat(Stream.of(Locale.ROOT, Locale.US, Locale.JAPAN), providerLocales.stream()).forEach(target -> { // pure JRE implementation OpenListResourceBundle rb = ((ResourceBundleBasedAdapter)LocaleProviderAdapter.forJRE()).getLocaleData().getTimeZoneNames(target); boolean jreSupportsTarget = jreimplloc.contains(target); @@ -111,7 +116,7 @@ jreSupportsTarget && jresname != null); } } - } + }); } final String pattern = "z"; @@ -175,7 +180,7 @@ df.parse(DISPLAY_NAMES_KYOTO[i]); } } catch (ParseException pe) { - throw new RuntimeException("parse error occured" + pe); + throw new RuntimeException("parse error occurred" + pe); } finally { // restore the reserved locale and time zone Locale.setDefault(defaultLocale); @@ -185,8 +190,8 @@ void test3() { final String[] TZNAMES = { - LATIME, PST, PST8PDT, US_PACIFIC, - TOKYOTIME, JST, JAPAN, + LATIME, PST8PDT, US_PACIFIC, + TOKYOTIME, JAPAN, }; for (String tzname : TZNAMES) { TimeZone tz = TimeZone.getTimeZone(tzname); @@ -207,17 +212,13 @@ } final String LATIME = "America/Los_Angeles"; - final String PST = "PST"; final String PST8PDT = "PST8PDT"; final String US_PACIFIC = "US/Pacific"; final String LATIME_IN_OSAKA = tznp.getDisplayName(LATIME, false, TimeZone.LONG, OSAKA); final String TOKYOTIME = "Asia/Tokyo"; - final String JST = "JST"; final String JAPAN = "Japan"; - final String JST_IN_OSAKA = - tznp.getDisplayName(JST, false, TimeZone.LONG, OSAKA); void aliasTest() { // Check that provider's name for a standard id (America/Los_Angeles) is @@ -227,32 +228,10 @@ throw new RuntimeException("Could not get provider's localized name. result: "+latime+" expected: "+LATIME_IN_OSAKA); } - String pst = TimeZone.getTimeZone(PST).getDisplayName(OSAKA); - if (!LATIME_IN_OSAKA.equals(pst)) { - throw new RuntimeException("Provider's localized name is not available for an alias ID: "+PST+". result: "+pst+" expected: "+LATIME_IN_OSAKA); - } - String us_pacific = TimeZone.getTimeZone(US_PACIFIC).getDisplayName(OSAKA); if (!LATIME_IN_OSAKA.equals(us_pacific)) { throw new RuntimeException("Provider's localized name is not available for an alias ID: "+US_PACIFIC+". result: "+us_pacific+" expected: "+LATIME_IN_OSAKA); } - - // Check that provider's name for an alias id (JST) is - // propagated to its standard id and alias ids. - String jstime = TimeZone.getTimeZone(JST).getDisplayName(OSAKA); - if (!JST_IN_OSAKA.equals(jstime)) { - throw new RuntimeException("Could not get provider's localized name. result: "+jstime+" expected: "+JST_IN_OSAKA); - } - - String tokyotime = TimeZone.getTimeZone(TOKYOTIME).getDisplayName(OSAKA); - if (!JST_IN_OSAKA.equals(tokyotime)) { - throw new RuntimeException("Provider's localized name is not available for a standard ID: "+TOKYOTIME+". result: "+tokyotime+" expected: "+JST_IN_OSAKA); - } - - String japan = TimeZone.getTimeZone(JAPAN).getDisplayName(OSAKA); - if (!JST_IN_OSAKA.equals(japan)) { - throw new RuntimeException("Provider's localized name is not available for an alias ID: "+JAPAN+". result: "+japan+" expected: "+JST_IN_OSAKA); - } } /* diff -Nru openjdk-17-17.0.17+10/test/jdk/java/util/Properties/StoreDeadlock.java openjdk-17-17.0.18+8/test/jdk/java/util/Properties/StoreDeadlock.java --- openjdk-17-17.0.17+10/test/jdk/java/util/Properties/StoreDeadlock.java 2025-10-13 07:48:04.000000000 +0000 +++ openjdk-17-17.0.18+8/test/jdk/java/util/Properties/StoreDeadlock.java 2026-01-15 15:23:06.000000000 +0000 @@ -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 @@ -23,7 +23,7 @@ /* * @test - * @bug 6199320 + * @bug 6199320 8347841 * @summary Properties.store() causes deadlock when concurrently calling TimeZone apis * @run main/timeout=20 StoreDeadlock * @author Xueming Shen @@ -59,7 +59,7 @@ } class Thread2 extends Thread { public void run() { - System.out.println("tz=" + TimeZone.getTimeZone("PST")); + System.out.println("tz=" + TimeZone.getTimeZone("America/Los_Angeles")); } } } diff -Nru openjdk-17-17.0.17+10/test/jdk/java/util/TimeZone/Bug5097350.java openjdk-17-17.0.18+8/test/jdk/java/util/TimeZone/Bug5097350.java --- openjdk-17-17.0.17+10/test/jdk/java/util/TimeZone/Bug5097350.java 2025-10-13 07:48:04.000000000 +0000 +++ openjdk-17-17.0.18+8/test/jdk/java/util/TimeZone/Bug5097350.java 2026-01-15 15:23:06.000000000 +0000 @@ -1,5 +1,5 @@ /* - * Copyright (c) 2004, 2016, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2004, 2025, Oracle and/or its affiliates. All rights reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * * This code is free software; you can redistribute it and/or modify it @@ -23,16 +23,19 @@ /* * @test - * @bug 5097350 + * @bug 5097350 8347841 * @summary Make sure that TimeZone.getTimeZone returns a clone of a cached TimeZone instance. */ +import java.time.ZoneId; import java.util.*; -import java.text.*; +import java.util.function.Predicate; public class Bug5097350 { public static void main(String[] args) { - String[] tzids = TimeZone.getAvailableIDs(); + String[] tzids = Arrays.stream(TimeZone.getAvailableIDs()) + .filter(Predicate.not(ZoneId.SHORT_IDS::containsKey)) + .toArray(String[]::new); List ids = new ArrayList<>(tzids.length + 10); ids.addAll(Arrays.asList(tzids)); // add some custom ids diff -Nru openjdk-17-17.0.17+10/test/jdk/java/util/TimeZone/Bug6329116.java openjdk-17-17.0.18+8/test/jdk/java/util/TimeZone/Bug6329116.java --- openjdk-17-17.0.17+10/test/jdk/java/util/TimeZone/Bug6329116.java 2025-10-13 07:48:04.000000000 +0000 +++ openjdk-17-17.0.18+8/test/jdk/java/util/TimeZone/Bug6329116.java 2026-01-15 15:23:06.000000000 +0000 @@ -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 @@ -25,14 +25,16 @@ * @test * @bug 6329116 6756569 6757131 6758988 6764308 6796489 6834474 6609737 6507067 * 7039469 7090843 7103108 7103405 7158483 8008577 8059206 8064560 8072042 - * 8077685 8151876 8166875 8169191 8170316 8176044 + * 8077685 8151876 8166875 8169191 8170316 8176044 8347841 * @summary Make sure that timezone short display names are idenical to Olson's data. * @run junit/othervm -Djava.locale.providers=COMPAT,SPI Bug6329116 */ import java.io.*; import java.text.*; +import java.time.ZoneId; import java.util.*; +import java.util.function.Predicate; import org.junit.jupiter.api.Test; @@ -41,7 +43,9 @@ public class Bug6329116 { static Locale[] locales = Locale.getAvailableLocales(); - static String[] timezones = TimeZone.getAvailableIDs(); + static String[] timezones = Arrays.stream(TimeZone.getAvailableIDs()) + .filter(Predicate.not(ZoneId.SHORT_IDS::containsKey)) + .toArray(String[]::new); @Test public void bug6329116() throws IOException { @@ -98,6 +102,9 @@ tzs[0] = timezoneID; for (int j = 0; j < tzs.length; j++) { + if (ZoneId.SHORT_IDS.containsKey(tzs[j])) { + continue; + } tz = TimeZone.getTimeZone(tzs[j]); if (!tzs[j].equals(tz.getID())) { diff -Nru openjdk-17-17.0.17+10/test/jdk/java/util/TimeZone/Bug6772689.java openjdk-17-17.0.18+8/test/jdk/java/util/TimeZone/Bug6772689.java --- openjdk-17-17.0.17+10/test/jdk/java/util/TimeZone/Bug6772689.java 2025-10-13 07:48:04.000000000 +0000 +++ openjdk-17-17.0.18+8/test/jdk/java/util/TimeZone/Bug6772689.java 2026-01-15 15:23:06.000000000 +0000 @@ -1,5 +1,5 @@ /* - * Copyright (c) 2011, 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 @@ -23,15 +23,18 @@ /* * @test - * @bug 6772689 + * @bug 6772689 8347841 * @summary Test for standard-to-daylight transitions at midnight: * date stays on the given day. */ +import java.time.ZoneId; +import java.util.Arrays; import java.util.Calendar; import java.util.Date; import java.util.GregorianCalendar; import java.util.TimeZone; +import java.util.function.Predicate; import static java.util.GregorianCalendar.*; public class Bug6772689 { @@ -43,7 +46,9 @@ int errors = 0; Calendar cal = new GregorianCalendar(BEGIN_YEAR, MARCH, 1); - String[] tzids = TimeZone.getAvailableIDs(); + String[] tzids = Arrays.stream(TimeZone.getAvailableIDs()) + .filter(Predicate.not(ZoneId.SHORT_IDS::containsKey)) + .toArray(String[]::new); try { for (String id : tzids) { TimeZone tz = TimeZone.getTimeZone(id); diff -Nru openjdk-17-17.0.17+10/test/jdk/java/util/TimeZone/DaylightTimeTest.java openjdk-17-17.0.18+8/test/jdk/java/util/TimeZone/DaylightTimeTest.java --- openjdk-17-17.0.17+10/test/jdk/java/util/TimeZone/DaylightTimeTest.java 2025-10-13 07:48:04.000000000 +0000 +++ openjdk-17-17.0.18+8/test/jdk/java/util/TimeZone/DaylightTimeTest.java 2026-01-15 15:23:06.000000000 +0000 @@ -1,5 +1,5 @@ /* - * Copyright (c) 2011, 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 @@ -23,17 +23,21 @@ /* * @test - * @bug 6936350 + * @bug 6936350 8347841 * @summary Test case for TimeZone.observesDaylightTime() */ +import java.time.ZoneId; import java.util.*; +import java.util.function.Predicate; import static java.util.GregorianCalendar.*; public class DaylightTimeTest { private static final int ONE_HOUR = 60 * 60 * 1000; // one hour private static final int INTERVAL = 24 * ONE_HOUR; // one day - private static final String[] ZONES = TimeZone.getAvailableIDs(); + private static final String[] ZONES = Arrays.stream(TimeZone.getAvailableIDs()) + .filter(Predicate.not(ZoneId.SHORT_IDS::containsKey)) + .toArray(String[]::new); private static int errors = 0; public static void main(String[] args) { diff -Nru openjdk-17-17.0.17+10/test/jdk/java/util/TimeZone/IDTest.java openjdk-17-17.0.18+8/test/jdk/java/util/TimeZone/IDTest.java --- openjdk-17-17.0.17+10/test/jdk/java/util/TimeZone/IDTest.java 2025-10-13 07:48:04.000000000 +0000 +++ openjdk-17-17.0.18+8/test/jdk/java/util/TimeZone/IDTest.java 2026-01-15 15:23:06.000000000 +0000 @@ -1,5 +1,5 @@ /* - * Copyright (c) 2002, 2016, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2002, 2025, Oracle and/or its affiliates. All rights reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * * This code is free software; you can redistribute it and/or modify it @@ -23,24 +23,30 @@ /* * @test - * @bug 4509255 5055567 6176318 7090844 + * @bug 4509255 5055567 6176318 7090844 8347841 * @summary Tests consistencies of time zone IDs. */ +import java.time.ZoneId; import java.util.Arrays; import java.util.HashSet; import java.util.Map; import java.util.Set; import java.util.TimeZone; import java.util.TreeMap; +import java.util.function.Predicate; public class IDTest { public static void main(String[] args) { Set ids = new HashSet<>(); Map> tree = new TreeMap<>(); - String[] tzs = TimeZone.getAvailableIDs(); - String[] tzs2 = TimeZone.getAvailableIDs(); + String[] tzs = Arrays.stream(TimeZone.getAvailableIDs()) + .filter(Predicate.not(ZoneId.SHORT_IDS::containsKey)) + .toArray(String[]::new); + String[] tzs2 = Arrays.stream(TimeZone.getAvailableIDs()) + .filter(Predicate.not(ZoneId.SHORT_IDS::containsKey)) + .toArray(String[]::new); if (tzs.length != tzs2.length) { throw new RuntimeException("tzs.length(" + tzs.length + ") != tzs2.length(" + tzs2.length + ")"); @@ -83,8 +89,12 @@ // Check the getAvailableIDs(int) call to return the same // set of IDs int offset = key.intValue(); - tzs = TimeZone.getAvailableIDs(offset); - tzs2 = TimeZone.getAvailableIDs(offset); + tzs = Arrays.stream(TimeZone.getAvailableIDs(offset)) + .filter(Predicate.not(ZoneId.SHORT_IDS::containsKey)) + .toArray(String[]::new); + tzs2 = Arrays.stream(TimeZone.getAvailableIDs(offset)) + .filter(Predicate.not(ZoneId.SHORT_IDS::containsKey)) + .toArray(String[]::new); if (!Arrays.equals(tzs, tzs2)) { throw new RuntimeException("inconsistent tzs from getAvailableIDs("+offset+")"); } diff -Nru openjdk-17-17.0.17+10/test/jdk/java/util/TimeZone/ListTimeZones.java openjdk-17-17.0.18+8/test/jdk/java/util/TimeZone/ListTimeZones.java --- openjdk-17-17.0.17+10/test/jdk/java/util/TimeZone/ListTimeZones.java 2025-10-13 07:48:04.000000000 +0000 +++ openjdk-17-17.0.18+8/test/jdk/java/util/TimeZone/ListTimeZones.java 2026-01-15 15:23:06.000000000 +0000 @@ -1,5 +1,5 @@ /* - * Copyright (c) 2009, 2013, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2009, 2025, Oracle and/or its affiliates. All rights reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * * This code is free software; you can redistribute it and/or modify it @@ -23,17 +23,21 @@ /** * @test - * @bug 6851214 + * @bug 6851214 8347841 * @summary Allow 24:00 as a valid end/start DST time stamp * @run main ListTimeZones */ +import java.time.ZoneId; import java.util.*; +import java.util.function.Predicate; public class ListTimeZones{ public static void main(String[] args){ Date date = new Date(); - String TimeZoneIds[] = TimeZone.getAvailableIDs(); + String[] TimeZoneIds = Arrays.stream(TimeZone.getAvailableIDs()) + .filter(Predicate.not(ZoneId.SHORT_IDS::containsKey)) + .toArray(String[]::new); for(int i = 0; i < TimeZoneIds.length; i++){ TimeZone tz = TimeZone.getTimeZone(TimeZoneIds[i]); Calendar calendar = new GregorianCalendar(tz); diff -Nru openjdk-17-17.0.17+10/test/jdk/java/util/TimeZone/NegativeDSTTest.java openjdk-17-17.0.18+8/test/jdk/java/util/TimeZone/NegativeDSTTest.java --- openjdk-17-17.0.17+10/test/jdk/java/util/TimeZone/NegativeDSTTest.java 2025-10-13 07:48:04.000000000 +0000 +++ openjdk-17-17.0.18+8/test/jdk/java/util/TimeZone/NegativeDSTTest.java 2026-01-15 15:23:06.000000000 +0000 @@ -1,5 +1,5 @@ /* - * Copyright (c) 2019, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2019, 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 @@ -37,7 +37,7 @@ /** * @test - * @bug 8212970 + * @bug 8212970 8324065 * @summary Test whether the savings are positive in time zones that have * negative savings in the source TZ files. * @run testng NegativeDSTTest @@ -81,7 +81,10 @@ {CASABLANCA, LocalDate.of(2019, 5, 6), 0, false}, {CASABLANCA, LocalDate.of(2037, 10, 5), 0, false}, {CASABLANCA, LocalDate.of(2037, 11, 16), ONE_HOUR, true}, + {CASABLANCA, LocalDate.of(2038, 9, 27), 0, false}, {CASABLANCA, LocalDate.of(2038, 11, 1), ONE_HOUR, true}, + {CASABLANCA, LocalDate.of(2087, 3, 31), 0, false}, + {CASABLANCA, LocalDate.of(2087, 5, 12), ONE_HOUR, true}, }; } diff -Nru openjdk-17-17.0.17+10/test/jdk/java/util/TimeZone/SimpleTimeZoneEqualsHashCodeTest.java openjdk-17-17.0.18+8/test/jdk/java/util/TimeZone/SimpleTimeZoneEqualsHashCodeTest.java --- openjdk-17-17.0.17+10/test/jdk/java/util/TimeZone/SimpleTimeZoneEqualsHashCodeTest.java 1970-01-01 00:00:00.000000000 +0000 +++ openjdk-17-17.0.18+8/test/jdk/java/util/TimeZone/SimpleTimeZoneEqualsHashCodeTest.java 2026-01-15 15:23:06.000000000 +0000 @@ -0,0 +1,83 @@ +/* + * 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 8369184 + * @summary Checks if equals()/hashCode() of SimpleTimeZone works correctly + * @run junit SimpleTimeZoneEqualsHashCodeTest + */ + +import java.util.SimpleTimeZone; +import static java.util.Calendar.MARCH; +import static java.util.Calendar.NOVEMBER; +import static java.util.Calendar.SUNDAY; + +import org.junit.jupiter.api.Test; + +import static org.junit.jupiter.api.Assertions.assertEquals; +import static org.junit.jupiter.api.Assertions.assertNotEquals; +import static org.junit.jupiter.api.Assertions.assertTrue; + +public class SimpleTimeZoneEqualsHashCodeTest { + private static final SimpleTimeZone STZ_WITH_DST = + new SimpleTimeZone(-288_000_000, "America/Los_Angeles", + MARCH, 8, -SUNDAY, 7_200_000, + NOVEMBER, 1, -SUNDAY, 7_200_000); + private static final SimpleTimeZone STZ_WITHOUT_DST = + new SimpleTimeZone(0, "foo"); + + @Test + void withDSTTest() { + var stz = (SimpleTimeZone)STZ_WITH_DST.clone(); + assertEquals(STZ_WITH_DST, stz); + assertEquals(STZ_WITH_DST.hashCode(), stz.hashCode()); + + stz.setEndRule(NOVEMBER, 8, -SUNDAY, 7_200_000); + assertNotEquals(STZ_WITH_DST, stz); + // From the contract point, hash codes may be the same. + // This tests the implementation which considers DST + // related fields for calculating the hash code. + assertNotEquals(STZ_WITH_DST.hashCode(), stz.hashCode()); + } + + @Test + void withoutDSTTest() { + var stz = (SimpleTimeZone)STZ_WITHOUT_DST.clone(); + + // Only setting start rule. Still considered non-DST zone + stz.setStartRule(MARCH, 8, -SUNDAY, 7_200_000); + assertTrue(!stz.useDaylightTime()); + assertEquals(STZ_WITHOUT_DST, stz); + assertEquals(STZ_WITHOUT_DST.hashCode(), stz.hashCode()); + + // Setting end rule as well. Now it is considered DST zone + stz.setEndRule(NOVEMBER, 8, -SUNDAY, 7_200_000); + assertTrue(stz.useDaylightTime()); + assertNotEquals(STZ_WITHOUT_DST, stz); + // From the contract point, hash codes may be the same. + // This tests the implementation which considers DST + // related fields for calculating the hash code. + assertNotEquals(STZ_WITHOUT_DST.hashCode(), stz.hashCode()); + } +} diff -Nru openjdk-17-17.0.17+10/test/jdk/java/util/TimeZone/TimeZoneBoundaryTest.java openjdk-17-17.0.18+8/test/jdk/java/util/TimeZone/TimeZoneBoundaryTest.java --- openjdk-17-17.0.17+10/test/jdk/java/util/TimeZone/TimeZoneBoundaryTest.java 2025-10-13 07:48:04.000000000 +0000 +++ openjdk-17-17.0.18+8/test/jdk/java/util/TimeZone/TimeZoneBoundaryTest.java 2026-01-15 15:23:06.000000000 +0000 @@ -1,5 +1,5 @@ /* - * Copyright (c) 1997, 2023, 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 @@ -23,6 +23,7 @@ /* * @test + * @bug 8347841 * @summary test Time Zone Boundary * @run junit TimeZoneBoundaryTest */ @@ -251,7 +252,7 @@ @Test public void TestBoundaries() { - TimeZone pst = TimeZone.getTimeZone("PST"); + TimeZone pst = TimeZone.getTimeZone("America/Los_Angeles"); TimeZone save = TimeZone.getDefault(); try { TimeZone.setDefault(pst); @@ -410,11 +411,8 @@ @Test public void TestStepwise() { - findBoundariesStepwise(1997, ONE_DAY, TimeZone.getTimeZone("ACT"), 0); - // "EST" is disabled because its behavior depends on the mapping property. (6466476). - //findBoundariesStepwise(1997, ONE_DAY, TimeZone.getTimeZone("EST"), 2); - findBoundariesStepwise(1997, ONE_DAY, TimeZone.getTimeZone("HST"), 0); - findBoundariesStepwise(1997, ONE_DAY, TimeZone.getTimeZone("PST"), 2); + findBoundariesStepwise(1997, ONE_DAY, TimeZone.getTimeZone("Australia/Darwin"), 0); + findBoundariesStepwise(1997, ONE_DAY, TimeZone.getTimeZone("Pacific/Honolulu"), 0); findBoundariesStepwise(1997, ONE_DAY, TimeZone.getTimeZone("PST8PDT"), 2); findBoundariesStepwise(1997, ONE_DAY, TimeZone.getTimeZone("SystemV/PST"), 0); findBoundariesStepwise(1997, ONE_DAY, TimeZone.getTimeZone("SystemV/PST8PDT"), 2); diff -Nru openjdk-17-17.0.17+10/test/jdk/java/util/TimeZone/TimeZoneRegression.java openjdk-17-17.0.18+8/test/jdk/java/util/TimeZone/TimeZoneRegression.java --- openjdk-17-17.0.17+10/test/jdk/java/util/TimeZone/TimeZoneRegression.java 2025-10-13 07:48:04.000000000 +0000 +++ openjdk-17-17.0.18+8/test/jdk/java/util/TimeZone/TimeZoneRegression.java 2026-01-15 15:23:06.000000000 +0000 @@ -1,5 +1,5 @@ /* - * Copyright (c) 1998, 2023, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 1998, 2025, Oracle and/or its affiliates. All rights reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * * This code is free software; you can redistribute it and/or modify it @@ -25,7 +25,7 @@ * @test * @bug 4052967 4073209 4073215 4084933 4096952 4109314 4126678 4151406 4151429 * 4154525 4154537 4154542 4154650 4159922 4162593 4173604 4176686 4184229 4208960 - * 4966229 6433179 6851214 8007520 8008577 + * 4966229 6433179 6851214 8007520 8008577 8347841 * @library /java/text/testlib * @run junit/othervm -Djava.locale.providers=COMPAT,SPI TimeZoneRegression */ @@ -42,8 +42,8 @@ @Test public void Test4073209() { - TimeZone z1 = TimeZone.getTimeZone("PST"); - TimeZone z2 = TimeZone.getTimeZone("PST"); + TimeZone z1 = TimeZone.getTimeZone("America/Los_Angeles"); + TimeZone z2 = TimeZone.getTimeZone("America/Los_Angeles"); if (z1 == z2) { fail("Fail: TimeZone should return clones"); } @@ -81,7 +81,7 @@ // test both SimpleTimeZone and ZoneInfo objects. // @since 1.4 sub4084933(getPST()); - sub4084933(TimeZone.getTimeZone("PST")); + sub4084933(TimeZone.getTimeZone("America/Los_Angeles")); } private void sub4084933(TimeZone tz) { @@ -122,7 +122,7 @@ @Test public void Test4096952() { - String[] ZONES = { "GMT", "MET", "IST" }; + String[] ZONES = { "GMT", "MET", "Asia/Kolkata" }; boolean pass = true; try { for (int i=0; i expected) { + var bytes = ser(expected); + var actual = deSer(bytes); + assertEquals(CopyOnWriteArraySet.class, actual.getClass()); + assertEquals(expected, actual); + } + + private static Stream> roundTripTest() { + return Stream.of( + new CopyOnWriteArraySet<>(), + new CopyOnWriteArraySet<>(List.of(1, 2, 3)), + new CopyOnWriteArraySet<>(Set.of("Foo", "Bar", "Baz")) + ); + } + + private static byte[] ser(Object obj) { + return assertDoesNotThrow(() -> { + try (ByteArrayOutputStream byteArrayOutputStream = new ByteArrayOutputStream(); + ObjectOutputStream oos = new ObjectOutputStream(byteArrayOutputStream)) { + oos.writeObject(obj); + return byteArrayOutputStream.toByteArray(); + } + }, "Unexpected error during serialization"); + } + + private static Object deSer(byte[] bytes) { + return assertDoesNotThrow(() -> { + try (ByteArrayInputStream byteArrayInputStream = new ByteArrayInputStream(bytes); + ObjectInputStream ois = new ObjectInputStream(byteArrayInputStream)) { + return ois.readObject(); + } + }, "Unexpected error during de-serialization"); + } +} diff -Nru openjdk-17-17.0.17+10/test/jdk/java/util/jar/Manifest/ValueUtf8Coding.java openjdk-17-17.0.18+8/test/jdk/java/util/jar/Manifest/ValueUtf8Coding.java --- openjdk-17-17.0.17+10/test/jdk/java/util/jar/Manifest/ValueUtf8Coding.java 2025-10-13 07:48:04.000000000 +0000 +++ openjdk-17-17.0.18+8/test/jdk/java/util/jar/Manifest/ValueUtf8Coding.java 2026-01-15 15:23:06.000000000 +0000 @@ -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 @@ -37,7 +37,7 @@ /** * @test - * @bug 8066619 + * @bug 8066619 8351567 * @run testng ValueUtf8Coding * @summary Tests encoding and decoding manifest header values to and from * UTF-8 with the complete Unicode character set. @@ -201,10 +201,6 @@ mf.write(out); byte[] mfBytes = out.toByteArray(); - System.out.println("-".repeat(72)); - System.out.print(new String(mfBytes, UTF_8)); - System.out.println("-".repeat(72)); - ByteArrayInputStream in = new ByteArrayInputStream(mfBytes); return new Manifest(in); } diff -Nru openjdk-17-17.0.17+10/test/jdk/java/util/logging/LocalizedLevelName.java openjdk-17-17.0.18+8/test/jdk/java/util/logging/LocalizedLevelName.java --- openjdk-17-17.0.17+10/test/jdk/java/util/logging/LocalizedLevelName.java 2025-10-13 07:48:04.000000000 +0000 +++ openjdk-17-17.0.18+8/test/jdk/java/util/logging/LocalizedLevelName.java 2026-01-15 15:23:06.000000000 +0000 @@ -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 @@ -52,6 +52,7 @@ public static void main(String args[]) throws Exception { Locale defaultLocale = Locale.getDefault(); for (int i=0; i list = new ArrayList<>(); byte[] buf1 = new byte[1024]; @@ -84,16 +92,17 @@ } } - int n = 10; - long cnt = list.size(); - while (n-- > 0 && cnt != 0) { - Thread.sleep(100); - System.gc(); - cnt = list.stream().filter(o -> addrOf(o) != 0).count(); + final AtomicLong numNotYetCleaned = new AtomicLong(); + // trigger GC + final boolean resourcesCleaned = ForceGC.wait(() -> { + final long remaining = list.stream().filter(o -> addrOf(o) != 0).count(); + numNotYetCleaned.set(remaining); + return remaining == 0; + }); + if (!resourcesCleaned) { + throw new RuntimeException(numNotYetCleaned.get() + + " resources haven't yet been cleaned"); } - if (cnt != 0) - throw new RuntimeException("cleaner failed to clean : " + cnt); - } @DontInline @@ -139,17 +148,18 @@ if (zsrc != null) { Field zfileField = zsrc.getClass().getDeclaredField("zfile"); if (!zfileField.trySetAccessible()) { - throw new RuntimeException("'ZipFile.Source.zfile' is not accesible"); - } - //System.out.println("zffile: " + zfileField.get(zsrc)); - int n = 10; - while (n-- > 0 && zfileField.get(zsrc) != null) { - System.out.println("waiting gc ... " + n); - System.gc(); - Thread.sleep(100); + throw new RuntimeException("'ZipFile.Source.zfile' is not accessible"); } - if (zfileField.get(zsrc) != null) { - throw new RuntimeException("cleaner failed to clean zipfile."); + final boolean resourceCleaned = ForceGC.wait(() -> { + try { + return zfileField.get(zsrc) == null; + } catch (IllegalAccessException e) { + // shouldn't happen + throw new RuntimeException(e); + } + }); + if (!resourceCleaned) { + throw new RuntimeException("cleaner failed to clean zipfile " + zip); } } } diff -Nru openjdk-17-17.0.17+10/test/jdk/javax/management/remote/mandatory/notif/ListenerScaleTest.java openjdk-17-17.0.18+8/test/jdk/javax/management/remote/mandatory/notif/ListenerScaleTest.java --- openjdk-17-17.0.17+10/test/jdk/javax/management/remote/mandatory/notif/ListenerScaleTest.java 2025-10-13 07:48:04.000000000 +0000 +++ openjdk-17-17.0.18+8/test/jdk/javax/management/remote/mandatory/notif/ListenerScaleTest.java 2026-01-15 15:23:06.000000000 +0000 @@ -1,5 +1,5 @@ /* - * Copyright (c) 2006, 2015, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2006, 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 @@ -77,6 +77,7 @@ private static final int WARMUP_WITH_ONE_MBEAN = 1000; private static final int NOTIFS_TO_TIME = 100; private static final int EXTRA_MBEANS = 20000; + private static final double RATIO_FAIL_VALUE = 2500.0; private static final ObjectName testObjectName; static { @@ -187,8 +188,9 @@ long manyMBeansTime = timeNotif(mbs); System.out.println("Time with many MBeans: " + manyMBeansTime + "ns"); double ratio = (double) manyMBeansTime / singleMBeanTime; - if (ratio > 500.0) + if (ratio > RATIO_FAIL_VALUE) { throw new Exception("Failed: ratio=" + ratio); + } System.out.println("Test passed: ratio=" + ratio); } } diff -Nru openjdk-17-17.0.17+10/test/jdk/javax/management/security/SecurityTest.java openjdk-17-17.0.18+8/test/jdk/javax/management/security/SecurityTest.java --- openjdk-17-17.0.17+10/test/jdk/javax/management/security/SecurityTest.java 2025-10-13 07:48:04.000000000 +0000 +++ openjdk-17-17.0.18+8/test/jdk/javax/management/security/SecurityTest.java 2026-01-15 15:23:06.000000000 +0000 @@ -1,5 +1,5 @@ /* - * Copyright (c) 2003, 2018, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2003, 2025, Oracle and/or its affiliates. All rights reserved. * 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,6 +142,9 @@ * map (argName, value) format, then calls original test's run method. */ public static void main(String args[]) throws Exception { + // Disable default KeyManager's certificate checking so we can use + // a certificate signed with MD5withRSA algorithm. + System.setProperty("jdk.tls.SunX509KeyManager.certChecking", "false"); System.out.println("================================================="); @@ -399,6 +402,8 @@ opts.add(JDKToolFinder.getJDKTool("java")); opts.addAll(Arrays.asList(jdk.test.lib.Utils.getTestJavaOpts())); + opts.add("-Djdk.rmi.ssl.client.enableEndpointIdentification=false"); + // We need to forward some properties to the client side opts.add("-Dtest.src=" + System.getProperty("test.src")); @@ -529,6 +534,10 @@ private MBeanServerConnection mbsc = null; public static void main(String args[]) throws Exception { + // Disable default KeyManager's certificate checking so we can use + // a certificate signed with MD5withRSA algorithm. + System.setProperty("jdk.tls.SunX509KeyManager.certChecking", + "false"); // Parses parameters Utils.parseDebugProperties(); diff -Nru openjdk-17-17.0.17+10/test/jdk/javax/net/ssl/DTLS/CipherSuite.java openjdk-17-17.0.18+8/test/jdk/javax/net/ssl/DTLS/CipherSuite.java --- openjdk-17-17.0.17+10/test/jdk/javax/net/ssl/DTLS/CipherSuite.java 2025-10-13 07:48:04.000000000 +0000 +++ openjdk-17-17.0.18+8/test/jdk/javax/net/ssl/DTLS/CipherSuite.java 2026-01-15 15:23:06.000000000 +0000 @@ -1,5 +1,5 @@ /* - * Copyright (c) 2015, 2019, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2015, 2024, Oracle and/or its affiliates. All rights reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * * This code is free software; you can redistribute it and/or modify it @@ -33,16 +33,16 @@ * jdk.crypto.ec * @library /test/lib * @build DTLSOverDatagram - * @run main/othervm CipherSuite TLS_RSA_WITH_AES_128_CBC_SHA + * @run main/othervm CipherSuite TLS_RSA_WITH_AES_128_CBC_SHA re-enable * @run main/othervm CipherSuite TLS_ECDHE_RSA_WITH_AES_128_CBC_SHA256 - * @run main/othervm CipherSuite TLS_RSA_WITH_AES_128_CBC_SHA256 + * @run main/othervm CipherSuite TLS_RSA_WITH_AES_128_CBC_SHA256 re-enable * @run main/othervm CipherSuite TLS_DHE_RSA_WITH_AES_128_CBC_SHA256 * @run main/othervm CipherSuite TLS_ECDHE_RSA_WITH_AES_128_CBC_SHA * @run main/othervm CipherSuite TLS_DHE_RSA_WITH_AES_128_CBC_SHA * @run main/othervm CipherSuite TLS_ECDHE_RSA_WITH_3DES_EDE_CBC_SHA re-enable * @run main/othervm CipherSuite TLS_ECDHE_ECDSA_WITH_AES_128_GCM_SHA256 * @run main/othervm CipherSuite TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256 - * @run main/othervm CipherSuite TLS_RSA_WITH_AES_128_GCM_SHA256 + * @run main/othervm CipherSuite TLS_RSA_WITH_AES_128_GCM_SHA256 re-enable * @run main/othervm CipherSuite TLS_ECDH_ECDSA_WITH_AES_128_GCM_SHA256 re-enable * @run main/othervm CipherSuite TLS_DHE_RSA_WITH_AES_128_GCM_SHA256 * @run main/othervm CipherSuite TLS_DHE_DSS_WITH_AES_128_GCM_SHA256 diff -Nru openjdk-17-17.0.17+10/test/jdk/javax/net/ssl/DTLS/DTLSOverDatagram.java openjdk-17-17.0.18+8/test/jdk/javax/net/ssl/DTLS/DTLSOverDatagram.java --- openjdk-17-17.0.17+10/test/jdk/javax/net/ssl/DTLS/DTLSOverDatagram.java 2025-10-13 07:48:04.000000000 +0000 +++ openjdk-17-17.0.18+8/test/jdk/javax/net/ssl/DTLS/DTLSOverDatagram.java 2026-01-15 15:23:06.000000000 +0000 @@ -1,5 +1,5 @@ /* - * Copyright (c) 2015, 2022, 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 @@ -52,7 +52,6 @@ */ public class DTLSOverDatagram { - private static final int SOCKET_TIMEOUT = 10 * 1000; // in millis private static final int BUFFER_SIZE = 1024; private static final int MAXIMUM_PACKET_SIZE = 1024; @@ -78,6 +77,7 @@ private final AtomicBoolean exceptionOccurred = new AtomicBoolean(false); private final CountDownLatch serverStarted = new CountDownLatch(1); + private int socketTimeout = 10 * 1000; // in millis /* * ============================================================= * The test case @@ -476,6 +476,10 @@ return null; } + public void setSocketTimeout(int socketTimeout) { + this.socketTimeout = socketTimeout; + } + // run delegated tasks void runDelegatedTasks(SSLEngine engine) throws Exception { Runnable runnable; @@ -529,8 +533,8 @@ try (DatagramSocket serverSocket = new DatagramSocket(serverSocketAddress); DatagramSocket clientSocket = new DatagramSocket(clientSocketAddress)) { - serverSocket.setSoTimeout(SOCKET_TIMEOUT); - clientSocket.setSoTimeout(SOCKET_TIMEOUT); + serverSocket.setSoTimeout(socketTimeout); + clientSocket.setSoTimeout(socketTimeout); InetSocketAddress serverSocketAddr = new InetSocketAddress( InetAddress.getLoopbackAddress(), serverSocket.getLocalPort()); diff -Nru openjdk-17-17.0.17+10/test/jdk/javax/net/ssl/DTLS/FragmentedFinished.java openjdk-17-17.0.18+8/test/jdk/javax/net/ssl/DTLS/FragmentedFinished.java --- openjdk-17-17.0.17+10/test/jdk/javax/net/ssl/DTLS/FragmentedFinished.java 1970-01-01 00:00:00.000000000 +0000 +++ openjdk-17-17.0.18+8/test/jdk/javax/net/ssl/DTLS/FragmentedFinished.java 2026-01-15 15:23:06.000000000 +0000 @@ -0,0 +1,72 @@ +/* + * 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. + */ + +// SunJSSE does not support dynamic system properties, no way to re-use +// system properties in samevm/agentvm mode. + +/* + * @test + * @bug 8367133 + * @summary Verify that handshake succeeds when Finished message is fragmented + * @modules java.base/sun.security.util + * @library /test/lib + * @build DTLSOverDatagram + * @run main/othervm FragmentedFinished + */ + +import javax.net.ssl.SSLEngine; +import javax.net.ssl.SSLParameters; +import java.net.DatagramPacket; +import java.net.SocketAddress; +import java.util.ArrayList; +import java.util.List; + +public class FragmentedFinished extends DTLSOverDatagram { + private SSLEngine serverSSLEngine; + public static void main(String[] args) throws Exception { + FragmentedFinished testCase = new FragmentedFinished(); + testCase.runTest(testCase); + } + + @Override + SSLEngine createSSLEngine(boolean isClient) throws Exception { + SSLEngine sslEngine = super.createSSLEngine(isClient); + if (!isClient) { + serverSSLEngine = sslEngine; + } + return sslEngine; + } + + @Override + DatagramPacket createHandshakePacket(byte[] ba, SocketAddress socketAddr) { + if (ba.length < 30) { // detect ChangeCipherSpec + // Reduce the maximumPacketSize to force fragmentation + // of the Finished message + SSLParameters params = serverSSLEngine.getSSLParameters(); + params.setMaximumPacketSize(53); + serverSSLEngine.setSSLParameters(params); + } + + return super.createHandshakePacket(ba, socketAddr); + } +} diff -Nru openjdk-17-17.0.17+10/test/jdk/javax/net/ssl/DTLS/PacketLossRetransmission.java openjdk-17-17.0.18+8/test/jdk/javax/net/ssl/DTLS/PacketLossRetransmission.java --- openjdk-17-17.0.17+10/test/jdk/javax/net/ssl/DTLS/PacketLossRetransmission.java 2025-10-13 07:48:04.000000000 +0000 +++ openjdk-17-17.0.18+8/test/jdk/javax/net/ssl/DTLS/PacketLossRetransmission.java 2026-01-15 15:23:06.000000000 +0000 @@ -1,5 +1,5 @@ /* - * Copyright (c) 2016, 2021, 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 @@ -32,37 +32,16 @@ * @library /test/lib * @build DTLSOverDatagram * - * @run main/othervm PacketLossRetransmission client 0 hello_request * @run main/othervm PacketLossRetransmission client 1 client_hello - * @run main/othervm PacketLossRetransmission client 2 server_hello - * @run main/othervm PacketLossRetransmission client 3 hello_verify_request - * @run main/othervm -Djdk.tls.client.enableSessionTicketExtension=false PacketLossRetransmission client 4 new_session_ticket - * @run main/othervm PacketLossRetransmission client 11 certificate - * @run main/othervm PacketLossRetransmission client 12 server_key_exchange - * @run main/othervm PacketLossRetransmission client 13 certificate_request - * @run main/othervm PacketLossRetransmission client 14 server_hello_done - * @run main/othervm PacketLossRetransmission client 15 certificate_verify * @run main/othervm PacketLossRetransmission client 16 client_key_exchange * @run main/othervm PacketLossRetransmission client 20 finished - * @run main/othervm PacketLossRetransmission client 21 certificate_url - * @run main/othervm PacketLossRetransmission client 22 certificate_status - * @run main/othervm PacketLossRetransmission client 23 supplemental_data * @run main/othervm PacketLossRetransmission client -1 change_cipher_spec - * @run main/othervm PacketLossRetransmission server 0 hello_request - * @run main/othervm PacketLossRetransmission server 1 client_hello * @run main/othervm PacketLossRetransmission server 2 server_hello * @run main/othervm PacketLossRetransmission server 3 hello_verify_request - * @run main/othervm -Djdk.tls.client.enableSessionTicketExtension=false PacketLossRetransmission server 4 new_session_ticket * @run main/othervm PacketLossRetransmission server 11 certificate * @run main/othervm PacketLossRetransmission server 12 server_key_exchange - * @run main/othervm PacketLossRetransmission server 13 certificate_request * @run main/othervm PacketLossRetransmission server 14 server_hello_done - * @run main/othervm PacketLossRetransmission server 15 certificate_verify - * @run main/othervm PacketLossRetransmission server 16 client_key_exchange * @run main/othervm PacketLossRetransmission server 20 finished - * @run main/othervm PacketLossRetransmission server 21 certificate_url - * @run main/othervm PacketLossRetransmission server 22 certificate_status - * @run main/othervm PacketLossRetransmission server 23 supplemental_data * @run main/othervm PacketLossRetransmission server -1 change_cipher_spec */ @@ -79,6 +58,7 @@ public class PacketLossRetransmission extends DTLSOverDatagram { private static boolean isClient; private static byte handshakeType; + private static final int TIMEOUT = 500; private boolean needPacketLoss = true; @@ -87,6 +67,7 @@ handshakeType = Byte.parseByte(args[1]); PacketLossRetransmission testCase = new PacketLossRetransmission(); + testCase.setSocketTimeout(TIMEOUT); testCase.runTest(testCase); } @@ -102,7 +83,7 @@ if (packet != null) { needPacketLoss = false; - System.out.println("Loss a packet of handshake messahe"); + System.out.println("Loss a packet of handshake message"); packets.remove(packet); } } diff -Nru openjdk-17-17.0.17+10/test/jdk/javax/net/ssl/SSLEngine/Basics.java openjdk-17-17.0.18+8/test/jdk/javax/net/ssl/SSLEngine/Basics.java --- openjdk-17-17.0.17+10/test/jdk/javax/net/ssl/SSLEngine/Basics.java 2025-10-13 07:48:04.000000000 +0000 +++ openjdk-17-17.0.18+8/test/jdk/javax/net/ssl/SSLEngine/Basics.java 2026-01-15 15:23:06.000000000 +0000 @@ -1,5 +1,5 @@ /* - * Copyright (c) 2003, 2022, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2003, 2024, Oracle and/or its affiliates. All rights reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * * This code is free software; you can redistribute it and/or modify it @@ -57,7 +57,8 @@ "/" + TRUSTSTORE_FILE; public static void main(String[] args) throws Exception { - SecurityUtils.removeFromDisabledTlsAlgs("TLSv1.1"); + // Re-enable TLSv1.1 and TLS_RSA_* since test depends on it. + SecurityUtils.removeFromDisabledTlsAlgs("TLSv1.1", "TLS_RSA_*"); runTest("TLSv1.3", "TLS_AES_256_GCM_SHA384"); runTest("TLSv1.2", "TLS_RSA_WITH_AES_256_GCM_SHA384"); diff -Nru openjdk-17-17.0.17+10/test/jdk/javax/net/ssl/SSLEngine/EngineCloseOnAlert.java openjdk-17-17.0.18+8/test/jdk/javax/net/ssl/SSLEngine/EngineCloseOnAlert.java --- openjdk-17-17.0.17+10/test/jdk/javax/net/ssl/SSLEngine/EngineCloseOnAlert.java 2025-10-13 07:48:04.000000000 +0000 +++ openjdk-17-17.0.18+8/test/jdk/javax/net/ssl/SSLEngine/EngineCloseOnAlert.java 2026-01-15 15:23:06.000000000 +0000 @@ -1,5 +1,5 @@ /* - * Copyright (c) 2004, 2023, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2004, 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 @@ -26,7 +26,8 @@ * @bug 8133632 * @summary javax.net.ssl.SSLEngine does not properly handle received * SSL fatal alerts - * @run main EngineCloseOnAlert + * @library /test/lib + * @run main/othervm EngineCloseOnAlert */ import java.io.FileInputStream; @@ -36,6 +37,7 @@ import java.util.*; import java.security.*; import static javax.net.ssl.SSLEngineResult.HandshakeStatus.*; +import jdk.test.lib.security.SecurityUtils; public class EngineCloseOnAlert { @@ -61,6 +63,8 @@ } public static void main(String[] args) throws Exception { + // Re-enable TLS_RSA_* since test depends on it. + SecurityUtils.removeFromDisabledTlsAlgs("TLS_RSA_*"); int failed = 0; List testMatrix = new LinkedList() {{ add(clientReceivesAlert); diff -Nru openjdk-17-17.0.17+10/test/jdk/javax/net/ssl/ServerName/EndingDotHostname.java openjdk-17-17.0.18+8/test/jdk/javax/net/ssl/ServerName/EndingDotHostname.java --- openjdk-17-17.0.17+10/test/jdk/javax/net/ssl/ServerName/EndingDotHostname.java 2025-10-13 07:48:04.000000000 +0000 +++ openjdk-17-17.0.18+8/test/jdk/javax/net/ssl/ServerName/EndingDotHostname.java 2026-01-15 15:23:06.000000000 +0000 @@ -1,5 +1,5 @@ /* - * Copyright (C) 2022 THL A29 Limited, a Tencent company. All rights reserved. + * Copyright (C) 2022, Tencent. All rights reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * * This code is free software; you can redistribute it and/or modify it @@ -248,4 +248,3 @@ sslIS.read(); } } - diff -Nru openjdk-17-17.0.17+10/test/jdk/javax/net/ssl/TLSCommon/TLSTest.java openjdk-17-17.0.18+8/test/jdk/javax/net/ssl/TLSCommon/TLSTest.java --- openjdk-17-17.0.17+10/test/jdk/javax/net/ssl/TLSCommon/TLSTest.java 2025-10-13 07:48:04.000000000 +0000 +++ openjdk-17-17.0.18+8/test/jdk/javax/net/ssl/TLSCommon/TLSTest.java 2026-01-15 15:23:06.000000000 +0000 @@ -1,5 +1,5 @@ /* - * Copyright (c) 2018, 2021, 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 @@ -52,91 +52,91 @@ * @test * @bug 8205111 * @summary Test TLS with different types of supported keys. - * @run main/othervm TLSTest TLSv1.3 rsa_pkcs1_sha1 TLS_AES_128_GCM_SHA256 - * @run main/othervm TLSTest TLSv1.3 rsa_pkcs1_sha256 TLS_AES_128_GCM_SHA256 - * @run main/othervm TLSTest TLSv1.3 rsa_pkcs1_sha384 TLS_AES_128_GCM_SHA256 - * @run main/othervm TLSTest TLSv1.3 rsa_pkcs1_sha512 TLS_AES_128_GCM_SHA256 - * @run main/othervm TLSTest TLSv1.3 ec_rsa_pkcs1_sha256 TLS_AES_128_GCM_SHA256 - * @run main/othervm TLSTest TLSv1.3 ecdsa_sha1 TLS_AES_128_GCM_SHA256 - * @run main/othervm TLSTest TLSv1.3 ecdsa_secp384r1_sha384 + * @run main/othervm -Djavax.net.debug=ssl,handshake TLSTest TLSv1.3 rsa_pkcs1_sha1 TLS_AES_128_GCM_SHA256 + * @run main/othervm -Djavax.net.debug=ssl,handshake TLSTest TLSv1.3 rsa_pkcs1_sha256 TLS_AES_128_GCM_SHA256 + * @run main/othervm -Djavax.net.debug=ssl,handshake TLSTest TLSv1.3 rsa_pkcs1_sha384 TLS_AES_128_GCM_SHA256 + * @run main/othervm -Djavax.net.debug=ssl,handshake TLSTest TLSv1.3 rsa_pkcs1_sha512 TLS_AES_128_GCM_SHA256 + * @run main/othervm -Djavax.net.debug=ssl,handshake TLSTest TLSv1.3 ec_rsa_pkcs1_sha256 TLS_AES_128_GCM_SHA256 + * @run main/othervm -Djavax.net.debug=ssl,handshake TLSTest TLSv1.3 ecdsa_sha1 TLS_AES_128_GCM_SHA256 + * @run main/othervm -Djavax.net.debug=ssl,handshake TLSTest TLSv1.3 ecdsa_secp384r1_sha384 * TLS_AES_128_GCM_SHA256 - * @run main/othervm TLSTest TLSv1.3 ecdsa_secp521r1_sha512 + * @run main/othervm -Djavax.net.debug=ssl,handshake TLSTest TLSv1.3 ecdsa_secp521r1_sha512 * TLS_AES_128_GCM_SHA256 - * @run main/othervm TLSTest TLSv1.3 rsa_pss_rsae_sha256 TLS_AES_128_GCM_SHA256 - * @run main/othervm TLSTest TLSv1.3 rsa_pss_rsae_sha384 TLS_AES_128_GCM_SHA256 - * @run main/othervm TLSTest TLSv1.3 rsa_pss_rsae_sha512 TLS_AES_128_GCM_SHA256 - * @run main/othervm TLSTest TLSv1.3 rsa_pss_pss_sha256 TLS_AES_128_GCM_SHA256 - * @run main/othervm TLSTest TLSv1.3 rsa_pss_pss_sha384 TLS_AES_128_GCM_SHA256 - * @run main/othervm TLSTest TLSv1.3 rsa_pss_pss_sha512 TLS_AES_128_GCM_SHA256 + * @run main/othervm -Djavax.net.debug=ssl,handshake TLSTest TLSv1.3 rsa_pss_rsae_sha256 TLS_AES_128_GCM_SHA256 + * @run main/othervm -Djavax.net.debug=ssl,handshake TLSTest TLSv1.3 rsa_pss_rsae_sha384 TLS_AES_128_GCM_SHA256 + * @run main/othervm -Djavax.net.debug=ssl,handshake TLSTest TLSv1.3 rsa_pss_rsae_sha512 TLS_AES_128_GCM_SHA256 + * @run main/othervm -Djavax.net.debug=ssl,handshake TLSTest TLSv1.3 rsa_pss_pss_sha256 TLS_AES_128_GCM_SHA256 + * @run main/othervm -Djavax.net.debug=ssl,handshake TLSTest TLSv1.3 rsa_pss_pss_sha384 TLS_AES_128_GCM_SHA256 + * @run main/othervm -Djavax.net.debug=ssl,handshake TLSTest TLSv1.3 rsa_pss_pss_sha512 TLS_AES_128_GCM_SHA256 * - * @run main/othervm TLSTest TLSv1.3 rsa_pkcs1_sha1 TLS_AES_256_GCM_SHA384 - * @run main/othervm TLSTest TLSv1.3 rsa_pkcs1_sha256 TLS_AES_256_GCM_SHA384 - * @run main/othervm TLSTest TLSv1.3 rsa_pkcs1_sha384 TLS_AES_256_GCM_SHA384 - * @run main/othervm TLSTest TLSv1.3 rsa_pkcs1_sha512 TLS_AES_256_GCM_SHA384 - * @run main/othervm TLSTest TLSv1.3 ec_rsa_pkcs1_sha256 TLS_AES_256_GCM_SHA384 - * @run main/othervm TLSTest TLSv1.3 ecdsa_sha1 TLS_AES_256_GCM_SHA384 - * @run main/othervm TLSTest TLSv1.3 ecdsa_secp384r1_sha384 + * @run main/othervm -Djavax.net.debug=ssl,handshake TLSTest TLSv1.3 rsa_pkcs1_sha1 TLS_AES_256_GCM_SHA384 + * @run main/othervm -Djavax.net.debug=ssl,handshake TLSTest TLSv1.3 rsa_pkcs1_sha256 TLS_AES_256_GCM_SHA384 + * @run main/othervm -Djavax.net.debug=ssl,handshake TLSTest TLSv1.3 rsa_pkcs1_sha384 TLS_AES_256_GCM_SHA384 + * @run main/othervm -Djavax.net.debug=ssl,handshake TLSTest TLSv1.3 rsa_pkcs1_sha512 TLS_AES_256_GCM_SHA384 + * @run main/othervm -Djavax.net.debug=ssl,handshake TLSTest TLSv1.3 ec_rsa_pkcs1_sha256 TLS_AES_256_GCM_SHA384 + * @run main/othervm -Djavax.net.debug=ssl,handshake TLSTest TLSv1.3 ecdsa_sha1 TLS_AES_256_GCM_SHA384 + * @run main/othervm -Djavax.net.debug=ssl,handshake TLSTest TLSv1.3 ecdsa_secp384r1_sha384 * TLS_AES_256_GCM_SHA384 - * @run main/othervm TLSTest TLSv1.3 ecdsa_secp521r1_sha512 + * @run main/othervm -Djavax.net.debug=ssl,handshake TLSTest TLSv1.3 ecdsa_secp521r1_sha512 * TLS_AES_256_GCM_SHA384 - * @run main/othervm TLSTest TLSv1.3 rsa_pss_rsae_sha256 TLS_AES_256_GCM_SHA384 - * @run main/othervm TLSTest TLSv1.3 rsa_pss_rsae_sha384 TLS_AES_256_GCM_SHA384 - * @run main/othervm TLSTest TLSv1.3 rsa_pss_rsae_sha512 TLS_AES_256_GCM_SHA384 - * @run main/othervm TLSTest TLSv1.3 rsa_pss_pss_sha256 TLS_AES_256_GCM_SHA384 - * @run main/othervm TLSTest TLSv1.3 rsa_pss_pss_sha384 TLS_AES_256_GCM_SHA384 - * @run main/othervm TLSTest TLSv1.3 rsa_pss_pss_sha512 TLS_AES_256_GCM_SHA384 + * @run main/othervm -Djavax.net.debug=ssl,handshake TLSTest TLSv1.3 rsa_pss_rsae_sha256 TLS_AES_256_GCM_SHA384 + * @run main/othervm -Djavax.net.debug=ssl,handshake TLSTest TLSv1.3 rsa_pss_rsae_sha384 TLS_AES_256_GCM_SHA384 + * @run main/othervm -Djavax.net.debug=ssl,handshake TLSTest TLSv1.3 rsa_pss_rsae_sha512 TLS_AES_256_GCM_SHA384 + * @run main/othervm -Djavax.net.debug=ssl,handshake TLSTest TLSv1.3 rsa_pss_pss_sha256 TLS_AES_256_GCM_SHA384 + * @run main/othervm -Djavax.net.debug=ssl,handshake TLSTest TLSv1.3 rsa_pss_pss_sha384 TLS_AES_256_GCM_SHA384 + * @run main/othervm -Djavax.net.debug=ssl,handshake TLSTest TLSv1.3 rsa_pss_pss_sha512 TLS_AES_256_GCM_SHA384 * - * @run main/othervm TLSTest TLSv1.2 rsa_pkcs1_sha1 TLS_RSA_WITH_AES_128_CBC_SHA - * @run main/othervm TLSTest TLSv1.2 rsa_pkcs1_sha256 + * @run main/othervm -Djavax.net.debug=ssl,handshake TLSTest TLSv1.2 rsa_pkcs1_sha1 TLS_RSA_WITH_AES_128_CBC_SHA + * @run main/othervm -Djavax.net.debug=ssl,handshake TLSTest TLSv1.2 rsa_pkcs1_sha256 * TLS_RSA_WITH_AES_128_CBC_SHA - * @run main/othervm TLSTest TLSv1.2 rsa_pkcs1_sha384 + * @run main/othervm -Djavax.net.debug=ssl,handshake TLSTest TLSv1.2 rsa_pkcs1_sha384 * TLS_RSA_WITH_AES_256_GCM_SHA384 - * @run main/othervm TLSTest TLSv1.2 rsa_pkcs1_sha512 + * @run main/othervm -Djavax.net.debug=ssl,handshake TLSTest TLSv1.2 rsa_pkcs1_sha512 * TLS_RSA_WITH_AES_128_GCM_SHA256 - * @run main/othervm TLSTest TLSv1.2 ec_rsa_pkcs1_sha256 + * @run main/othervm -Djavax.net.debug=ssl,handshake TLSTest TLSv1.2 ec_rsa_pkcs1_sha256 * TLS_ECDHE_ECDSA_WITH_AES_128_GCM_SHA256 - * @run main/othervm TLSTest TLSv1.2 ecdsa_sha1 + * @run main/othervm -Djavax.net.debug=ssl,handshake TLSTest TLSv1.2 ecdsa_sha1 * TLS_ECDHE_ECDSA_WITH_AES_256_GCM_SHA384 - * @run main/othervm TLSTest TLSv1.2 ecdsa_secp384r1_sha384 + * @run main/othervm -Djavax.net.debug=ssl,handshake TLSTest TLSv1.2 ecdsa_secp384r1_sha384 * TLS_ECDHE_ECDSA_WITH_AES_256_CBC_SHA384 - * @run main/othervm TLSTest TLSv1.2 ecdsa_secp521r1_sha512 + * @run main/othervm -Djavax.net.debug=ssl,handshake TLSTest TLSv1.2 ecdsa_secp521r1_sha512 * TLS_ECDHE_ECDSA_WITH_AES_256_CBC_SHA - * @run main/othervm TLSTest TLSv1.2 rsa_pss_rsae_sha256 + * @run main/othervm -Djavax.net.debug=ssl,handshake TLSTest TLSv1.2 rsa_pss_rsae_sha256 * TLS_RSA_WITH_AES_256_CBC_SHA256 - * @run main/othervm TLSTest TLSv1.2 rsa_pss_rsae_sha384 + * @run main/othervm -Djavax.net.debug=ssl,handshake TLSTest TLSv1.2 rsa_pss_rsae_sha384 * TLS_RSA_WITH_AES_256_CBC_SHA - * @run main/othervm TLSTest TLSv1.2 rsa_pss_rsae_sha512 + * @run main/othervm -Djavax.net.debug=ssl,handshake TLSTest TLSv1.2 rsa_pss_rsae_sha512 * TLS_RSA_WITH_AES_128_CBC_SHA256 - * @run main/othervm TLSTest TLSv1.2 rsa_pss_pss_sha256 + * @run main/othervm -Djavax.net.debug=ssl,handshake TLSTest TLSv1.2 rsa_pss_pss_sha256 * TLS_DHE_RSA_WITH_AES_256_CBC_SHA256 - * @run main/othervm TLSTest TLSv1.2 rsa_pss_pss_sha384 + * @run main/othervm -Djavax.net.debug=ssl,handshake TLSTest TLSv1.2 rsa_pss_pss_sha384 * TLS_DHE_RSA_WITH_AES_256_GCM_SHA384 - * @run main/othervm TLSTest TLSv1.2 rsa_pss_pss_sha512 + * @run main/othervm -Djavax.net.debug=ssl,handshake TLSTest TLSv1.2 rsa_pss_pss_sha512 * TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256 * - * @run main/othervm TLSTest TLSv1.1 rsa_pkcs1_sha1 TLS_RSA_WITH_AES_128_CBC_SHA - * @run main/othervm TLSTest TLSv1.1 rsa_pkcs1_sha256 + * @run main/othervm -Djavax.net.debug=ssl,handshake TLSTest TLSv1.1 rsa_pkcs1_sha1 TLS_RSA_WITH_AES_128_CBC_SHA + * @run main/othervm -Djavax.net.debug=ssl,handshake TLSTest TLSv1.1 rsa_pkcs1_sha256 * TLS_RSA_WITH_AES_256_CBC_SHA - * @run main/othervm TLSTest TLSv1.1 rsa_pkcs1_sha384 + * @run main/othervm -Djavax.net.debug=ssl,handshake TLSTest TLSv1.1 rsa_pkcs1_sha384 * TLS_RSA_WITH_AES_128_CBC_SHA - * @run main/othervm TLSTest TLSv1.1 rsa_pkcs1_sha512 + * @run main/othervm -Djavax.net.debug=ssl,handshake TLSTest TLSv1.1 rsa_pkcs1_sha512 * TLS_RSA_WITH_AES_256_CBC_SHA - * @run main/othervm TLSTest TLSv1.1 rsa_pss_rsae_sha256 + * @run main/othervm -Djavax.net.debug=ssl,handshake TLSTest TLSv1.1 rsa_pss_rsae_sha256 * TLS_RSA_WITH_AES_128_CBC_SHA - * @run main/othervm TLSTest TLSv1.1 rsa_pss_rsae_sha384 + * @run main/othervm -Djavax.net.debug=ssl,handshake TLSTest TLSv1.1 rsa_pss_rsae_sha384 * TLS_RSA_WITH_AES_256_CBC_SHA - * @run main/othervm TLSTest TLSv1.1 rsa_pss_rsae_sha512 + * @run main/othervm -Djavax.net.debug=ssl,handshake TLSTest TLSv1.1 rsa_pss_rsae_sha512 * TLS_RSA_WITH_AES_128_CBC_SHA * - * @run main/othervm TLSTest TLSv1 rsa_pkcs1_sha1 TLS_RSA_WITH_AES_128_CBC_SHA - * @run main/othervm TLSTest TLSv1 rsa_pkcs1_sha256 TLS_RSA_WITH_AES_256_CBC_SHA - * @run main/othervm TLSTest TLSv1 rsa_pkcs1_sha384 TLS_RSA_WITH_AES_128_CBC_SHA - * @run main/othervm TLSTest TLSv1 rsa_pkcs1_sha512 TLS_RSA_WITH_AES_256_CBC_SHA - * @run main/othervm TLSTest TLSv1 rsa_pss_rsae_sha256 + * @run main/othervm -Djavax.net.debug=ssl,handshake TLSTest TLSv1 rsa_pkcs1_sha1 TLS_RSA_WITH_AES_128_CBC_SHA + * @run main/othervm -Djavax.net.debug=ssl,handshake TLSTest TLSv1 rsa_pkcs1_sha256 TLS_RSA_WITH_AES_256_CBC_SHA + * @run main/othervm -Djavax.net.debug=ssl,handshake TLSTest TLSv1 rsa_pkcs1_sha384 TLS_RSA_WITH_AES_128_CBC_SHA + * @run main/othervm -Djavax.net.debug=ssl,handshake TLSTest TLSv1 rsa_pkcs1_sha512 TLS_RSA_WITH_AES_256_CBC_SHA + * @run main/othervm -Djavax.net.debug=ssl,handshake TLSTest TLSv1 rsa_pss_rsae_sha256 * TLS_RSA_WITH_AES_128_CBC_SHA - * @run main/othervm TLSTest TLSv1 rsa_pss_rsae_sha384 + * @run main/othervm -Djavax.net.debug=ssl,handshake TLSTest TLSv1 rsa_pss_rsae_sha384 * TLS_RSA_WITH_AES_256_CBC_SHA - * @run main/othervm TLSTest TLSv1 rsa_pss_rsae_sha512 + * @run main/othervm -Djavax.net.debug=ssl,handshake TLSTest TLSv1 rsa_pss_rsae_sha512 * TLS_RSA_WITH_AES_128_CBC_SHA */ public class TLSTest { @@ -281,7 +281,7 @@ keyType.getTrustedCert(), null, null, keyType.getKeyType()); SSLSocketFactory sslsf = ctx.getSocketFactory(); try (SSLSocket sslSocket - = (SSLSocket) sslsf.createSocket("localhost", serverPort)) { + = (SSLSocket) sslsf.createSocket(InetAddress.getLoopbackAddress(), serverPort)) { // Specify the client cipher suites sslSocket.setEnabledCipherSuites(new String[]{this.cipher}); sslSocket.setEnabledProtocols(new String[]{this.tlsProtocol}); diff -Nru openjdk-17-17.0.17+10/test/jdk/javax/net/ssl/TLSv11/GenericBlockCipher.java openjdk-17-17.0.18+8/test/jdk/javax/net/ssl/TLSv11/GenericBlockCipher.java --- openjdk-17-17.0.17+10/test/jdk/javax/net/ssl/TLSv11/GenericBlockCipher.java 2025-10-13 07:48:04.000000000 +0000 +++ openjdk-17-17.0.18+8/test/jdk/javax/net/ssl/TLSv11/GenericBlockCipher.java 2026-01-15 15:23:06.000000000 +0000 @@ -1,5 +1,5 @@ /* - * Copyright (c) 2010, 2020, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2010, 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 @@ -174,8 +174,8 @@ volatile Exception clientException = null; public static void main(String[] args) throws Exception { - // Re-enable TLSv1.1 since test depends on it. - SecurityUtils.removeFromDisabledTlsAlgs("TLSv1.1"); + // Re-enable TLSv1.1 and TLS_RSA_* since test depends on it. + SecurityUtils.removeFromDisabledTlsAlgs("TLSv1.1", "TLS_RSA_*"); String keyFilename = System.getProperty("test.src", ".") + "/" + pathToStores + diff -Nru openjdk-17-17.0.17+10/test/jdk/javax/net/ssl/TLSv12/ProtocolFilter.java openjdk-17-17.0.18+8/test/jdk/javax/net/ssl/TLSv12/ProtocolFilter.java --- openjdk-17-17.0.17+10/test/jdk/javax/net/ssl/TLSv12/ProtocolFilter.java 2025-10-13 07:48:04.000000000 +0000 +++ openjdk-17-17.0.18+8/test/jdk/javax/net/ssl/TLSv12/ProtocolFilter.java 2026-01-15 15:23:06.000000000 +0000 @@ -1,5 +1,5 @@ /* - * Copyright (c) 2014, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2014, 2024, Oracle and/or its affiliates. All rights reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * * This code is free software; you can redistribute it and/or modify it @@ -28,6 +28,7 @@ * @test * @bug 8052406 * @summary SSLv2Hello protocol may be filter out unexpectedly + * @library /test/lib * @run main/othervm ProtocolFilter */ @@ -35,6 +36,8 @@ import java.net.*; import javax.net.ssl.*; +import jdk.test.lib.security.SecurityUtils; + public class ProtocolFilter { /* @@ -156,6 +159,8 @@ volatile Exception clientException = null; public static void main(String[] args) throws Exception { + // Re-enable TLS_RSA_* since test depends on it. + SecurityUtils.removeFromDisabledTlsAlgs("TLS_RSA_*"); String keyFilename = System.getProperty("test.src", ".") + "/" + pathToStores + "/" + keyStoreFile; diff -Nru openjdk-17-17.0.17+10/test/jdk/javax/net/ssl/ciphersuites/DisabledAlgorithms.java openjdk-17-17.0.18+8/test/jdk/javax/net/ssl/ciphersuites/DisabledAlgorithms.java --- openjdk-17-17.0.17+10/test/jdk/javax/net/ssl/ciphersuites/DisabledAlgorithms.java 2025-10-13 07:48:04.000000000 +0000 +++ openjdk-17-17.0.18+8/test/jdk/javax/net/ssl/ciphersuites/DisabledAlgorithms.java 2026-01-15 15:23:06.000000000 +0000 @@ -1,5 +1,5 @@ /* - * Copyright (c) 2015, 2023, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2015, 2024, Oracle and/or its affiliates. All rights reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * * This code is free software; you can redistribute it and/or modify it @@ -23,7 +23,7 @@ /* * @test - * @bug 8076221 8211883 8279164 + * @bug 8076221 8211883 8279164 8245545 * @summary Check if weak cipher suites are disabled * @library /javax/net/ssl/templates * @modules jdk.crypto.ec @@ -110,7 +110,13 @@ "TLS_ECDH_ECDSA_WITH_AES_256_CBC_SHA", "TLS_ECDH_RSA_WITH_AES_256_CBC_SHA", "TLS_ECDH_ECDSA_WITH_AES_128_CBC_SHA", - "TLS_ECDH_RSA_WITH_AES_128_CBC_SHA" + "TLS_ECDH_RSA_WITH_AES_128_CBC_SHA", + "TLS_RSA_WITH_AES_256_GCM_SHA384", + "TLS_RSA_WITH_AES_128_GCM_SHA256", + "TLS_RSA_WITH_AES_256_CBC_SHA256", + "TLS_RSA_WITH_AES_128_CBC_SHA256", + "TLS_RSA_WITH_AES_256_CBC_SHA", + "TLS_RSA_WITH_AES_128_CBC_SHA" }; public static void main(String[] args) throws Exception { diff -Nru openjdk-17-17.0.17+10/test/jdk/javax/net/ssl/sanity/ciphersuites/CheckCipherSuites.java openjdk-17-17.0.18+8/test/jdk/javax/net/ssl/sanity/ciphersuites/CheckCipherSuites.java --- openjdk-17-17.0.17+10/test/jdk/javax/net/ssl/sanity/ciphersuites/CheckCipherSuites.java 2025-10-13 07:48:04.000000000 +0000 +++ openjdk-17-17.0.18+8/test/jdk/javax/net/ssl/sanity/ciphersuites/CheckCipherSuites.java 2026-01-15 15:23:06.000000000 +0000 @@ -1,5 +1,5 @@ /* - * Copyright (c) 2002, 2022, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2002, 2024, Oracle and/or its affiliates. All rights reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * * This code is free software; you can redistribute it and/or modify it @@ -23,7 +23,7 @@ /* * @test - * @bug 4750141 4895631 8217579 8163326 8279164 + * @bug 4750141 4895631 8217579 8163326 8279164 8245545 * @summary Check enabled and supported ciphersuites are correct * @run main/othervm CheckCipherSuites default * @run main/othervm CheckCipherSuites limited @@ -99,12 +99,6 @@ "TLS_DHE_DSS_WITH_AES_128_CBC_SHA", // deprecated - "TLS_RSA_WITH_AES_256_GCM_SHA384", - "TLS_RSA_WITH_AES_128_GCM_SHA256", - "TLS_RSA_WITH_AES_256_CBC_SHA256", - "TLS_RSA_WITH_AES_128_CBC_SHA256", - "TLS_RSA_WITH_AES_256_CBC_SHA", - "TLS_RSA_WITH_AES_128_CBC_SHA", "TLS_EMPTY_RENEGOTIATION_INFO_SCSV" }; @@ -124,9 +118,6 @@ "TLS_ECDHE_RSA_WITH_AES_128_CBC_SHA", "TLS_DHE_RSA_WITH_AES_128_CBC_SHA", "TLS_DHE_DSS_WITH_AES_128_CBC_SHA", - "TLS_RSA_WITH_AES_128_GCM_SHA256", - "TLS_RSA_WITH_AES_128_CBC_SHA256", - "TLS_RSA_WITH_AES_128_CBC_SHA", "TLS_EMPTY_RENEGOTIATION_INFO_SCSV" }; @@ -194,12 +185,6 @@ "TLS_DHE_DSS_WITH_AES_128_CBC_SHA", // deprecated - "TLS_RSA_WITH_AES_256_GCM_SHA384", - "TLS_RSA_WITH_AES_128_GCM_SHA256", - "TLS_RSA_WITH_AES_256_CBC_SHA256", - "TLS_RSA_WITH_AES_128_CBC_SHA256", - "TLS_RSA_WITH_AES_256_CBC_SHA", - "TLS_RSA_WITH_AES_128_CBC_SHA", "TLS_EMPTY_RENEGOTIATION_INFO_SCSV" }; @@ -219,9 +204,6 @@ "TLS_ECDHE_RSA_WITH_AES_128_CBC_SHA", "TLS_DHE_RSA_WITH_AES_128_CBC_SHA", "TLS_DHE_DSS_WITH_AES_128_CBC_SHA", - "TLS_RSA_WITH_AES_128_GCM_SHA256", - "TLS_RSA_WITH_AES_128_CBC_SHA256", - "TLS_RSA_WITH_AES_128_CBC_SHA", "TLS_EMPTY_RENEGOTIATION_INFO_SCSV" }; diff -Nru openjdk-17-17.0.17+10/test/jdk/javax/net/ssl/sanity/ciphersuites/SystemPropCipherSuitesOrder.java openjdk-17-17.0.18+8/test/jdk/javax/net/ssl/sanity/ciphersuites/SystemPropCipherSuitesOrder.java --- openjdk-17-17.0.17+10/test/jdk/javax/net/ssl/sanity/ciphersuites/SystemPropCipherSuitesOrder.java 2025-10-13 07:48:04.000000000 +0000 +++ openjdk-17-17.0.18+8/test/jdk/javax/net/ssl/sanity/ciphersuites/SystemPropCipherSuitesOrder.java 2026-01-15 15:23:06.000000000 +0000 @@ -1,5 +1,5 @@ /* - * Copyright (c) 2019, 2020, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2019, 2024, Oracle and/or its affiliates. All rights reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * * This code is free software; you can redistribute it and/or modify it @@ -21,6 +21,7 @@ * questions. */ import java.util.Arrays; +import java.util.stream.Stream; import javax.net.ssl.SSLServerSocket; import javax.net.ssl.SSLSocket; @@ -86,8 +87,20 @@ clientcipherSuites = toArray(System.getProperty("jdk.tls.client.cipherSuites")); System.out.printf("SYSTEM PROPERTIES: ServerProp:%s - ClientProp:%s%n", - Arrays.deepToString(servercipherSuites), - Arrays.deepToString(clientcipherSuites)); + Arrays.deepToString(servercipherSuites), + Arrays.deepToString(clientcipherSuites)); + + // Re-enable TLS_RSA_* cipher suites if needed since test depends on it. + if (Stream.concat( + Arrays.stream( + servercipherSuites == null + ? new String[0] : servercipherSuites), + Arrays.stream( + clientcipherSuites == null + ? new String[0] : clientcipherSuites)) + .anyMatch(s -> s.startsWith("TLS_RSA_"))) { + SecurityUtils.removeFromDisabledTlsAlgs("TLS_RSA_*"); + } try { new SystemPropCipherSuitesOrder(args[0]).run(); diff -Nru openjdk-17-17.0.17+10/test/jdk/javax/net/ssl/sanity/ciphersuites/TLSCipherSuitesOrder.java openjdk-17-17.0.18+8/test/jdk/javax/net/ssl/sanity/ciphersuites/TLSCipherSuitesOrder.java --- openjdk-17-17.0.17+10/test/jdk/javax/net/ssl/sanity/ciphersuites/TLSCipherSuitesOrder.java 2025-10-13 07:48:04.000000000 +0000 +++ openjdk-17-17.0.18+8/test/jdk/javax/net/ssl/sanity/ciphersuites/TLSCipherSuitesOrder.java 2026-01-15 15:23:06.000000000 +0000 @@ -1,5 +1,5 @@ /* - * Copyright (c) 2019, 2020, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2019, 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 @@ -58,6 +58,8 @@ private final String[] clientcipherSuites; public static void main(String[] args) { + // Re-enable TLS_RSA_* since test depends on it. + SecurityUtils.removeFromDisabledTlsAlgs("TLS_RSA_*"); PROTOCOL protocol = PROTOCOL.valueOf(args[0]); try { new TLSCipherSuitesOrder(protocol.getProtocol(), diff -Nru openjdk-17-17.0.17+10/test/jdk/javax/net/ssl/templates/SSLExampleCert.java openjdk-17-17.0.18+8/test/jdk/javax/net/ssl/templates/SSLExampleCert.java --- openjdk-17-17.0.17+10/test/jdk/javax/net/ssl/templates/SSLExampleCert.java 2025-10-13 07:48:04.000000000 +0000 +++ openjdk-17-17.0.18+8/test/jdk/javax/net/ssl/templates/SSLExampleCert.java 2026-01-15 15:23:06.000000000 +0000 @@ -1,5 +1,5 @@ /* - * Copyright (C) 2022 THL A29 Limited, a Tencent company. All rights reserved. + * Copyright (C) 2022, Tencent. All rights reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * * This code is free software; you can redistribute it and/or modify it diff -Nru openjdk-17-17.0.17+10/test/jdk/javax/net/ssl/templates/SSLSocketTemplate.java openjdk-17-17.0.18+8/test/jdk/javax/net/ssl/templates/SSLSocketTemplate.java --- openjdk-17-17.0.17+10/test/jdk/javax/net/ssl/templates/SSLSocketTemplate.java 2025-10-13 07:48:04.000000000 +0000 +++ openjdk-17-17.0.18+8/test/jdk/javax/net/ssl/templates/SSLSocketTemplate.java 2026-01-15 15:23:06.000000000 +0000 @@ -168,7 +168,7 @@ /* * What's the server address? null means binding to the wildcard. */ - protected volatile InetAddress serverAddress = null; + protected volatile InetAddress serverAddress = InetAddress.getLoopbackAddress(); /* * Define the server side of the test. @@ -177,13 +177,8 @@ // kick start the server side service SSLContext context = createServerSSLContext(); SSLServerSocketFactory sslssf = context.getServerSocketFactory(); - InetAddress serverAddress = this.serverAddress; - SSLServerSocket sslServerSocket = serverAddress == null ? - (SSLServerSocket)sslssf.createServerSocket(serverPort) - : (SSLServerSocket)sslssf.createServerSocket(); - if (serverAddress != null) { - sslServerSocket.bind(new InetSocketAddress(serverAddress, serverPort)); - } + SSLServerSocket sslServerSocket = (SSLServerSocket)sslssf.createServerSocket( + serverPort, 0, serverAddress); configureServerSocket(sslServerSocket); serverPort = sslServerSocket.getLocalPort(); @@ -271,10 +266,8 @@ try (SSLSocket sslSocket = (SSLSocket)sslsf.createSocket()) { try { configureClientSocket(sslSocket); - InetAddress serverAddress = this.serverAddress; - InetSocketAddress connectAddress = serverAddress == null - ? new InetSocketAddress(InetAddress.getLoopbackAddress(), serverPort) - : new InetSocketAddress(serverAddress, serverPort); + InetSocketAddress connectAddress = new InetSocketAddress(serverAddress, + serverPort); sslSocket.connect(connectAddress, 15000); } catch (IOException ioe) { // The server side may be impacted by naughty test cases or diff -Nru openjdk-17-17.0.17+10/test/jdk/javax/print/PrintServiceLookup/CountPrintServices.java openjdk-17-17.0.18+8/test/jdk/javax/print/PrintServiceLookup/CountPrintServices.java --- openjdk-17-17.0.17+10/test/jdk/javax/print/PrintServiceLookup/CountPrintServices.java 2025-10-13 07:48:04.000000000 +0000 +++ openjdk-17-17.0.18+8/test/jdk/javax/print/PrintServiceLookup/CountPrintServices.java 2026-01-15 15:23:06.000000000 +0000 @@ -1,5 +1,5 @@ /* - * Copyright (c) 2014, 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 @@ -25,25 +25,21 @@ import java.io.InputStreamReader; import javax.print.PrintService; import javax.print.PrintServiceLookup; -import javax.print.attribute.AttributeSet; -import javax.print.attribute.HashAttributeSet; -import javax.print.attribute.standard.PrinterName; +import java.io.IOException; + +import jtreg.SkippedException; /* * @test * @bug 8032693 * @key printer + * @library /test/lib/ + * @requires (os.family == "linux") * @summary Test that lpstat and JDK agree whether there are printers. */ public class CountPrintServices { public static void main(String[] args) throws Exception { - String os = System.getProperty("os.name").toLowerCase(); - System.out.println("OS is " + os); - if (!os.equals("linux")) { - System.out.println("Linux specific test. No need to continue"); - return; - } PrintService services[] = PrintServiceLookup.lookupPrintServices(null, null); if (services.length > 0) { @@ -51,7 +47,16 @@ return; } String[] lpcmd = { "lpstat", "-a" }; - Process proc = Runtime.getRuntime().exec(lpcmd); + Process proc; + try { + proc = Runtime.getRuntime().exec(lpcmd); + } catch (IOException e) { + if (e.getMessage().contains("No such file or directory")) { + throw new SkippedException("Cannot find lpstat"); + } else { + throw e; + } + } proc.waitFor(); InputStreamReader ir = new InputStreamReader(proc.getInputStream()); BufferedReader br = new BufferedReader(ir); @@ -66,4 +71,3 @@ } } } - diff -Nru openjdk-17-17.0.17+10/test/jdk/javax/rmi/ssl/SSLSocketParametersTest.java openjdk-17-17.0.18+8/test/jdk/javax/rmi/ssl/SSLSocketParametersTest.java --- openjdk-17-17.0.17+10/test/jdk/javax/rmi/ssl/SSLSocketParametersTest.java 2025-10-13 07:48:04.000000000 +0000 +++ openjdk-17-17.0.18+8/test/jdk/javax/rmi/ssl/SSLSocketParametersTest.java 2026-01-15 15:23:06.000000000 +0000 @@ -1,5 +1,5 @@ /* - * Copyright (c) 2004, 2023, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2004, 2025, Oracle and/or its affiliates. All rights reserved. * 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,6 +134,7 @@ } public static void main(String[] args) throws Exception { + System.setProperty("jdk.rmi.ssl.client.enableEndpointIdentification", "false"); // Set keystore properties (server-side) // final String keystore = System.getProperty("test.src") + @@ -153,4 +154,4 @@ SSLSocketParametersTest test = new SSLSocketParametersTest(); test.runTest(Integer.parseInt(args[0])); } -} \ No newline at end of file +} diff -Nru openjdk-17-17.0.17+10/test/jdk/javax/security/auth/callback/PasswordCallback/CheckCleanerBound.java openjdk-17-17.0.18+8/test/jdk/javax/security/auth/callback/PasswordCallback/CheckCleanerBound.java --- openjdk-17-17.0.17+10/test/jdk/javax/security/auth/callback/PasswordCallback/CheckCleanerBound.java 2025-10-13 07:48:04.000000000 +0000 +++ openjdk-17-17.0.18+8/test/jdk/javax/security/auth/callback/PasswordCallback/CheckCleanerBound.java 2026-01-15 15:23:06.000000000 +0000 @@ -1,5 +1,5 @@ /* - * Copyright (C) 2022 THL A29 Limited, a Tencent company. All rights reserved. + * Copyright (C) 2022, Tencent. All rights reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * * This code is free software; you can redistribute it and/or modify it @@ -55,4 +55,3 @@ } } } - diff -Nru openjdk-17-17.0.17+10/test/jdk/javax/security/auth/callback/PasswordCallback/PasswordCleanup.java openjdk-17-17.0.18+8/test/jdk/javax/security/auth/callback/PasswordCallback/PasswordCleanup.java --- openjdk-17-17.0.17+10/test/jdk/javax/security/auth/callback/PasswordCallback/PasswordCleanup.java 2025-10-13 07:48:04.000000000 +0000 +++ openjdk-17-17.0.18+8/test/jdk/javax/security/auth/callback/PasswordCallback/PasswordCleanup.java 2026-01-15 15:23:06.000000000 +0000 @@ -1,5 +1,5 @@ /* - * Copyright (C) 2022 THL A29 Limited, a Tencent company. All rights reserved. + * Copyright (C) 2022, Tencent. All rights reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * * This code is free software; you can redistribute it and/or modify it @@ -49,4 +49,3 @@ } } } - diff -Nru openjdk-17-17.0.17+10/test/jdk/javax/security/auth/login/TEST.properties openjdk-17-17.0.18+8/test/jdk/javax/security/auth/login/TEST.properties --- openjdk-17-17.0.17+10/test/jdk/javax/security/auth/login/TEST.properties 2025-10-13 07:48:04.000000000 +0000 +++ openjdk-17-17.0.18+8/test/jdk/javax/security/auth/login/TEST.properties 1970-01-01 00:00:00.000000000 +0000 @@ -1,2 +0,0 @@ -# disabled till JDK-8219408 is fixed -allowSmartActionArgs=false diff -Nru openjdk-17-17.0.17+10/test/jdk/javax/security/auth/login/modules/JaasModularClientTest.java openjdk-17-17.0.18+8/test/jdk/javax/security/auth/login/modules/JaasModularClientTest.java --- openjdk-17-17.0.17+10/test/jdk/javax/security/auth/login/modules/JaasModularClientTest.java 2025-10-13 07:48:04.000000000 +0000 +++ openjdk-17-17.0.18+8/test/jdk/javax/security/auth/login/modules/JaasModularClientTest.java 2026-01-15 15:23:06.000000000 +0000 @@ -1,5 +1,5 @@ /* - * Copyright (c) 2015, 2017, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2015, 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 @@ -33,19 +33,21 @@ import java.io.OutputStream; import java.lang.module.ModuleDescriptor; import java.lang.module.ModuleDescriptor.Builder; -import jdk.internal.module.ModuleInfoWriter; import java.util.stream.Stream; import jdk.test.lib.process.ProcessTools; import jdk.test.lib.process.OutputAnalyzer; import jdk.test.lib.util.JarUtils; +import jdk.test.lib.util.ModuleInfoWriter; /* * @test * @bug 8078813 8183310 * @summary Test custom JAAS login module with all possible modular option. + * @modules java.base/jdk.internal.org.objectweb.asm + * java.base/jdk.internal.org.objectweb.asm.commons + * java.base/jdk.internal.module * @library /test/lib - * @modules java.base/jdk.internal.module - * @build jdk.test.lib.util.JarUtils + * @build jdk.test.lib.util.JarUtils jdk.test.lib.util.ModuleInfoWriter * @build TestLoginModule JaasClient * @run main JaasModularClientTest false * @run main JaasModularClientTest true diff -Nru openjdk-17-17.0.17+10/test/jdk/javax/security/auth/login/modules/JaasModularDefaultHandlerTest.java openjdk-17-17.0.18+8/test/jdk/javax/security/auth/login/modules/JaasModularDefaultHandlerTest.java --- openjdk-17-17.0.17+10/test/jdk/javax/security/auth/login/modules/JaasModularDefaultHandlerTest.java 2025-10-13 07:48:04.000000000 +0000 +++ openjdk-17-17.0.18+8/test/jdk/javax/security/auth/login/modules/JaasModularDefaultHandlerTest.java 2026-01-15 15:23:06.000000000 +0000 @@ -1,5 +1,5 @@ /* - * Copyright (c) 2016, 2017, 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 @@ -32,19 +32,21 @@ import java.io.OutputStream; import java.lang.module.ModuleDescriptor; import java.lang.module.ModuleDescriptor.Builder; -import jdk.internal.module.ModuleInfoWriter; import java.util.stream.Stream; import jdk.test.lib.process.ProcessTools; import jdk.test.lib.process.OutputAnalyzer; import jdk.test.lib.util.JarUtils; +import jdk.test.lib.util.ModuleInfoWriter; /* * @test * @bug 8151654 8183310 * @summary Test default callback handler with all possible modular option. + * @modules java.base/jdk.internal.org.objectweb.asm + * java.base/jdk.internal.org.objectweb.asm.commons + * java.base/jdk.internal.module * @library /test/lib - * @modules java.base/jdk.internal.module - * @build jdk.test.lib.util.JarUtils + * @build jdk.test.lib.util.JarUtils jdk.test.lib.util.ModuleInfoWriter * @build TestCallbackHandler TestLoginModule JaasClientWithDefaultHandler * @run main JaasModularDefaultHandlerTest */ diff -Nru openjdk-17-17.0.17+10/test/jdk/javax/sound/midi/BulkSoundBank/BulkSoundBank.java openjdk-17-17.0.18+8/test/jdk/javax/sound/midi/BulkSoundBank/BulkSoundBank.java --- openjdk-17-17.0.17+10/test/jdk/javax/sound/midi/BulkSoundBank/BulkSoundBank.java 1970-01-01 00:00:00.000000000 +0000 +++ openjdk-17-17.0.18+8/test/jdk/javax/sound/midi/BulkSoundBank/BulkSoundBank.java 2026-01-15 15:23:06.000000000 +0000 @@ -0,0 +1,53 @@ +/* + * 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. + */ + +import javax.sound.midi.InvalidMidiDataException; +import javax.sound.midi.MidiSystem; +import java.io.ByteArrayInputStream; +import java.io.IOException; + +/** + * @test + * @bug 8350813 + * @summary Rendering of bulky sound bank from MIDI sequence can cause OutOfMemoryError. + * @run main/othervm -Xmx1g BulkSoundBank + */ + +public class BulkSoundBank { + static final byte[] midi = {77, 84, 104, 100, 0, 0, 0, 6, 0, 0, 0, 1, 1, + -32, 77, 84, 114, 107, 0, 0, 0, 50, 0, -1, 88, 4, 4, 2, 24, 8, 0, -1, + 81, 3, 7, -95, 32, 0, -112, 60, 64, -125, 96, -128, 60, 64, -125, -44, + -51, 32, -112, 48, 64, 1, -128, 48, 64, -127, -64, -45, 127, -112, 60, + 64, 1, -128, 60, 64, 0, -1, 47, 0}; + + public static void main(String[] args) throws IOException { + try (ByteArrayInputStream bis = new ByteArrayInputStream(midi)) { + MidiSystem.getSoundbank(bis); + throw new RuntimeException("Test should throw InvalidMidiDataException" + + " but it did not."); + } catch (InvalidMidiDataException imda) { + System.out.println("Caught InvalidMidiDataException as expected"); + } + } +} + diff -Nru openjdk-17-17.0.17+10/test/jdk/javax/swing/JButton/bug4151763.java openjdk-17-17.0.18+8/test/jdk/javax/swing/JButton/bug4151763.java --- openjdk-17-17.0.17+10/test/jdk/javax/swing/JButton/bug4151763.java 1970-01-01 00:00:00.000000000 +0000 +++ openjdk-17-17.0.18+8/test/jdk/javax/swing/JButton/bug4151763.java 2026-01-15 15:23:06.000000000 +0000 @@ -0,0 +1,94 @@ +/* + * 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 + * 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 4151763 + * @summary Tests that button icon is not drawn upon button border + * @library /java/awt/regtesthelpers /test/lib + * @build PassFailJFrame jtreg.SkippedException + * @run main/manual bug4151763 + */ + +import java.awt.Color; +import java.awt.Dimension; +import java.awt.FlowLayout; +import java.awt.Graphics2D; +import java.awt.image.BufferedImage; +import javax.swing.ImageIcon; +import javax.swing.JButton; +import javax.swing.JFrame; +import javax.swing.UIManager; +import javax.swing.border.CompoundBorder; +import javax.swing.border.EmptyBorder; +import javax.swing.border.LineBorder; +import jtreg.SkippedException; + +public class bug4151763 { + private static final int IMAGE_SIZE = 150; + private static final String INSTRUCTIONS = """ + Verify that image icon is NOT painted outside + the black rectangle. + + If above is true press PASS else FAIL. + """; + + public static void main(String[] args) throws Exception { + PassFailJFrame.builder() + .instructions(INSTRUCTIONS) + .columns(40) + .testUI(bug4151763::createAndShowUI) + .build() + .awaitAndCheck(); + } + + private static JFrame createAndShowUI() { + try { + UIManager.setLookAndFeel("com.sun.java.swing.plaf.motif.MotifLookAndFeel"); + } catch (Exception e) { + throw new SkippedException("Unsupported LaF", e); + } + + JFrame frame = new JFrame("bug4151763"); + final JButton b = new JButton(createImageIcon()); + b.setBorder(new CompoundBorder( + new EmptyBorder(20, 20, 20, 20), + new LineBorder(Color.BLACK))); + b.setPreferredSize(new Dimension(100, 100)); + + frame.setLayout(new FlowLayout()); + frame.add(b); + frame.setSize(400, 300); + return frame; + } + + private static ImageIcon createImageIcon() { + BufferedImage redImg = new BufferedImage(IMAGE_SIZE, IMAGE_SIZE, + BufferedImage.TYPE_INT_RGB); + Graphics2D g = redImg.createGraphics(); + g.setColor(Color.RED); + g.fillRect(0, 0, IMAGE_SIZE, IMAGE_SIZE); + g.dispose(); + return new ImageIcon(redImg); + } +} diff -Nru openjdk-17-17.0.17+10/test/jdk/javax/swing/JButton/bug4415505.java openjdk-17-17.0.18+8/test/jdk/javax/swing/JButton/bug4415505.java --- openjdk-17-17.0.17+10/test/jdk/javax/swing/JButton/bug4415505.java 1970-01-01 00:00:00.000000000 +0000 +++ openjdk-17-17.0.18+8/test/jdk/javax/swing/JButton/bug4415505.java 2026-01-15 15:23:06.000000000 +0000 @@ -0,0 +1,77 @@ +/* + * Copyright (c) 2001, 2025, Oracle and/or its affiliates. All rights reserved. + * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. + * + * This code is free software; you can redistribute it and/or modify it + * under the terms of the GNU General Public License version 2 only, as + * published by the Free Software Foundation. + * + * This code is distributed in the hope that it will be useful, but WITHOUT + * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or + * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License + * version 2 for more details (a copy is included in the LICENSE file that + * accompanied this code). + * + * You should have received a copy of the GNU General Public License version + * 2 along with this work; if not, write to the Free Software Foundation, + * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. + * + * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA + * or visit www.oracle.com if you need additional information or have any + * questions. + */ + +/* + * @test + * @bug 4415505 + * @requires (os.family == "windows") + * @summary Tests JButton appearance under Windows LAF + * @library /java/awt/regtesthelpers + * @build PassFailJFrame + * @run main/manual bug4415505 + */ + +import java.awt.FlowLayout; +import javax.swing.JButton; +import javax.swing.JFrame; +import javax.swing.JToggleButton; +import javax.swing.UIManager; + +public class bug4415505 { + private static final String INSTRUCTIONS = """ + +

This test is for Windows LaF. + Press the button named "Button" using mouse and check that it has + "pressed" look. It should look like the selected toggle button + near it.

+ +

If above is true press PASS else FAIL.

+ + """; + + public static void main(String[] args) throws Exception { + UIManager.setLookAndFeel("com.sun.java.swing.plaf.windows.WindowsLookAndFeel"); + + PassFailJFrame.builder() + .instructions(INSTRUCTIONS) + .rows(5) + .columns(40) + .testUI(bug4415505::createAndShowUI) + .build() + .awaitAndCheck(); + } + + private static JFrame createAndShowUI() { + JButton button = new JButton("Button"); + button.setFocusPainted(false); + JToggleButton tbutton = new JToggleButton("ToggleButton"); + tbutton.setSelected(true); + + JFrame jFrame = new JFrame("bug4415505"); + jFrame.setLayout(new FlowLayout(FlowLayout.CENTER)); + jFrame.add(button); + jFrame.add(tbutton); + jFrame.setSize(300, 100); + return jFrame; + } +} diff -Nru openjdk-17-17.0.17+10/test/jdk/javax/swing/JButton/bug4978274.java openjdk-17-17.0.18+8/test/jdk/javax/swing/JButton/bug4978274.java --- openjdk-17-17.0.17+10/test/jdk/javax/swing/JButton/bug4978274.java 1970-01-01 00:00:00.000000000 +0000 +++ openjdk-17-17.0.18+8/test/jdk/javax/swing/JButton/bug4978274.java 2026-01-15 15:23:06.000000000 +0000 @@ -0,0 +1,108 @@ +/* + * Copyright (c) 2004, 2025, Oracle and/or its affiliates. All rights reserved. + * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. + * + * This code is free software; you can redistribute 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 4978274 + * @summary Tests that JButton is painted with same visible height + * as toggle buttons + * @library /java/awt/regtesthelpers + * @build PassFailJFrame + * @run main/manual bug4978274 + */ + +import java.awt.BorderLayout; +import java.awt.FlowLayout; +import java.awt.event.MouseAdapter; +import java.awt.event.MouseEvent; +import javax.swing.JButton; +import javax.swing.JFrame; +import javax.swing.JPanel; +import javax.swing.JToggleButton; +import javax.swing.UIManager; +import javax.swing.border.EmptyBorder; +import javax.swing.plaf.metal.MetalLookAndFeel; +import javax.swing.plaf.metal.OceanTheme; + +public class bug4978274 { + private static final String INSTRUCTIONS = """ + The toggle buttons must be painted to the same visible + height as button. In addition to that verify the following: + + a) All three buttons - "Button", "Toggle Btn" and + "Selected Toggle Btn" have the same border. + + b) Verify that when "Button" is pressed and moused over + it has the EXACT same border as "Toggle Btn" and + "Selected Toggle Btn" on press & mouse over. + + c) Click to the test window (panel) to disable/enable all + three buttons. In disabled state verify that all three + buttons have the exact same border. + + If all of the above conditions are true press PASS, else FAIL. + """; + + public static void main(String[] args) throws Exception { + MetalLookAndFeel.setCurrentTheme(new OceanTheme()); + UIManager.setLookAndFeel(UIManager.getCrossPlatformLookAndFeelClassName()); + + PassFailJFrame.builder() + .instructions(INSTRUCTIONS) + .columns(40) + .testUI(createAndShowUI()) + .build() + .awaitAndCheck(); + } + + private static JFrame createAndShowUI() { + JFrame frame = new JFrame("bug4978274"); + frame.setLayout(new BorderLayout()); + + JPanel panel = new JPanel(); + panel.setLayout(new FlowLayout()); + panel.setBorder(new EmptyBorder(12, 12, 12, 12)); + JButton jButton = new JButton("Button"); + JToggleButton jToggleButton = new JToggleButton("Selected Toggle Btn"); + jToggleButton.setSelected(true); + + panel.add(jButton); + panel.add(new JToggleButton("Toggle Btn")); + panel.add(jToggleButton); + + panel.addMouseListener(new MouseAdapter() { + @Override + public void mouseClicked(MouseEvent event) { + jButton.setEnabled(!jButton.isEnabled()); + jToggleButton.setEnabled(jButton.isEnabled()); + for(int i = 0; i < panel.getComponentCount(); i++) { + panel.getComponent(i).setEnabled(jButton.isEnabled()); + } + } + }); + + frame.add(panel); + frame.pack(); + return frame; + } +} diff -Nru openjdk-17-17.0.17+10/test/jdk/javax/swing/JCheckBox/4449413/bug4449413.java openjdk-17-17.0.18+8/test/jdk/javax/swing/JCheckBox/4449413/bug4449413.java --- openjdk-17-17.0.17+10/test/jdk/javax/swing/JCheckBox/4449413/bug4449413.java 2025-10-13 07:48:04.000000000 +0000 +++ openjdk-17-17.0.18+8/test/jdk/javax/swing/JCheckBox/4449413/bug4449413.java 2026-01-15 15:23:06.000000000 +0000 @@ -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 @@ -24,7 +24,6 @@ /* @test * @bug 4449413 * @summary Tests that checkbox and radiobuttons' check marks are visible when background is black - * @author Ilya Boyandin * @run main/manual bug4449413 */ @@ -56,8 +55,16 @@ public class bug4449413 extends JFrame { + private static boolean isWindowsLF; + + private static String INSTRUCTIONS_WINDOWSLF = + "There are eight controls, JCheckBox/JRadioButton with black background\n" + + "and JRadioButtonMenuItem/JCheckboxMenuItem with gray background\n"; + private static final String INSTRUCTIONS = - "There are eight controls with black backgrounds.\n" + + "There are eight controls with black backgrounds.\n"; + + private static final String INSTRUCTIONS_COMMON = "Four enabled (on the left side) and four disabled (on the right side)\n" + "checkboxes and radiobuttons.\n\n" + "1. If at least one of the controls' check marks is not visible:\n" + @@ -82,6 +89,8 @@ } public static void main(String[] args) throws Exception { + isWindowsLF = "Windows".equals(UIManager.getLookAndFeel().getID()); + SwingUtilities.invokeLater(() -> { instance = new bug4449413(); instance.createAndShowGUI(); @@ -150,8 +159,10 @@ JTextArea instructionArea = new JTextArea( isMetalLookAndFeel() - ? INSTRUCTIONS + INSTRUCTIONS_ADDITIONS_METAL - : INSTRUCTIONS + ? INSTRUCTIONS + INSTRUCTIONS_COMMON + INSTRUCTIONS_ADDITIONS_METAL + : isWindowsLF + ? (INSTRUCTIONS_WINDOWSLF + INSTRUCTIONS_COMMON) + : (INSTRUCTIONS + INSTRUCTIONS_COMMON) ); instructionArea.setEditable(false); @@ -189,7 +200,13 @@ }; b.setOpaque(true); - b.setBackground(Color.black); + if (isWindowsLF + && ((b instanceof JRadioButtonMenuItem) + || (b instanceof JCheckBoxMenuItem))) { + b.setBackground(Color.lightGray); + } else { + b.setBackground(Color.black); + } b.setForeground(Color.white); b.setEnabled(enabled == 1); b.setSelected(true); diff -Nru openjdk-17-17.0.17+10/test/jdk/javax/swing/JComboBox/bug4139900.java openjdk-17-17.0.18+8/test/jdk/javax/swing/JComboBox/bug4139900.java --- openjdk-17-17.0.17+10/test/jdk/javax/swing/JComboBox/bug4139900.java 1970-01-01 00:00:00.000000000 +0000 +++ openjdk-17-17.0.18+8/test/jdk/javax/swing/JComboBox/bug4139900.java 2026-01-15 15:23:06.000000000 +0000 @@ -0,0 +1,119 @@ +/* + * Copyright (c) 1999, 2025, Oracle and/or its affiliates. All rights reserved. + * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. + * + * This code is free software; you can redistribute 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 4139900 + * @summary height of combobox may differ + * @key headful + * @run main bug4139900 +*/ + +import java.awt.Dimension; +import java.awt.Robot; +import java.awt.event.ActionListener; +import javax.swing.DefaultComboBoxModel; +import javax.swing.JButton; +import javax.swing.JComboBox; +import javax.swing.JFrame; +import javax.swing.JPanel; +import javax.swing.SwingUtilities; + +public class bug4139900 { + static JButton button; + static JFrame frame; + static JComboBox comboBox; + static int initialHeight; + + public static void main(String[] args) throws Exception { + try { + SwingUtilities.invokeAndWait(bug4139900::init); + test(); + } finally { + SwingUtilities.invokeAndWait(() -> { + if (frame != null) { + frame.dispose(); + } + }); + } + } + + private static void test() throws Exception { + Robot robot = new Robot(); + robot.waitForIdle(); + robot.delay(500); + + SwingUtilities.invokeAndWait(() -> initialHeight = comboBox.getHeight()); + + for (int i = 0; i < 10; i++) { + SwingUtilities.invokeAndWait(() -> button.doClick()); + robot.waitForIdle(); + robot.delay(200); + SwingUtilities.invokeAndWait(() -> { + if (comboBox.getHeight() != initialHeight) { + throw new RuntimeException( + "Test failed: height differs from initial %d != %d" + .formatted(comboBox.getHeight(), initialHeight) + ); + } + }); + } + } + + public static void init() { + frame = new JFrame("bug4139900"); + + DefaultComboBoxModel model = + new DefaultComboBoxModel<>(new String[]{ + "Coma Berenices", + "Triangulum", + "Camelopardis", + "Cassiopea" + }); + + comboBox = new JComboBox<>(); + comboBox.setEditable(true); + + button = new JButton("Add/Remove Items"); + + ActionListener actionListener = e -> { + if (comboBox.getModel() == model) { + comboBox.setModel(new DefaultComboBoxModel<>()); + } else { + comboBox.setModel(model); + } + }; + + button.addActionListener(actionListener); + + JPanel panel = new JPanel(); + panel.setPreferredSize(new Dimension(300, 100)); + panel.add(comboBox); + panel.add(button); + + frame.add(panel); + frame.pack(); + frame.setLocationRelativeTo(null); + frame.setVisible(true); + } +} diff -Nru openjdk-17-17.0.17+10/test/jdk/javax/swing/JComboBox/bug4166593.java openjdk-17-17.0.18+8/test/jdk/javax/swing/JComboBox/bug4166593.java --- openjdk-17-17.0.17+10/test/jdk/javax/swing/JComboBox/bug4166593.java 1970-01-01 00:00:00.000000000 +0000 +++ openjdk-17-17.0.18+8/test/jdk/javax/swing/JComboBox/bug4166593.java 2026-01-15 15:23:06.000000000 +0000 @@ -0,0 +1,98 @@ +/* + * Copyright (c) 1998, 2025, Oracle and/or its affiliates. All rights reserved. + * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. + * + * This code is free software; you can redistribute it and/or modify it + * under the terms of the GNU General Public License version 2 only, as + * published by the Free Software Foundation. + * + * This code is distributed in the hope that it will be useful, but WITHOUT + * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or + * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License + * version 2 for more details (a copy is included in the LICENSE file that + * accompanied this code). + * + * You should have received a copy of the GNU General Public License version + * 2 along with this work; if not, write to the Free Software Foundation, + * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. + * + * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA + * or visit www.oracle.com if you need additional information or have any + * questions. + */ + +import java.awt.Robot; +import java.awt.event.ActionListener; +import javax.swing.JComboBox; +import javax.swing.JFrame; +import javax.swing.JLabel; +import javax.swing.JPanel; +import javax.swing.SwingUtilities; + +/* + * @test + * @bug 4166593 + * @summary Tests that JComboBox fires action events every time the user does an action + * @key headful + * @run main bug4166593 + */ + +public class bug4166593 { + static JFrame frame; + static JComboBox comboBox; + static volatile int numberOfActionEvents = 0; + + public static void main(String[] args) throws Exception { + try { + Robot robot = new Robot(); + SwingUtilities.invokeAndWait(() -> createTestUI()); + robot.waitForIdle(); + robot.delay(250); + + // change selected index 3 times + SwingUtilities.invokeAndWait(() -> { + comboBox.setSelectedIndex(1); + comboBox.setSelectedIndex(3); + comboBox.setSelectedIndex(2); + }); + robot.waitForIdle(); + robot.delay(250); + + if (numberOfActionEvents != 3) { + throw new RuntimeException("Unexpected number of Action Events!\n" + + "Expected: 3\nActual: " + numberOfActionEvents); + } + } finally { + SwingUtilities.invokeAndWait(() -> { + if (frame != null) { + frame.dispose(); + } + }); + } + } + + public static void createTestUI() { + comboBox = new JComboBox(new Object[]{ + "Bob", "Fred", "Hank", "Joe", "Mildred", "Agatha", "Buffy" + }); + JPanel panel = new JPanel(); + JLabel label = new JLabel("0"); + frame = new JFrame("bug4166593"); + comboBox.setEditable(true); + + ActionListener actionCounter = e -> { + ++numberOfActionEvents; + label.setText(Integer.toString(numberOfActionEvents)); + }; + + comboBox.addActionListener(actionCounter); + + panel.add(comboBox); + panel.add(label); + + frame.add(panel); + frame.pack(); + frame.setLocationRelativeTo(null); + frame.setVisible(true); + } +} diff -Nru openjdk-17-17.0.17+10/test/jdk/javax/swing/JComboBox/bug4174876.java openjdk-17-17.0.18+8/test/jdk/javax/swing/JComboBox/bug4174876.java --- openjdk-17-17.0.17+10/test/jdk/javax/swing/JComboBox/bug4174876.java 1970-01-01 00:00:00.000000000 +0000 +++ openjdk-17-17.0.18+8/test/jdk/javax/swing/JComboBox/bug4174876.java 2026-01-15 15:23:06.000000000 +0000 @@ -0,0 +1,78 @@ +/* + * Copyright (c) 1999, 2025, Oracle and/or its affiliates. All rights reserved. + * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. + * + * This code is free software; you can redistribute 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 4174876 + * @summary JComboBox tooltips do not work properly + * @library /java/awt/regtesthelpers + * @build PassFailJFrame + * @run main/manual bug4174876 + */ + +import javax.swing.JComboBox; +import javax.swing.JComponent; +import javax.swing.JPanel; + +public class bug4174876 { + private static final String INSTRUCTIONS = """ + Hold the mouse over both combo boxes. + A tool tip should appear over every area of both of them. + Notably, if you hold the mouse over the button on the right one, + a tool tip should appear. + """; + + public static void main(String[] args) throws Exception { + PassFailJFrame.builder() + .title("TransparentTitleTest Instructions") + .instructions(INSTRUCTIONS) + .columns(40) + .splitUIBottom(bug4174876::createTestUI) + .build() + .awaitAndCheck(); + } + + private static JComponent createTestUI() { + JComboBox comboBox1 = new JComboBox<>(new String[]{ + "Coma Berenices", + "Triangulum", + "Camelopardis", + "Cassiopea" + }); + JComboBox comboBox2 = new JComboBox<>(new String[]{ + "Coma Berenices", + "Triangulum", + "Camelopardis", + "Cassiopea" + }); + + comboBox1.setToolTipText("Combo Box #1"); + comboBox2.setToolTipText("Combo Box #2"); + comboBox2.setEditable(true); + + JPanel panel = new JPanel(); + panel.add(comboBox1); + panel.add(comboBox2); + return panel; + } +} diff -Nru openjdk-17-17.0.17+10/test/jdk/javax/swing/JComboBox/bug4180054.java openjdk-17-17.0.18+8/test/jdk/javax/swing/JComboBox/bug4180054.java --- openjdk-17-17.0.17+10/test/jdk/javax/swing/JComboBox/bug4180054.java 1970-01-01 00:00:00.000000000 +0000 +++ openjdk-17-17.0.18+8/test/jdk/javax/swing/JComboBox/bug4180054.java 2026-01-15 15:23:06.000000000 +0000 @@ -0,0 +1,112 @@ +/* + * Copyright (c) 1998, 2025, Oracle and/or its affiliates. All rights reserved. + * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. + * + * This code is free software; you can redistribute it and/or modify it + * under the terms of the GNU General Public License version 2 only, as + * published by the Free Software Foundation. + * + * This code is distributed in the hope that it will be useful, but WITHOUT + * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or + * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License + * version 2 for more details (a copy is included in the LICENSE file that + * accompanied this code). + * + * You should have received a copy of the GNU General Public License version + * 2 along with this work; if not, write to the Free Software Foundation, + * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. + * + * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA + * or visit www.oracle.com if you need additional information or have any + * questions. + */ + +import java.awt.Robot; +import javax.swing.DefaultComboBoxModel; +import javax.swing.JComboBox; +import javax.swing.JFrame; +import javax.swing.JLabel; +import javax.swing.JPanel; +import javax.swing.SwingUtilities; +import javax.swing.event.ListDataEvent; +import javax.swing.event.ListDataListener; + +/* + * @test + * @bug 4180054 + * @summary Tests that DefaultComboBoxModel doesn't fire a "contents changed" unnecessarily + * @key headful + * @run main bug4180054 + */ + +public class bug4180054 { + static JFrame frame; + static JComboBox comboBox; + static volatile int numberOfContentsChangedEvents = 0; + + public static void main(String[] args) throws Exception { + try { + Robot robot = new Robot(); + SwingUtilities.invokeAndWait(() -> createTestUI()); + robot.waitForIdle(); + robot.delay(250); + + // change selected index 3 times + SwingUtilities.invokeAndWait(() -> { + comboBox.setSelectedIndex(1); + comboBox.setSelectedIndex(3); + comboBox.setSelectedIndex(2); + comboBox.setSelectedIndex(2); + }); + robot.waitForIdle(); + robot.delay(250); + + if (numberOfContentsChangedEvents != 3) { + throw new RuntimeException("Unexpected number of Contents Changed Events!\n" + + "Expected: 3\nActual: " + numberOfContentsChangedEvents); + } + } finally { + SwingUtilities.invokeAndWait(() -> { + if (frame != null) { + frame.dispose(); + } + }); + } + } + + public static void createTestUI() { + frame = new JFrame("bug4180054"); + JPanel panel = new JPanel(); + JLabel label = new JLabel("0"); + + DefaultComboBoxModel model = new DefaultComboBoxModel(); + for (int i = 0; i < 100; ++i) { + model.addElement(Integer.toString(i)); + } + comboBox = new JComboBox(model); + comboBox.setEditable(true); + + ListDataListener contentsCounter = new ListDataListener() { + public void contentsChanged(ListDataEvent e) { + ++numberOfContentsChangedEvents; + label.setText(Integer.toString(numberOfContentsChangedEvents)); + } + + public void intervalAdded(ListDataEvent e) { + } + + public void intervalRemoved(ListDataEvent e) { + } + }; + + comboBox.getModel().addListDataListener(contentsCounter); + + panel.add(comboBox); + panel.add(label); + + frame.add(panel); + frame.pack(); + frame.setLocationRelativeTo(null); + frame.setVisible(true); + } +} diff -Nru openjdk-17-17.0.17+10/test/jdk/javax/swing/JComboBox/bug4185024.java openjdk-17-17.0.18+8/test/jdk/javax/swing/JComboBox/bug4185024.java --- openjdk-17-17.0.17+10/test/jdk/javax/swing/JComboBox/bug4185024.java 1970-01-01 00:00:00.000000000 +0000 +++ openjdk-17-17.0.18+8/test/jdk/javax/swing/JComboBox/bug4185024.java 2026-01-15 15:23:06.000000000 +0000 @@ -0,0 +1,109 @@ +/* + * Copyright (c) 1998, 2025, Oracle and/or its affiliates. All rights reserved. + * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. + * + * This code is free software; you can redistribute it and/or modify it + * under the terms of the GNU General Public License version 2 only, as + * published by the Free Software Foundation. + * + * This code is distributed in the hope that it will be useful, but WITHOUT + * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or + * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License + * version 2 for more details (a copy is included in the LICENSE file that + * accompanied this code). + * + * You should have received a copy of the GNU General Public License version + * 2 along with this work; if not, write to the Free Software Foundation, + * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. + * + * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA + * or visit www.oracle.com if you need additional information or have any + * questions. + */ + +import java.awt.BorderLayout; +import java.awt.Point; +import javax.swing.JComboBox; +import javax.swing.JComponent; +import javax.swing.JDesktopPane; +import javax.swing.JFrame; +import javax.swing.JInternalFrame; +import javax.swing.JPanel; + +/* + * @test + * @bug 4185024 + * @summary Tests that Heavyweight combo boxes on JDesktop work correctly + * @library /java/awt/regtesthelpers + * @build PassFailJFrame + * @run main/manual bug4185024 + */ + +public class bug4185024 { + private static final String INSTRUCTIONS = """ + Click on the JComboBox button inside the JInternalFrame to bring up the menu. + Select one of the menu items and verify that the choice is highlighted correctly. + Click and drag the menu's scroll bar down and verify that it causes the menu to scroll down. + + Inside JInternalFrame: + This test is for the JComboBox in the JInternalFrame. + To test, please click on the combobox and check the following: + Does the selection in the popup list follow the mouse? + Does the popup list respond to clicking and dragging the scroll bar? + If so, press PASS, otherwise, press FAIL. + """; + + public static void main(String[] args) throws Exception { + PassFailJFrame.builder() + .instructions(INSTRUCTIONS) + .columns(50) + .testUI(bug4185024::createTestUI) + .build() + .awaitAndCheck(); + } + + public static JFrame createTestUI() { + JFrame frame = new JFrame("bug4185024"); + JPanel p = new JPanel(); + p.setLayout(new BorderLayout()); + JDesktopPane desktop = new JDesktopPane(); + p.add(desktop); + frame.add(p); + + JComboBox months = new JComboBox(); + months.addItem("January"); + months.addItem("February"); + months.addItem("March"); + months.addItem("April"); + months.addItem("May"); + months.addItem("June"); + months.addItem("July"); + months.addItem("August"); + months.addItem("September"); + months.addItem("October"); + months.addItem("November"); + months.addItem("December"); + months.getAccessibleContext().setAccessibleName("Months"); + months.getAccessibleContext().setAccessibleDescription("Choose a month of the year"); + + // Set this to true and the popup works correctly... + months.setLightWeightPopupEnabled(false); + + addFrame("Months", desktop, months); + + frame.setSize(300, 300); + return frame; + } + + private static void addFrame(String title, JDesktopPane desktop, JComponent component) { + JInternalFrame jf = new JInternalFrame(title); + Point newPos = new Point(20, 20); + jf.setResizable(true); + jf.add(component); + jf.setLocation(newPos); + desktop.add(jf); + + jf.pack(); + jf.show(); + } +} diff -Nru openjdk-17-17.0.17+10/test/jdk/javax/swing/JComboBox/bug4201964.java openjdk-17-17.0.18+8/test/jdk/javax/swing/JComboBox/bug4201964.java --- openjdk-17-17.0.17+10/test/jdk/javax/swing/JComboBox/bug4201964.java 1970-01-01 00:00:00.000000000 +0000 +++ openjdk-17-17.0.18+8/test/jdk/javax/swing/JComboBox/bug4201964.java 2026-01-15 15:23:06.000000000 +0000 @@ -0,0 +1,77 @@ +/* + * Copyright (c) 1999, 2025, Oracle and/or its affiliates. All rights reserved. + * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. + * + * This code is free software; you can redistribute 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.swing.JComboBox; +import javax.swing.JFrame; +import javax.swing.JPanel; +import javax.swing.UIManager; + +/* + * @test + * @bug 4201964 + * @summary Tests that JComboBox's arrow button isn't drawn too wide in Windows Look&Feel + * @requires (os.family == "windows") + * @library /java/awt/regtesthelpers + * @build PassFailJFrame + * @run main/manual bug4201964 + */ + +public class bug4201964 { + private static final String INSTRUCTIONS = """ + Does the arrow look too large? If not, it passes. + """; + + public static void main(String[] args) throws Exception { + try { + UIManager.setLookAndFeel("com.sun.java.swing.plaf.windows.WindowsLookAndFeel"); + } catch (Exception e) { + PassFailJFrame.forceFail("Couldn't load the Windows look and feel."); + } + + PassFailJFrame.builder() + .instructions(INSTRUCTIONS) + .rows(8) + .columns(30) + .testUI(bug4201964::createTestUI) + .build() + .awaitAndCheck(); + } + + public static JFrame createTestUI() { + JFrame frame = new JFrame("bug4201964"); + JPanel panel = new JPanel(); + JComboBox comboBox; + + comboBox = new JComboBox(new Object[]{ + "Coma Berenices", + "Triangulum", + "Camelopardis", + "Cassiopea"}); + + panel.add(comboBox); + + frame.add(panel); + frame.pack(); + return frame; + } +} diff -Nru openjdk-17-17.0.17+10/test/jdk/javax/swing/JComboBox/bug4249732.java openjdk-17-17.0.18+8/test/jdk/javax/swing/JComboBox/bug4249732.java --- openjdk-17-17.0.17+10/test/jdk/javax/swing/JComboBox/bug4249732.java 1970-01-01 00:00:00.000000000 +0000 +++ openjdk-17-17.0.18+8/test/jdk/javax/swing/JComboBox/bug4249732.java 2026-01-15 15:23:06.000000000 +0000 @@ -0,0 +1,72 @@ +/* + * Copyright (c) 1999, 2025, Oracle and/or its affiliates. All rights reserved. + * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. + * + * This code is free software; you can redistribute it and/or modify it + * under the terms of the GNU General Public License version 2 only, as + * published by the Free Software Foundation. + * + * This code is distributed in the hope that it will be useful, but WITHOUT + * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or + * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License + * version 2 for more details (a copy is included in the LICENSE file that + * accompanied this code). + * + * You should have received a copy of the GNU General Public License version + * 2 along with this work; if not, write to the Free Software Foundation, + * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. + * + * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA + * or visit www.oracle.com if you need additional information or have any + * questions. + */ + +import java.awt.BorderLayout; +import javax.swing.JComboBox; +import javax.swing.JFrame; +import javax.swing.UIManager; + +/* + * @test + * @bug 4249732 + * @requires (os.family == "windows") + * @summary Tests that Windows editable combo box selects text picked from its list + * @library /java/awt/regtesthelpers + * @build PassFailJFrame + * @run main/manual bug4249732 + */ + +public class bug4249732 { + private static final String INSTRUCTIONS = """ + Click on combo box arrow button to open its dropdown list, and + select an item from there. The text in the combo box editor should + be selected, otherwise test fails. + """; + + public static void main(String[] args) throws Exception { + try { + UIManager.setLookAndFeel("com.sun.java.swing.plaf.windows.WindowsLookAndFeel"); + } catch (Exception e) { + PassFailJFrame.forceFail("Couldn't load the Windows look and feel."); + } + + PassFailJFrame.builder() + .instructions(INSTRUCTIONS) + .rows(8) + .columns(40) + .testUI(bug4249732::createTestUI) + .build() + .awaitAndCheck(); + } + + public static JFrame createTestUI() { + JFrame frame = new JFrame("bug4249732"); + + JComboBox cb = new JComboBox(new Object[]{"foo", "bar", "baz"}); + cb.setEditable(true); + + frame.add(cb, BorderLayout.NORTH); + frame.pack(); + return frame; + } +} diff -Nru openjdk-17-17.0.17+10/test/jdk/javax/swing/JComboBox/bug4368848.java openjdk-17-17.0.18+8/test/jdk/javax/swing/JComboBox/bug4368848.java --- openjdk-17-17.0.17+10/test/jdk/javax/swing/JComboBox/bug4368848.java 1970-01-01 00:00:00.000000000 +0000 +++ openjdk-17-17.0.18+8/test/jdk/javax/swing/JComboBox/bug4368848.java 2026-01-15 15:23:06.000000000 +0000 @@ -0,0 +1,129 @@ +/* + * 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 + * 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.swing.DefaultCellEditor; +import javax.swing.JComboBox; +import javax.swing.JFrame; +import javax.swing.JScrollPane; +import javax.swing.JTable; +import javax.swing.table.AbstractTableModel; + +/* + * @test + * @bug 4368848 + * @summary Tests that mouse wheel events cancel popups + * @library /java/awt/regtesthelpers + * @build PassFailJFrame + * @run main/manual bug4368848 + */ + +public class bug4368848 { + static final String[] names = {"First Name", "Last Name", "Veggy"}; + static Object[][] data = { + {"Mark", "Andrews", false}, + {"Tom", "Ball", false}, + {"Alan", "Chung", false}, + {"Jeff", "Dinkins", false}, + {"Amy", "Fowler", false}, + {"Brian", "Gerhold", false}, + {"James", "Gosling", false}, + {"David", "Karlton", false}, + {"Dave", "Kloba", false}, + {"Peter", "Korn", false}, + {"Phil", "Milne", false}, + {"Dave", "Moore", false}, + {"Hans", "Muller", false}, + {"Rick", "Levenson", false}, + {"Tim", "Prinzing", false}, + {"Chester", "Rose", false}, + {"Ray", "Ryan", false}, + {"Georges", "Saab", false}, + {"Willie", "Walker", false}, + {"Kathy", "Walrath", false}, + {"Arnaud", "Weber", false} + }; + + private static final String INSTRUCTIONS = """ + Click any cell in the 'Veggy' column, so that combo box appears. + Make sure mouse pointer is over the table, but _not_ over the combo + box. Try scrolling the table using the mouse wheel. The combo popup + should disappear. If it stays visible, test fails. + """; + + public static void main(String[] args) throws Exception { + PassFailJFrame.builder() + .instructions(INSTRUCTIONS) + .columns(50) + .testUI(bug4368848::createTestUI) + .build() + .awaitAndCheck(); + } + + public static JFrame createTestUI() { + JFrame frame = new JFrame("bug4368848"); + ExampleTableModel dataModel = new ExampleTableModel(); + + JComboBox _editor = new JComboBox(); + _editor.addItem(false); + _editor.addItem(true); + + JTable tableView = new JTable(dataModel); + tableView.setDefaultEditor(Boolean.class, new DefaultCellEditor(_editor)); + + frame.add(new JScrollPane(tableView)); + frame.setSize(200, 200); + return frame; + } + + static class ExampleTableModel extends AbstractTableModel { + // These methods always need to be implemented. + @Override + public int getColumnCount() { + return names.length; + } + + @Override + public int getRowCount() { + return data.length; + } + + public Object getValueAt(int row, int col) { + return data[row][col]; + } + + @Override + public boolean isCellEditable(int row, int col) { + return true; + } + + @Override + public String getColumnName(int column) { + return names[column]; + } + + @Override + public Class getColumnClass(int col) { + return getValueAt(0, col).getClass(); + } + } +} diff -Nru openjdk-17-17.0.17+10/test/jdk/javax/swing/JComboBox/bug4474400.java openjdk-17-17.0.18+8/test/jdk/javax/swing/JComboBox/bug4474400.java --- openjdk-17-17.0.17+10/test/jdk/javax/swing/JComboBox/bug4474400.java 1970-01-01 00:00:00.000000000 +0000 +++ openjdk-17-17.0.18+8/test/jdk/javax/swing/JComboBox/bug4474400.java 2026-01-15 15:23:06.000000000 +0000 @@ -0,0 +1,78 @@ +/* + * Copyright (c) 2001, 2025, Oracle and/or its affiliates. All rights reserved. + * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. + * + * This code is free software; you can redistribute it and/or modify it + * under the terms of the GNU General Public License version 2 only, as + * published by the Free Software Foundation. + * + * This code is distributed in the hope that it will be useful, but WITHOUT + * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or + * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License + * version 2 for more details (a copy is included in the LICENSE file that + * accompanied this code). + * + * You should have received a copy of the GNU General Public License version + * 2 along with this work; if not, write to the Free Software Foundation, + * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. + * + * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA + * or visit www.oracle.com if you need additional information or have any + * questions. + */ + +/* + * @test + * @bug 4474400 + * @summary Tests JTextArea wrapping with font change + * @library /java/awt/regtesthelpers + * @build PassFailJFrame + * @run main/manual bug4474400 + */ + +import java.awt.BorderLayout; +import java.awt.Dimension; +import java.awt.Font; +import javax.swing.JButton; +import javax.swing.JComponent; +import javax.swing.JPanel; +import javax.swing.JTextArea; + +public class bug4474400 { + private static final String INSTRUCTIONS = """ + Press the "Change Font" button. The two lines of text should be + properly drawn using the larger font, there should be empty line + between them. If display is garbled, test fails. + """; + + public static void main(String[] args) throws Exception { + PassFailJFrame.builder() + .title("bug4474400 Instructions") + .instructions(INSTRUCTIONS) + .columns(40) + .splitUIRight(bug4474400::createTestUI) + .build() + .awaitAndCheck(); + } + + private static JComponent createTestUI() { + Font smallFont = new Font("SansSerif", Font.PLAIN, 12); + Font largeFont = new Font("SansSerif", Font.PLAIN, 36); + + JTextArea textArea = new JTextArea("This is the first line\n\nThis is the third line"); + textArea.setFont(smallFont); + textArea.setEditable(false); + textArea.setLineWrap(true); + textArea.setWrapStyleWord(true); + + JButton b = new JButton("Change Font"); + b.addActionListener((e) -> textArea.setFont(largeFont)); + + JPanel panel = new JPanel(new BorderLayout()); + panel.setPreferredSize(new Dimension(200, 300)); + panel.add(textArea, BorderLayout.CENTER); + panel.add(b, BorderLayout.SOUTH); + + return panel; + } +} diff -Nru openjdk-17-17.0.17+10/test/jdk/javax/swing/JComboBox/bug4530952.java openjdk-17-17.0.18+8/test/jdk/javax/swing/JComboBox/bug4530952.java --- openjdk-17-17.0.17+10/test/jdk/javax/swing/JComboBox/bug4530952.java 1970-01-01 00:00:00.000000000 +0000 +++ openjdk-17-17.0.18+8/test/jdk/javax/swing/JComboBox/bug4530952.java 2026-01-15 15:23:06.000000000 +0000 @@ -0,0 +1,147 @@ +/* + * Copyright (c) 2001, 2025, Oracle and/or its affiliates. All rights reserved. + * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. + * + * This code is free software; you can redistribute it and/or modify it + * under the terms of the GNU General Public License version 2 only, as + * published by the Free Software Foundation. + * + * This code is distributed in the hope that it will be useful, but WITHOUT + * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or + * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License + * version 2 for more details (a copy is included in the LICENSE file that + * accompanied this code). + * + * You should have received a copy of the GNU General Public License version + * 2 along with this work; if not, write to the Free Software Foundation, + * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. + * + * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA + * or visit www.oracle.com if you need additional information or have any + * questions. + */ + +import java.awt.Dimension; +import java.awt.FlowLayout; +import java.awt.Point; +import java.awt.Robot; +import java.awt.event.ActionListener; +import java.awt.event.InputEvent; +import java.awt.event.KeyEvent; +import javax.swing.JButton; +import javax.swing.JComboBox; +import javax.swing.JFrame; +import javax.swing.JTextField; +import javax.swing.SwingUtilities; +import javax.swing.event.DocumentEvent; +import javax.swing.event.DocumentListener; + +/* + * @test + * @bug 4530952 + * @summary Tests that double mouse clicks invoke Event + * @key headful + * @run main bug4530952 + */ + +public class bug4530952 { + static JFrame frame; + static JButton btnAction; + static JComboBox cmbAction; + static volatile Point loc; + static volatile Dimension btnSize; + + private static volatile boolean flag; + + public static void main(String[] args) throws Exception { + try { + Robot robot = new Robot(); + SwingUtilities.invokeAndWait(() -> createTestUI()); + robot.waitForIdle(); + robot.delay(1000); + + // enter some text in combo box + robot.keyPress(KeyEvent.VK_A); + robot.keyRelease(KeyEvent.VK_A); + robot.keyPress(KeyEvent.VK_A); + robot.keyRelease(KeyEvent.VK_A); + robot.waitForIdle(); + robot.delay(250); + + // find and click action button + SwingUtilities.invokeAndWait(() -> { + loc = btnAction.getLocationOnScreen(); + btnSize = btnAction.getSize(); + }); + robot.waitForIdle(); + robot.delay(250); + + robot.mouseMove(loc.x + btnSize.width / 2, + loc.y + btnSize.height / 2); + robot.mousePress(InputEvent.BUTTON1_DOWN_MASK); + robot.mouseRelease(InputEvent.BUTTON1_DOWN_MASK); + robot.mousePress(InputEvent.BUTTON1_DOWN_MASK); + robot.mouseRelease(InputEvent.BUTTON1_DOWN_MASK); + robot.waitForIdle(); + robot.delay(1000); + + if (!flag) { + throw new RuntimeException("Failed: button action was not fired"); + } + } finally { + SwingUtilities.invokeAndWait(() -> { + if (frame != null) { + frame.dispose(); + } + }); + } + } + + public static void createTestUI() { + frame = new JFrame("bug4530952"); + frame.setLayout(new FlowLayout()); + + btnAction = new JButton("Action"); + cmbAction = new JComboBox(); + + flag = false; + + ActionListener al = e -> flag = true; + DocumentListener dl = new DocumentListener() { + @Override + public void changedUpdate(DocumentEvent evt) { + resetButtons(); + } + + @Override + public void insertUpdate(DocumentEvent evt) { + resetButtons(); + } + + @Override + public void removeUpdate(DocumentEvent evt) { + resetButtons(); + } + }; + + // Add an editable combo box + cmbAction.setEditable(true); + frame.add(cmbAction); + + btnAction.setEnabled(false); + frame.add(btnAction); + + btnAction.addActionListener(al); + ((JTextField) cmbAction.getEditor().getEditorComponent()). + getDocument().addDocumentListener(dl); + frame.pack(); + frame.setLocationRelativeTo(null); + frame.setVisible(true); + } + + public static void resetButtons() { + int length = ((JTextField) cmbAction.getEditor().getEditorComponent()). + getDocument().getLength(); + btnAction.setEnabled(length > 0); + } +} diff -Nru openjdk-17-17.0.17+10/test/jdk/javax/swing/JComboBox/bug4530953.java openjdk-17-17.0.18+8/test/jdk/javax/swing/JComboBox/bug4530953.java --- openjdk-17-17.0.17+10/test/jdk/javax/swing/JComboBox/bug4530953.java 1970-01-01 00:00:00.000000000 +0000 +++ openjdk-17-17.0.18+8/test/jdk/javax/swing/JComboBox/bug4530953.java 2026-01-15 15:23:06.000000000 +0000 @@ -0,0 +1,98 @@ +/* + * Copyright (c) 2001, 2025, Oracle and/or its affiliates. All rights reserved. + * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. + * + * This code is free software; you can redistribute it and/or modify it + * under the terms of the GNU General Public License version 2 only, as + * published by the Free Software Foundation. + * + * This code is distributed in the hope that it will be useful, but WITHOUT + * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or + * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License + * version 2 for more details (a copy is included in the LICENSE file that + * accompanied this code). + * + * You should have received a copy of the GNU General Public License version + * 2 along with this work; if not, write to the Free Software Foundation, + * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. + * + * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA + * or visit www.oracle.com if you need additional information or have any + * questions. + */ + +import java.awt.FlowLayout; +import java.awt.Robot; +import java.awt.event.KeyEvent; +import javax.swing.JComboBox; +import javax.swing.JFrame; +import javax.swing.SwingUtilities; + +/* + * @test + * @bug 4530953 + * @summary Tests that highlighted Item appears after automatically scrolling to the item + * @key headful + * @run main bug4530953 + */ + +public class bug4530953 { + static JFrame frame; + static JComboBox combo; + static String[] data = {"Apple", "Orange", "Cherry"}; + + public static void main(String[] args) throws Exception { + try { + Robot robot = new Robot(); + SwingUtilities.invokeAndWait(() -> createTestUI()); + robot.waitForIdle(); + robot.delay(250); + + // enter some text in combo box editor + robot.keyPress(KeyEvent.VK_A); + robot.keyRelease(KeyEvent.VK_A); + robot.keyPress(KeyEvent.VK_A); + robot.keyRelease(KeyEvent.VK_A); + robot.keyPress(KeyEvent.VK_ENTER); + robot.keyRelease(KeyEvent.VK_ENTER); + robot.waitForIdle(); + robot.delay(250); + + // select orange in combo box + robot.keyPress(KeyEvent.VK_DOWN); + robot.keyRelease(KeyEvent.VK_DOWN); + robot.keyPress(KeyEvent.VK_DOWN); + robot.keyRelease(KeyEvent.VK_DOWN); + robot.keyPress(KeyEvent.VK_DOWN); + robot.keyRelease(KeyEvent.VK_DOWN); + robot.keyPress(KeyEvent.VK_ENTER); + robot.keyRelease(KeyEvent.VK_ENTER); + robot.waitForIdle(); + robot.delay(250); + + String currSelection = (String) combo.getEditor().getItem(); + if (!currSelection.equals("Orange")) { + throw new RuntimeException("Unexpected Selection.\n" + + "Expected: Orange\nActual: " + currSelection); + } + } finally { + SwingUtilities.invokeAndWait(() -> { + if (frame != null) { + frame.dispose(); + } + }); + } + } + + public static void createTestUI() { + frame = new JFrame("bug4530953"); + combo = new JComboBox(data); + combo.setEditable(true); + combo.setSelectedIndex(1); + frame.setLayout(new FlowLayout()); + frame.add(combo); + frame.pack(); + frame.setLocationRelativeTo(null); + frame.setVisible(true); + } +} diff -Nru openjdk-17-17.0.17+10/test/jdk/javax/swing/JComponent/bug4235215.java openjdk-17-17.0.18+8/test/jdk/javax/swing/JComponent/bug4235215.java --- openjdk-17-17.0.17+10/test/jdk/javax/swing/JComponent/bug4235215.java 1970-01-01 00:00:00.000000000 +0000 +++ openjdk-17-17.0.18+8/test/jdk/javax/swing/JComponent/bug4235215.java 2026-01-15 15:23:06.000000000 +0000 @@ -0,0 +1,64 @@ +/* + * Copyright (c) 1999, 2025, Oracle and/or its affiliates. All rights reserved. + * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. + * + * This code is free software; you can redistribute 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 4235215 + * @summary Tests that Toolkit.getPrintJob() do not throw NPE + * @library /java/awt/regtesthelpers + * @build PassFailJFrame + * @run main/manual bug4235215 + */ + +import java.awt.Toolkit; +import javax.swing.JButton; +import javax.swing.JFrame; + +public class bug4235215 { + + private static final String INSTRUCTIONS = """ + Press "Print Dialog" button. + If you see a print dialog, test passes. + Click "Cancel" button to close it."""; + + public static void main(String[] args) throws Exception { + PassFailJFrame.builder() + .title("bug4235215 Instructions") + .instructions(INSTRUCTIONS) + .columns(35) + .testUI(bug4235215::createTestUI) + .build() + .awaitAndCheck(); + } + + private static JFrame createTestUI() { + JFrame frame = new JFrame("bug4235215"); + JButton button = new JButton("Print Dialog"); + button.addActionListener(ev -> { + Toolkit.getDefaultToolkit().getPrintJob(frame, "Test Printing", null); + }); + frame.add(button); + frame.pack(); + return frame; + } +} diff -Nru openjdk-17-17.0.17+10/test/jdk/javax/swing/JComponent/bug4247610.java openjdk-17-17.0.18+8/test/jdk/javax/swing/JComponent/bug4247610.java --- openjdk-17-17.0.17+10/test/jdk/javax/swing/JComponent/bug4247610.java 1970-01-01 00:00:00.000000000 +0000 +++ openjdk-17-17.0.18+8/test/jdk/javax/swing/JComponent/bug4247610.java 2026-01-15 15:23:06.000000000 +0000 @@ -0,0 +1,128 @@ +/* + * 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 + * 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 4247610 + * @summary Tests an unnecessary repaint issue + * @key headful + * @run main bug4247610 + */ + +import java.awt.Dimension; +import java.awt.FlowLayout; +import java.awt.Graphics; +import java.awt.Point; +import java.awt.Robot; +import java.awt.event.InputEvent; +import javax.swing.JButton; +import javax.swing.JDesktopPane; +import javax.swing.JFrame; +import javax.swing.JInternalFrame; +import javax.swing.JLabel; +import javax.swing.JPanel; +import javax.swing.SwingUtilities; + +import java.util.concurrent.atomic.AtomicInteger; +import java.util.Random; + +public class bug4247610 { + + private static JFrame frame; + private static JButton damager; + private static volatile Point loc; + private static volatile Dimension size; + private static volatile boolean traced; + private static volatile boolean failed; + + public static void main(String[] args) throws Exception { + Robot robot = new Robot(); + SwingUtilities.invokeAndWait(() -> { + frame = new JFrame("bug4247610"); + JDesktopPane pane = new JDesktopPane(); + + JInternalFrame jif = new JInternalFrame( + "Damager", true, true, true, true); + InternalFramePanel ifp = new InternalFramePanel(); + damager = new JButton("Damage!"); + ifp.add(damager); + jif.setContentPane(ifp); + jif.setBounds(0, 0, 300, 300); + jif.setVisible(true); + pane.add(jif); + + jif = new JInternalFrame("Damagee", true, true, true, true); + JPanel panel = new JPanel(new FlowLayout(FlowLayout.LEFT)); + final JLabel damagee = new JLabel(""); + panel.add(damagee); + jif.setContentPane(panel); + jif.setBounds(60, 220, 300, 100); + jif.setVisible(true); + pane.add(jif); + + final Random random = new Random(); + + damager.addActionListener((e) -> { + System.out.println("trace paints enabled"); + traced = true; + damagee.setText(Integer.toString(random.nextInt())); + }); + frame.setContentPane(pane); + frame.setSize(500, 500); + frame.setLocationRelativeTo(null); + frame.setVisible(true); + }); + robot.waitForIdle(); + robot.delay(1000); + SwingUtilities.invokeAndWait(() -> { + loc = damager.getLocationOnScreen(); + size = damager.getSize(); + }); + robot.mouseMove(loc.x + size.width / 2, loc.y + size.height / 2); + robot.waitForIdle(); + robot.delay(200); + robot.mousePress(InputEvent.BUTTON1_DOWN_MASK); + robot.mouseRelease(InputEvent.BUTTON1_DOWN_MASK); + if (failed) { + throw new RuntimeException("Failed: unnecessary repaint occured"); + } + } + + + static class InternalFramePanel extends JPanel { + final AtomicInteger repaintCounter = new AtomicInteger(0); + InternalFramePanel() { + super(new FlowLayout()); + setOpaque(true); + } + + public synchronized void paintComponent(Graphics g) { + super.paintComponent(g); + repaintCounter.incrementAndGet(); + System.out.println("repaintCounter " + repaintCounter.intValue()); + if (traced) { + failed = true; + } + } + } +} diff -Nru openjdk-17-17.0.17+10/test/jdk/javax/swing/JComponent/bug4254995.java openjdk-17-17.0.18+8/test/jdk/javax/swing/JComponent/bug4254995.java --- openjdk-17-17.0.17+10/test/jdk/javax/swing/JComponent/bug4254995.java 1970-01-01 00:00:00.000000000 +0000 +++ openjdk-17-17.0.18+8/test/jdk/javax/swing/JComponent/bug4254995.java 2026-01-15 15:23:06.000000000 +0000 @@ -0,0 +1,60 @@ +/* + * Copyright (c) 1999, 2025, Oracle and/or its affiliates. All rights reserved. + * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. + * + * This code is free software; you can redistribute 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 4254995 + * @summary Tests that html in renderer works correctly + * @library /java/awt/regtesthelpers + * @build PassFailJFrame + * @run main/manual bug4254995 + */ + +import javax.swing.JFrame; +import javax.swing.JList; +import javax.swing.JScrollPane; + +public class bug4254995 { + + private static final String INSTRUCTIONS = """ + If you see a list containing digits from one to seven, test passes. + Otherwise it fails."""; + + public static void main(String[] args) throws Exception { + PassFailJFrame.builder() + .title("bug4254995 Instructions") + .instructions(INSTRUCTIONS) + .columns(35) + .testUI(bug4254995::createTestUI) + .build() + .awaitAndCheck(); + } + + private static JFrame createTestUI() { + JFrame frame = new JFrame("bug4254995"); + String[] data = { "1", "2", "3", "4", "5", "6", "7" }; + frame.add(new JScrollPane(new JList(data))); + frame.pack(); + return frame; + } +} diff -Nru openjdk-17-17.0.17+10/test/jdk/javax/swing/JEditorPane/ScrollToReferenceTest/ScrollToReferenceTest.java openjdk-17-17.0.18+8/test/jdk/javax/swing/JEditorPane/ScrollToReferenceTest/ScrollToReferenceTest.java --- openjdk-17-17.0.17+10/test/jdk/javax/swing/JEditorPane/ScrollToReferenceTest/ScrollToReferenceTest.java 1970-01-01 00:00:00.000000000 +0000 +++ openjdk-17-17.0.18+8/test/jdk/javax/swing/JEditorPane/ScrollToReferenceTest/ScrollToReferenceTest.java 2026-01-15 15:23:06.000000000 +0000 @@ -0,0 +1,91 @@ +/* + * Copyright (c) 1999, 2025, Oracle and/or its affiliates. All rights reserved. + * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. + * + * This code is free software; you can redistribute 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 4194428 + * @summary Checks that scrolling an href to visible scrolls it to the top of the page. + * @library /java/awt/regtesthelpers + * @build PassFailJFrame + * @run main/manual ScrollToReferenceTest + */ + +import java.awt.Container; +import java.awt.Dimension; +import java.io.IOException; +import java.net.URL; +import javax.swing.JEditorPane; +import javax.swing.JFrame; +import javax.swing.JScrollPane; +import javax.swing.event.HyperlinkEvent; +import javax.swing.event.HyperlinkListener; + +public class ScrollToReferenceTest { + + static final String INSTRUCTIONS = """ + Wait for the html document to finish loading, click on the anchor + with text 'CLICK ME'. If 'should be at top of editor pane' is + scrolled to the top of the visible region of the text, click PASS, + otherwise click FAIL. + """; + + public static void main(String[] args) throws Exception { + PassFailJFrame.builder() + .instructions(INSTRUCTIONS) + .columns(40) + .testUI(ScrollToReferenceTest::createUI) + .build() + .awaitAndCheck(); + } + + static JFrame createUI() { + JFrame frame = new JFrame("ScrollToReferenceTest"); + JEditorPane pane = new JEditorPane(); + + try { + pane.setPage(ScrollToReferenceTest.class.getResource("test.html")); + } catch (IOException ioe) { + PassFailJFrame.forceFail("Couldn't find html file"); + } + + + pane.addHyperlinkListener(new HyperlinkListener() { + public void hyperlinkUpdate(HyperlinkEvent e) { + if (e.getEventType() == HyperlinkEvent.EventType.ACTIVATED && + e.getURL() != null) { + try { + pane.setPage(e.getURL()); + } catch (IOException ioe) { + pane.setText("error finding url, click fail!"); + } + } + } + }); + pane.setEditable(false); + JScrollPane sp = new JScrollPane(pane); + sp.setPreferredSize(new Dimension(400, 400)); + frame.add(sp); + frame.setSize(400, 400); + return frame; + } +} diff -Nru openjdk-17-17.0.17+10/test/jdk/javax/swing/JEditorPane/ScrollToReferenceTest/test.html openjdk-17-17.0.18+8/test/jdk/javax/swing/JEditorPane/ScrollToReferenceTest/test.html --- openjdk-17-17.0.17+10/test/jdk/javax/swing/JEditorPane/ScrollToReferenceTest/test.html 1970-01-01 00:00:00.000000000 +0000 +++ openjdk-17-17.0.18+8/test/jdk/javax/swing/JEditorPane/ScrollToReferenceTest/test.html 2026-01-15 15:23:06.000000000 +0000 @@ -0,0 +1,93 @@ + + +

Click ME! +

a +

a +

a +

a +

a +

a +

a +

a +

a +

a +

a +

a +

a +

a +

a +

a +

a +

a +

a +

a +

a +

a +

a +

a +

a +

a +

a +

a +

a +

a +

a +

a +

a +

a +

a +

a +

a +

a +

a +

a +

a +

a +

a +

a +

a +

should be at top of editor pane +

a +

a +

a +

a +

a +

a +

a +

a +

a +

a +

a +

a +

a +

a +

a +

a +

a +

a +

a +

a +

a +

a +

a +

a +

a +

a +

a +

a +

a +

a +

a +

a +

a +

a +

a +

a +

a +

a +

a +

a +

TEST! +

a + + diff -Nru openjdk-17-17.0.17+10/test/jdk/javax/swing/JFileChooser/6798062/bug6798062.html openjdk-17-17.0.18+8/test/jdk/javax/swing/JFileChooser/6798062/bug6798062.html --- openjdk-17-17.0.17+10/test/jdk/javax/swing/JFileChooser/6798062/bug6798062.html 2025-10-13 07:48:04.000000000 +0000 +++ openjdk-17-17.0.18+8/test/jdk/javax/swing/JFileChooser/6798062/bug6798062.html 1970-01-01 00:00:00.000000000 +0000 @@ -1,36 +0,0 @@ - - - - - -The test is suitable only for Windows - -1. Create a link -2. Copy path to the link into TextField -3. Run the Windows Task Manager. Select the Processes tab and find the java process -4. Press the Start button in the test window -5. Wait several minutes and observe in the Windows Task Manager -that Memory Usage of java process is not increasing - - diff -Nru openjdk-17-17.0.17+10/test/jdk/javax/swing/JFileChooser/6798062/bug6798062.java openjdk-17-17.0.18+8/test/jdk/javax/swing/JFileChooser/6798062/bug6798062.java --- openjdk-17-17.0.17+10/test/jdk/javax/swing/JFileChooser/6798062/bug6798062.java 2025-10-13 07:48:04.000000000 +0000 +++ openjdk-17-17.0.18+8/test/jdk/javax/swing/JFileChooser/6798062/bug6798062.java 1970-01-01 00:00:00.000000000 +0000 @@ -1,202 +0,0 @@ -/* - * Copyright (c) 2009, 2015, Oracle and/or its affiliates. All rights reserved. - * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. - * - * This code is free software; you can redistribute it and/or modify it - * under the terms of the GNU General Public License version 2 only, as - * published by the Free Software Foundation. - * - * This code is distributed in the hope that it will be useful, but WITHOUT - * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or - * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License - * version 2 for more details (a copy is included in the LICENSE file that - * accompanied this code). - * - * You should have received a copy of the GNU General Public License version - * 2 along with this work; if not, write to the Free Software Foundation, - * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. - * - * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA - * or visit www.oracle.com if you need additional information or have any - * questions. - */ - -/* @test %W% %E% - @bug 6798062 - @summary Memory Leak on using getFiles of FileSystemView - @author Pavel Porvatov - @modules java.desktop/sun.awt - java.desktop/sun.awt.shell - @run applet/manual=done bug6798062.html -*/ - -import sun.awt.OSInfo; -import sun.awt.shell.ShellFolder; - -import javax.swing.*; -import java.awt.event.ActionEvent; -import java.awt.event.ActionListener; -import java.awt.*; -import java.io.File; -import java.io.FileNotFoundException; - -public class bug6798062 extends JApplet { - - private final JSlider slider = new JSlider(0, 100); - - private final JTextField tfLink = new JTextField(); - - private final JButton btnStart = new JButton("Start"); - - private final JButton btnStop = new JButton("Stop"); - - private final JButton btnGC = new JButton("Run System.gc()"); - - private ShellFolder folder; - - private Thread thread; - - public static void main(String[] args) { - JFrame frame = new JFrame("bug6798062"); - - frame.setSize(400, 300); - frame.setLocationRelativeTo(null); - frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE); - frame.add(new bug6798062().initialize()); - - frame.setVisible(true); - } - - public void init() { - add(initialize()); - } - - private JComponent initialize() { - if (OSInfo.getOSType() != OSInfo.OSType.WINDOWS) { - return new JLabel("The test is suitable only for Windows"); - } - - String tempDir = System.getProperty("java.io.tmpdir"); - - if (tempDir.length() == 0) { // 'java.io.tmpdir' isn't guaranteed to be defined - tempDir = System.getProperty("user.home"); - } - - System.out.println("Temp directory: " + tempDir); - - try { - folder = ShellFolder.getShellFolder(new File(tempDir)); - } catch (FileNotFoundException e) { - fail("Directory " + tempDir + " not found"); - } - - slider.setMajorTickSpacing(10); - slider.setPaintTicks(true); - slider.setPaintLabels(true); - slider.setSnapToTicks(true); - slider.setValue(10); - - btnStart.addActionListener(new ActionListener() { - public void actionPerformed(ActionEvent e) { - setEnabledState(false); - - thread = new MyThread(slider.getValue(), tfLink.getText()); - thread.start(); - } - }); - - btnStop.setEnabled(false); - - btnStop.addActionListener(new ActionListener() { - public void actionPerformed(ActionEvent e) { - thread.interrupt(); - thread = null; - - setEnabledState(true); - } - }); - - btnGC.addActionListener(new ActionListener() { - public void actionPerformed(ActionEvent e) { - System.gc(); - } - }); - - setEnabledState(true); - - JPanel pnButtons = new JPanel(); - - pnButtons.setLayout(new BoxLayout(pnButtons, BoxLayout.X_AXIS)); - - pnButtons.add(btnStart); - pnButtons.add(btnStop); - pnButtons.add(btnGC); - - tfLink.setMaximumSize(new Dimension(300, 20)); - - JPanel pnContent = new JPanel(); - - pnContent.setLayout(new BoxLayout(pnContent, BoxLayout.Y_AXIS)); - pnContent.add(new JLabel("Delay between listFiles() invocation (ms):")); - pnContent.add(slider); - pnContent.add(new JLabel("Provide link here:")); - pnContent.add(tfLink); - pnContent.add(pnButtons); - - return pnContent; - } - - private void setEnabledState(boolean enabled) { - slider.setEnabled(enabled); - btnStart.setEnabled(enabled); - btnStop.setEnabled(!enabled); - } - - private static void fail(String msg) { - throw new RuntimeException(msg); - } - - private class MyThread extends Thread { - private final int delay; - - private final ShellFolder link; - - private MyThread(int delay, String link) { - this.delay = delay; - - ShellFolder linkFolder; - - try { - linkFolder = ShellFolder.getShellFolder(new File(link)); - } catch (FileNotFoundException e) { - e.printStackTrace(); - - linkFolder = null; - } - - this.link = linkFolder; - } - - public void run() { - while (!isInterrupted()) { - folder.listFiles(); - if (link != null) { - try { - link.getLinkLocation(); - } catch (FileNotFoundException e) { - e.printStackTrace(); - } - } - - if (delay > 0) { - try { - Thread.sleep(delay); - } catch (InterruptedException e1) { - // The thread was interrupted - return; - } - } - } - } - } -} diff -Nru openjdk-17-17.0.17+10/test/jdk/javax/swing/JFileChooser/FileFilterDescription/FileFilterDescription.java openjdk-17-17.0.18+8/test/jdk/javax/swing/JFileChooser/FileFilterDescription/FileFilterDescription.java --- openjdk-17-17.0.17+10/test/jdk/javax/swing/JFileChooser/FileFilterDescription/FileFilterDescription.java 2025-10-13 07:48:04.000000000 +0000 +++ openjdk-17-17.0.18+8/test/jdk/javax/swing/JFileChooser/FileFilterDescription/FileFilterDescription.java 1970-01-01 00:00:00.000000000 +0000 @@ -1,98 +0,0 @@ -/* - * Copyright (c) 2014, 2024, Oracle and/or its affiliates. All rights reserved. - * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. - * - * This code is free software; you can redistribute it and/or modify it - * under the terms of the GNU General Public License version 2 only, as - * published by the Free Software Foundation. - * - * This code is distributed in the hope that it will be useful, but WITHOUT - * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or - * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License - * version 2 for more details (a copy is included in the LICENSE file that - * accompanied this code). - * - * You should have received a copy of the GNU General Public License version - * 2 along with this work; if not, write to the Free Software Foundation, - * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. - * - * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA - * or visit www.oracle.com if you need additional information or have any - * questions. - */ - -import java.io.File; -import java.awt.BorderLayout; -import javax.swing.JFileChooser; -import javax.swing.JFrame; -import javax.swing.SwingUtilities; -import javax.swing.UIManager; -import javax.swing.UnsupportedLookAndFeelException; -import javax.swing.filechooser.FileFilter; - -/* - * @test - * @bug 8029536 - * @library /java/awt/regtesthelpers - * @build PassFailJFrame - * @run main/manual FileFilterDescription - */ -public final class FileFilterDescription { - - private static final String INSTRUCTIONS = """ - 1) Check that current filter in the opened JFileChooser is a "CustomFileFilter". - 2) Close the JFileChooser. - 3) Test will repeat steps 1 - 2 for all supported look and feels. - 4) If it's true for all look and feels then click Pass else click Fail. """; - - public static void main(String[] args) throws Exception { - PassFailJFrame passFailJFrame = PassFailJFrame.builder() - .title("JFileChooser Filefilter Instructions") - .instructions(INSTRUCTIONS) - .rows(10) - .columns(35) - .position(PassFailJFrame.Position.TOP_LEFT_CORNER) - .build(); - - final UIManager.LookAndFeelInfo[] infos = UIManager - .getInstalledLookAndFeels(); - for (final UIManager.LookAndFeelInfo info : infos) { - SwingUtilities.invokeAndWait(() -> { - setLookAndFeel(info); - JFrame frame = new JFrame("JFileChooser FileFilter test"); - final JFileChooser chooser = new JFileChooser(); - chooser.setAcceptAllFileFilterUsed(false); - chooser.setFileFilter(new CustomFileFilter()); - SwingUtilities.updateComponentTreeUI(chooser); - frame.add(chooser, BorderLayout.CENTER); - frame.pack(); - PassFailJFrame.addTestWindow(frame); - PassFailJFrame.positionTestWindow(frame, PassFailJFrame.Position.TOP_LEFT_CORNER); - chooser.showDialog(null, "Open"); - }); - } - passFailJFrame.awaitAndCheck(); - } - - private static void setLookAndFeel(final UIManager.LookAndFeelInfo info) { - try { - UIManager.setLookAndFeel(info.getClassName()); - } catch (ClassNotFoundException | InstantiationException | - UnsupportedLookAndFeelException | IllegalAccessException e) { - throw new RuntimeException(e); - } - } - - private static class CustomFileFilter extends FileFilter { - - @Override - public boolean accept(final File f) { - return false; - } - - @Override - public String getDescription() { - return "CustomFileFilter"; - } - } -} diff -Nru openjdk-17-17.0.17+10/test/jdk/javax/swing/JFileChooser/FileFilterDescription.java openjdk-17-17.0.18+8/test/jdk/javax/swing/JFileChooser/FileFilterDescription.java --- openjdk-17-17.0.17+10/test/jdk/javax/swing/JFileChooser/FileFilterDescription.java 1970-01-01 00:00:00.000000000 +0000 +++ openjdk-17-17.0.18+8/test/jdk/javax/swing/JFileChooser/FileFilterDescription.java 2026-01-15 15:23:06.000000000 +0000 @@ -0,0 +1,98 @@ +/* + * Copyright (c) 2014, 2024, Oracle and/or its affiliates. All rights reserved. + * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. + * + * This code is free software; you can redistribute it and/or modify it + * under the terms of the GNU General Public License version 2 only, as + * published by the Free Software Foundation. + * + * This code is distributed in the hope that it will be useful, but WITHOUT + * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or + * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License + * version 2 for more details (a copy is included in the LICENSE file that + * accompanied this code). + * + * You should have received a copy of the GNU General Public License version + * 2 along with this work; if not, write to the Free Software Foundation, + * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. + * + * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA + * or visit www.oracle.com if you need additional information or have any + * questions. + */ + +import java.io.File; +import java.awt.BorderLayout; +import javax.swing.JFileChooser; +import javax.swing.JFrame; +import javax.swing.SwingUtilities; +import javax.swing.UIManager; +import javax.swing.UnsupportedLookAndFeelException; +import javax.swing.filechooser.FileFilter; + +/* + * @test + * @bug 8029536 + * @library /java/awt/regtesthelpers + * @build PassFailJFrame + * @run main/manual FileFilterDescription + */ +public final class FileFilterDescription { + + private static final String INSTRUCTIONS = """ + 1) Check that current filter in the opened JFileChooser is a "CustomFileFilter". + 2) Close the JFileChooser. + 3) Test will repeat steps 1 - 2 for all supported look and feels. + 4) If it's true for all look and feels then click Pass else click Fail. """; + + public static void main(String[] args) throws Exception { + PassFailJFrame passFailJFrame = PassFailJFrame.builder() + .title("JFileChooser Filefilter Instructions") + .instructions(INSTRUCTIONS) + .rows(10) + .columns(35) + .position(PassFailJFrame.Position.TOP_LEFT_CORNER) + .build(); + + final UIManager.LookAndFeelInfo[] infos = UIManager + .getInstalledLookAndFeels(); + for (final UIManager.LookAndFeelInfo info : infos) { + SwingUtilities.invokeAndWait(() -> { + setLookAndFeel(info); + JFrame frame = new JFrame("JFileChooser FileFilter test"); + final JFileChooser chooser = new JFileChooser(); + chooser.setAcceptAllFileFilterUsed(false); + chooser.setFileFilter(new CustomFileFilter()); + SwingUtilities.updateComponentTreeUI(chooser); + frame.add(chooser, BorderLayout.CENTER); + frame.pack(); + PassFailJFrame.addTestWindow(frame); + PassFailJFrame.positionTestWindow(frame, PassFailJFrame.Position.TOP_LEFT_CORNER); + chooser.showDialog(null, "Open"); + }); + } + passFailJFrame.awaitAndCheck(); + } + + private static void setLookAndFeel(final UIManager.LookAndFeelInfo info) { + try { + UIManager.setLookAndFeel(info.getClassName()); + } catch (ClassNotFoundException | InstantiationException | + UnsupportedLookAndFeelException | IllegalAccessException e) { + throw new RuntimeException(e); + } + } + + private static class CustomFileFilter extends FileFilter { + + @Override + public boolean accept(final File f) { + return false; + } + + @Override + public String getDescription() { + return "CustomFileFilter"; + } + } +} diff -Nru openjdk-17-17.0.17+10/test/jdk/javax/swing/JFileChooser/HTMLFileName.java openjdk-17-17.0.18+8/test/jdk/javax/swing/JFileChooser/HTMLFileName.java --- openjdk-17-17.0.17+10/test/jdk/javax/swing/JFileChooser/HTMLFileName.java 1970-01-01 00:00:00.000000000 +0000 +++ openjdk-17-17.0.18+8/test/jdk/javax/swing/JFileChooser/HTMLFileName.java 2026-01-15 15:23:06.000000000 +0000 @@ -0,0 +1,175 @@ +/* + * 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. + */ + +import java.io.File; +import java.util.List; +import javax.swing.Icon; +import javax.swing.JFileChooser; +import javax.swing.JFrame; +import javax.swing.SwingUtilities; +import javax.swing.UIManager; +import javax.swing.filechooser.FileSystemView; + +/* + * @test id=metal + * @bug 8139228 + * @summary JFileChooser should not render Directory names in HTML format + * @library /java/awt/regtesthelpers + * @build PassFailJFrame + * @run main/manual HTMLFileName metal + */ + +/* + * @test id=system + * @bug 8139228 8358532 + * @summary JFileChooser should not render Directory names in HTML format + * @library /java/awt/regtesthelpers + * @build PassFailJFrame + * @run main/manual HTMLFileName system + */ + +public class HTMLFileName { + private static final String INSTRUCTIONS = """ + +

    +
  1. JFileChooser shows a virtual directory. + The first file in the list has the following name: + <html><h1 color=#ff00ff><font + face="Serif">Swing Rocks! +
    +
    +
  2. In HTML disabled frame: +
      +
    1. Verify that the first file name displays + as plain text, + that is you see the HTML tags in the file name. +
    2. If the file name in the file pane and + in the navigation combo box above is displayed + as HTML, that is in large font and magenta color, + then press Fail. +
    + +
  3. In HTML enabled frame: +
      +
    1. Verify that the first file name displays as HTML, + that is Swing Rocks! in large font + and magenta color.
      + Note: On macOS in Aqua L&F, the file name with + HTML displays as an empty file name. It is not an error. +
    2. If the file name in the file pane and + in the navigation combo box above is displayed + as HTML, then press Pass.
      + If it is in plain text, then press Fail. +
    +
+ + """; + + public static void main(String[] args) throws Exception { + if (args.length < 1) { + throw new IllegalArgumentException("Look-and-Feel keyword is required"); + } + + final String lafClassName; + switch (args[0]) { + case "metal" -> lafClassName = UIManager.getCrossPlatformLookAndFeelClassName(); + case "system" -> lafClassName = UIManager.getSystemLookAndFeelClassName(); + default -> throw new IllegalArgumentException("Unsupported Look-and-Feel keyword: " + args[0]); + } + + SwingUtilities.invokeAndWait(() -> { + try { + UIManager.setLookAndFeel(lafClassName); + } catch (Exception e) { + throw new RuntimeException(e); + } + }); + + System.out.println("Test for LookAndFeel " + lafClassName); + PassFailJFrame.builder() + .instructions(INSTRUCTIONS) + .columns(45) + .rows(20) + .testUI(HTMLFileName::initialize) + .positionTestUIBottomRowCentered() + .build() + .awaitAndCheck(); + System.out.println("Test passed for LookAndFeel " + lafClassName); + } + + private static List initialize() { + return List.of(createFileChooser(true), createFileChooser(false)); + } + + private static JFrame createFileChooser(boolean htmlDisabled) { + JFileChooser jfc = new JFileChooser(new VirtualFileSystemView()); + jfc.putClientProperty("html.disable", htmlDisabled); + jfc.setControlButtonsAreShown(false); + + JFrame frame = new JFrame(htmlDisabled ? "HTML disabled" : "HTML enabled"); + frame.add(jfc); + frame.pack(); + return frame; + } + + private static class VirtualFileSystemView extends FileSystemView { + private final File[] files = { + new File("/", "

Swing Rocks!"), + new File("/", "virtualFile1.txt"), + new File("/", "virtualFile2.log") + }; + + @Override + public File createNewFolder(File containingDir) { + return null; + } + + @Override + public File[] getRoots() { + return files; + } + + @Override + public File getHomeDirectory() { + return new File("/"); + } + + @Override + public File getDefaultDirectory() { + return new File("/"); + } + + @Override + public File[] getFiles(File dir, boolean useFileHiding) { + // Simulate a virtual folder structure + return files; + } + + @Override + public Icon getSystemIcon(File f) { + return null; + } + } +} diff -Nru openjdk-17-17.0.17+10/test/jdk/javax/swing/JFileChooser/bug4357012.java openjdk-17-17.0.18+8/test/jdk/javax/swing/JFileChooser/bug4357012.java --- openjdk-17-17.0.17+10/test/jdk/javax/swing/JFileChooser/bug4357012.java 1970-01-01 00:00:00.000000000 +0000 +++ openjdk-17-17.0.18+8/test/jdk/javax/swing/JFileChooser/bug4357012.java 2026-01-15 15:23:06.000000000 +0000 @@ -0,0 +1,99 @@ +/* + * Copyright (c) 2002, 2025, Oracle and/or its affiliates. All rights reserved. + * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. + * + * This code is free software; you can redistribute it and/or modify it + * under the terms of the GNU General Public License version 2 only, as + * published by the Free Software Foundation. + * + * This code is distributed in the hope that it will be useful, but WITHOUT + * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or + * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License + * version 2 for more details (a copy is included in the LICENSE file that + * accompanied this code). + * + * You should have received a copy of the GNU General Public License version + * 2 along with this work; if not, write to the Free Software Foundation, + * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. + * + * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA + * or visit www.oracle.com if you need additional information or have any + * questions. + */ + +/* + * @test + * @bug 4357012 + * @requires (os.family == "windows") + * @summary JFileChooser.showSaveDialog inconsistent with Windows Save Dialog + * @library /java/awt/regtesthelpers + * @build PassFailJFrame + * @run main/manual bug4357012 + */ + +import java.io.File; +import java.io.IOException; +import javax.swing.JComponent; +import javax.swing.JFileChooser; +import javax.swing.UIManager; + +public class bug4357012 { + private static File workDir = null; + private static File dir = null; + private static File file = null; + private static final String INSTRUCTIONS = """ + + Test is for Windows LAF only +

In JFileChooser's files list : +

    +
  1. Select directory. Verify that the directory name doesn't + appear in "file name" field.
  2. +
  3. Select file. Verify that the file name appears in + "file name" field.
  4. +
  5. Select directory again. Verify that the previous file name + remains in file name field.
  6. +
+

+ + """; + + public static void main(String[] argv) throws Exception { + try { + UIManager.setLookAndFeel(UIManager.getSystemLookAndFeelClassName()); + createTestDir(); + PassFailJFrame.builder() + .instructions(INSTRUCTIONS) + .rows(10) + .columns(40) + .testUI(bug4357012::createTestUI) + .build() + .awaitAndCheck(); + } finally { + if (workDir != null) { + System.out.println("Deleting '" + file + "': " + file.delete()); + System.out.println("Deleting '" + dir + "': " + dir.delete()); + System.out.println("Deleting '" + workDir + "': " + workDir.delete()); + } + } + } + + private static void createTestDir() throws IOException { + String tempDir = "."; + String fs = System.getProperty("file.separator"); + + workDir = new File(tempDir + fs + "bug4357012"); + System.out.println("Creating '" + workDir + "': " + workDir.mkdir()); + + dir = new File(workDir + fs + "Directory"); + System.out.println("Creating '" + dir + "': " + dir.mkdir()); + + file = new File(workDir + fs + "File.txt"); + System.out.println("Creating '" + file + "': " + file.createNewFile()); + } + + private static JComponent createTestUI() { + JFileChooser fc = new JFileChooser(workDir); + fc.setDialogType(JFileChooser.SAVE_DIALOG); + return fc; + } +} diff -Nru openjdk-17-17.0.17+10/test/jdk/javax/swing/JFileChooser/bug4464774.java openjdk-17-17.0.18+8/test/jdk/javax/swing/JFileChooser/bug4464774.java --- openjdk-17-17.0.17+10/test/jdk/javax/swing/JFileChooser/bug4464774.java 1970-01-01 00:00:00.000000000 +0000 +++ openjdk-17-17.0.18+8/test/jdk/javax/swing/JFileChooser/bug4464774.java 2026-01-15 15:23:06.000000000 +0000 @@ -0,0 +1,62 @@ +/* + * Copyright (c) 2003, 2025, Oracle and/or its affiliates. All rights reserved. + * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. + * + * This code is free software; you can redistribute 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 4464774 + * @requires (os.family == "windows") + * @summary JFileChooser: selection of left-side folder buttons shown incorrectly + in Windows L&F + * @library /java/awt/regtesthelpers + * @build PassFailJFrame + * @run main/manual bug4464774 + */ + +import javax.swing.JFileChooser; +import javax.swing.UIManager; + +public class bug4464774 { + private static final String INSTRUCTIONS = """ + Click any button from the buttons to the left + ("Documents", "Desktop", "My Computer" etc.) in FileChooser dialog. + When the button is toggled, it should be lowered and + should NOT have focus painted inside it (black dotted frame). + + If the above is true, press PASS else FAIL. + """; + + public static void main(String[] argv) throws Exception { + UIManager.setLookAndFeel(UIManager.getSystemLookAndFeelClassName()); + PassFailJFrame.builder() + .instructions(INSTRUCTIONS) + .columns(65) + .rows(10) + .testUI(() -> { + JFileChooser jfc = new JFileChooser(); + jfc.setControlButtonsAreShown(false); + return jfc; + }) + .build() + .awaitAndCheck(); + } +} diff -Nru openjdk-17-17.0.17+10/test/jdk/javax/swing/JFileChooser/bug4522756.java openjdk-17-17.0.18+8/test/jdk/javax/swing/JFileChooser/bug4522756.java --- openjdk-17-17.0.17+10/test/jdk/javax/swing/JFileChooser/bug4522756.java 1970-01-01 00:00:00.000000000 +0000 +++ openjdk-17-17.0.18+8/test/jdk/javax/swing/JFileChooser/bug4522756.java 2026-01-15 15:23:06.000000000 +0000 @@ -0,0 +1,64 @@ +/* + * Copyright (c) 2002, 2025, Oracle and/or its affiliates. All rights reserved. + * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. + * + * This code is free software; you can redistribute it and/or modify it + * under the terms of the GNU General Public License version 2 only, as + * published by the Free Software Foundation. + * + * This code is distributed in the hope that it will be useful, but WITHOUT + * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or + * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License + * version 2 for more details (a copy is included in the LICENSE file that + * accompanied this code). + * + * You should have received a copy of the GNU General Public License version + * 2 along with this work; if not, write to the Free Software Foundation, + * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. + * + * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA + * or visit www.oracle.com if you need additional information or have any + * questions. + */ + +/* + * @test + * @bug 4522756 + * @requires (os.family == "windows") + * @summary Verifies that the Desktop icon is not missing when + JFileChooser is opened for the first time. + * @library /java/awt/regtesthelpers + * @build PassFailJFrame + * @run main/manual bug4522756 + */ + +import javax.swing.JFileChooser; +import javax.swing.UIManager; + +public class bug4522756 { + private static final String INSTRUCTIONS = """ + Verify the following: + + 1. If Desktop icon image is present on the Desktop button + on the left panel of JFileChooser. + 2. Press Desktop button. Check that you actually + go up to the desktop. + + If the above is true, press PASS else FAIL. + """; + + public static void main(String[] args) throws Exception { + UIManager.setLookAndFeel(UIManager.getSystemLookAndFeelClassName()); + PassFailJFrame.builder() + .instructions(INSTRUCTIONS) + .columns(50) + .rows(12) + .testUI(() -> { + JFileChooser jfc = new JFileChooser(); + jfc.setControlButtonsAreShown(false); + return jfc; + }) + .build() + .awaitAndCheck(); + } +} diff -Nru openjdk-17-17.0.17+10/test/jdk/javax/swing/JFileChooser/bug4759934.java openjdk-17-17.0.18+8/test/jdk/javax/swing/JFileChooser/bug4759934.java --- openjdk-17-17.0.17+10/test/jdk/javax/swing/JFileChooser/bug4759934.java 1970-01-01 00:00:00.000000000 +0000 +++ openjdk-17-17.0.18+8/test/jdk/javax/swing/JFileChooser/bug4759934.java 2026-01-15 15:23:06.000000000 +0000 @@ -0,0 +1,124 @@ +/* + * Copyright (c) 2003, 2025, Oracle and/or its affiliates. All rights reserved. + * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. + * + * This code is free software; you can redistribute it and/or modify it + * under the terms of the GNU General Public License version 2 only, as + * published by the Free Software Foundation. + * + * This code is distributed in the hope that it will be useful, but WITHOUT + * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or + * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License + * version 2 for more details (a copy is included in the LICENSE file that + * accompanied this code). + * + * You should have received a copy of the GNU General Public License version + * 2 along with this work; if not, write to the Free Software Foundation, + * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. + * + * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA + * or visit www.oracle.com if you need additional information or have any + * questions. + */ + +/* + * @test + * @key headful + * @bug 4759934 + * @summary windows activation problem + * @library /javax/swing/regtesthelpers + * @build Util + * @run main bug4759934 + */ + +import java.awt.Dialog; +import java.awt.Point; +import java.awt.Robot; +import java.awt.event.KeyEvent; +import java.awt.event.MouseEvent; +import javax.swing.JButton; +import javax.swing.JDialog; +import javax.swing.JFileChooser; +import javax.swing.JFrame; +import javax.swing.SwingUtilities; + +public class bug4759934 { + private static JFrame fr; + private static Dialog dlg; + private static JFileChooser jfc; + + private static JButton frameBtn; + private static JButton dialogBtn; + + public static void main(String[] args) throws Exception { + try { + Robot robot = new Robot(); + robot.setAutoWaitForIdle(true); + robot.setAutoDelay(50); + + SwingUtilities.invokeAndWait(bug4759934::createTestUI); + robot.waitForIdle(); + robot.delay(1000); + + Point frameBtnLoc = Util.getCenterPoint(frameBtn); + robot.mouseMove(frameBtnLoc.x, frameBtnLoc.y); + robot.mousePress(MouseEvent.BUTTON1_DOWN_MASK); + robot.mouseRelease(MouseEvent.BUTTON1_DOWN_MASK); + robot.delay(500); + + Point dlgBtnLoc = Util.getCenterPoint(dialogBtn); + robot.mouseMove(dlgBtnLoc.x , dlgBtnLoc.y); + robot.mousePress(MouseEvent.BUTTON1_DOWN_MASK); + robot.mouseRelease(MouseEvent.BUTTON1_DOWN_MASK); + robot.delay(500); + + robot.keyPress(KeyEvent.VK_ESCAPE); + robot.keyRelease(KeyEvent.VK_ESCAPE); + robot.delay(500); + + SwingUtilities.invokeAndWait(() -> { + if (frameBtn.hasFocus() && !dialogBtn.hasFocus()) { + throw new RuntimeException("Test failed! Focus was passed back" + + " to Frame instead of Dialog"); + } + }); + } finally { + SwingUtilities.invokeAndWait(() -> { + if (dlg != null) { + dlg.dispose(); + } + if (fr != null) { + fr.dispose(); + } + }); + } + } + + private static void createTestUI() { + fr = new JFrame("bug4759934 - JFrame"); + + frameBtn = new JButton("Show Dialog"); + frameBtn.addActionListener(e -> createDialog()); + fr.add(frameBtn); + + fr.setSize(300, 200); + fr.setLocationRelativeTo(null); + fr.setVisible(true); + } + + private static void createDialog() { + dlg = new JDialog(fr, "bug4759934 - JDialog"); + + dialogBtn = new JButton("Show FileChooser"); + dlg.add(dialogBtn); + + dialogBtn.addActionListener(e -> { + jfc = new JFileChooser(); + jfc.showOpenDialog(dlg); + }); + + dlg.setSize(300, 200); + dlg.setLocation(fr.getX() + fr.getWidth() + 10, fr.getY()); + dlg.setVisible(true); + } +} diff -Nru openjdk-17-17.0.17+10/test/jdk/javax/swing/JFileChooser/bug4926884.java openjdk-17-17.0.18+8/test/jdk/javax/swing/JFileChooser/bug4926884.java --- openjdk-17-17.0.17+10/test/jdk/javax/swing/JFileChooser/bug4926884.java 1970-01-01 00:00:00.000000000 +0000 +++ openjdk-17-17.0.18+8/test/jdk/javax/swing/JFileChooser/bug4926884.java 2026-01-15 15:23:06.000000000 +0000 @@ -0,0 +1,114 @@ +/* + * 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 + * 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 4926884 + * @requires (os.family == "windows") + * @summary Win L&F: JFileChooser problems with "My Documents" folder + * @library /java/awt/regtesthelpers + * @build PassFailJFrame + * @run main/manual bug4926884 + */ + +import java.io.File; +import java.io.FileOutputStream; +import java.io.IOException; +import java.io.OutputStream; +import javax.swing.JFileChooser; +import javax.swing.UIManager; + +public class bug4926884 { + private static final String INSTRUCTIONS = """ + Validate next statements step by step: + + 1. In the file list there are several dirs and files (like "ski", + "Snowboard" etc.) + 2. Select "Details" view mode. + 3. Make file list in focus (e.g. by pressing mouse button) + 4. Press key "w" several times with delay LESS than 1 second. + Selection should be changed across files started with letter "w" + (without case sensitive). + 5. Press key "w" several times with delay MORE than 1 second. + Selection should be changed across files started with letter "w" + (without case sensitive). + 6. Type "winnt" (with delay less than 1 second between letters) - + directory "winnt" should be selected. + 7. Change conditions: + - Move column "Name" to the second position + - Change sort mode by clicking column "Size" + 8. Repeat items 4-6 + + If above is true press PASS else FAIL + """; + + private static final String[] DIRS = {"www", "winnt", "ski"}; + private static final String[] FILES = {"Window", "weel", "mice", + "Wall", "Snowboard", "wood"}; + private static final File testDir = new File("."); + + public static void main(String[] argv) throws Exception { + UIManager.setLookAndFeel(UIManager.getSystemLookAndFeelClassName()); + try { + createTestDir(); + PassFailJFrame.builder() + .instructions(INSTRUCTIONS) + .columns(40) + .testUI(() -> new JFileChooser(testDir)) + .build() + .awaitAndCheck(); + } finally { + deleteTempDir(); + } + } + + private static void createTestDir() throws IOException { + testDir.mkdir(); + + for (String dir : DIRS) { + new File(testDir, dir).mkdir(); + } + + for (int i = 0; i < FILES.length; i++) { + + try (OutputStream outputStream = new FileOutputStream( + new File(testDir, FILES[i]))) { + for (int j = 0; j < i * 1024; j++) { + outputStream.write('#'); + } + } + } + } + + private static void deleteTempDir() { + File[] files = testDir.listFiles(); + + for (File file : files) { + if (file != null) { + file.delete(); + } + } + + testDir.delete(); + } +} diff -Nru openjdk-17-17.0.17+10/test/jdk/javax/swing/JFileChooser/bug4943900.java openjdk-17-17.0.18+8/test/jdk/javax/swing/JFileChooser/bug4943900.java --- openjdk-17-17.0.17+10/test/jdk/javax/swing/JFileChooser/bug4943900.java 1970-01-01 00:00:00.000000000 +0000 +++ openjdk-17-17.0.18+8/test/jdk/javax/swing/JFileChooser/bug4943900.java 2026-01-15 15:23:06.000000000 +0000 @@ -0,0 +1,118 @@ +/* + * Copyright (c) 2004, 2025, Oracle and/or its affiliates. All rights reserved. + * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. + * + * This code is free software; you can redistribute 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 4943900 + * @summary Tests that FileFilter combo box is shown in FileChooser + * @library /java/awt/regtesthelpers + * @build PassFailJFrame + * @run main/manual bug4943900 + */ + +import java.io.File; +import javax.swing.JFileChooser; +import javax.swing.JFrame; +import javax.swing.UIManager; +import javax.swing.filechooser.FileFilter; + +public class bug4943900 { + private static final String INSTRUCTIONS = """ + +
    +
  1. When the test runs, a JFileChooser will be displayed. +
  2. Ensure that there is a filter combo box with these two items: +
      +
    • Text Files (*.txt) + — [must be selected when the dialog opens] +
    • All Files +
    +
  3. Leave the Text files item selected and check that the + filter works: only *.txt files can appear in the file list. + You can navigate directories in the file chooser and find one + that contains some *.txt files to ensure they are shown in + the file list. On macOS when the text filter is applied verify + that the non-text files are greyed out. +
  4. Try switching the filters and ensure that the file list + is updated properly. +
  5. If the FileFilter works correctly, + press Pass else press Fail. +
+ + """; + + public static void main(String[] args) throws Exception { + UIManager.setLookAndFeel(UIManager.getSystemLookAndFeelClassName()); + + PassFailJFrame.builder() + .title("bug4943900 Test Instructions") + .instructions(INSTRUCTIONS) + .rows(14) + .columns(50) + .testUI(bug4943900::createAndShowUI) + .build() + .awaitAndCheck(); + } + + public static JFrame createAndShowUI() { + JFileChooser fc = new JFileChooser(); + fc.setControlButtonsAreShown(false); + TextFileFilter filter = new TextFileFilter(); + fc.setFileFilter(filter); + + JFrame frame = new JFrame("bug4943900 - JFileChooser"); + frame.add(fc); + frame.pack(); + return frame; + } + + private static final class TextFileFilter extends FileFilter { + @Override + public boolean accept(File f) { + if (f != null) { + if (f.isDirectory()) { + return true; + } + String extension = getExtension(f); + return extension != null && extension.equals("txt"); + } + return false; + } + + @Override + public String getDescription() { + return "Text Files (*.txt)"; + } + + private static String getExtension(File f) { + if (f != null) { + String filename = f.getName(); + int i = filename.lastIndexOf('.'); + if (i > 0 && i < filename.length() - 1) { + return filename.substring(i + 1).toLowerCase(); + } + } + return null; + } + } +} diff -Nru openjdk-17-17.0.17+10/test/jdk/javax/swing/JFileChooser/bug5045464.java openjdk-17-17.0.18+8/test/jdk/javax/swing/JFileChooser/bug5045464.java --- openjdk-17-17.0.17+10/test/jdk/javax/swing/JFileChooser/bug5045464.java 1970-01-01 00:00:00.000000000 +0000 +++ openjdk-17-17.0.18+8/test/jdk/javax/swing/JFileChooser/bug5045464.java 2026-01-15 15:23:06.000000000 +0000 @@ -0,0 +1,68 @@ +/* + * Copyright (c) 2004, 2025, Oracle and/or its affiliates. All rights reserved. + * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. + * + * This code is free software; you can redistribute 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 5045464 + * @requires (os.family == "linux") + * @summary Regression: GTK L&F, JFileChooser shows "null/" in folder list + * @library /java/awt/regtesthelpers + * @build PassFailJFrame + * @run main/manual bug5045464 + */ + +import javax.swing.JComponent; +import javax.swing.JFileChooser; +import javax.swing.SwingUtilities; +import javax.swing.UIManager; + +public class bug5045464 { + private static final String INSTRUCTIONS = """ + When the filechooser appears check the directory list (the left list). + If it starts with two items: "./" (current directory) + and "../" (parent directory) press PASS. + If something else is here (e.g. "null/" instead of "./") + press FAIL. + """; + + public static void main(String[] argv) throws Exception { + PassFailJFrame.builder() + .instructions(INSTRUCTIONS) + .columns(40) + .testUI(bug5045464::createTestUI) + .build() + .awaitAndCheck(); + } + + private static JComponent createTestUI() { + JFileChooser fc = new JFileChooser(); + fc.setControlButtonsAreShown(false); + try { + UIManager.setLookAndFeel("com.sun.java.swing.plaf.gtk.GTKLookAndFeel"); + } catch (Exception ex) { + throw new RuntimeException("Test Failed!", ex); + } + SwingUtilities.updateComponentTreeUI(fc); + return fc; + } +} diff -Nru openjdk-17-17.0.17+10/test/jdk/javax/swing/JFileChooser/bug6515169.java openjdk-17-17.0.18+8/test/jdk/javax/swing/JFileChooser/bug6515169.java --- openjdk-17-17.0.17+10/test/jdk/javax/swing/JFileChooser/bug6515169.java 1970-01-01 00:00:00.000000000 +0000 +++ openjdk-17-17.0.18+8/test/jdk/javax/swing/JFileChooser/bug6515169.java 2026-01-15 15:23:06.000000000 +0000 @@ -0,0 +1,106 @@ +/* + * 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 + * 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 6515169 + * @requires (os.family == "windows") + * @summary wrong grid header in JFileChooser + * @library /java/awt/regtesthelpers + * @build PassFailJFrame + * @run main/manual bug6515169 + */ + +import javax.swing.ButtonGroup; +import javax.swing.JCheckBoxMenuItem; +import javax.swing.JFileChooser; +import javax.swing.JFrame; +import javax.swing.JMenu; +import javax.swing.JMenuBar; +import javax.swing.SwingUtilities; +import javax.swing.UIManager; + +public class bug6515169 { + private static JFrame frame; + private static final String INSTRUCTIONS = """ + This test is to verify JFileChooser on Windows and Metal LAF. + Use the "Change LaF" menu to switch between the 2 LaF + and verify the following. + + a. Change view mode to "Details" + b. Check that 4 columns appear: Name, Size, Type and Date Modified + c. Change current directory by pressing any available subdirectory + or by pressing button "Up One Level". + d. Check that still four columns exist. + + Change LaF and repeat the steps a-d. + If all conditions are true press PASS, else FAIL. + """; + + public static void main(String[] argv) throws Exception { + PassFailJFrame.builder() + .instructions(INSTRUCTIONS) + .columns(40) + .testUI(bug6515169::createTestUI) + .build() + .awaitAndCheck(); + } + + private static JFrame createTestUI() { + frame = new JFrame("bug6515169"); + JMenuBar bar = new JMenuBar(); + JMenu lafMenu = new JMenu("Change LaF"); + ButtonGroup lafGroup = new ButtonGroup(); + JCheckBoxMenuItem lafItem1 = new JCheckBoxMenuItem("Window LaF"); + lafItem1.addActionListener(e -> + setLaF(UIManager.getSystemLookAndFeelClassName())); + lafGroup.add(lafItem1); + lafMenu.add(lafItem1); + + JCheckBoxMenuItem lafItem2 = new JCheckBoxMenuItem("Metal LaF"); + lafItem2.addActionListener(e -> + setLaF(UIManager.getCrossPlatformLookAndFeelClassName())); + lafGroup.add(lafItem2); + lafMenu.add(lafItem2); + + bar.add(lafMenu); + frame.setJMenuBar(bar); + + String dir = "."; + JFileChooser fc = new JFileChooser(dir); + fc.setControlButtonsAreShown(false); + frame.add(fc); + frame.pack(); + + return frame; + } + + private static void setLaF(String laf) { + try { + UIManager.setLookAndFeel(laf); + SwingUtilities.updateComponentTreeUI(frame); + } catch (Exception e) { + throw new RuntimeException("Test Failed!", e); + } + } +} diff -Nru openjdk-17-17.0.17+10/test/jdk/javax/swing/JFileChooser/bug6798062.java openjdk-17-17.0.18+8/test/jdk/javax/swing/JFileChooser/bug6798062.java --- openjdk-17-17.0.17+10/test/jdk/javax/swing/JFileChooser/bug6798062.java 1970-01-01 00:00:00.000000000 +0000 +++ openjdk-17-17.0.18+8/test/jdk/javax/swing/JFileChooser/bug6798062.java 2026-01-15 15:23:06.000000000 +0000 @@ -0,0 +1,230 @@ +/* + * Copyright (c) 2009, 2024, Oracle and/or its affiliates. All rights reserved. + * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. + * + * This code is free software; you can redistribute it and/or modify it + * 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 6798062 + * @requires (os.family == "windows") + * @summary Memory Leak on using getFiles of FileSystemView + * @library /java/awt/regtesthelpers + * @build PassFailJFrame + * @modules java.desktop/sun.awt + * java.desktop/sun.awt.shell + * @run main/manual bug6798062 + */ + +import sun.awt.OSInfo; +import sun.awt.shell.ShellFolder; + +import java.awt.Dimension; +import java.awt.event.ActionEvent; +import java.awt.event.ActionListener; +import java.io.File; +import java.io.FileNotFoundException; +import javax.swing.BoxLayout; +import javax.swing.JButton; +import javax.swing.JComponent; +import javax.swing.JFrame; +import javax.swing.JLabel; +import javax.swing.JPanel; +import javax.swing.JSlider; +import javax.swing.JTextField; + +public class bug6798062 { + + private static final String INSTRUCTIONS = """ + The test is suitable only for Windows. + + 1. Create a shortcut (.lnk) file + 2. Copy path to the shortcut (.lnk file) into TextField + 3. Run the Windows Task Manager. Select the Processes tab and find the java process + 4. Press the Start button in the test window + 5. Wait several minutes and observe in the Windows Task Manager + that Memory Usage of java process is not increasing + If memory usage is increasing, click Fail else click Pass."""; + + private static JSlider slider; + private static JTextField tfLink; + private static JButton btnStart; + private static JButton btnStop; + private static JButton btnGC; + + private ShellFolder folder; + private Thread thread; + + public static void main(String[] args) throws Exception { + PassFailJFrame.builder() + .title("JFileChooser Instructions") + .instructions(INSTRUCTIONS) + .testTimeOut(10) + .rows(10) + .columns(35) + .testUI(bug6798062::createUI) + .build() + .awaitAndCheck(); + } + + private static JFrame createUI() { + slider = new JSlider(0, 100); + tfLink = new JTextField(); + btnStart = new JButton("Start"); + btnStop = new JButton("Stop"); + btnGC = new JButton("Run System.gc()"); + JFrame frame = new JFrame("bug6798062"); + + frame.setSize(400, 300); + frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE); + frame.add(new bug6798062().initialize()); + + return frame; + } + + private JComponent initialize() { + if (OSInfo.getOSType() != OSInfo.OSType.WINDOWS) { + return new JLabel("The test is suitable only for Windows"); + } + + String tempDir = System.getProperty("java.io.tmpdir"); + + if (tempDir.length() == 0) { // 'java.io.tmpdir' isn't guaranteed to be defined + tempDir = System.getProperty("user.home"); + } + + System.out.println("Temp directory: " + tempDir); + + try { + folder = ShellFolder.getShellFolder(new File(tempDir)); + } catch (FileNotFoundException e) { + fail("Directory not found"); + } + + slider.setMajorTickSpacing(10); + slider.setPaintTicks(true); + slider.setPaintLabels(true); + slider.setSnapToTicks(true); + slider.setValue(10); + + btnStart.addActionListener(new ActionListener() { + public void actionPerformed(ActionEvent e) { + setEnabledState(false); + + thread = new MyThread(slider.getValue(), tfLink.getText()); + thread.start(); + } + }); + + btnStop.setEnabled(false); + + btnStop.addActionListener(new ActionListener() { + public void actionPerformed(ActionEvent e) { + thread.interrupt(); + thread = null; + + setEnabledState(true); + } + }); + + btnGC.addActionListener(new ActionListener() { + public void actionPerformed(ActionEvent e) { + System.gc(); + } + }); + + setEnabledState(true); + + JPanel pnButtons = new JPanel(); + + pnButtons.setLayout(new BoxLayout(pnButtons, BoxLayout.X_AXIS)); + + pnButtons.add(btnStart); + pnButtons.add(btnStop); + pnButtons.add(btnGC); + + tfLink.setMaximumSize(new Dimension(300, 20)); + + JPanel pnContent = new JPanel(); + + pnContent.setLayout(new BoxLayout(pnContent, BoxLayout.Y_AXIS)); + pnContent.add(new JLabel("Delay between listFiles() invocation (ms):")); + pnContent.add(slider); + pnContent.add(new JLabel("Provide link here:")); + pnContent.add(tfLink); + pnContent.add(pnButtons); + + return pnContent; + } + + private void setEnabledState(boolean enabled) { + slider.setEnabled(enabled); + btnStart.setEnabled(enabled); + btnStop.setEnabled(!enabled); + } + + private static void fail(String msg) { + PassFailJFrame.forceFail(msg); + } + + private class MyThread extends Thread { + private final int delay; + + private final ShellFolder link; + + private MyThread(int delay, String link) { + this.delay = delay; + + ShellFolder linkFolder; + + try { + linkFolder = ShellFolder.getShellFolder(new File(link)); + } catch (FileNotFoundException e) { + fail("File not found"); + + linkFolder = null; + } + + this.link = linkFolder; + } + + public void run() { + while (!isInterrupted()) { + folder.listFiles(); + if (link != null) { + try { + link.getLinkLocation(); + } catch (FileNotFoundException e) { + fail("File not found"); + } + } + + if (delay > 0) { + try { + Thread.sleep(delay); + } catch (InterruptedException e1) { + // The thread was interrupted + return; + } + } + } + } + } +} diff -Nru openjdk-17-17.0.17+10/test/jdk/javax/swing/JFrame/bug4419914.java openjdk-17-17.0.18+8/test/jdk/javax/swing/JFrame/bug4419914.java --- openjdk-17-17.0.17+10/test/jdk/javax/swing/JFrame/bug4419914.java 2025-10-13 07:48:04.000000000 +0000 +++ openjdk-17-17.0.18+8/test/jdk/javax/swing/JFrame/bug4419914.java 2026-01-15 15:23:06.000000000 +0000 @@ -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 @@ -28,55 +28,141 @@ * @library /java/awt/regtesthelpers * @build PassFailJFrame * @run main/manual bug4419914 -*/ + */ import java.awt.BorderLayout; import java.awt.ComponentOrientation; +import java.awt.Frame; +import java.awt.Window; +import java.util.List; +import java.util.Locale; import javax.swing.JButton; +import javax.swing.JDialog; import javax.swing.JFrame; -import java.util.Locale; +import javax.swing.JLabel; +import javax.swing.JWindow; public class bug4419914 { + private static JFrame frame; private static final String INSTRUCTIONS = """ - 1. You will see a frame with five buttons. - 2. Confirm that each button is placed as follows: - NORTH - END CENTER START - SOUTH - 3. Press the "NORTH" button and confirm the button is focused. - 4. Press TAB repeatedly and confirm that the TAB focus moves from right to left. - (NORTH - START - CENTER - END - SOUTH - NORTH - START - CENTER - ...) + This test verifies tab movement on RTL component orientation + in JWindow, JFrame and JDialog. + + When test starts 3 test windows are displayed - JFrame, JWindow and JDialog. + Follow the instructions below and if any condition does not hold + press FAIL. + + 1. Confirm that each button in the child window is placed as follows: + + For JFrame: + NORTH + END CENTER START + SOUTH + + For JWindow: + END CENTER START + QUIT + + For JDialog: + END CENTER START + + 3. Press on the "START" button in case of JWindow & JDialog and "NORTH" + in case of JFrame, confirm that the respective button is focused. + + 4. Press TAB repeatedly and confirm that the TAB focus moves + from right to left. - If there's anything different from the above items, click Fail else click Pass."""; + For JFrame: + (NORTH - START - CENTER - END - SOUTH - NORTH - START - CENTER - ...) + + For JWindow: + (START - CENTER - END - QUIT - START - CENTER - END - QUIT - ...) + + For JDialog: + (START - CENTER - END - START - CENTER - END - ...) + + If all of the above conditions are true press PASS else FAIL. + """; public static void main(String[] args) throws Exception { PassFailJFrame.builder() - .title("Tab movement Instructions") .instructions(INSTRUCTIONS) - .rows((int) INSTRUCTIONS.lines().count() + 2) - .columns(48) - .testUI(bug4419914::createTestUI) + .columns(45) + .testTimeOut(10) + .testUI(bug4419914::createAndShowUI) + .positionTestUI(WindowLayouts::rightOneColumn) .build() .awaitAndCheck(); } - private static JFrame createTestUI() { - JFrame frame = new JFrame("bug4419914"); + private static List createAndShowUI() { + return List.of(createJFrame(), createJWindow(), createJDialog()); + } + + private static JFrame createJFrame() { + frame = new JFrame("bug4419914 JFrame"); frame.setFocusCycleRoot(true); + // Tab movement set to RTL frame.setComponentOrientation(ComponentOrientation.RIGHT_TO_LEFT); frame.setLocale(Locale.ENGLISH); frame.enableInputMethods(false); + // Component placement within content pane set to RTL frame.getContentPane().setComponentOrientation( - ComponentOrientation.RIGHT_TO_LEFT); + ComponentOrientation.RIGHT_TO_LEFT); frame.getContentPane().setLocale(Locale.ENGLISH); - frame.getContentPane().setLayout(new BorderLayout()); + frame.setLayout(new BorderLayout()); frame.add(new JButton("SOUTH"), BorderLayout.SOUTH); frame.add(new JButton("CENTER"), BorderLayout.CENTER); frame.add(new JButton("END"), BorderLayout.LINE_END); frame.add(new JButton("START"), BorderLayout.LINE_START); frame.add(new JButton("NORTH"), BorderLayout.NORTH); - frame.setSize(300, 150); + frame.setSize(300, 160); return frame; } + + private static JWindow createJWindow() { + JWindow window = new JWindow(frame); + window.setFocusableWindowState(true); + // Tab movement set to RTL + window.setComponentOrientation(ComponentOrientation.RIGHT_TO_LEFT); + window.setLocale(new Locale("en")); + window.enableInputMethods(false); + + // Component placement within content pane set to RTL + window.getContentPane().setComponentOrientation( + ComponentOrientation.RIGHT_TO_LEFT); + window.getContentPane().setLocale(new Locale("en")); + window.setLayout(new BorderLayout()); + window.add(new JLabel("bug4419914 JWindow"), BorderLayout.NORTH); + window.add(new JButton("START"), BorderLayout.LINE_START); + window.add(new JButton("CENTER"), BorderLayout.CENTER); + window.add(new JButton("END"), BorderLayout.LINE_END); + + JButton quitButton = new JButton("QUIT"); + quitButton.addActionListener(e1 -> window.dispose()); + window.add(quitButton, BorderLayout.SOUTH); + window.setSize(300, 153); + window.requestFocus(); + return window; + } + + private static JDialog createJDialog() { + JDialog dialog = new JDialog((Frame) null, "bug4419914 JDialog"); + // Tab movement set to RTL + dialog.setComponentOrientation(ComponentOrientation.RIGHT_TO_LEFT); + dialog.setLocale(new Locale("en")); + dialog.enableInputMethods(false); + + // Component placement within content pane set to RTL + dialog.getContentPane().setComponentOrientation( + ComponentOrientation.RIGHT_TO_LEFT); + dialog.getContentPane().setLocale(new Locale("en")); + dialog.setLayout(new BorderLayout()); + dialog.add(new JButton("CENTER"), BorderLayout.CENTER); + dialog.add(new JButton("END"), BorderLayout.LINE_END); + dialog.add(new JButton("START"), BorderLayout.LINE_START); + dialog.setSize(300, 160); + return dialog; + } } diff -Nru openjdk-17-17.0.17+10/test/jdk/javax/swing/JInternalFrame/6726866/bug6726866.java openjdk-17-17.0.18+8/test/jdk/javax/swing/JInternalFrame/6726866/bug6726866.java --- openjdk-17-17.0.17+10/test/jdk/javax/swing/JInternalFrame/6726866/bug6726866.java 2025-10-13 07:48:04.000000000 +0000 +++ openjdk-17-17.0.18+8/test/jdk/javax/swing/JInternalFrame/6726866/bug6726866.java 1970-01-01 00:00:00.000000000 +0000 @@ -1,87 +0,0 @@ -/* - * Copyright (c) 2009, 2024, Oracle and/or its affiliates. All rights reserved. - * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. - * - * This code is free software; you can redistribute it and/or modify it - * 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 6726866 8186617 - * @summary Repainting artifacts when resizing or dragging JInternalFrames in - non-opaque toplevel - * @library /java/awt/regtesthelpers - * @build PassFailJFrame - * @run main/manual bug6726866 -*/ - -import java.awt.Color; -import java.awt.Window; - -import javax.swing.JApplet; -import javax.swing.JDesktopPane; -import javax.swing.JFrame; -import javax.swing.JInternalFrame; -import javax.swing.JLabel; -import javax.swing.SwingUtilities; - -public class bug6726866 { - - private static final String INSTRUCTIONS = """ - Drag the internal frame inside the green undecorated window, - if you can drag it the test passes, otherwise fails. """; - - public static void main(String[] args) throws Exception { - PassFailJFrame.builder() - .title("JInternalFrame Instructions") - .instructions(INSTRUCTIONS) - .rows(5) - .columns(35) - .testUI(bug6726866::createUI) - .build() - .awaitAndCheck(); - } - - private static JFrame createUI() { - JFrame frame = new JFrame("bug6726866"); - frame.setUndecorated(true); - setWindowNonOpaque(frame); - - JDesktopPane desktop = new JDesktopPane(); - desktop.setBackground(Color.GREEN); - JInternalFrame iFrame = new JInternalFrame("Test", true, true, true, true); - iFrame.add(new JLabel("internal Frame")); - iFrame.setBounds(10, 10, 300, 200); - iFrame.setVisible(true); - desktop.add(iFrame); - frame.add(desktop); - - frame.setSize(400, 400); - return frame; - } - - public static void setWindowNonOpaque(Window window) { - Color bg = window.getBackground(); - if (bg == null) { - bg = new Color(0, 0, 0, 0); - } - window.setBackground( - new Color(bg.getRed(), bg.getGreen(), bg.getBlue(), 0)); - } -} diff -Nru openjdk-17-17.0.17+10/test/jdk/javax/swing/JInternalFrame/8160248/JInternalFrameDraggingTest.java openjdk-17-17.0.18+8/test/jdk/javax/swing/JInternalFrame/8160248/JInternalFrameDraggingTest.java --- openjdk-17-17.0.17+10/test/jdk/javax/swing/JInternalFrame/8160248/JInternalFrameDraggingTest.java 2025-10-13 07:48:04.000000000 +0000 +++ openjdk-17-17.0.18+8/test/jdk/javax/swing/JInternalFrame/8160248/JInternalFrameDraggingTest.java 2026-01-15 15:23:06.000000000 +0000 @@ -1,5 +1,5 @@ /* - * Copyright (c) 2016, 2018, 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 @@ -21,6 +21,7 @@ * questions. */ +import java.io.File; import java.awt.BorderLayout; import java.awt.Color; import java.awt.Point; @@ -28,6 +29,7 @@ import java.awt.Robot; import java.awt.event.InputEvent; import java.awt.image.BufferedImage; +import javax.imageio.ImageIO; import javax.swing.JDesktopPane; import javax.swing.JFrame; import javax.swing.JInternalFrame; @@ -51,6 +53,7 @@ private static JInternalFrame internalFrame; private static int FRAME_SIZE = 500; private static Color BACKGROUND_COLOR = Color.ORANGE; + private static final int tolerance = 10; public static void main(String[] args) throws Exception { try { @@ -69,14 +72,24 @@ BufferedImage img = robot.createScreenCapture(rect); int testRGB = BACKGROUND_COLOR.getRGB(); + Color testColor = new Color(testRGB); for (int i = 1; i < size; i++) { int rgbCW = img.getRGB(i, size / 2); int rgbCH = img.getRGB(size / 2, i); - if (rgbCW != testRGB || rgbCH != testRGB) { + Color rgbCWColor = new Color(rgbCW); + Color rgbCHColor = new Color(rgbCH); + + if (Math.abs(rgbCWColor.getRed() - testColor.getRed()) > tolerance + || Math.abs(rgbCWColor.getGreen() - testColor.getGreen()) > tolerance + || Math.abs(rgbCWColor.getBlue() - testColor.getBlue()) > tolerance + || Math.abs(rgbCHColor.getRed() - testColor.getRed()) > tolerance + || Math.abs(rgbCHColor.getGreen() - testColor.getGreen()) > tolerance + || Math.abs(rgbCHColor.getBlue() - testColor.getBlue()) > tolerance) { System.out.println("i " + i + " rgbCW " + Integer.toHexString(rgbCW) + " testRGB " + Integer.toHexString(testRGB) + " rgbCH " + Integer.toHexString(rgbCH)); + ImageIO.write(img, "png", new File("JInternalFrameDraggingTest.png")); throw new RuntimeException("Background color is wrong!"); } } diff -Nru openjdk-17-17.0.17+10/test/jdk/javax/swing/JInternalFrame/InternalFrameTitleButtonTest.java openjdk-17-17.0.18+8/test/jdk/javax/swing/JInternalFrame/InternalFrameTitleButtonTest.java --- openjdk-17-17.0.17+10/test/jdk/javax/swing/JInternalFrame/InternalFrameTitleButtonTest.java 1970-01-01 00:00:00.000000000 +0000 +++ openjdk-17-17.0.18+8/test/jdk/javax/swing/JInternalFrame/InternalFrameTitleButtonTest.java 2026-01-15 15:23:06.000000000 +0000 @@ -0,0 +1,127 @@ +/* + * Copyright (c) 2023, Oracle and/or its affiliates. All rights reserved. + * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. + * + * This code is free software; you can redistribute it and/or modify it + * under the terms of the GNU General Public License version 2 only, as + * published by the Free Software Foundation. + * + * This code is distributed in the hope that it will be useful, but WITHOUT + * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or + * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License + * version 2 for more details (a copy is included in the LICENSE file that + * accompanied this code). + * + * You should have received a copy of the GNU General Public License version + * 2 along with this work; if not, write to the Free Software Foundation, + * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. + * + * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA + * or visit www.oracle.com if you need additional information or have any + * questions. + */ + +/* + * @test + * @bug 8140527 + * @key headful + * @requires (os.family == "windows") + * @summary InternalFrame has incorrect title button width + * @run main InternalFrameTitleButtonTest + */ + +import java.awt.Component; +import java.awt.Robot; + +import javax.swing.Icon; +import javax.swing.JButton; +import javax.swing.JComponent; +import javax.swing.JDesktopPane; +import javax.swing.JFrame; +import javax.swing.JInternalFrame; +import javax.swing.SwingUtilities; +import javax.swing.UIManager; +import javax.swing.plaf.basic.BasicInternalFrameUI; + +public class InternalFrameTitleButtonTest { + + private static JFrame frame; + private static JInternalFrame iframe; + + public static void main(String[] args) throws Exception { + String osName = System.getProperty("os.name"); + if (!osName.toLowerCase().contains("win")) { + System.out.println("The test is applicable only for Windows."); + return; + } + + UIManager.setLookAndFeel( + "com.sun.java.swing.plaf.windows.WindowsClassicLookAndFeel"); + try { + test(2); + } finally { + SwingUtilities.invokeAndWait(() -> { + if (frame != null) { + frame.dispose(); + } + }); + } + + UIManager.setLookAndFeel( + "com.sun.java.swing.plaf.windows.WindowsLookAndFeel"); + try { + test(14); + } finally { + SwingUtilities.invokeAndWait(() -> { + if (frame != null) { + frame.dispose(); + } + }); + } + + System.out.println("ok"); + } + + private static void test(final int widthAdd) throws Exception { + SwingUtilities.invokeAndWait(() -> { + frame = new JFrame(); + + JDesktopPane pane = new JDesktopPane(); + frame.setContentPane(pane); + frame.setSize(400, 400); + frame.setVisible(true); + + iframe = new JInternalFrame("Mail Reader", true, + true, true, true); + iframe.setSize(200, 200); + pane.add(iframe); + iframe.setVisible(true); + }); + + Robot robot = new Robot(); + robot.waitForIdle(); + robot.delay(1000); + + SwingUtilities.invokeAndWait(() -> { + JComponent title = ((BasicInternalFrameUI) iframe.getUI()).getNorthPane(); + for (int i = 0; i < title.getComponentCount(); i++) { + Component c = title.getComponent(i); + if (c instanceof JButton button + && !testButtonSize(button, widthAdd)) { + throw new RuntimeException("Wrong title icon size"); + } + } + }); + } + + private static boolean testButtonSize(final JButton button, + final int widthAdd) { + int height = UIManager.getInt("InternalFrame.titleButtonHeight") - 4; + Icon icon = button.getIcon(); + return height == button.getHeight() + && (height + widthAdd) == button.getWidth() + && height == icon.getIconHeight() + && (height + widthAdd) == icon.getIconWidth(); + } +} + diff -Nru openjdk-17-17.0.17+10/test/jdk/javax/swing/JInternalFrame/bug4151444.java openjdk-17-17.0.18+8/test/jdk/javax/swing/JInternalFrame/bug4151444.java --- openjdk-17-17.0.17+10/test/jdk/javax/swing/JInternalFrame/bug4151444.java 1970-01-01 00:00:00.000000000 +0000 +++ openjdk-17-17.0.18+8/test/jdk/javax/swing/JInternalFrame/bug4151444.java 2026-01-15 15:23:06.000000000 +0000 @@ -0,0 +1,84 @@ +/* + * Copyright (c) 2003, 2025, Oracle and/or its affiliates. All rights reserved. + * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. + * + * This code is free software; you can redistribute 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 4151444 + * @summary The maximize button acts like the restore button + * @library /java/awt/regtesthelpers + * @build PassFailJFrame + * @run main/manual bug4151444 +*/ + +import javax.swing.JDesktopPane; +import javax.swing.JFrame; +import javax.swing.JInternalFrame; +import javax.swing.JLayeredPane; +import javax.swing.UIManager; + + +public class bug4151444 { + + private static JFrame frame; + private static JInternalFrame interFrame; + + private static final String INSTRUCTIONS = """ + - maximize the internal frame + - then minimize the internal frame + - then maximize the internal frame again + - Check whether internal frame is maximized + - Test will fail automatically even if "Pass" is pressed + if internal frame is not maximized."""; + + public static void main(String[] args) throws Exception { + + UIManager.setLookAndFeel(UIManager.getSystemLookAndFeelClassName()); + + PassFailJFrame pfj = PassFailJFrame.builder() + .title("bug4151444 Instructions") + .instructions(INSTRUCTIONS) + .columns(45) + .testUI(bug4151444::createTestUI) + .build(); + try { + pfj.awaitAndCheck(); + } finally { + if (!interFrame.isMaximum()) { + throw new RuntimeException ("Test failed. The maximize button acts like the restore button"); + } + } + } + + private static JFrame createTestUI() { + JFrame frame = new JFrame("bug4151444 frame"); + JDesktopPane desktop = new JDesktopPane(); + frame.setContentPane(desktop); + interFrame = new JInternalFrame( + "Internal frame", true, true, true, true); + desktop.add(interFrame, JLayeredPane.DEFAULT_LAYER); + interFrame.setBounds(0, 0, 200, 100); + interFrame.setVisible(true); + frame.setSize(300, 200); + return frame; + } +} diff -Nru openjdk-17-17.0.17+10/test/jdk/javax/swing/JInternalFrame/bug4190516.java openjdk-17-17.0.18+8/test/jdk/javax/swing/JInternalFrame/bug4190516.java --- openjdk-17-17.0.17+10/test/jdk/javax/swing/JInternalFrame/bug4190516.java 1970-01-01 00:00:00.000000000 +0000 +++ openjdk-17-17.0.18+8/test/jdk/javax/swing/JInternalFrame/bug4190516.java 2026-01-15 15:23:06.000000000 +0000 @@ -0,0 +1,75 @@ +/* + * 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 + * 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 4190516 + * @summary JInternalFrame should be maximized when Desktop resized + * @library /java/awt/regtesthelpers + * @build PassFailJFrame + * @run main/manual bug4190516 + */ + +import javax.swing.JDesktopPane; +import javax.swing.JFrame; +import javax.swing.JInternalFrame; +import javax.swing.SwingUtilities; + +public class bug4190516 { + + private static final String INSTRUCTIONS = """ + Try to resize frame "bug4190516 Frame". + If the internal frame remains maximized + inside this frame then test passes, else test fails."""; + + public static void main(String[] args) throws Exception { + PassFailJFrame.builder() + .title("bug4190516 Instructions") + .instructions(INSTRUCTIONS) + .columns(25) + .testUI(bug4190516::createTestUI) + .build() + .awaitAndCheck(); + } + + private static JFrame createTestUI() { + JFrame fr = new JFrame("bug4190516 Frame"); + JDesktopPane jdp = new JDesktopPane(); + fr.getContentPane().add(jdp); + + JInternalFrame jif = new JInternalFrame("Title", true, true, true, true); + jdp.add(jif); + jif.setSize(150, 150); + jif.setVisible(true); + + fr.setSize(300, 200); + try { + jif.setMaximum(true); + } catch (Exception e) { + throw new RuntimeException(e); + } + + SwingUtilities.updateComponentTreeUI(fr); + return fr; + } +} diff -Nru openjdk-17-17.0.17+10/test/jdk/javax/swing/JInternalFrame/bug4215380.java openjdk-17-17.0.18+8/test/jdk/javax/swing/JInternalFrame/bug4215380.java --- openjdk-17-17.0.17+10/test/jdk/javax/swing/JInternalFrame/bug4215380.java 1970-01-01 00:00:00.000000000 +0000 +++ openjdk-17-17.0.18+8/test/jdk/javax/swing/JInternalFrame/bug4215380.java 2026-01-15 15:23:06.000000000 +0000 @@ -0,0 +1,109 @@ +/* + * 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 + * 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 4215380 + * @summary Internal Frame should get focus + * @key headful + * @run main bug4215380 + */ + +import java.awt.BorderLayout; +import java.awt.Dimension; +import java.awt.event.InputEvent; +import java.awt.Point; +import java.awt.Robot; + +import javax.swing.JButton; +import javax.swing.JDesktopPane; +import javax.swing.JFrame; +import javax.swing.JInternalFrame; +import javax.swing.JLayeredPane; +import javax.swing.JPanel; +import javax.swing.SwingUtilities; + +public class bug4215380 { + + private static String button; + private static JButton b; + private static JFrame frame; + private static JInternalFrame jif; + private static volatile Point loc; + private static volatile Dimension size; + + public static void main(String[] args) throws Exception { + Robot robot = new Robot(); + try { + SwingUtilities.invokeAndWait(() -> { + frame = new JFrame("bug4215380"); + JDesktopPane desktop = new JDesktopPane(); + frame.add(desktop, BorderLayout.CENTER); + + jif = iFrame(1); + desktop.add(jif, JLayeredPane.DEFAULT_LAYER); + desktop.add(iFrame(2), JLayeredPane.DEFAULT_LAYER); + frame.setSize(200, 200); + frame.setLocationRelativeTo(null); + frame.setVisible(true); + }); + robot.waitForIdle(); + robot.delay(1000); + SwingUtilities.invokeAndWait(() -> { + loc = b.getLocationOnScreen(); + size = b.getSize(); + }); + robot.mouseMove(loc.x + size.width / 2, loc.y + size.height / 2); + robot.mousePress(InputEvent.BUTTON1_DOWN_MASK); + robot.mouseRelease(InputEvent.BUTTON1_DOWN_MASK); + robot.waitForIdle(); + robot.delay(500); + if (!(jif.isSelected()) && !button.equals("Frame 1")) { + throw new RuntimeException("Internal frame \"Frame 1\" should be selected..."); + } + } finally { + SwingUtilities.invokeAndWait(() -> { + if (frame != null) { + frame.dispose(); + } + }); + } + } + + private static JInternalFrame iFrame(int i) { + JInternalFrame frame = new JInternalFrame("Frame " + i); + JPanel panel = new JPanel(); + JButton bt = new JButton("Button " + i); + if (i == 1) { + b = bt; + } + bt.addActionListener(e -> button = ((JButton)e.getSource()).getText()); + + panel.add(bt); + + frame.getContentPane().add(panel); + frame.setBounds(10, i * 80 - 70, 120, 90); + frame.setVisible(true); + return frame; + } +} diff -Nru openjdk-17-17.0.17+10/test/jdk/javax/swing/JInternalFrame/bug4242045.java openjdk-17-17.0.18+8/test/jdk/javax/swing/JInternalFrame/bug4242045.java --- openjdk-17-17.0.17+10/test/jdk/javax/swing/JInternalFrame/bug4242045.java 1970-01-01 00:00:00.000000000 +0000 +++ openjdk-17-17.0.18+8/test/jdk/javax/swing/JInternalFrame/bug4242045.java 2026-01-15 15:23:06.000000000 +0000 @@ -0,0 +1,123 @@ +/* + * 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 + * 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 4242045 + * @requires (os.family == "windows") + * @summary JInternalFrame titlepane icons should be restored after attribute change + * @library /java/awt/regtesthelpers + * @build PassFailJFrame + * @run main/manual bug4242045 + */ + +import java.awt.BorderLayout; +import java.awt.event.ActionEvent; + +import javax.swing.JButton; +import javax.swing.JDesktopPane; +import javax.swing.JFrame; +import javax.swing.JInternalFrame; +import javax.swing.JPanel; +import javax.swing.SwingUtilities; +import javax.swing.UIManager; +import javax.swing.UnsupportedLookAndFeelException; + +public class bug4242045 { + + private static JFrame frame; + + private static final String INSTRUCTIONS = """ + Add and remove iconify/maximize/close buttons using the buttons + "Iconifiable", "Maximizable", "Closable" under different LookAndFeels. + If they appears and disappears correctly then test passes. If any + button does not appear or disappear as expected or appear with incorrect + placement then test fails."""; + + public static void main(String[] args) throws Exception { + PassFailJFrame.builder() + .title("bug4242045 Instructions") + .instructions(INSTRUCTIONS) + .columns(35) + .testUI(bug4242045::createTestUI) + .build() + .awaitAndCheck(); + } + + private static void setLF(ActionEvent e) { + try { + UIManager.setLookAndFeel(((JButton)e.getSource()).getActionCommand()); + SwingUtilities.updateComponentTreeUI(frame); + } catch (ClassNotFoundException | InstantiationException + | UnsupportedLookAndFeelException + | IllegalAccessException ex) { + throw new RuntimeException(ex); + } + } + + private static JFrame createTestUI() { + + frame = new JFrame("bug4242045"); + JDesktopPane jdp = new JDesktopPane(); + JInternalFrame jif = new JInternalFrame("Test", true); + frame.add(jdp); + + jdp.add(jif); + jif.setSize(150, 150); + jif.setVisible(true); + + JPanel p = new JPanel(); + + JButton metal = new JButton("Metal"); + metal.setActionCommand("javax.swing.plaf.metal.MetalLookAndFeel"); + metal.addActionListener((ActionEvent e) -> setLF(e)); + p.add(metal); + + JButton windows = new JButton("Windows"); + windows.setActionCommand("com.sun.java.swing.plaf.windows.WindowsLookAndFeel"); + windows.addActionListener((ActionEvent e) -> setLF(e)); + p.add(windows); + + JButton motif = new JButton("Motif"); + motif.setActionCommand("com.sun.java.swing.plaf.motif.MotifLookAndFeel"); + motif.addActionListener((ActionEvent e) -> setLF(e)); + p.add(motif); + + JButton clo = new JButton("Closable"); + clo.addActionListener(e -> jif.setClosable(!jif.isClosable())); + p.add(clo); + + JButton ico = new JButton("Iconifiable"); + ico.addActionListener(e -> jif.setIconifiable(!jif.isIconifiable())); + p.add(ico); + + JButton max = new JButton("Maximizable"); + max.addActionListener(e -> jif.setMaximizable(!jif.isMaximizable())); + p.add(max); + + frame.add(p, BorderLayout.SOUTH); + frame.setSize(650, 250); + return frame; + } + +} diff -Nru openjdk-17-17.0.17+10/test/jdk/javax/swing/JInternalFrame/bug4321312.java openjdk-17-17.0.18+8/test/jdk/javax/swing/JInternalFrame/bug4321312.java --- openjdk-17-17.0.17+10/test/jdk/javax/swing/JInternalFrame/bug4321312.java 1970-01-01 00:00:00.000000000 +0000 +++ openjdk-17-17.0.18+8/test/jdk/javax/swing/JInternalFrame/bug4321312.java 2026-01-15 15:23:06.000000000 +0000 @@ -0,0 +1,126 @@ +/* + * 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 + * 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 4321312 + * @summary Verifies no Exception thrown from BasicInternalFrameUI$BorderListener + * @key headful + * @run main bug4321312 + */ + +import java.awt.Dimension; +import java.awt.event.InputEvent; +import java.awt.event.MouseEvent; +import java.awt.Point; +import java.awt.Robot; + +import javax.swing.JDesktopPane; +import javax.swing.JFrame; +import javax.swing.JInternalFrame; +import javax.swing.SwingUtilities; +import javax.swing.UIManager; +import javax.swing.UnsupportedLookAndFeelException; + +public class bug4321312 { + + private static JFrame frame; + private static MyInternalFrame jif; + private static volatile Point loc; + private static volatile Dimension size; + + static boolean fails; + static Exception exc; + + private static synchronized boolean isFails() { + return fails; + } + + private static synchronized void setFails(Exception e) { + fails = true; + exc = e; + } + + public static void main(String[] args) throws Exception { + Robot robot = new Robot(); + try { + SwingUtilities.invokeAndWait(() -> { + try { + UIManager.setLookAndFeel( + "com.sun.java.swing.plaf.motif.MotifLookAndFeel"); + } catch (ClassNotFoundException | InstantiationException + | UnsupportedLookAndFeelException + | IllegalAccessException e) { + throw new RuntimeException(e); + } + + frame = new JFrame("bug4321312"); + JDesktopPane jdp = new JDesktopPane(); + frame.add(jdp); + + jif = new MyInternalFrame("Internal Frame", true); + jdp.add(jif); + jif.setSize(150, 150); + jif.setVisible(true); + + frame.setSize(200, 200); + frame.setLocationRelativeTo(null); + frame.setVisible(true); + }); + robot.waitForIdle(); + robot.delay(1000); + SwingUtilities.invokeAndWait(() -> { + loc = jif.getLocationOnScreen(); + size = jif.getSize(); + }); + robot.mouseMove(loc.x + size.width / 2, loc.y + size.height / 2); + robot.mousePress(InputEvent.BUTTON1_DOWN_MASK); + robot.mouseRelease(InputEvent.BUTTON1_DOWN_MASK); + robot.waitForIdle(); + robot.delay(200); + if (isFails()) { + throw new RuntimeException(exc); + } + } finally { + SwingUtilities.invokeAndWait(() -> { + if (frame != null) { + frame.dispose(); + } + }); + } + } + + static class MyInternalFrame extends JInternalFrame { + MyInternalFrame(String str, boolean b) { + super(str, b); + } + + protected void processMouseEvent(MouseEvent e) { + try { + super.processMouseEvent(e); + } catch (Exception exc) { + setFails(exc); + } + } + } +} diff -Nru openjdk-17-17.0.17+10/test/jdk/javax/swing/JInternalFrame/bug4322726.java openjdk-17-17.0.18+8/test/jdk/javax/swing/JInternalFrame/bug4322726.java --- openjdk-17-17.0.17+10/test/jdk/javax/swing/JInternalFrame/bug4322726.java 1970-01-01 00:00:00.000000000 +0000 +++ openjdk-17-17.0.18+8/test/jdk/javax/swing/JInternalFrame/bug4322726.java 2026-01-15 15:23:06.000000000 +0000 @@ -0,0 +1,109 @@ +/* + * 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 + * 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 4322726 + * @summary Tests that JInternalFrame throws ArrayIndexOutOfBoundsException when Control-F4 pressed + * @key headful + * @run main bug4322726 + */ + +import java.awt.event.KeyEvent; +import java.awt.Robot; + +import javax.swing.JDesktopPane; +import javax.swing.JFrame; +import javax.swing.JInternalFrame; +import javax.swing.KeyStroke; +import javax.swing.SwingUtilities; +import java.beans.PropertyVetoException; + +public class bug4322726 { + + private static JFrame frame; + private static JInternalFrame internalFrame; + private static volatile boolean failed; + + public static void main(String[] args) throws Exception { + Robot robot = new Robot(); + try { + SwingUtilities.invokeAndWait(() -> { + frame = new JFrame("bug4322726"); + frame.setSize(600, 400); + TestDesktopPane desktopPane = new TestDesktopPane(); + frame.setContentPane(desktopPane); + internalFrame = new JInternalFrame(); + internalFrame.setClosable(true); + internalFrame.setMaximizable(true); + internalFrame.setIconifiable(true); + internalFrame.setResizable(true); + internalFrame.setTitle("Internal Frame"); + internalFrame.setSize(300, 200); + internalFrame.setVisible(true); + desktopPane.add(internalFrame); + + frame.setSize(400, 400); + frame.setLocationRelativeTo(null); + frame.setVisible(true); + }); + robot.waitForIdle(); + robot.delay(1000); + SwingUtilities.invokeAndWait(() -> { + try { + internalFrame.setSelected(true); + } catch (PropertyVetoException e) { + throw new RuntimeException("PropertyVetoException thrown"); + } + }); + robot.waitForIdle(); + robot.delay(200); + robot.keyPress(KeyEvent.VK_CONTROL); + robot.keyPress(KeyEvent.VK_F4); + robot.keyRelease(KeyEvent.VK_F4); + robot.keyRelease(KeyEvent.VK_CONTROL); + robot.waitForIdle(); + robot.delay(200); + if (failed) { + throw new RuntimeException("Failed: index is out of bounds"); + } + } finally { + SwingUtilities.invokeAndWait(() -> { + if (frame != null) { + frame.dispose(); + } + }); + } + } + + static class TestDesktopPane extends JDesktopPane { + protected boolean processKeyBinding(KeyStroke ks, KeyEvent e, int condition, boolean pressed) { + try { + return super.processKeyBinding(ks, e, condition, pressed); + } catch (ArrayIndexOutOfBoundsException ex) { + failed = true; + } + return failed; + } + } +} diff -Nru openjdk-17-17.0.17+10/test/jdk/javax/swing/JInternalFrame/bug6726866.java openjdk-17-17.0.18+8/test/jdk/javax/swing/JInternalFrame/bug6726866.java --- openjdk-17-17.0.17+10/test/jdk/javax/swing/JInternalFrame/bug6726866.java 1970-01-01 00:00:00.000000000 +0000 +++ openjdk-17-17.0.18+8/test/jdk/javax/swing/JInternalFrame/bug6726866.java 2026-01-15 15:23:06.000000000 +0000 @@ -0,0 +1,87 @@ +/* + * Copyright (c) 2009, 2024, Oracle and/or its affiliates. All rights reserved. + * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. + * + * This code is free software; you can redistribute it and/or modify it + * 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 6726866 8186617 + * @summary Repainting artifacts when resizing or dragging JInternalFrames in + non-opaque toplevel + * @library /java/awt/regtesthelpers + * @build PassFailJFrame + * @run main/manual bug6726866 +*/ + +import java.awt.Color; +import java.awt.Window; + +import javax.swing.JApplet; +import javax.swing.JDesktopPane; +import javax.swing.JFrame; +import javax.swing.JInternalFrame; +import javax.swing.JLabel; +import javax.swing.SwingUtilities; + +public class bug6726866 { + + private static final String INSTRUCTIONS = """ + Drag the internal frame inside the green undecorated window, + if you can drag it the test passes, otherwise fails. """; + + public static void main(String[] args) throws Exception { + PassFailJFrame.builder() + .title("JInternalFrame Instructions") + .instructions(INSTRUCTIONS) + .rows(5) + .columns(35) + .testUI(bug6726866::createUI) + .build() + .awaitAndCheck(); + } + + private static JFrame createUI() { + JFrame frame = new JFrame("bug6726866"); + frame.setUndecorated(true); + setWindowNonOpaque(frame); + + JDesktopPane desktop = new JDesktopPane(); + desktop.setBackground(Color.GREEN); + JInternalFrame iFrame = new JInternalFrame("Test", true, true, true, true); + iFrame.add(new JLabel("internal Frame")); + iFrame.setBounds(10, 10, 300, 200); + iFrame.setVisible(true); + desktop.add(iFrame); + frame.add(desktop); + + frame.setSize(400, 400); + return frame; + } + + public static void setWindowNonOpaque(Window window) { + Color bg = window.getBackground(); + if (bg == null) { + bg = new Color(0, 0, 0, 0); + } + window.setBackground( + new Color(bg.getRed(), bg.getGreen(), bg.getBlue(), 0)); + } +} diff -Nru openjdk-17-17.0.17+10/test/jdk/javax/swing/JLabel/bug4106007.java openjdk-17-17.0.18+8/test/jdk/javax/swing/JLabel/bug4106007.java --- openjdk-17-17.0.17+10/test/jdk/javax/swing/JLabel/bug4106007.java 1970-01-01 00:00:00.000000000 +0000 +++ openjdk-17-17.0.18+8/test/jdk/javax/swing/JLabel/bug4106007.java 2026-01-15 15:23:06.000000000 +0000 @@ -0,0 +1,66 @@ +/* + * Copyright (c) 1999, 2025, Oracle and/or its affiliates. All rights reserved. + * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. + * + * This code is free software; you can redistribute 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 4106007 + * @summary Multi-line JLabel is now supported for HTML labels. + * @library /java/awt/regtesthelpers + * @build PassFailJFrame + * @run main/manual bug4106007 + * */ + +import java.awt.BorderLayout; +import javax.swing.JFrame; +import javax.swing.JLabel; + +public class bug4106007 { + + static final String INSTRUCTIONS = """ + The test window should have a label spanning multiple lines. + If it is press PASS, else press FAIL. + """; + + public static void main(String[] args) throws Exception { + PassFailJFrame.builder() + .instructions(INSTRUCTIONS) + .columns(40) + .testUI(bug4106007::createUI) + .build() + .awaitAndCheck(); + } + + static JFrame createUI() { + JFrame frame = new JFrame("Bug4106007"); + frame.setLayout(new BorderLayout()); + String str = ""; + String longLine = + "I hope multi-line JLabel is now supported and you can see several lines instead of one long line. "; + str += longLine; + str += longLine; + str += ""; + JLabel lab = new JLabel(str); + frame.add(lab, BorderLayout.NORTH); + frame.setSize(400, 400); + return frame; + } +} diff -Nru openjdk-17-17.0.17+10/test/jdk/javax/swing/JLabel/bug4945795.java openjdk-17-17.0.18+8/test/jdk/javax/swing/JLabel/bug4945795.java --- openjdk-17-17.0.17+10/test/jdk/javax/swing/JLabel/bug4945795.java 1970-01-01 00:00:00.000000000 +0000 +++ openjdk-17-17.0.18+8/test/jdk/javax/swing/JLabel/bug4945795.java 2026-01-15 15:23:06.000000000 +0000 @@ -0,0 +1,73 @@ +/* + * Copyright (c) 2004, 2025, Oracle and/or its affiliates. All rights reserved. + * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. + * + * This code is free software; you can redistribute 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 4945795 + * @summary With mnemonic hiding turned on, Java does not display all mnemonics with ALT key + * @requires (os.family == "windows") + * @library /java/awt/regtesthelpers + * @build PassFailJFrame + * @run main/manual bug4945795 + * */ + +import java.awt.BorderLayout; +import javax.swing.JFrame; +import javax.swing.JLabel; +import javax.swing.UIManager; + +public class bug4945795 { + + static final String INSTRUCTIONS = """ + This test is for the Swing Windows Look And Feel. + A test window will be displayed with the label 'Mnemonic Test' + Click the mouse in the test window to make sure it has keyboard focus. + Now press and hold the 'Alt' key. + An underline should be displayed below the initial 'M' character. + If it is press PASS, else press FAIL. + """; + + public static void main(String[] args) throws Exception { + PassFailJFrame.builder() + .instructions(INSTRUCTIONS) + .columns(40) + .testUI(bug4945795::createUI) + .build() + .awaitAndCheck(); + } + + static JFrame createUI() { + JFrame mainFrame = new JFrame("Bug4945795"); + try { + UIManager.setLookAndFeel(UIManager.getSystemLookAndFeelClassName()); + } catch (Exception ex) { + throw new RuntimeException("Can not set system look and feel"); + } + mainFrame.setLayout(new BorderLayout()); + mainFrame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE); + JLabel label = new JLabel("Mnemonic test"); + label.setDisplayedMnemonic('M'); + mainFrame.add(label, BorderLayout.NORTH); + mainFrame.setSize(400, 300); + return mainFrame; + } +} diff -Nru openjdk-17-17.0.17+10/test/jdk/javax/swing/JList/bug4193267.java openjdk-17-17.0.18+8/test/jdk/javax/swing/JList/bug4193267.java --- openjdk-17-17.0.17+10/test/jdk/javax/swing/JList/bug4193267.java 1970-01-01 00:00:00.000000000 +0000 +++ openjdk-17-17.0.18+8/test/jdk/javax/swing/JList/bug4193267.java 2026-01-15 15:23:06.000000000 +0000 @@ -0,0 +1,117 @@ +/* + * Copyright (c) 2001, 2025, Oracle and/or its affiliates. All rights reserved. + * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. + * + * This code is free software; you can redistribute it and/or modify it + * under the terms of the GNU General Public License version 2 only, as + * published by the Free Software Foundation. + * + * This code is distributed in the hope that it will be useful, but WITHOUT + * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or + * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License + * version 2 for more details (a copy is included in the LICENSE file that + * accompanied this code). + * + * You should have received a copy of the GNU General Public License version + * 2 along with this work; if not, write to the Free Software Foundation, + * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. + * + * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA + * or visit www.oracle.com if you need additional information or have any + * questions. + */ + +/* + * @test + * @bug 4193267 + * @summary Tests that JList first and last visible indices are + * updated properly + * @library /java/awt/regtesthelpers + * @build PassFailJFrame + * @run main/manual bug4193267 + */ + +import java.awt.Color; +import java.awt.FlowLayout; +import java.awt.GridLayout; +import java.util.List; +import javax.swing.JFrame; +import javax.swing.JLabel; +import javax.swing.JList; +import javax.swing.JPanel; +import javax.swing.JScrollPane; +import javax.swing.JTextField; +import javax.swing.event.ChangeEvent; +import javax.swing.event.ChangeListener; + +public class bug4193267 { + public static void main(String[] args) throws Exception { + String INSTRUCTIONS = """ + Resize the frame "JList" with a different ways and scroll the list + (if it possible). The indices of first and last visible elements + should be indicated in the corresponding fields in "Index" frame. + If the indicated indices is not right then test fails. + + Note: + - the first and last visible indices should be -1 if nothing + is visible; + - the first or last visible cells may only be partially visible. + """; + PassFailJFrame.builder() + .title("bug4193267 Instructions") + .instructions(INSTRUCTIONS) + .positionTestUI(WindowLayouts::rightOneRow) + .columns(35) + .testUI(bug4193267::initialize) + .build() + .awaitAndCheck(); + } + + private static List initialize() { + String[] data = {"000000000000000", "111111111111111", + "222222222222222", "333333333333333", + "444444444444444", "555555555555555", + "666666666666666", "777777777777777", + "888888888888888", "999999999999999"}; + + JFrame[] fr = new JFrame[2]; + fr[0] = new JFrame("JList"); + JList lst = new JList(data); + lst.setLayoutOrientation(JList.VERTICAL_WRAP); + lst.setVisibleRowCount(4); + JScrollPane jsp = new JScrollPane(lst); + fr[0].add(jsp); + fr[0].setSize(400, 200); + + JPanel pL = new JPanel(); + pL.setLayout(new GridLayout(2, 1)); + pL.add(new JLabel("First Visible Index")); + pL.add(new JLabel("Last Visible Index")); + + JPanel p = new JPanel(); + p.setLayout(new GridLayout(2, 1)); + JTextField first = new JTextField("0", 2); + first.setEditable(false); + first.setBackground(Color.white); + p.add(first); + JTextField last = new JTextField("9", 2); + last.setEditable(false); + last.setBackground(Color.white); + p.add(last); + + fr[1] = new JFrame("Index"); + fr[1].setSize(200, 200); + fr[1].setLayout(new FlowLayout()); + fr[1].add(pL); + fr[1].add(p); + + jsp.getViewport().addChangeListener(new ChangeListener() { + public void stateChanged(ChangeEvent e) { + first.setText(String.valueOf(lst.getFirstVisibleIndex())); + last.setText(String.valueOf(lst.getLastVisibleIndex())); + } + }); + List frameList = List.of(fr[0], fr[1]); + return frameList; + } +} diff -Nru openjdk-17-17.0.17+10/test/jdk/javax/swing/JList/bug4249161.java openjdk-17-17.0.18+8/test/jdk/javax/swing/JList/bug4249161.java --- openjdk-17-17.0.17+10/test/jdk/javax/swing/JList/bug4249161.java 1970-01-01 00:00:00.000000000 +0000 +++ openjdk-17-17.0.18+8/test/jdk/javax/swing/JList/bug4249161.java 2026-01-15 15:23:06.000000000 +0000 @@ -0,0 +1,96 @@ +/* + * Copyright (c) 2001, 2025, Oracle and/or its affiliates. All rights reserved. + * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. + * + * This code is free software; you can redistribute it and/or modify it + * under the terms of the GNU General Public License version 2 only, as + * published by the Free Software Foundation. + * + * This code is distributed in the hope that it will be useful, but WITHOUT + * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or + * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License + * version 2 for more details (a copy is included in the LICENSE file that + * accompanied this code). + * + * You should have received a copy of the GNU General Public License version + * 2 along with this work; if not, write to the Free Software Foundation, + * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. + * + * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA + * or visit www.oracle.com if you need additional information or have any + * questions. + */ + +/* + * @test + * @bug 4249161 + * @summary Tests that JList.setComponentOrientation() works correctly + * @library /java/awt/regtesthelpers + * @build PassFailJFrame + * @run main/manual bug4249161 + */ + +import java.awt.BorderLayout; +import java.awt.ComponentOrientation; +import java.awt.event.ActionEvent; +import java.awt.event.ActionListener; +import javax.swing.JButton; +import javax.swing.JFrame; +import javax.swing.JList; +import javax.swing.JScrollPane; + +public class bug4249161 { + public static void main(String[] args) throws Exception { + String INSTRUCTIONS = """ + 1. With a scroll bar, confirm that all words ("one" - "twenty") are + aligned at the left side of a list. + 2. Press "Change!" button. All words on the list should be moved + to the right side. + 3. Press the same button again. All words should be moved to the + left side. + + If all items in a list are moved as soon as "Change!" button is + pressed, test passes. + """; + PassFailJFrame.builder() + .title("bug4249161 Instructions") + .instructions(INSTRUCTIONS) + .columns(35) + .testUI(bug4249161::initialize) + .build() + .awaitAndCheck(); + } + + private static JFrame initialize() { + JFrame fr = new JFrame("bug4249161"); + + String[] data = {"one", "two", "three", "four", "five", + "six", "seven", "eight", "nine", "ten", + "eleven", "twelve", "thirteen", "fourteen", "fifteen", + "sixteen", "seventeen", "eighteen", "nineteen", "twenty" + }; + final JList list = new JList(data); + list.setSize(200, 200); + list.setComponentOrientation(ComponentOrientation.LEFT_TO_RIGHT); + JScrollPane pane = new JScrollPane(list); + fr.add(pane); + + JButton button = new JButton("Change!"); + button.addActionListener(new ActionListener() { + public void actionPerformed(ActionEvent e) { + if (list.getComponentOrientation() != + ComponentOrientation.RIGHT_TO_LEFT) { + list.setComponentOrientation + (ComponentOrientation.RIGHT_TO_LEFT); + } else { + list.setComponentOrientation + (ComponentOrientation.LEFT_TO_RIGHT); + } + } + }); + fr.add(button, BorderLayout.SOUTH); + fr.setSize(200, 300); + fr.setAlwaysOnTop(true); + return fr; + } +} diff -Nru openjdk-17-17.0.17+10/test/jdk/javax/swing/JList/bug4618767.java openjdk-17-17.0.18+8/test/jdk/javax/swing/JList/bug4618767.java --- openjdk-17-17.0.17+10/test/jdk/javax/swing/JList/bug4618767.java 1970-01-01 00:00:00.000000000 +0000 +++ openjdk-17-17.0.18+8/test/jdk/javax/swing/JList/bug4618767.java 2026-01-15 15:23:06.000000000 +0000 @@ -0,0 +1,127 @@ +/* + * Copyright (c) 1999, 2025, Oracle and/or its affiliates. All rights reserved. + * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. + * + * This code is free software; you can redistribute 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 4618767 + * @summary First letter navigation in JList interferes with mnemonics + * @key headful + * @run main bug4618767 + */ + +import java.awt.Robot; +import java.awt.event.FocusAdapter; +import java.awt.event.FocusEvent; +import java.awt.event.KeyEvent; +import java.util.concurrent.CountDownLatch; +import java.util.concurrent.TimeUnit; +import javax.swing.JFrame; +import javax.swing.JList; +import javax.swing.JMenu; +import javax.swing.JMenuBar; +import javax.swing.JMenuItem; +import javax.swing.SwingUtilities; +import javax.swing.event.MenuEvent; +import javax.swing.event.MenuListener; + +public class bug4618767 { + private static JFrame f; + private static final JList list = new + JList(new String[] {"one", "two", "three", "four"}); + private static boolean menuSelected; + private static volatile boolean failed; + private static CountDownLatch listGainedFocusLatch = new CountDownLatch(1); + + public static void main(String[] args) throws Exception { + try { + createUI(); + runTest(); + } finally { + SwingUtilities.invokeAndWait(() -> { + if (f != null) { + f.dispose(); + } + }); + } + } + + private static void createUI() throws Exception { + SwingUtilities.invokeAndWait(() -> { + f = new JFrame("bug4618767"); + JMenu menu = new JMenu("File"); + menu.setMnemonic('F'); + JMenuItem menuItem = new JMenuItem("item"); + menu.add(menuItem); + JMenuBar menuBar = new JMenuBar(); + menuBar.add(menu); + f.setJMenuBar(menuBar); + + menu.addMenuListener(new MenuListener() { + public void menuCanceled(MenuEvent e) {} + public void menuDeselected(MenuEvent e) {} + public void menuSelected(MenuEvent e) { + menuSelected = true; + } + }); + + list.addFocusListener(new FocusAdapter() { + @Override + public void focusGained(FocusEvent e) { + listGainedFocusLatch.countDown(); + } + }); + f.add(list); + f.pack(); + f.setLocationRelativeTo(null); + f.setAlwaysOnTop(true); + f.setVisible(true); + }); + } + + private static void runTest() throws Exception { + if (!listGainedFocusLatch.await(3, TimeUnit.SECONDS)) { + throw new RuntimeException("Waited too long, but can't gain" + + " focus for list"); + } + Robot robot = new Robot(); + robot.setAutoDelay(200); + robot.waitForIdle(); + robot.keyPress(KeyEvent.VK_O); + robot.keyRelease(KeyEvent.VK_O); + robot.waitForIdle(); + robot.keyPress(KeyEvent.VK_ALT); + robot.keyPress(KeyEvent.VK_F); + robot.keyRelease(KeyEvent.VK_F); + robot.keyRelease(KeyEvent.VK_ALT); + + SwingUtilities.invokeAndWait(() -> { + if (menuSelected && list.getSelectedIndex()!= 0) { + failed = true; + } + }); + if (failed) { + throw new RuntimeException("Mnemonics interferes with Jlist" + + " item selection using KeyEvent"); + } + } +} diff -Nru openjdk-17-17.0.17+10/test/jdk/javax/swing/JMenuBar/RightLeftOrientation.java openjdk-17-17.0.18+8/test/jdk/javax/swing/JMenuBar/RightLeftOrientation.java --- openjdk-17-17.0.17+10/test/jdk/javax/swing/JMenuBar/RightLeftOrientation.java 2025-10-13 07:48:04.000000000 +0000 +++ openjdk-17-17.0.18+8/test/jdk/javax/swing/JMenuBar/RightLeftOrientation.java 2026-01-15 15:23:06.000000000 +0000 @@ -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 @@ -20,75 +20,76 @@ * or visit www.oracle.com if you need additional information or have any * questions. */ + /* * @test * @bug 4211731 4214512 * @summary * This test checks if menu bars lay out correctly when their - * ComponentOrientation property is set to RIGHT_TO_LEFT. This test is - * manual. The tester is asked to compare left-to-right and - * right-to-left menu bars and judge whether they are mirror images of each - * other. + * ComponentOrientation property is set to RIGHT_TO_LEFT. + * The tester is asked to compare left-to-right and + * right-to-left menu bars and decide whether they are mirror + * images of each other. * @library /test/jdk/java/awt/regtesthelpers * @build PassFailJFrame * @run main/manual RightLeftOrientation */ import java.awt.ComponentOrientation; -import java.awt.Point; import java.awt.event.ActionEvent; import java.awt.event.ActionListener; +import java.util.List; + import javax.swing.ButtonGroup; import javax.swing.JFrame; import javax.swing.JMenu; import javax.swing.JMenuBar; +import javax.swing.JOptionPane; import javax.swing.JPanel; import javax.swing.JRadioButton; import javax.swing.SwingUtilities; import javax.swing.UIManager; -public class RightLeftOrientation { +public final class RightLeftOrientation { - static JFrame ltrFrame; - static JFrame rtlFrame; + private static List frames; private static final String INSTRUCTIONS = """ - This test checks menu bars for correct Right-To-Left Component Orientation. - - You should see two frames, each containing a menu bar. + This test checks menu bars for correct Right-To-Left component orientation. - One frame will be labelled "Left To Right" and will contain + You should see two frames, each contains a menu bar. + One frame is labelled "Left To Right" and contains a menu bar with menus starting on its left side. - The other frame will be labelled "Right To Left" and will - contain a menu bar with menus starting on its right side. + The other frame is labelled "Right To Left" and + contains a menu bar with menus starting on its right side. - The test will also contain radio buttons that can be used to set - the look and feel of the menu bars. - For each look and feel, you should compare the two menu - bars and make sure they are mirror images of each other. """; + The test also displays a frame with radio buttons + to change the look and feel of the menu bars. + For each look and feel, compare the two menu bars + in LTR and RTL orientation and make sure they are mirror + images of each other."""; public static void main(String[] args) throws Exception { PassFailJFrame.builder() - .title("RTL test Instructions") + .title("Menu Bar RTL Instructions") .instructions(INSTRUCTIONS) - .rows((int) INSTRUCTIONS.lines().count() + 2) .columns(30) .testUI(RightLeftOrientation::createTestUI) + .positionTestUIRightColumn() .build() .awaitAndCheck(); } - private static JFrame createTestUI() { - JFrame frame = new JFrame("RightLeftOrientation"); + private static JFrame createPlafChangerFrame() { + JFrame frame = new JFrame("Change Look and Feel"); JPanel panel = new JPanel(); ButtonGroup group = new ButtonGroup(); - JRadioButton rb; ActionListener plafChanger = new PlafChanger(); UIManager.LookAndFeelInfo[] lafInfos = UIManager.getInstalledLookAndFeels(); for (int i = 0; i < lafInfos.length; i++) { - rb = new JRadioButton(lafInfos[i].getName()); + JRadioButton rb = new JRadioButton(lafInfos[i].getName()); rb.setActionCommand(lafInfos[i].getClassName()); rb.addActionListener(plafChanger); group.add(rb); @@ -99,33 +100,39 @@ } frame.add(panel); + frame.pack(); + return frame; + } - ltrFrame = new JFrame("Left To Right"); + private static List createTestUI() { + JFrame plafFrame = createPlafChangerFrame(); + + JFrame ltrFrame = new JFrame("Left To Right"); ltrFrame.setJMenuBar(createMenuBar(ComponentOrientation.LEFT_TO_RIGHT)); ltrFrame.setSize(400, 100); - ltrFrame.setLocation(new Point(10, 10)); - ltrFrame.setVisible(true); - rtlFrame = new JFrame("Right To Left"); + JFrame rtlFrame = new JFrame("Right To Left"); rtlFrame.setJMenuBar(createMenuBar(ComponentOrientation.RIGHT_TO_LEFT)); rtlFrame.setSize(400, 100); - rtlFrame.setLocation(new Point(10, 120)); - rtlFrame.setVisible(true); - frame.pack(); - return frame; + + return (frames = List.of(plafFrame, ltrFrame, rtlFrame)); } - static class PlafChanger implements ActionListener { + private static final class PlafChanger implements ActionListener { + @Override public void actionPerformed(ActionEvent e) { String lnfName = e.getActionCommand(); try { UIManager.setLookAndFeel(lnfName); - SwingUtilities.updateComponentTreeUI(ltrFrame); - SwingUtilities.updateComponentTreeUI(rtlFrame); - } - catch (Exception exc) { - System.err.println("Could not load LookAndFeel: " + lnfName); + frames.forEach(SwingUtilities::updateComponentTreeUI); + } catch (Exception exc) { + String message = "Could not set Look and Feel to " + lnfName; + System.err.println(message); + JOptionPane.showMessageDialog(frames.get(0), + message, + "Look and Feel Error", + JOptionPane.ERROR_MESSAGE); } } diff -Nru openjdk-17-17.0.17+10/test/jdk/javax/swing/JMenuItem/MenuItemTest/MenuItemTestHelper.java openjdk-17-17.0.18+8/test/jdk/javax/swing/JMenuItem/MenuItemTest/MenuItemTestHelper.java --- openjdk-17-17.0.17+10/test/jdk/javax/swing/JMenuItem/MenuItemTest/MenuItemTestHelper.java 1970-01-01 00:00:00.000000000 +0000 +++ openjdk-17-17.0.18+8/test/jdk/javax/swing/JMenuItem/MenuItemTest/MenuItemTestHelper.java 2026-01-15 15:23:06.000000000 +0000 @@ -0,0 +1,163 @@ +/* + * 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 + * under the terms of the GNU General Public License version 2 only, as + * published by the Free Software Foundation. + * + * This code is distributed in the hope that it will be useful, but WITHOUT + * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or + * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License + * version 2 for more details (a copy is included in the LICENSE file that + * accompanied this code). + * + * You should have received a copy of the GNU General Public License version + * 2 along with this work; if not, write to the Free Software Foundation, + * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. + * + * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA + * or visit www.oracle.com if you need additional information or have any + * questions. + */ + +import java.awt.BorderLayout; +import java.awt.Color; +import java.awt.Component; +import java.awt.ComponentOrientation; +import java.awt.Graphics; +import java.awt.event.KeyEvent; +import javax.swing.Icon; +import javax.swing.JCheckBoxMenuItem; +import javax.swing.JFrame; +import javax.swing.JLabel; +import javax.swing.JMenu; +import javax.swing.JMenuBar; +import javax.swing.JMenuItem; +import javax.swing.JRadioButtonMenuItem; +import javax.swing.KeyStroke; +import javax.swing.UIManager; + +final class MenuItemTestHelper { + + public static JFrame getMenuItemTestFrame(boolean isLeft, String lafName) { + boolean applyLookAndFeel = lafName != null; + if (applyLookAndFeel) { + try { + UIManager.setLookAndFeel(lafName); + } catch (Exception e) { + throw new RuntimeException(e); + } + } + + Icon myIcon = new ColoredIcon(Color.RED, 10, 10); + Icon myIcon2 = new ColoredIcon(Color.GREEN, 15, 10); + + JMenuBar menuBar = new JMenuBar(); + menuBar.add(createViewMenu(myIcon, myIcon2)); + menuBar.add(createNoNothingMenu()); + menuBar.add(createSomeIconsMenu(myIcon, myIcon2)); + + String title = (isLeft ? "(Left-to-right)" : "(Right-to-left)") + " - Menu Item Test"; + JFrame frame = new JFrame(title); + frame.setJMenuBar(menuBar); + frame.applyComponentOrientation(isLeft + ? ComponentOrientation.LEFT_TO_RIGHT + : ComponentOrientation.RIGHT_TO_LEFT); + + if (applyLookAndFeel) { + String shortName = lafName.substring(lafName.lastIndexOf('.') + 1); + JLabel label = new JLabel("

" + shortName + "

"); + frame.setLayout(new BorderLayout()); + frame.add(label, BorderLayout.CENTER); + } + + frame.setSize(300, 300); + return frame; + } + + public static JFrame getMenuItemTestFrame(boolean isLeft) { + return getMenuItemTestFrame(isLeft, null); + } + + private static JMenu createViewMenu(Icon myIcon, Icon myIcon2) { + JMenu menu = new JMenu("View"); + menu.setMnemonic('V'); + menu.add(new JMenuItem("Refresh")); + menu.add(new JMenuItem("Customize...")); + menu.add(new JCheckBoxMenuItem("Show Toolbar")); + menu.addSeparator(); + menu.add(new JRadioButtonMenuItem("List")); + menu.add(new JRadioButtonMenuItem("Icons")); + + JRadioButtonMenuItem rm2 = new JRadioButtonMenuItem("And icon."); + rm2.setAccelerator(KeyStroke.getKeyStroke(KeyEvent.VK_F1, KeyEvent.SHIFT_DOWN_MASK)); + rm2.setIcon(myIcon2); + menu.add(rm2); + + JRadioButtonMenuItem mi3 = new JRadioButtonMenuItem("Radio w/icon"); + mi3.setIcon(myIcon); + menu.add(mi3); + + menu.add(new JMenuItem(myIcon2)); + + JMenuItem mi4 = new JMenuItem("Item with icon"); + mi4.setIcon(myIcon); + menu.addSeparator(); + menu.add(mi4); + + return menu; + } + + private static JMenu createNoNothingMenu() { + final JMenu noMenu = new JMenu("No nothing"); + + for (String label : new String[]{"One", "Two", "Threeee"}) { + JMenuItem item = new JMenuItem(label); + item.addActionListener((e) -> + PassFailJFrame.log("menu.width = " + + noMenu.getPopupMenu().getWidth())); + noMenu.add(item); + } + + return noMenu; + } + + private static JMenu createSomeIconsMenu(Icon myIcon, Icon myIcon2) { + JMenu someIcons = new JMenu("Some icons"); + + JMenuItem imi1 = new JMenuItem("Icon!"); + imi1.setIcon(myIcon); + someIcons.add(imi1); + + JMenuItem imi2 = new JMenuItem("Wide icon!"); + imi2.setIcon(myIcon2); + someIcons.add(imi2); + + someIcons.add(new JCheckBoxMenuItem("CheckBox")); + someIcons.add(new JRadioButtonMenuItem("RadioButton")); + + return someIcons; + } + + private record ColoredIcon(Color color, int width, int height) + implements Icon { + @Override + public void paintIcon(Component c, Graphics g, int x, int y) { + Color oldColor = g.getColor(); + g.setColor(color); + g.fillRect(x, y, width, height); + g.setColor(oldColor); + } + + @Override + public int getIconWidth() { + return width; + } + + @Override + public int getIconHeight() { + return height; + } + } +} diff -Nru openjdk-17-17.0.17+10/test/jdk/javax/swing/JMenuItem/MenuItemTest/bug4729669.java openjdk-17-17.0.18+8/test/jdk/javax/swing/JMenuItem/MenuItemTest/bug4729669.java --- openjdk-17-17.0.17+10/test/jdk/javax/swing/JMenuItem/MenuItemTest/bug4729669.java 1970-01-01 00:00:00.000000000 +0000 +++ openjdk-17-17.0.18+8/test/jdk/javax/swing/JMenuItem/MenuItemTest/bug4729669.java 2026-01-15 15:23:06.000000000 +0000 @@ -0,0 +1,61 @@ +/* + * 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 + * 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 4729669 + * @summary 1.4 REGRESSION: Text edge of different types of JMenuItems are not aligned + * @library /java/awt/regtesthelpers + * @build PassFailJFrame + * @run main/manual bug4729669 + */ + +import java.util.List; +import javax.swing.JFrame; + +public class bug4729669 { + + private static final String INSTRUCTIONS = """ + Two windows should appear: Left-to-right and Right-to-left. + Check that text on all the menu items of all menus + is properly vertically aligned."""; + + public static void main(String[] args) throws Exception { + PassFailJFrame.builder() + .title("bug4729669 Instructions") + .instructions(INSTRUCTIONS) + .columns(35) + .testUI(bug4729669::createTestUI) + .positionTestUIRightColumn() + .logArea() + .build() + .awaitAndCheck(); + } + + private static List createTestUI() { + JFrame f1 = MenuItemTestHelper.getMenuItemTestFrame(true); + JFrame f2 = MenuItemTestHelper.getMenuItemTestFrame(false); + return List.of(f1, f2); + } +} + diff -Nru openjdk-17-17.0.17+10/test/jdk/javax/swing/JMenuItem/MenuItemTest/bug6197830.java openjdk-17-17.0.18+8/test/jdk/javax/swing/JMenuItem/MenuItemTest/bug6197830.java --- openjdk-17-17.0.17+10/test/jdk/javax/swing/JMenuItem/MenuItemTest/bug6197830.java 1970-01-01 00:00:00.000000000 +0000 +++ openjdk-17-17.0.18+8/test/jdk/javax/swing/JMenuItem/MenuItemTest/bug6197830.java 2026-01-15 15:23:06.000000000 +0000 @@ -0,0 +1,67 @@ +/* + * 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 + * 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 6197830 + * @requires (os.family == "linux") + * @summary Fix for 4729669 does not work on Motif and GTK look and feels + * @library /java/awt/regtesthelpers + * @build PassFailJFrame + * @run main/manual bug6197830 + */ + +import java.util.List; +import javax.swing.JFrame; + +public class bug6197830 { + + private static final String INSTRUCTIONS = """ + Four windows should appear: Left-to-right and Right-to-left for + the two different Look and Feels (Motif and GTK). + Check that text on all the menu items of all menus is properly + vertically aligned."""; + + public static void main(String[] args) throws Exception { + PassFailJFrame.builder() + .title("bug6197830 Instructions") + .instructions(INSTRUCTIONS) + .columns(35) + .testUI(bug6197830::createTestUI) + .positionTestUIBottomRowCentered() + .build() + .awaitAndCheck(); + } + + private static List createTestUI() { + JFrame frame1 = MenuItemTestHelper.getMenuItemTestFrame(true, + "com.sun.java.swing.plaf.motif.MotifLookAndFeel"); + JFrame frame2 = MenuItemTestHelper.getMenuItemTestFrame(false, + "com.sun.java.swing.plaf.motif.MotifLookAndFeel"); + JFrame frame3 = MenuItemTestHelper.getMenuItemTestFrame(true, + "com.sun.java.swing.plaf.gtk.GTKLookAndFeel"); + JFrame frame4 = MenuItemTestHelper.getMenuItemTestFrame(false, + "com.sun.java.swing.plaf.gtk.GTKLookAndFeel"); + return List.of(frame1, frame2, frame3, frame4); + } +} diff -Nru openjdk-17-17.0.17+10/test/jdk/javax/swing/JMenuItem/RightLeftOrientation.java openjdk-17-17.0.18+8/test/jdk/javax/swing/JMenuItem/RightLeftOrientation.java --- openjdk-17-17.0.17+10/test/jdk/javax/swing/JMenuItem/RightLeftOrientation.java 2025-10-13 07:48:04.000000000 +0000 +++ openjdk-17-17.0.18+8/test/jdk/javax/swing/JMenuItem/RightLeftOrientation.java 2026-01-15 15:23:06.000000000 +0000 @@ -22,18 +22,36 @@ */ /* - * @test + * @test id=metal * @bug 4211052 * @requires (os.family == "windows") - * @summary - * This test checks if menu items lay out correctly when their + * @summary Verifies if menu items lay out correctly when their * ComponentOrientation property is set to RIGHT_TO_LEFT. - * The tester is asked to compare left-to-right and - * right-to-left menus and judge whether they are mirror images of each - * other. * @library /java/awt/regtesthelpers * @build PassFailJFrame - * @run main/manual RightLeftOrientation + * @run main/manual RightLeftOrientation metal + */ + +/* + * @test id=motif + * @bug 4211052 + * @requires (os.family == "windows") + * @summary Verifies if menu items lay out correctly when their + * ComponentOrientation property is set to RIGHT_TO_LEFT. + * @library /java/awt/regtesthelpers + * @build PassFailJFrame + * @run main/manual RightLeftOrientation motif + */ + +/* + * @test id=windows + * @bug 4211052 8370465 + * @requires (os.family == "windows") + * @summary Verifies if menu items lay out correctly when their + * ComponentOrientation property is set to RIGHT_TO_LEFT. + * @library /java/awt/regtesthelpers + * @build PassFailJFrame + * @run main/manual RightLeftOrientation windows */ import java.awt.Color; @@ -52,29 +70,47 @@ import javax.swing.JMenuItem; import javax.swing.JRadioButtonMenuItem; import javax.swing.KeyStroke; -import javax.swing.LookAndFeel; import javax.swing.SwingConstants; +import javax.swing.SwingUtilities; import javax.swing.UIManager; public class RightLeftOrientation { private static final String INSTRUCTIONS = """ - A menu bar is shown containing a menu for each look and feel. - A disabled menu means that the look and feel is not available for - testing in this environment. - Every effort should be made to run this test - in an environment that covers all look and feels. + A menu bar is shown with a menu. - Each menu is divided into two halves. The upper half is oriented + The menu is divided into two halves. The upper half is oriented left-to-right and the lower half is oriented right-to-left. - For each menu, ensure that the lower half mirrors the upper half. + Ensure that the lower half mirrors the upper half. Note that when checking the positioning of the sub-menus, it helps to position the frame away from the screen edges."""; public static void main(String[] args) throws Exception { + if (args.length < 1) { + throw new IllegalArgumentException("Look-and-Feel keyword is required"); + } + + final String lafClassName; + switch (args[0]) { + case "metal" -> lafClassName = UIManager.getCrossPlatformLookAndFeelClassName(); + case "motif" -> lafClassName = "com.sun.java.swing.plaf.motif.MotifLookAndFeel"; + case "windows" -> lafClassName = "com.sun.java.swing.plaf.windows.WindowsLookAndFeel"; + default -> throw new IllegalArgumentException( + "Unsupported Look-and-Feel keyword for this test: " + args[0]); + } + + SwingUtilities.invokeAndWait(() -> { + try { + UIManager.setLookAndFeel(lafClassName); + } catch (Exception e) { + throw new RuntimeException(e); + } + }); + + System.out.println("Test for LookAndFeel " + lafClassName); + PassFailJFrame.builder() - .title("RightLeftOrientation Instructions") .instructions(INSTRUCTIONS) .columns(35) .testUI(RightLeftOrientation::createTestUI) @@ -86,32 +122,19 @@ JFrame frame = new JFrame("RightLeftOrientation"); JMenuBar menuBar = new JMenuBar(); - menuBar.add(createMenu("javax.swing.plaf.metal.MetalLookAndFeel", - "Metal")); - menuBar.add(createMenu("com.sun.java.swing.plaf.motif.MotifLookAndFeel", - "Motif")); - menuBar.add(createMenu("com.sun.java.swing.plaf.windows.WindowsLookAndFeel", - "Windows")); + menuBar.add(createMenu()); frame.setJMenuBar(menuBar); - frame.pack(); + frame.setSize(250, 70); return frame; } - static JMenu createMenu(String laf, String name) { - JMenu menu = new JMenu(name); - try { - LookAndFeel save = UIManager.getLookAndFeel(); - UIManager.setLookAndFeel(laf); - addMenuItems(menu, ComponentOrientation.LEFT_TO_RIGHT); - menu.addSeparator(); - addMenuItems(menu, ComponentOrientation.RIGHT_TO_LEFT); - UIManager.setLookAndFeel(save); - } catch (Exception e) { - menu = new JMenu(name); - menu.setEnabled(false); - } + static JMenu createMenu() { + JMenu menu = new JMenu(UIManager.getLookAndFeel().getID()); + addMenuItems(menu, ComponentOrientation.LEFT_TO_RIGHT); + menu.addSeparator(); + addMenuItems(menu, ComponentOrientation.RIGHT_TO_LEFT); return menu; } @@ -132,6 +155,16 @@ menuItem.setHorizontalTextPosition(SwingConstants.LEADING); menu.add(menuItem); + menuItem = new JMenuItem("Text to the left", new MyMenuItemIcon()); + menuItem.setComponentOrientation(o); + menuItem.setHorizontalTextPosition(SwingConstants.LEFT); + menu.add(menuItem); + + menuItem = new JMenuItem("Text to the right", new MyMenuItemIcon()); + menuItem.setComponentOrientation(o); + menuItem.setHorizontalTextPosition(SwingConstants.RIGHT); + menu.add(menuItem); + menuItem = new JRadioButtonMenuItem("Radio Button Menu Item"); menuItem.setComponentOrientation(o); menuItem.setSelected(true); diff -Nru openjdk-17-17.0.17+10/test/jdk/javax/swing/JMenuItem/bug4207339.java openjdk-17-17.0.18+8/test/jdk/javax/swing/JMenuItem/bug4207339.java --- openjdk-17-17.0.17+10/test/jdk/javax/swing/JMenuItem/bug4207339.java 1970-01-01 00:00:00.000000000 +0000 +++ openjdk-17-17.0.18+8/test/jdk/javax/swing/JMenuItem/bug4207339.java 2026-01-15 15:23:06.000000000 +0000 @@ -0,0 +1,67 @@ +/* + * Copyright (c) 1999, 2025, Oracle and/or its affiliates. All rights reserved. + * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. + * + * This code is free software; you can redistribute 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 4207339 + * @summary Verifies HTML label support for MenuItems + * @library /java/awt/regtesthelpers + * @build PassFailJFrame + * @run main/manual bug4207339 + */ + +import javax.swing.JPanel; +import javax.swing.JMenuItem; + +public class bug4207339 { + + private static final String INSTRUCTIONS = """ + This tests html support in menuItem. + A MenuItem will be shown. + If the MenuItem is showing "big" text bigger than rest + and "red" text in red color and the text are in multiple lines, + and text "Yo" in blue color, + then press Pass else press Fail."""; + + public static void main(String[] args) throws Exception { + PassFailJFrame.builder() + .title("bug4207339 Instructions") + .instructions(INSTRUCTIONS) + .columns(35) + .splitUI(bug4207339::createTestUI) + .build() + .awaitAndCheck(); + } + + private static JPanel createTestUI() { + JPanel panel = new JPanel(); + JMenuItem mi = new JMenuItem("
Is this text big" + + "and red?" + + "
And on multiple lines?

" + + "Yo!" + + "Then press PASS!
"); + panel.add(mi); + return panel; + } + +} diff -Nru openjdk-17-17.0.17+10/test/jdk/javax/swing/JMenuItem/bug4327146.java openjdk-17-17.0.18+8/test/jdk/javax/swing/JMenuItem/bug4327146.java --- openjdk-17-17.0.17+10/test/jdk/javax/swing/JMenuItem/bug4327146.java 1970-01-01 00:00:00.000000000 +0000 +++ openjdk-17-17.0.18+8/test/jdk/javax/swing/JMenuItem/bug4327146.java 2026-01-15 15:23:06.000000000 +0000 @@ -0,0 +1,114 @@ +/* + * Copyright (c) 2001, 2025, Oracle and/or its affiliates. All rights reserved. + * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. + * + * This code is free software; you can redistribute it and/or modify it + * under the terms of the GNU General Public License version 2 only, as + * published by the Free Software Foundation. + * + * This code is distributed in the hope that it will be useful, but WITHOUT + * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or + * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License + * version 2 for more details (a copy is included in the LICENSE file that + * accompanied this code). + * + * You should have received a copy of the GNU General Public License version + * 2 along with this work; if not, write to the Free Software Foundation, + * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. + * + * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA + * or visit www.oracle.com if you need additional information or have any + * questions. + */ + +/* + * @test + * @bug 4327146 + * @summary Tests menu width after removeAll() + * @key headful + * @run main bug4327146 + */ + +import java.awt.Dimension; +import java.awt.Point; +import java.awt.Rectangle; +import java.awt.Robot; +import java.awt.event.InputEvent; +import javax.swing.JButton; +import javax.swing.JFrame; +import javax.swing.JMenu; +import javax.swing.JMenuBar; +import javax.swing.JMenuItem; +import javax.swing.SwingUtilities; + +public class bug4327146 { + private static JButton b; + private static JMenu m; + private static JFrame frame; + private static volatile Point loc; + private static volatile Dimension dim; + private static volatile Rectangle old_popupBounds; + private static volatile Rectangle new_popupBounds; + + public static void main(String[] args) throws Exception { + Robot robot = new Robot(); + try { + SwingUtilities.invokeAndWait(() -> { + frame = new JFrame("bug4327146"); + m = new JMenu("Menu"); + m.add(new JMenuItem("I'm an ugly bug, fix me right now please!")); + + JMenuBar mbar = new JMenuBar(); + mbar.add(m); + frame.setJMenuBar(mbar); + + b = new JButton("Cut"); + b.addActionListener(e -> { + m.removeAll(); + m.add(new JMenuItem("Fixed :)")); + }); + mbar.add(b); + frame.pack(); + frame.setLocationRelativeTo(null); + frame.setVisible(true); + }); + robot.waitForIdle(); + robot.delay(1000); + SwingUtilities.invokeAndWait(() -> { + loc = b.getLocationOnScreen(); + dim = b.getSize(); + m.doClick(); + }); + robot.waitForIdle(); + robot.delay(500); + SwingUtilities.invokeAndWait(() -> { + old_popupBounds = m.getPopupMenu().getBounds(); + }); + robot.mouseMove(loc.x + dim.width / 2, loc.y + dim.height / 2); + robot.mousePress(InputEvent.BUTTON1_DOWN_MASK); + robot.mouseRelease(InputEvent.BUTTON1_DOWN_MASK); + robot.waitForIdle(); + robot.delay(500); + SwingUtilities.invokeAndWait(() -> { + m.doClick(); + }); + robot.waitForIdle(); + robot.delay(500); + SwingUtilities.invokeAndWait(() -> { + new_popupBounds = m.getPopupMenu().getBounds(); + }); + if (new_popupBounds.getWidth() >= old_popupBounds.getWidth()) { + System.out.println("before cut popup Bounds " + old_popupBounds); + System.out.println("after cut popupBounds " + new_popupBounds); + throw new RuntimeException("JMenu popup width is wrong"); + } + } finally { + SwingUtilities.invokeAndWait(() -> { + if (frame != null) { + frame.dispose(); + } + }); + } + } + +} diff -Nru openjdk-17-17.0.17+10/test/jdk/javax/swing/JMenuItem/bug4402082.java openjdk-17-17.0.18+8/test/jdk/javax/swing/JMenuItem/bug4402082.java --- openjdk-17-17.0.17+10/test/jdk/javax/swing/JMenuItem/bug4402082.java 1970-01-01 00:00:00.000000000 +0000 +++ openjdk-17-17.0.18+8/test/jdk/javax/swing/JMenuItem/bug4402082.java 2026-01-15 15:23:06.000000000 +0000 @@ -0,0 +1,81 @@ +/* + * Copyright (c) 2001, 2025, Oracle and/or its affiliates. All rights reserved. + * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. + * + * This code is free software; you can redistribute it and/or modify it + * under the terms of the GNU General Public License version 2 only, as + * published by the Free Software Foundation. + * + * This code is distributed in the hope that it will be useful, but WITHOUT + * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or + * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License + * version 2 for more details (a copy is included in the LICENSE file that + * accompanied this code). + * + * You should have received a copy of the GNU General Public License version + * 2 along with this work; if not, write to the Free Software Foundation, + * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. + * + * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA + * or visit www.oracle.com if you need additional information or have any + * questions. + */ + +/* + * @test + * @bug 4402082 + * @requires (os.family == "windows") + * @summary Tests that JMenuItem accelerator is rendered correctly. + * @library /java/awt/regtesthelpers + * @build PassFailJFrame + * @run main/manual bug4402082 + */ + +import java.awt.Container; +import java.awt.GridLayout; +import java.awt.event.KeyEvent; +import javax.swing.JFrame; +import javax.swing.JMenuItem; +import javax.swing.KeyStroke; +import javax.swing.UIManager; + +public class bug4402082 { + + private static final String INSTRUCTIONS = """ + You see three menu items, each having different look-and-feels. + Each menu item should display accelerator "F1" on its right side. + The accelerator should be fully visible. If it is partially + offscreen, or not visible at all, test fails."""; + + public static void main(String[] args) throws Exception { + PassFailJFrame.builder() + .title("bug4402082 Instructions") + .instructions(INSTRUCTIONS) + .columns(35) + .testUI(bug4402082::createTestUI) + .build() + .awaitAndCheck(); + } + + static JMenuItem getMenuItem(String lnf) { + try { + UIManager.setLookAndFeel(lnf); + } catch (Exception exc) { + System.err.println("Could not load LookAndFeel: " + lnf); + } + JMenuItem mi = new JMenuItem("Bad Item"); + mi.setAccelerator(KeyStroke.getKeyStroke(KeyEvent.VK_F1, 0)); + return mi; + } + + private static JFrame createTestUI() { + JFrame frame = new JFrame("bug4402082"); + Container pane = frame.getContentPane(); + pane.setLayout(new GridLayout(3,1)); + pane.add(getMenuItem("javax.swing.plaf.metal.MetalLookAndFeel")); + pane.add(getMenuItem("com.sun.java.swing.plaf.motif.MotifLookAndFeel")); + pane.add(getMenuItem("com.sun.java.swing.plaf.windows.WindowsLookAndFeel")); + frame.pack(); + return frame; + } +} diff -Nru openjdk-17-17.0.17+10/test/jdk/javax/swing/JMenuItem/bug4729669.java openjdk-17-17.0.18+8/test/jdk/javax/swing/JMenuItem/bug4729669.java --- openjdk-17-17.0.17+10/test/jdk/javax/swing/JMenuItem/bug4729669.java 2025-10-13 07:48:04.000000000 +0000 +++ openjdk-17-17.0.18+8/test/jdk/javax/swing/JMenuItem/bug4729669.java 1970-01-01 00:00:00.000000000 +0000 @@ -1,186 +0,0 @@ -/* - * 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 - * 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 4729669 - * @summary 1.4 REGRESSION: Text edge of different types of JMenuItems are not aligned - * @library /java/awt/regtesthelpers - * @build PassFailJFrame - * @run main/manual bug4729669 - */ - -import java.awt.Color; -import java.awt.ComponentOrientation; -import java.awt.Component; -import java.awt.Graphics; -import java.awt.event.ActionEvent; -import java.awt.event.KeyEvent; - -import javax.swing.AbstractAction; -import javax.swing.Icon; -import javax.swing.JCheckBoxMenuItem; -import javax.swing.JFrame; -import javax.swing.JMenu; -import javax.swing.JMenuBar; -import javax.swing.JMenuItem; -import javax.swing.JRadioButtonMenuItem; -import javax.swing.KeyStroke; - -import java.util.List; - -public class bug4729669 { - - private static final String INSTRUCTIONS = """ - Two windows should appear: Left-to-right and Right-to-left. - Check that text on all the menu items of all menus - is properly vertically aligned."""; - - public static void main(String[] args) throws Exception { - PassFailJFrame.builder() - .title("bug4729669 Instructions") - .instructions(INSTRUCTIONS) - .columns(35) - .testUI(bug4729669::createTestUI) - .position(PassFailJFrame.Position.TOP_LEFT_CORNER) - .logArea() - .build() - .awaitAndCheck(); - } - - private static List createTestUI() { - JFrame f1 = MenuItemTest.doMenuItemTest(true); - f1.setLocation(300, 300); - JFrame f2 = MenuItemTest.doMenuItemTest(false); - f2.setLocation(500, 300); - return List.of(f1, f2); - } -} - -class MenuItemTest { - public static JFrame doMenuItemTest(boolean isLeft) { - JMenu menu = new JMenu("View"); - menu.setMnemonic('V'); - - menu.add(new JMenuItem("Refresh")); - menu.add(new JMenuItem("Customize...")); - menu.add(new JCheckBoxMenuItem("Show Toolbar")); - menu.addSeparator(); - menu.add(new JRadioButtonMenuItem("List")); - menu.add(new JRadioButtonMenuItem("Icons")); - JRadioButtonMenuItem rm2 = new JRadioButtonMenuItem("And icon."); - rm2.setAccelerator(KeyStroke.getKeyStroke(KeyEvent.VK_F1, - KeyEvent.SHIFT_MASK)); - menu.add(rm2); - JRadioButtonMenuItem mi3 = new JRadioButtonMenuItem("Radio w/icon"); - - Icon myIcon = new Icon() { // 10 pixel red - public void paintIcon(Component c, Graphics g, int x, int y) { - Color color = g.getColor(); - g.setColor(Color.RED); - g.fillRect(x, y, 10, 10); - g.setColor(color); - } - - public int getIconWidth() { - return 10; - } - - public int getIconHeight() { - return 10; - } - }; - - Icon myIcon2 = new Icon() { // 15 pixel green - public void paintIcon(Component c, Graphics g, int x, int y) { - Color color = g.getColor(); - g.setColor(Color.GREEN); - g.fillRect(x, y, 15, 10); - g.setColor(color); - } - - public int getIconWidth() { - return 15; - } - - public int getIconHeight() { - return 10; - } - }; - - rm2.setIcon(myIcon2); - - mi3.setIcon(myIcon); - menu.add(mi3); - menu.add(new JMenuItem(myIcon2)); - - final JMenu menu2 = new JMenu("No nothing"); - menu2.add("One").addActionListener(new AbstractAction() { - public void actionPerformed(ActionEvent e) { - PassFailJFrame.log("menu.width = " + menu2.getPopupMenu().getWidth()); - } - }); - menu2.add("Two").addActionListener(new AbstractAction() { - public void actionPerformed(ActionEvent e) { - PassFailJFrame.log("menu.width = " + menu2.getPopupMenu().getWidth()); - } - }); - menu2.add("Threeee").addActionListener(new AbstractAction() { - public void actionPerformed(ActionEvent e) { - PassFailJFrame.log("menu.width = " + menu2.getPopupMenu().getWidth()); - } - }); - - JMenuItem mi4 = new JMenuItem("Item with icon"); - mi4.setIcon(myIcon); - menu.addSeparator(); - menu.add(mi4); - String title = "Menu Item Test " + (isLeft ? "(Left-to-right)" : "(Right-to-left)"); - JFrame frame = new JFrame(title); - - JMenuBar menuBar = new JMenuBar(); - menuBar.add(menu); - menuBar.add(menu2); - - JMenu someIcons = new JMenu("Some icons"); - JMenuItem imi1 = new JMenuItem("Icon!"); - imi1.setIcon(myIcon); - someIcons.add(imi1); - JMenuItem imi2 = new JMenuItem("Wide icon!"); - imi2.setIcon(myIcon2); - someIcons.add(imi2); - someIcons.add(new JCheckBoxMenuItem("CheckBox")); - someIcons.add(new JRadioButtonMenuItem("RadioButton")); - menuBar.add(someIcons); - frame.setJMenuBar(menuBar); - ComponentOrientation co = (isLeft ? - ComponentOrientation.LEFT_TO_RIGHT : - ComponentOrientation.RIGHT_TO_LEFT); - frame.applyComponentOrientation(co); - frame.setSize(300, 300); - int frameX = isLeft ? 0 : 600; - frame.setLocation(frameX, 20); - return frame; - } - -} diff -Nru openjdk-17-17.0.17+10/test/jdk/javax/swing/JOptionPane/TestJOptionHTMLTag.java openjdk-17-17.0.18+8/test/jdk/javax/swing/JOptionPane/TestJOptionHTMLTag.java --- openjdk-17-17.0.17+10/test/jdk/javax/swing/JOptionPane/TestJOptionHTMLTag.java 2025-10-13 07:48:04.000000000 +0000 +++ openjdk-17-17.0.18+8/test/jdk/javax/swing/JOptionPane/TestJOptionHTMLTag.java 1970-01-01 00:00:00.000000000 +0000 @@ -1,68 +0,0 @@ -/* - * Copyright (c) 2022, Oracle and/or its affiliates. All rights reserved. - * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. - * - * This code is free software; you can redistribute it and/or modify it - * under the terms of the GNU General Public License version 2 only, as - * published by the Free Software Foundation. - * - * This code is distributed in the hope that it will be useful, but WITHOUT - * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or - * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License - * version 2 for more details (a copy is included in the LICENSE file that - * accompanied this code). - * - * You should have received a copy of the GNU General Public License version - * 2 along with this work; if not, write to the Free Software Foundation, - * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. - * - * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA - * or visit www.oracle.com if you need additional information or have any - * questions. - */ -/* @test - * @bug 5074006 - * @key headful - * @library /java/awt/regtesthelpers - * @build PassFailJFrame - * @summary Swing JOptionPane shows tag as a string after newline - * @run main/manual TestJOptionHTMLTag -*/ - -import javax.swing.JDialog; -import javax.swing.JOptionPane; -import javax.swing.SwingUtilities; - -public class TestJOptionHTMLTag { - static String instructions - = """ - INSTRUCTIONS: - A dialog will be shown. - If it does not contain string, press Pass else press Fail. - """; - static PassFailJFrame passFailJFrame; - - public static void main(String[] args) throws Exception { - - SwingUtilities.invokeAndWait(() -> { - try { - String message = "" + "This is a test\n" + ""; - JOptionPane optionPane = new JOptionPane(); - optionPane.setMessage(message); - optionPane.setMessageType(JOptionPane.INFORMATION_MESSAGE); - JDialog dialog = new JDialog(); - dialog.setContentPane(optionPane); - dialog.pack(); - dialog.setVisible(true); - - passFailJFrame = new PassFailJFrame(instructions); - PassFailJFrame.addTestWindow(dialog); - PassFailJFrame.positionTestWindow(dialog, PassFailJFrame.Position.HORIZONTAL); - } catch (Exception e) { - e.printStackTrace(); - } - }); - passFailJFrame.awaitAndCheck(); - } -} - diff -Nru openjdk-17-17.0.17+10/test/jdk/javax/swing/JOptionPane/bug4194862.java openjdk-17-17.0.18+8/test/jdk/javax/swing/JOptionPane/bug4194862.java --- openjdk-17-17.0.17+10/test/jdk/javax/swing/JOptionPane/bug4194862.java 1970-01-01 00:00:00.000000000 +0000 +++ openjdk-17-17.0.18+8/test/jdk/javax/swing/JOptionPane/bug4194862.java 2026-01-15 15:23:06.000000000 +0000 @@ -0,0 +1,94 @@ +/* + * 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 + * 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 4194862 + * @summary Tests that internal frame-based dialogs are centered relative + to their parents + * @library /java/awt/regtesthelpers + * @build PassFailJFrame + * @run main/manual bug4194862 + */ + +import javax.swing.JButton; +import javax.swing.JDesktopPane; +import javax.swing.JFrame; +import javax.swing.JInternalFrame; +import javax.swing.JOptionPane; + +public class bug4194862 { + private static final String INSTRUCTIONS = """ + In the internal frame titled "Main", + click the "Show JOptionPane Dialog" button. + A dialog will appear. It should be centered with + respect to the JInternalFrame - "Main". + + If the above is true then click on JOptionPane's "YES" button + to PASS else click JOptionPane's "NO" button to FAIL the test. + """; + + public static void main(String[] args) throws Exception{ + PassFailJFrame.builder() + .title("Instructions") + .instructions(INSTRUCTIONS) + .columns(40) + .testUI(bug4194862::createAndShowUI) + .screenCapture() + .build() + .awaitAndCheck(); + } + + private static JFrame createAndShowUI() { + JFrame frame = new JFrame("bug4194862 - JInternalFrame JOptionPane"); + JDesktopPane desktop = new JDesktopPane(); + frame.add(desktop); + JInternalFrame jInternalFrame = new JInternalFrame("Main", true); + desktop.add(jInternalFrame); + jInternalFrame.setBounds(5, 30, 390, 240); + jInternalFrame.setVisible(true); + + JButton b = new JButton("Show JOptionPane Dialog"); + b.addActionListener(e -> { + int retVal = JOptionPane.showInternalConfirmDialog( + jInternalFrame, "Am I centered?", + "bug4194862 JOptionPane", JOptionPane.YES_NO_OPTION); + switch (retVal) { + case JOptionPane.YES_OPTION -> PassFailJFrame.forcePass(); + case JOptionPane.NO_OPTION -> + PassFailJFrame.forceFail("JOptionPane isn't centered" + + " within JInternalFrame \"Main\""); + } + }); + jInternalFrame.add(b); + + for (int i = 0; i < 4; i++) { + JInternalFrame f = new JInternalFrame("JIF: "+ i); + f.setBounds(i * 50, i * 33, 120, 120); + f.setVisible(true); + desktop.add(f); + } + frame.setSize(450, 400); + return frame; + } +} diff -Nru openjdk-17-17.0.17+10/test/jdk/javax/swing/JPasswordField/PasswordFieldInputMapWordTest.java openjdk-17-17.0.18+8/test/jdk/javax/swing/JPasswordField/PasswordFieldInputMapWordTest.java --- openjdk-17-17.0.17+10/test/jdk/javax/swing/JPasswordField/PasswordFieldInputMapWordTest.java 1970-01-01 00:00:00.000000000 +0000 +++ openjdk-17-17.0.18+8/test/jdk/javax/swing/JPasswordField/PasswordFieldInputMapWordTest.java 2026-01-15 15:23:06.000000000 +0000 @@ -0,0 +1,118 @@ +/* + * 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 + * @key headful + * @bug 8358813 + * @summary Password fields' InputMap should not include any word-related action. + * + * @run main PasswordFieldInputMapWordTest + */ + +import java.util.Collection; +import java.util.Set; + +import javax.swing.InputMap; +import javax.swing.JComponent; +import javax.swing.JPasswordField; +import javax.swing.KeyStroke; +import javax.swing.SwingUtilities; +import javax.swing.UIManager; +import javax.swing.UnsupportedLookAndFeelException; +import javax.swing.text.DefaultEditorKit; + +public class PasswordFieldInputMapWordTest { + public static void main(String[] args) throws Exception { + for (UIManager.LookAndFeelInfo laf : + UIManager.getInstalledLookAndFeels()) { + System.out.println("Testing LAF: " + laf.getClassName()); + SwingUtilities.invokeAndWait(() -> { + if (setLookAndFeel(laf)) { + runTest(); + } + }); + } + } + + private static boolean setLookAndFeel(UIManager.LookAndFeelInfo laf) { + try { + UIManager.setLookAndFeel(laf.getClassName()); + return true; + } catch (UnsupportedLookAndFeelException e) { + System.err.println("Skipping unsupported look and feel:"); + e.printStackTrace(); + return false; + } catch (Exception e) { + throw new RuntimeException(e); + } + } + + static int[] inputMapConditions = new int[] { + JComponent.WHEN_IN_FOCUSED_WINDOW, + JComponent.WHEN_FOCUSED, + JComponent.WHEN_ANCESTOR_OF_FOCUSED_COMPONENT + }; + + /** + * These are all the actions with "word" in their field name. + */ + static Collection wordActions = Set.of( + DefaultEditorKit.deleteNextWordAction, + DefaultEditorKit.deletePrevWordAction, + DefaultEditorKit.beginWordAction, + DefaultEditorKit.endWordAction, + DefaultEditorKit.selectionBeginWordAction, + DefaultEditorKit.selectionEndWordAction, + DefaultEditorKit.previousWordAction, + DefaultEditorKit.nextWordAction, + DefaultEditorKit.selectionPreviousWordAction, + DefaultEditorKit.selectionNextWordAction + ); + + private static void runTest() { + JPasswordField field = new JPasswordField(); + + boolean testPassed = true; + for (int condition : inputMapConditions) { + InputMap inputMap = field.getInputMap(condition); + if (inputMap.allKeys() == null) { + continue; + } + for (KeyStroke keyStroke : inputMap.allKeys()) { + Object actionBinding = inputMap.get(keyStroke); + if (wordActions.contains(actionBinding)) { + if (testPassed) { + System.err.println("The following inputs/actions should not be available in a JPasswordField:"); + } + System.err.println(inputMap.get(keyStroke) + " (try typing " + keyStroke + ")"); + testPassed = false; + } + } + } + + if (!testPassed) { + throw new RuntimeException("One or more input/action binding was observed for a JPasswordField."); + } + } +} diff -Nru openjdk-17-17.0.17+10/test/jdk/javax/swing/JPasswordField/bug4382819.java openjdk-17-17.0.18+8/test/jdk/javax/swing/JPasswordField/bug4382819.java --- openjdk-17-17.0.17+10/test/jdk/javax/swing/JPasswordField/bug4382819.java 1970-01-01 00:00:00.000000000 +0000 +++ openjdk-17-17.0.18+8/test/jdk/javax/swing/JPasswordField/bug4382819.java 2026-01-15 15:23:06.000000000 +0000 @@ -0,0 +1,86 @@ +/* + * 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 + * under the terms of the GNU General Public License version 2 only, as + * published by the Free Software Foundation. + * + * This code is distributed in the hope that it will be useful, but WITHOUT + * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or + * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License + * version 2 for more details (a copy is included in the LICENSE file that + * accompanied this code). + * + * You should have received a copy of the GNU General Public License version + * 2 along with this work; if not, write to the Free Software Foundation, + * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. + * + * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA + * or visit www.oracle.com if you need additional information or have any + * questions. + */ + +import java.awt.FlowLayout; +import java.awt.event.ItemListener; +import javax.swing.JCheckBox; +import javax.swing.JFrame; +import javax.swing.JPasswordField; + +/* + * @test + * @bug 4382819 + * @summary Tests the correctness of color used for the disabled passwordField. + * @library /java/awt/regtesthelpers + * @build PassFailJFrame + * @run main/manual bug4382819 + */ + +public class bug4382819 { + static JCheckBox enabledCheckBox; + static JPasswordField passwordField; + + private static final String INSTRUCTIONS = """ + Clear the "enabled" checkbox. + If the JPasswordField's foreground color changes to + light gray press Pass. If it stays black press Fail. + """; + + public static void main(String[] args) throws Exception { + PassFailJFrame.builder() + .instructions(INSTRUCTIONS) + .columns(50) + .testUI(bug4382819::createTestUI) + .build() + .awaitAndCheck(); + } + + public static JFrame createTestUI() { + JFrame mainFrame = new JFrame("bug4382819"); + enabledCheckBox = new javax.swing.JCheckBox(); + enabledCheckBox.setSelected(true); + enabledCheckBox.setText("enabled"); + enabledCheckBox.setActionCommand("enabled"); + mainFrame.add(enabledCheckBox); + + passwordField = new javax.swing.JPasswordField(); + passwordField.setText("blahblahblah"); + mainFrame.add(passwordField); + SymItem lSymItem = new SymItem(); + enabledCheckBox.addItemListener(lSymItem); + + mainFrame.setSize(300, 100); + mainFrame.setLayout(new FlowLayout(FlowLayout.CENTER, 5, 5)); + return mainFrame; + } + + static class SymItem implements ItemListener { + public void itemStateChanged(java.awt.event.ItemEvent event) { + Object object = event.getSource(); + if (object == enabledCheckBox) { + passwordField.setEnabled(enabledCheckBox.isSelected()); + } + } + } +} + diff -Nru openjdk-17-17.0.17+10/test/jdk/javax/swing/JPopupMenu/bug4119993.java openjdk-17-17.0.18+8/test/jdk/javax/swing/JPopupMenu/bug4119993.java --- openjdk-17-17.0.17+10/test/jdk/javax/swing/JPopupMenu/bug4119993.java 1970-01-01 00:00:00.000000000 +0000 +++ openjdk-17-17.0.18+8/test/jdk/javax/swing/JPopupMenu/bug4119993.java 2026-01-15 15:23:06.000000000 +0000 @@ -0,0 +1,112 @@ +/* + * Copyright (c) 1999, 2025, Oracle and/or its affiliates. All rights reserved. + * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. + * + * This code is free software; you can redistribute 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 4119993 + * @library /java/awt/regtesthelpers + * @build PassFailJFrame + * @summary Check that mouse button 3 is reserved for popup invocation not selection. + * @run main/manual bug4119993 + */ + +import java.awt.BorderLayout; +import java.awt.Dimension; +import javax.swing.BoxLayout; +import javax.swing.JFrame; +import javax.swing.JLabel; +import javax.swing.JList; +import javax.swing.JPanel; +import javax.swing.JScrollPane; +import javax.swing.JTable; +import javax.swing.JTextArea; +import javax.swing.border.BevelBorder; + +/* + * This is a sort of negative test. Mouse Button 3 is not supposed to cause selections. + * If it did, then it would not be useable to invoke popup menus. + * So this popup menu test .. does not popup menus. + */ + +public class bug4119993 { + + static final String INSTRUCTIONS = """ + + The test window contains a text area, a table, and a list. +

+ For each component, try to select text/cells/rows/items as appropriate + using the RIGHT mouse button (Mouse Button 3). +

+ If the selection changes, then press FAIL. +

+ If the selection does not change, press PASS + """; + + public static void main(String[] args) throws Exception { + PassFailJFrame.builder() + .instructions(INSTRUCTIONS) + .columns(60) + .testUI(bug4119993::createUI) + .build() + .awaitAndCheck(); + } + + static JFrame createUI() { + JFrame frame = new JFrame("bug4119993"); + JPanel p = new JPanel(); + p.setLayout(new BoxLayout(p, BoxLayout.Y_AXIS)); + frame.add(p); + + String text = "This is some text that you should try to select using the right mouse button"; + JTextArea area = new JTextArea(text, 5, 40); + JScrollPane scrollpane0 = new JScrollPane(area); + scrollpane0.setBorder(new BevelBorder(BevelBorder.LOWERED)); + scrollpane0.setPreferredSize(new Dimension(430, 200)); + p.add(scrollpane0); + + String[][] data = new String[5][5]; + String[] cols = new String[5]; + for (int r = 0; r < 5; r ++) { + cols[r] = "col " + r; + for (int c = 0; c < 5; c ++) { + data[r][c] = "(" + r + "," + c + ")"; + } + } + + JTable tableView = new JTable(data, cols); + JScrollPane scrollpane = new JScrollPane(tableView); + scrollpane.setBorder(new BevelBorder(BevelBorder.LOWERED)); + scrollpane.setPreferredSize(new Dimension(430, 200)); + p.add(scrollpane); + + String[] s = {"1", "2", "3", "4", "5", "6", "7", "8", "9", "10"}; + JList listView = new JList(s); + JScrollPane scrollpane2 = new JScrollPane(listView); + scrollpane2.setBorder(new BevelBorder(BevelBorder.LOWERED)); + scrollpane2.setPreferredSize(new Dimension(430, 200)); + p.add(scrollpane2); + + frame.pack(); + return frame; + } +} diff -Nru openjdk-17-17.0.17+10/test/jdk/javax/swing/JPopupMenu/bug4187004.java openjdk-17-17.0.18+8/test/jdk/javax/swing/JPopupMenu/bug4187004.java --- openjdk-17-17.0.17+10/test/jdk/javax/swing/JPopupMenu/bug4187004.java 1970-01-01 00:00:00.000000000 +0000 +++ openjdk-17-17.0.18+8/test/jdk/javax/swing/JPopupMenu/bug4187004.java 2026-01-15 15:23:06.000000000 +0000 @@ -0,0 +1,97 @@ +/* + * Copyright (c) 1999, 2025, Oracle and/or its affiliates. All rights reserved. + * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. + * + * This code is free software; you can redistribute 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 4187004 + @summary test that title/label is show on menu for Motif L&F + @key headful +*/ + +import java.awt.Dimension; +import java.awt.Robot; +import javax.swing.JFrame; +import javax.swing.JPopupMenu; +import javax.swing.SwingUtilities; +import javax.swing.UIManager; + +public class bug4187004 { + + static volatile JPopupMenu m; + static volatile Dimension d1, d2; + + public static void main(String[] args) throws Exception { + try { + SwingUtilities.invokeAndWait(bug4187004::createUI); + + Robot robot = new Robot(); + robot.waitForIdle(); + robot.delay(1000); + d1 = m.getSize(); + SwingUtilities.invokeAndWait(bug4187004::hideMenu); + robot.waitForIdle(); + robot.delay(1000); + SwingUtilities.invokeAndWait(bug4187004::updateUI); + robot.waitForIdle(); + robot.delay(1000); + SwingUtilities.invokeAndWait(bug4187004::showMenu); + robot.waitForIdle(); + robot.delay(1000); + d2 = m.getSize(); + } finally { + SwingUtilities.invokeAndWait(bug4187004::hideMenu); + } + System.out.println(d1); + System.out.println(d2); + if (d1.width <= d2.width) { + throw new RuntimeException("Menu not updated"); + } + } + + static void createUI() { + try { + UIManager.setLookAndFeel("com.sun.java.swing.plaf.motif.MotifLookAndFeel"); + } catch (Exception e) { + throw new RuntimeException(e); + } + m = new JPopupMenu("One really long menu title"); + m.add("Item 1"); + m.add("Item 2"); + m.add("Item 3"); + m.add("Item 4"); + m.pack(); + m.setVisible(true); + } + + static void hideMenu() { + m.setVisible(false); + } + + static void showMenu() { + m.setVisible(true); + } + + static void updateUI() { + m.setLabel("short"); + m.pack(); + } +} diff -Nru openjdk-17-17.0.17+10/test/jdk/javax/swing/JPopupMenu/bug4188832.java openjdk-17-17.0.18+8/test/jdk/javax/swing/JPopupMenu/bug4188832.java --- openjdk-17-17.0.17+10/test/jdk/javax/swing/JPopupMenu/bug4188832.java 1970-01-01 00:00:00.000000000 +0000 +++ openjdk-17-17.0.18+8/test/jdk/javax/swing/JPopupMenu/bug4188832.java 2026-01-15 15:23:06.000000000 +0000 @@ -0,0 +1,82 @@ +/* + * Copyright (c) 1999, 2025, Oracle and/or its affiliates. All rights reserved. + * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. + * + * This code is free software; you can redistribute it and/or modify it + * under the terms of the GNU General Public License version 2 only, as + * published by the Free Software Foundation. + * + * This code is distributed in the hope that it will be useful, but WITHOUT + * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or + * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License + * version 2 for more details (a copy is included in the LICENSE file that + * accompanied this code). + * + * You should have received a copy of the GNU General Public License version + * 2 along with this work; if not, write to the Free Software Foundation, + * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. + * + * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA + * or visit www.oracle.com if you need additional information or have any + * questions. + */ + +/* @test + * @summary Test that medium weight submenus are not hidden by a heavyweight canvas. + * @bug 4188832 + * @library /java/awt/regtesthelpers + * @build PassFailJFrame + * @run main/manual bug4188832 + */ + +import java.awt.Color; +import java.awt.Panel; +import javax.swing.JFrame; +import javax.swing.JMenu; +import javax.swing.JMenuBar; +import javax.swing.JMenuItem; +import javax.swing.JPopupMenu; + +public class bug4188832 { + + static final String INSTRUCTIONS = """ + Select the File menu, then select the "Save As..." submenu. + If you can see the submenu items displayed, press PASS, else press FAIL + """; + + public static void main(String[] args) throws Exception { + PassFailJFrame.builder() + .instructions(INSTRUCTIONS) + .columns(40) + .testUI(bug4188832::createUI) + .build() + .awaitAndCheck(); + } + + static JFrame createUI() { + // for Medium Weight menus + JPopupMenu.setDefaultLightWeightPopupEnabled(false); + JFrame frame = new JFrame("bug4188832"); + + // Create the menus + JMenuBar menuBar = new JMenuBar(); + JMenu fileMenu = new JMenu("File"); + menuBar.add(fileMenu); + fileMenu.add(new JMenuItem("New")); + fileMenu.add(new JMenuItem("Open")); + fileMenu.add(new JMenuItem("Save")); + JMenu sm = new JMenu("Save As..."); + // these guys don't show up + sm.add(new JMenuItem("This")); + sm.add(new JMenuItem("That")); + fileMenu.add(sm); + fileMenu.add(new JMenuItem("Exit")); + frame.setJMenuBar(menuBar); + + Panel field = new Panel(); // a heavyweight container + field.setBackground(Color.blue); + frame.add(field); + frame.setSize(400, 400); + return frame; + } +} diff -Nru openjdk-17-17.0.17+10/test/jdk/javax/swing/JPopupMenu/bug4212464.java openjdk-17-17.0.18+8/test/jdk/javax/swing/JPopupMenu/bug4212464.java --- openjdk-17-17.0.17+10/test/jdk/javax/swing/JPopupMenu/bug4212464.java 1970-01-01 00:00:00.000000000 +0000 +++ openjdk-17-17.0.18+8/test/jdk/javax/swing/JPopupMenu/bug4212464.java 2026-01-15 15:23:06.000000000 +0000 @@ -0,0 +1,142 @@ +/* + * Copyright (c) 1999, 2025, Oracle and/or its affiliates. All rights reserved. + * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. + * + * This code is free software; you can redistribute 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 4212464 + * @library /java/awt/regtesthelpers + * @build PassFailJFrame + * @summary Verify popup menu borders are drawn correctly when switching L&Fs + * @run main/manual bug4212464 + */ + +import java.awt.BorderLayout; +import java.awt.FlowLayout; +import java.awt.Font; +import java.awt.event.ActionEvent; +import java.awt.event.ActionListener; +import java.awt.event.MouseAdapter; +import java.awt.event.MouseEvent; +import javax.swing.JApplet; +import javax.swing.JButton; +import javax.swing.JFrame; +import javax.swing.JLabel; +import javax.swing.JPanel; +import javax.swing.JPopupMenu; +import javax.swing.SwingUtilities; +import javax.swing.UIManager; + +public class bug4212464 extends JFrame implements ActionListener { + + static String strMotif = "Motif"; + static String motifClassName = "com.sun.java.swing.plaf.motif.MotifLookAndFeel"; + + static String strMetal = "Metal"; + static String metalClassName = "javax.swing.plaf.metal.MetalLookAndFeel"; + + static bug4212464 frame; + static JPopupMenu popup; + + static final String INSTRUCTIONS = """ + This test is to see whether popup menu borders behave properly when switching + back and forth between Motif and Metal L&F. The initial L&F is Metal. + + Pressing the mouse button on the label in the center of the test window brings + up a popup menu. + + In order to test, use the labeled buttons to switch the look and feel. + Clicking a button will cause the menu to be hidden. This is OK. Just click the label again. + Switch back and forth and verify that the popup menu border changes consistently + and there is a title for the menu when using Motif L&F (Metal won't have a title). + + Make sure you switch back and forth several times. + If the change is consistent, press PASS otherwise press FAIL. + """; + + public static void main(String[] args) throws Exception { + PassFailJFrame.builder() + .instructions(INSTRUCTIONS) + .columns(50) + .testUI(bug4212464::createUI) + .build() + .awaitAndCheck(); + } + + static JFrame createUI() { + try { + UIManager.setLookAndFeel(metalClassName); // initialize to Metal. + } catch (Exception e) { + throw new RuntimeException(e); + } + frame = new bug4212464("bug4212464"); + popup = new JPopupMenu("Test"); + popup.add("Item 1"); + popup.add("Item 2"); + popup.add("Item 3"); + popup.add("Item 4"); + + JPanel p = new JPanel(); + p.setLayout(new FlowLayout()); + JButton motif = (JButton)p.add(new JButton(strMotif)); + JButton metal = (JButton)p.add(new JButton(strMetal)); + motif.setActionCommand(motifClassName); + metal.setActionCommand(metalClassName); + motif.addActionListener(frame); + metal.addActionListener(frame); + frame.add(BorderLayout.NORTH, p); + + JLabel l = new JLabel("Click any mouse button on this big label"); + l.setFont(new Font(Font.DIALOG, Font.PLAIN, 20)); + l.addMouseListener(new MouseAdapter() { + public void mousePressed(MouseEvent e) { + popup.show(e.getComponent(), e.getX(), e.getY()); + } + }); + frame.add(BorderLayout.CENTER, l); + frame.setSize(500, 400); + return frame; + } + + public bug4212464(String title) { + super(title); + } + + public void actionPerformed(ActionEvent e) { + String str = e.getActionCommand(); + if (str.equals(metalClassName) || str.equals(motifClassName)) { + changeLNF(str); + } else { + System.out.println("ActionEvent: " + str); + } + } + + public void changeLNF(String str) { + System.out.println("Changing LNF to " + str); + try { + UIManager.setLookAndFeel(str); + SwingUtilities.updateComponentTreeUI(frame); + SwingUtilities.updateComponentTreeUI(popup); + } catch (Exception e) { + throw new RuntimeException(e); + } + } +} diff -Nru openjdk-17-17.0.17+10/test/jdk/javax/swing/JPopupMenu/bug4234793.java openjdk-17-17.0.18+8/test/jdk/javax/swing/JPopupMenu/bug4234793.java --- openjdk-17-17.0.17+10/test/jdk/javax/swing/JPopupMenu/bug4234793.java 1970-01-01 00:00:00.000000000 +0000 +++ openjdk-17-17.0.18+8/test/jdk/javax/swing/JPopupMenu/bug4234793.java 2026-01-15 15:23:06.000000000 +0000 @@ -0,0 +1,242 @@ +/* + * Copyright (c) 2002, 2025, Oracle and/or its affiliates. All rights reserved. + * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. + * + * This code is free software; you can redistribute it and/or modify it + * under the terms of the GNU General Public License version 2 only, as + * published by the Free Software Foundation. + * + * This code is distributed in the hope that it will be useful, but WITHOUT + * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or + * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License + * version 2 for more details (a copy is included in the LICENSE file that + * accompanied this code). + * + * You should have received a copy of the GNU General Public License version + * 2 along with this work; if not, write to the Free Software Foundation, + * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. + * + * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA + * or visit www.oracle.com if you need additional information or have any + * questions. + */ + +/* @test + * @bug 4234793 + * @library /java/awt/regtesthelpers + * @build PassFailJFrame + * @summary PopupMenuListener popupMenuCanceled is never called + * @run main/manual bug4234793 + */ + +import java.awt.BorderLayout; +import java.awt.Component; +import java.awt.Dimension; +import java.awt.event.ActionEvent; +import java.awt.event.InputEvent; +import java.awt.event.KeyEvent; +import java.awt.event.MouseAdapter; +import java.awt.event.MouseEvent; + +import javax.swing.AbstractAction; +import javax.swing.JButton; +import javax.swing.JComboBox; +import javax.swing.JFrame; +import javax.swing.JLabel; +import javax.swing.JMenu; +import javax.swing.JMenuBar; +import javax.swing.JMenuItem; +import javax.swing.JPanel; +import javax.swing.JPopupMenu; +import javax.swing.JSeparator; +import javax.swing.KeyStroke; +import javax.swing.event.PopupMenuEvent; +import javax.swing.event.PopupMenuListener; + +/** + * For all 3 components (JPopupMenu, JComboBox, JPopup) when the popup is visible, + * the popupMenuCanceled should be invoked in these two circumstances: + * + * 1. The ESCAPE key is pressed while the popup is open. + * + * 2. The mouse is clicked on another component. + * + */ + +public class bug4234793 extends JFrame implements PopupMenuListener { + + static final String INSTRUCTIONS = """ + The test window will contain several kinds of menus. + + * A menu bar with two menus labeled "1 - First Menu" and "2 - Second Menu" + * A drop down combo box - ie a button which pops up a menu when clicked + * Clicking any where on the background of the window will display a popup menu + + That is 4 menus in total. + + For each case, verify that the menu can be cancelled (hidden) in two ways + 1) Click to display the menu, then to hide it, press the ESCAPE key. + 2) Click to display the menu, then to hide it, LEFT click on the window background. + Note : the popup menu must be displayed using RIGHT click, the others use LEFT click. + + Notice each time you perform a hide/cancel action an appropriate message should + appear in the log area + If this is true for all 8 combinations of menus + hide actions the test PASSES + """; + + public static void main(String[] args) throws Exception { + PassFailJFrame.builder() + .instructions(INSTRUCTIONS) + .columns(60) + .testUI(bug4234793::createUI) + .logArea() + .build() + .awaitAndCheck(); + } + + private static String[] numData = { + "One", "Two", "Three", "Four", "Five", "Six", "Seven" + }; + + private static String[] dayData = { + "Monday", "Tuesday", "Wednesday", "Thursday", "Friday", "Saturday", "Sunday" + }; + + private static char[] mnDayData = { + 'M', 'T', 'W', 'R', 'F', 'S', 'U' + }; + + bug4234793(String title) { + super(title); + } + + static volatile JPopupMenu popupMenu; + static volatile bug4234793 frame; + + static JFrame createUI() { + frame = new bug4234793("bug4234793"); + frame.setJMenuBar(createMenuBar()); + JPanel panel = createContentPane(); + frame.add(panel); + + // CTRL-down will show the popup. + panel.getInputMap().put(KeyStroke.getKeyStroke( + KeyEvent.VK_DOWN, InputEvent.CTRL_MASK), "OPEN_POPUP"); + panel.getActionMap().put("OPEN_POPUP", new PopupHandler()); + panel.addMouseListener(new PopupListener(popupMenu)); + panel.setPreferredSize(new Dimension(400, 300)); + frame.setSize(400, 300); + return frame; + } + + static class PopupListener extends MouseAdapter { + private JPopupMenu popup; + + public PopupListener(JPopupMenu popup) { + this.popup = popup; + } + + public void mousePressed(MouseEvent e) { + maybeShowPopup(e); + } + + public void mouseReleased(MouseEvent e) { + maybeShowPopup(e); + } + + public void mouseClicked(MouseEvent ex) { + } + + private void maybeShowPopup(MouseEvent e) { + if (e.isPopupTrigger()) { + popup.show(e.getComponent(), e.getX(), e.getY()); + } + } + } + + static class PopupHandler extends AbstractAction { + public void actionPerformed(ActionEvent e) { + if (!popupMenu.isVisible()) + popupMenu.show((Component)e.getSource(), 40, 40); + } + } + + static JPanel createContentPane() { + popupMenu = new JPopupMenu(); + JMenuItem item; + for (int i = 0; i < dayData.length; i++) { + item = popupMenu.add(new JMenuItem(dayData[i], mnDayData[i])); + } + popupMenu.addPopupMenuListener(frame); + + JComboBox combo = new JComboBox(numData); + combo.addPopupMenuListener(frame); + JPanel comboPanel = new JPanel(); + comboPanel.add(combo); + + JPanel panel = new JPanel(new BorderLayout()); + + panel.add(new JLabel("Right click on the panel to show the PopupMenu"), BorderLayout.NORTH); + panel.add(comboPanel, BorderLayout.CENTER); + + return panel; + } + + static JMenuBar createMenuBar() { + JMenuBar menubar = new JMenuBar(); + JMenuItem menuitem; + + JMenu menu = new JMenu("1 - First Menu"); + menu.setMnemonic('1'); + menu.getPopupMenu().addPopupMenuListener(frame); + + menubar.add(menu); + for (int i = 0; i < 10; i ++) { + menuitem = new JMenuItem("1 JMenuItem" + i); + menuitem.setMnemonic('0' + i); + menu.add(menuitem); + } + + // second menu + menu = new JMenu("2 - Second Menu"); + menu.getPopupMenu().addPopupMenuListener(frame); + menu.setMnemonic('2'); + + menubar.add(menu); + for (int i = 0; i < 5; i++) { + menuitem = new JMenuItem("2 JMenuItem" + i); + menuitem.setMnemonic('0' + i); + menu.add(menuitem); + } + + JMenu submenu = new JMenu("Sub Menu"); + submenu.setMnemonic('S'); + submenu.getPopupMenu().addPopupMenuListener(frame); + for (int i = 0; i < 5; i++) { + menuitem = new JMenuItem("S JMenuItem" + i); + menuitem.setMnemonic('0' + i); + submenu.add(menuitem); + } + menu.add(new JSeparator()); + menu.add(submenu); + + return menubar; + } + + // PopupMenuListener methods. + + public void popupMenuWillBecomeVisible(PopupMenuEvent e) { + Object source = e.getSource(); + PassFailJFrame.log("popupmenu visible: " + source.getClass().getName()); + } + + public void popupMenuWillBecomeInvisible(PopupMenuEvent e) { + Object source = e.getSource(); + PassFailJFrame.log("popupMenuWillBecomeInvisible: " + source.getClass().getName()); + } + + public void popupMenuCanceled(PopupMenuEvent e) { + Object source = e.getSource(); + PassFailJFrame.log("POPUPMENU CANCELED: " + source.getClass().getName()); + } +} diff -Nru openjdk-17-17.0.17+10/test/jdk/javax/swing/JPopupMenu/bug4530303.java openjdk-17-17.0.18+8/test/jdk/javax/swing/JPopupMenu/bug4530303.java --- openjdk-17-17.0.17+10/test/jdk/javax/swing/JPopupMenu/bug4530303.java 1970-01-01 00:00:00.000000000 +0000 +++ openjdk-17-17.0.18+8/test/jdk/javax/swing/JPopupMenu/bug4530303.java 2026-01-15 15:23:06.000000000 +0000 @@ -0,0 +1,85 @@ +/* + * Copyright (c) 2002, 2025, Oracle and/or its affiliates. All rights reserved. + * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. + * + * This code is free software; you can redistribute it and/or modify it + * under the terms of the GNU General Public License version 2 only, as + * published by the Free Software Foundation. + * + * This code is distributed in the hope that it will be useful, but WITHOUT + * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or + * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License + * version 2 for more details (a copy is included in the LICENSE file that + * accompanied this code). + * + * You should have received a copy of the GNU General Public License version + * 2 along with this work; if not, write to the Free Software Foundation, + * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. + * + * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA + * or visit www.oracle.com if you need additional information or have any + * questions. + */ + +/* @test + * @bug 4530303 + * @library /java/awt/regtesthelpers + * @build PassFailJFrame + * @summary Tests JPopupMenu.pack() + * @run main/manual bug4530303 + */ + +import java.awt.event.MouseAdapter; +import java.awt.event.MouseEvent; +import javax.swing.JFrame; +import javax.swing.JMenu; +import javax.swing.JMenuBar; +import javax.swing.JMenuItem; +import javax.swing.JPopupMenu; + +public class bug4530303 { + + static final String INSTRUCTIONS = """ + The test window has a menu bar. + Open the menu "Menu" and place the mouse pointer over the first menu item, "Point here". + The second menu item, "Ghost", should be replaced with another item, "Fixed!". + If the item just disappears and no new item appears in the empty space, the test FAILS. + """; + + static volatile JMenu menu; + + public static void main(String[] args) throws Exception { + PassFailJFrame.builder() + .instructions(INSTRUCTIONS) + .columns(60) + .testUI(bug4530303::createUI) + .build() + .awaitAndCheck(); + } + + static JFrame createUI() { + JFrame frame = new JFrame("bug4530303"); + menu = new JMenu("Menu"); + JMenuItem item = new JMenuItem("Point here"); + item.addMouseListener(new MenuBuilder()); + menu.add(item); + menu.add(new JMenuItem("Ghost")); + + JMenuBar mbar = new JMenuBar(); + mbar.add(menu); + frame.setJMenuBar(mbar); + frame.setSize(300, 300); + return frame; + } + + static class MenuBuilder extends MouseAdapter { + public void mouseEntered(MouseEvent ev) { + menu.remove(1); + menu.add(new JMenuItem("Fixed!")); + + JPopupMenu pm = menu.getPopupMenu(); + pm.pack(); + pm.paintImmediately(pm.getBounds()); + } + } +} diff -Nru openjdk-17-17.0.17+10/test/jdk/javax/swing/JProgressBar/RightLeftOrientation.java openjdk-17-17.0.18+8/test/jdk/javax/swing/JProgressBar/RightLeftOrientation.java --- openjdk-17-17.0.17+10/test/jdk/javax/swing/JProgressBar/RightLeftOrientation.java 1970-01-01 00:00:00.000000000 +0000 +++ openjdk-17-17.0.18+8/test/jdk/javax/swing/JProgressBar/RightLeftOrientation.java 2026-01-15 15:23:06.000000000 +0000 @@ -0,0 +1,147 @@ +/* + * 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 + * 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 4230355 + * @summary + * This test checks if progress bars lay out correctly when their + * ComponentOrientation property is set to RIGHT_TO_LEFT. This test is + * manual. The tester is asked to compare left-to-right and + * right-to-left progress bars and judge whether they are mirror images + * of each other. + * @library /java/awt/regtesthelpers + * @build PassFailJFrame + * @run main/manual RightLeftOrientation + */ + +import java.awt.ComponentOrientation; +import java.awt.Container; +import javax.swing.BorderFactory; +import javax.swing.Box; +import javax.swing.BoxLayout; +import javax.swing.JFrame; +import javax.swing.JLabel; +import javax.swing.LookAndFeel; +import javax.swing.JPanel; +import javax.swing.JProgressBar; +import javax.swing.UIManager; + +public class RightLeftOrientation { + + static final String INSTRUCTIONS = """ + This test checks progress bars for correct Right-To-Left Component Orientation. + The progress bars in the left column should fill up from the left while the bars in + the right column should fill up from the right. + If this is so, the test PASSES, otherwise it FAILS. + """; + + public static void main(String[] args) throws Exception { + PassFailJFrame.builder() + .title("Progress Bar Orientation Test Instructions") + .instructions(INSTRUCTIONS) + .columns(60) + .testUI(RightLeftOrientation::createUI) + .build() + .awaitAndCheck(); + } + + static JFrame createUI() { + JFrame frame = new JFrame("Progress Bar Orientation Test"); + Container contentPane = frame.getContentPane(); + contentPane.setLayout(new BoxLayout(contentPane, BoxLayout.X_AXIS)); + contentPane.add(createBarSet(ComponentOrientation.LEFT_TO_RIGHT)); + contentPane.add(createBarSet(ComponentOrientation.RIGHT_TO_LEFT)); + frame.pack(); + return frame; + } + + static JPanel createBarSet(ComponentOrientation o) { + JPanel panel = new JPanel(); + panel.setLayout(new BoxLayout(panel, BoxLayout.Y_AXIS)); + panel.setBorder(BorderFactory.createEmptyBorder(20, 20, 20, 20)); + JLabel header; + if (o.isLeftToRight()) + header = new JLabel("Left To Right"); + else + header = new JLabel("Right To Left"); + panel.add(header); + + UIManager.LookAndFeelInfo[] lafs = UIManager.getInstalledLookAndFeels(); + for (int i = 0; i < lafs.length; i++) { + if (i > 0) + panel.add(Box.createVerticalStrut(10)); + panel.add(createProgressBars(lafs[i].getName(), + lafs[i].getClassName(), o)); + } + + return panel; + } + + static JPanel createProgressBars(String name, String plaf, + ComponentOrientation o) { + JPanel panel = new JPanel(); + panel.setLayout(new BoxLayout(panel, BoxLayout.Y_AXIS)); + JLabel label = new JLabel(name); + panel.add(label); + try { + LookAndFeel save = UIManager.getLookAndFeel(); + UIManager.setLookAndFeel(plaf); + + panel.add(createProgressBar(true, 0, o)); + panel.add(Box.createVerticalStrut(5)); + + panel.add(createProgressBar(true, 5, o)); + panel.add(Box.createVerticalStrut(5)); + + panel.add(createProgressBar(true, 10, o)); + panel.add(Box.createVerticalStrut(5)); + + panel.add(createProgressBar(true, 20, o)); + panel.add(Box.createVerticalStrut(5)); + + UIManager.put("ProgressBar.cellSpacing", Integer.valueOf(2)); + UIManager.put("ProgressBar.cellLength", Integer.valueOf(7)); + + panel.add(createProgressBar(false, 5, o)); + panel.add(Box.createVerticalStrut(5)); + + panel.add(createProgressBar(false, 20, o)); + + UIManager.setLookAndFeel(save); + } catch (Exception e) { + System.err.println(e); + } + return panel; + } + + static JProgressBar createProgressBar(boolean paintStr, int value, + ComponentOrientation o) { + JProgressBar p = new JProgressBar(JProgressBar.HORIZONTAL, 0, 20); + p.setStringPainted(paintStr); + p.setValue(value); + p.setComponentOrientation(o); + return p; + } + +} diff -Nru openjdk-17-17.0.17+10/test/jdk/javax/swing/JProgressBar/bug4230391.java openjdk-17-17.0.18+8/test/jdk/javax/swing/JProgressBar/bug4230391.java --- openjdk-17-17.0.17+10/test/jdk/javax/swing/JProgressBar/bug4230391.java 1970-01-01 00:00:00.000000000 +0000 +++ openjdk-17-17.0.18+8/test/jdk/javax/swing/JProgressBar/bug4230391.java 2026-01-15 15:23:06.000000000 +0000 @@ -0,0 +1,139 @@ +/* + * Copyright (c) 1999, 2025, Oracle and/or its affiliates. All rights reserved. + * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. + * + * This code is free software; you can redistribute 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 4230391 + * @summary Tests that JProgressBar draws correctly when Insets are not zero + * @library /java/awt/regtesthelpers + * @build PassFailJFrame + * @run main/manual bug4230391 +*/ + +import java.awt.ComponentOrientation; +import java.awt.Container; +import java.awt.Insets; +import javax.swing.BorderFactory; +import javax.swing.Box; +import javax.swing.BoxLayout; +import javax.swing.JFrame; +import javax.swing.JLabel; +import javax.swing.LookAndFeel; +import javax.swing.JPanel; +import javax.swing.JProgressBar; +import javax.swing.UIManager; + +public class bug4230391 { + + static final String INSTRUCTIONS = """ + Tests that progress bars honor insets in different L&Fs. + Different L&Fs render the progress bar differently, and may or may + not have a different colored background around the progress bar, + and may or may not draw a border around the bar+background. + The progress bars should be of equal width and the progress + rendering line/bar should not extend past/overlap any border. + If it is as described, the test PASSES. + """; + + static class InsetProgressBar extends JProgressBar { + private Insets insets = new Insets(12, 12, 12, 12); + + public InsetProgressBar(boolean horiz, int low, int hi) { + super((horiz)?JProgressBar.HORIZONTAL:JProgressBar.VERTICAL, low, hi); + } + + public Insets getInsets() { + return insets; + } + } + + static JPanel createBarSet() { + JPanel panel = new JPanel(); + panel.setLayout(new BoxLayout(panel, BoxLayout.Y_AXIS)); + panel.setBorder(BorderFactory.createEmptyBorder(20,20,20,20)); + UIManager.LookAndFeelInfo[] lafs = UIManager.getInstalledLookAndFeels(); + for (int i = 0; i < lafs.length; i++) { + if (i > 0) { + panel.add(Box.createVerticalStrut(10)); + } + panel.add(createProgressBars(lafs[i].getName(), lafs[i].getClassName())); + } + return panel; + } + + static JPanel createProgressBars(String name, String plaf) { + JPanel panel = new JPanel(); + panel.setLayout(new BoxLayout(panel, BoxLayout.X_AXIS)); + try { + LookAndFeel save = UIManager.getLookAndFeel(); + UIManager.setLookAndFeel(plaf); + + ComponentOrientation ltr = ComponentOrientation.LEFT_TO_RIGHT; + + Box b = Box.createVerticalBox(); + panel.add(b); + panel.add(Box.createHorizontalStrut(5)); + panel.add(createProgressBar(false, true, ltr)); + UIManager.setLookAndFeel(save); + } catch (Exception e) { + System.err.println(e); + } + return panel; + } + + static JProgressBar createProgressBar(boolean solid, boolean horiz, + ComponentOrientation o) { + if (solid) { + UIManager.put("ProgressBar.cellSpacing", Integer.valueOf(0)); + UIManager.put("ProgressBar.cellLength", Integer.valueOf(1)); + } else { + UIManager.put("ProgressBar.cellSpacing", Integer.valueOf(2)); + UIManager.put("ProgressBar.cellLength", Integer.valueOf(7)); + } + + JProgressBar p = new InsetProgressBar(horiz, 0, 20); + p.setStringPainted(solid); + p.setValue(20); + p.setComponentOrientation(o); + + return p; + } + + static JFrame createUI() { + JFrame frame = new JFrame("Progress Bar Insets Test"); + Container contentPane = frame.getContentPane(); + contentPane.setLayout(new BoxLayout(contentPane, BoxLayout.X_AXIS)); + contentPane.add(createBarSet()); + frame.setSize(400, 300); + return frame; + } + + public static void main(String[] args) throws Exception { + PassFailJFrame.builder() + .title("Progress Bar Insets Test Instructions") + .instructions(INSTRUCTIONS) + .columns(60) + .testUI(bug4230391::createUI) + .build() + .awaitAndCheck(); + } +} diff -Nru openjdk-17-17.0.17+10/test/jdk/javax/swing/JProgressBar/bug4393042.java openjdk-17-17.0.18+8/test/jdk/javax/swing/JProgressBar/bug4393042.java --- openjdk-17-17.0.17+10/test/jdk/javax/swing/JProgressBar/bug4393042.java 1970-01-01 00:00:00.000000000 +0000 +++ openjdk-17-17.0.18+8/test/jdk/javax/swing/JProgressBar/bug4393042.java 2026-01-15 15:23:06.000000000 +0000 @@ -0,0 +1,90 @@ +/* + * Copyright (c) 2001, 2025, Oracle and/or its affiliates. All rights reserved. + * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. + * + * This code is free software; you can redistribute it and/or modify it + * under the terms of the GNU General Public License version 2 only, as + * published by the Free Software Foundation. + * + * This code is distributed in the hope that it will be useful, but WITHOUT + * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or + * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License + * version 2 for more details (a copy is included in the LICENSE file that + * accompanied this code). + * + * You should have received a copy of the GNU General Public License version + * 2 along with this work; if not, write to the Free Software Foundation, + * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. + * + * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA + * or visit www.oracle.com if you need additional information or have any + * questions. + */ + +/* @test + * @bug 4393042 + * @summary JProgressBar should update painting when maximum value is very large + * @key headful + */ + +import java.awt.Graphics; +import javax.swing.JFrame; +import javax.swing.JProgressBar; +import javax.swing.SwingUtilities; +import javax.swing.UIManager; + +public class bug4393042 extends JProgressBar { + + static final int MAXIMUM = Integer.MAX_VALUE - 100; + static volatile int value = 0; + static volatile bug4393042 progressBar; + static JFrame frame; + static volatile int paintCount = 0; + + public void paintComponent(Graphics g) { + super.paintComponent(g); + System.out.println("paint count=" + (++paintCount)); + } + + public bug4393042(int min, int max) { + super(min, max); + } + + public static void main(String[] args) throws Exception { + + UIManager.setLookAndFeel("javax.swing.plaf.metal.MetalLookAndFeel"); + + try { + SwingUtilities.invokeAndWait(bug4393042::createUI); + + value = 0; + for (int i = 0; i <= 10; i++) { + Thread.sleep(1000); + SwingUtilities.invokeAndWait(() -> { + progressBar.setValue(value); + }); + value += MAXIMUM / 10; + } + + } finally { + SwingUtilities.invokeAndWait(() -> { + if (frame != null) { + frame.dispose(); + } + }); + } + if (paintCount < 10 || paintCount > 100) { + throw new RuntimeException("Unexpected paint count : " + paintCount); + } + } + + static void createUI() { + frame = new JFrame("bug4393042"); + progressBar = new bug4393042(0, MAXIMUM); + progressBar.setStringPainted(true); + progressBar.setValue(0); + frame.add(progressBar); + frame.setSize(400, 200); + frame.setVisible(true); + } +} diff -Nru openjdk-17-17.0.17+10/test/jdk/javax/swing/JProgressBar/bug5003022.java openjdk-17-17.0.18+8/test/jdk/javax/swing/JProgressBar/bug5003022.java --- openjdk-17-17.0.17+10/test/jdk/javax/swing/JProgressBar/bug5003022.java 1970-01-01 00:00:00.000000000 +0000 +++ openjdk-17-17.0.18+8/test/jdk/javax/swing/JProgressBar/bug5003022.java 2026-01-15 15:23:06.000000000 +0000 @@ -0,0 +1,82 @@ +/* + * Copyright (c) 2004, 2025, Oracle and/or its affiliates. All rights reserved. + * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. + * + * This code is free software; you can redistribute 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 5003022 + * @summary Test that setting zero value on JProgressBar works in GTK L&F + * @library /java/awt/regtesthelpers + * @build PassFailJFrame + * @run main/manual bug5003022 +*/ + +import java.awt.FlowLayout; +import javax.swing.JFrame; +import javax.swing.JProgressBar; +import javax.swing.UIManager; + +public class bug5003022 { + + static final String INSTRUCTIONS = """ + There are two progress bars, they should display progress strings. + The first progress bar should display 0% and the bar should show no progress color fill. + The second progress bar should display 30% and the bar should show 30% progress color fill. + If it is as described, the test PASSES, otherwise it FAILS. + """; + + public static void main(String[] args) throws Exception { + PassFailJFrame.builder() + .title("bug5003022 Test Instructions") + .instructions(INSTRUCTIONS) + .columns(60) + .testUI(bug5003022::createUI) + .build() + .awaitAndCheck(); + } + + static JFrame createUI() { + try { + /* This will only succeed on Linux, but the test is valid for other platforms and L&Fs */ + UIManager.setLookAndFeel("com.sun.java.swing.plaf.gtk.GTKLookAndFeel"); + } catch (Exception e) { + e.printStackTrace(); + } + + JFrame frame = new JFrame("bug5003022"); + JProgressBar pb1 = new JProgressBar(); + pb1.setValue(0); + pb1.setStringPainted(true); + + JProgressBar pb2 = new JProgressBar(); + pb2.setValue(30); + pb2.setStringPainted(true); + + frame.setLayout(new FlowLayout()); + frame.add(pb1); + frame.add(pb2); + + frame.setSize(300, 300); + return frame; + } + +} diff -Nru openjdk-17-17.0.17+10/test/jdk/javax/swing/JRadioButton/bug4673850.java openjdk-17-17.0.18+8/test/jdk/javax/swing/JRadioButton/bug4673850.java --- openjdk-17-17.0.17+10/test/jdk/javax/swing/JRadioButton/bug4673850.java 1970-01-01 00:00:00.000000000 +0000 +++ openjdk-17-17.0.18+8/test/jdk/javax/swing/JRadioButton/bug4673850.java 2026-01-15 15:23:06.000000000 +0000 @@ -0,0 +1,104 @@ +/* + * Copyright (c) 2004, 2025, Oracle and/or its affiliates. All rights reserved. + * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. + * + * This code is free software; you can redistribute 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 4673850 + * @summary Tests that JRadioButton and JCheckBox checkmarks are painted entirely + * inside circular/rectangle checkboxes for Motif LaF. + * @library /java/awt/regtesthelpers /test/lib + * @build PassFailJFrame jtreg.SkippedException + * @run main/manual bug4673850 + */ + +import java.awt.FlowLayout; +import javax.swing.JCheckBox; +import javax.swing.JFrame; +import javax.swing.JRadioButton; +import javax.swing.SwingConstants; +import javax.swing.UIManager; +import jtreg.SkippedException; + +public class bug4673850 { + private static final String INSTRUCTIONS = """ + + + + + +

This test is for Motif LaF.

+ +

+ When the test starts, you'll see 2 radio buttons and 2 check boxes + with the checkmarks painted.

+ +

+ Ensure that all the button's checkmarks are painted entirely + within the circular/rectangle checkbox, NOT over them or outside them. +

+ + """; + + public static void main(String[] args) throws Exception { + try { + UIManager.setLookAndFeel("com.sun.java.swing.plaf.motif.MotifLookAndFeel"); + } catch (Exception e) { + throw new SkippedException("Unsupported LaF", e); + } + + PassFailJFrame.builder() + .instructions(INSTRUCTIONS) + .rows(10) + .columns(45) + .testUI(createAndShowUI()) + .build() + .awaitAndCheck(); + } + + private static JFrame createAndShowUI() { + JFrame frame = new JFrame("bug4673850"); + frame.setLayout(new FlowLayout()); + + JRadioButton rb = new JRadioButton("RadioButt"); + rb.setSelected(true); + frame.add(rb); + JRadioButton rb2 = new JRadioButton("RadioButt"); + rb2.setHorizontalTextPosition(SwingConstants.LEFT); + rb2.setSelected(true); + frame.add(rb2); + + JCheckBox cb = new JCheckBox("CheckBox"); + cb.setSelected(true); + frame.add(cb); + JCheckBox cb2 = new JCheckBox("CheckBox"); + cb2.setHorizontalTextPosition(SwingConstants.LEFT); + cb2.setSelected(true); + frame.add(cb2); + frame.setSize(200, 150); + return frame; + } +} \ No newline at end of file diff -Nru openjdk-17-17.0.17+10/test/jdk/javax/swing/JRootPane/bug4614623.java openjdk-17-17.0.18+8/test/jdk/javax/swing/JRootPane/bug4614623.java --- openjdk-17-17.0.17+10/test/jdk/javax/swing/JRootPane/bug4614623.java 1970-01-01 00:00:00.000000000 +0000 +++ openjdk-17-17.0.18+8/test/jdk/javax/swing/JRootPane/bug4614623.java 2026-01-15 15:23:06.000000000 +0000 @@ -0,0 +1,84 @@ +/* + * Copyright (c) 2002, 2025, Oracle and/or its affiliates. All rights reserved. + * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. + * + * This code is free software; you can redistribute it and/or modify it + * under the terms of the GNU General Public License version 2 only, as + * published by the Free Software Foundation. + * + * This code is distributed in the hope that it will be useful, but WITHOUT + * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or + * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License + * version 2 for more details (a copy is included in the LICENSE file that + * accompanied this code). + * + * You should have received a copy of the GNU General Public License version + * 2 along with this work; if not, write to the Free Software Foundation, + * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. + * + * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA + * or visit www.oracle.com if you need additional information or have any + * questions. + */ + +/* + * @test + * @bug 4614623 + * @requires (os.family == "windows") + * @summary Tests that w2k mnemonic underlining works when there's no + focus owner + * @library /java/awt/regtesthelpers + * @build PassFailJFrame + * @run main/manual bug4614623 + */ + +import javax.swing.JFrame; +import javax.swing.JMenu; +import javax.swing.JMenuBar; +import javax.swing.UIManager; + +public class bug4614623 { + private static final String INSTRUCTIONS = """ + This test verifies if the short-cut character + (menu mnemonic) is underlined when the ALT key is held down. + + Check if the following is true. + 1) Press Alt key. The letter 'F' (menu mnemonic) of + the "File" menu should now be underlined. + 2) Release the Alt key, the selection background (light grey) + should appear around the "File" menu. Compare "About" menu + with "File" menu to see the light grey selection background. + + If the above is true, press PASS else FAIL. + """; + + public static void main(String[] args) throws Exception { + UIManager.setLookAndFeel("com.sun.java.swing.plaf.windows.WindowsLookAndFeel"); + + PassFailJFrame.builder() + .instructions(INSTRUCTIONS) + .columns(62) + .rows(12) + .testUI(bug4614623::createAndShowUI) + .build() + .awaitAndCheck(); + } + + public static JFrame createAndShowUI() { + JFrame frame = new JFrame("bug4614623 - File menu test"); + JMenuBar menuBar = new JMenuBar(); + + JMenu fileMenu = new JMenu("File"); + fileMenu.setMnemonic('F'); + menuBar.add(fileMenu); + + JMenu about = new JMenu("About"); + menuBar.add(about); + menuBar.setSize(300, 100); + + frame.setJMenuBar(menuBar); + menuBar.requestFocus(); + frame.setSize(300, 200); + return frame; + } +} diff -Nru openjdk-17-17.0.17+10/test/jdk/javax/swing/JSlider/6524424/bug6524424.html openjdk-17-17.0.18+8/test/jdk/javax/swing/JSlider/6524424/bug6524424.html --- openjdk-17-17.0.17+10/test/jdk/javax/swing/JSlider/6524424/bug6524424.html 2025-10-13 07:48:04.000000000 +0000 +++ openjdk-17-17.0.18+8/test/jdk/javax/swing/JSlider/6524424/bug6524424.html 1970-01-01 00:00:00.000000000 +0000 @@ -1,34 +0,0 @@ - - - - - -To test fix follow the next steps: -1. Select a slider (do the next steps for every slider) -2. Check that the next keyboard buttons work correctly: - Up, Down, Left, Right, Page Up, Page Down -3. Press left mouse button on a free space of the slider and check - that thumb moves correctly - - diff -Nru openjdk-17-17.0.17+10/test/jdk/javax/swing/JSlider/6524424/bug6524424.java openjdk-17-17.0.18+8/test/jdk/javax/swing/JSlider/6524424/bug6524424.java --- openjdk-17-17.0.17+10/test/jdk/javax/swing/JSlider/6524424/bug6524424.java 2025-10-13 07:48:04.000000000 +0000 +++ openjdk-17-17.0.18+8/test/jdk/javax/swing/JSlider/6524424/bug6524424.java 1970-01-01 00:00:00.000000000 +0000 @@ -1,101 +0,0 @@ -/* - * Copyright (c) 2008, 2017, Oracle and/or its affiliates. All rights reserved. - * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. - * - * This code is free software; you can redistribute it and/or modify it - * under the terms of the GNU General Public License version 2 only, as - * published by the Free Software Foundation. - * - * This code is distributed in the hope that it will be useful, but WITHOUT - * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or - * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License - * version 2 for more details (a copy is included in the LICENSE file that - * accompanied this code). - * - * You should have received a copy of the GNU General Public License version - * 2 along with this work; if not, write to the Free Software Foundation, - * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. - * - * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA - * or visit www.oracle.com if you need additional information or have any - * questions. - */ - -/* @test - * @bug 6524424 - * @requires (os.family == "windows") - * @summary JSlider Clicking In Tracks Behavior Inconsistent For Different Tick Spacings - * @author Pavel Porvatov - * @modules java.desktop/com.sun.java.swing.plaf.windows - * @run applet/manual=done bug6524424.html - */ - -import java.awt.*; -import javax.swing.*; - -import com.sun.java.swing.plaf.windows.WindowsLookAndFeel; - -public class bug6524424 extends JApplet { - public static void main(String[] args) { - try { - UIManager.setLookAndFeel(new WindowsLookAndFeel()); - } catch (UnsupportedLookAndFeelException e) { - e.printStackTrace(); - - return; - } - - TestPanel panel = new TestPanel(); - - JFrame frame = new JFrame(); - - frame.setContentPane(panel); - frame.setDefaultCloseOperation(JFrame.DISPOSE_ON_CLOSE); - frame.pack(); - frame.setLocationRelativeTo(null); - - frame.setVisible(true); - } - - public void init() { - TestPanel panel = new TestPanel(); - - setContentPane(panel); - } - - private static class TestPanel extends JPanel { - - private TestPanel() { - super(new GridBagLayout()); - - JSlider slider1 = createSlider(1, 2); - JSlider slider2 = createSlider(2, 4); - JSlider slider3 = createSlider(3, 6); - - addComponent(this, slider1); - addComponent(this, slider2); - addComponent(this, slider3); - } - - private JSlider createSlider(int tickMinor, int tickMajor) { - JSlider result = new JSlider(); - - result.setPaintLabels(true); - result.setPaintTicks(true); - result.setSnapToTicks(true); - result.setMinimum(0); - result.setMaximum(12); - result.setMinorTickSpacing(tickMinor); - result.setMajorTickSpacing(tickMajor); - - return result; - } - } - - private static void addComponent(JPanel panel, Component component) { - panel.add(component, new GridBagConstraints(0, - panel.getComponentCount(), 1, 1, - 1, 0, GridBagConstraints.NORTHWEST, GridBagConstraints.HORIZONTAL, - new Insets(0, 0, 0, 0), 0, 0)); - } -} diff -Nru openjdk-17-17.0.17+10/test/jdk/javax/swing/JSlider/bug4186062.java openjdk-17-17.0.18+8/test/jdk/javax/swing/JSlider/bug4186062.java --- openjdk-17-17.0.17+10/test/jdk/javax/swing/JSlider/bug4186062.java 1970-01-01 00:00:00.000000000 +0000 +++ openjdk-17-17.0.18+8/test/jdk/javax/swing/JSlider/bug4186062.java 2026-01-15 15:23:06.000000000 +0000 @@ -0,0 +1,99 @@ +/* + * Copyright (c) 1999, 2025, Oracle and/or its affiliates. All rights reserved. + * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. + * + * This code is free software; you can redistribute 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 4382876 + * @summary Tests if JSlider fires ChangeEvents when thumb is clicked and not moved + * @key headful + * @run main bug4186062 + */ + +import java.awt.Point; +import java.awt.Robot; +import java.awt.event.InputEvent; + +import javax.swing.JFrame; +import javax.swing.JLabel; +import javax.swing.JPanel; +import javax.swing.JSlider; +import javax.swing.SwingUtilities; +import javax.swing.event.ChangeListener; + +public class bug4186062 { + private static JFrame f; + private static JSlider slider; + private static volatile Point loc; + private static volatile int labelNum; + + public static void main(String[] args) throws Exception { + try { + SwingUtilities.invokeAndWait(() -> { + f = new JFrame("JSlider Click Value Test"); + f.setSize(400, 200); + f.setLocationRelativeTo(null); + f.setVisible(true); + JPanel panel = new JPanel(); + slider = new JSlider(); + final JLabel label = new JLabel("0"); + labelNum = 0; + + ChangeListener listener = e -> { + labelNum++; + label.setText("" + labelNum); + }; + slider.addChangeListener(listener); + + panel.add(slider); + panel.add(label); + f.add(panel); + }); + + Robot r = new Robot(); + r.setAutoDelay(100); + r.waitForIdle(); + r.delay(1000); + + SwingUtilities.invokeAndWait(() -> { + loc = slider.getLocationOnScreen(); + loc.setLocation(loc.x + (slider.getWidth() / 2), + loc.y + (slider.getHeight() / 2)); + }); + + r.mouseMove(loc.x, loc.y); + r.mousePress(InputEvent.BUTTON1_DOWN_MASK); + r.mouseRelease(InputEvent.BUTTON1_DOWN_MASK); + + if (labelNum > 0) { + throw new RuntimeException(labelNum + " ChangeEvents fired. " + + "Test failed"); + } + } finally { + SwingUtilities.invokeAndWait(() -> { + if (f != null) { + f.dispose(); + } + }); + } + } +} diff -Nru openjdk-17-17.0.17+10/test/jdk/javax/swing/JSlider/bug4275631.java openjdk-17-17.0.18+8/test/jdk/javax/swing/JSlider/bug4275631.java --- openjdk-17-17.0.17+10/test/jdk/javax/swing/JSlider/bug4275631.java 1970-01-01 00:00:00.000000000 +0000 +++ openjdk-17-17.0.18+8/test/jdk/javax/swing/JSlider/bug4275631.java 2026-01-15 15:23:06.000000000 +0000 @@ -0,0 +1,132 @@ +/* + * Copyright (c) 2001, 2025, Oracle and/or its affiliates. All rights reserved. + * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. + * + * This code is free software; you can redistribute it and/or modify it + * under the terms of the GNU General Public License version 2 only, as + * published by the Free Software Foundation. + * + * This code is distributed in the hope that it will be useful, but WITHOUT + * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or + * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License + * version 2 for more details (a copy is included in the LICENSE file that + * accompanied this code). + * + * You should have received a copy of the GNU General Public License version + * 2 along with this work; if not, write to the Free Software Foundation, + * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. + * + * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA + * or visit www.oracle.com if you need additional information or have any + * questions. + */ + +/* + * @test + * @bug 4275631 + * @summary Tests if vertical JSlider is properly aligned in large container + * @key headful + * @run main bug4275631 + */ + +import java.awt.BorderLayout; +import java.awt.Dimension; +import java.awt.GridBagConstraints; +import java.awt.GridBagLayout; +import java.awt.Point; +import java.awt.Robot; + +import javax.swing.BorderFactory; +import javax.swing.Box; +import javax.swing.JFrame; +import javax.swing.JPanel; +import javax.swing.JSlider; +import javax.swing.SwingUtilities; + +public class bug4275631 { + private static final int OFFSET = 1; + private static JFrame f; + private static JSlider slider1; + private static JSlider slider2; + private static volatile Point loc1; + private static volatile Point loc2; + + public static void main(String[] args) throws Exception { + try { + SwingUtilities.invokeAndWait(() -> { + f = new JFrame("JSlider Alignment Test"); + f.setSize(400, 200); + f.setLocationRelativeTo(null); + + // Create two sliders, verify the alignment on the slider to be + // used in the border layout + slider1 = new JSlider(JSlider.VERTICAL, 0, 99, 50); + slider1.setInverted(true); + slider1.setMajorTickSpacing(10); + slider1.setMinorTickSpacing(1); + slider1.setPaintTicks(true); + slider1.setPaintLabels(true); + slider2 = new JSlider(JSlider.VERTICAL, 0, 99, 50); + slider2.setInverted(true); + slider2.setMajorTickSpacing(10); + slider2.setMinorTickSpacing(1); + slider2.setPaintTicks(true); + slider2.setPaintLabels(true); + + // Try to center the natural way, using a border layout in the "Center" + JPanel borderPanel = new JPanel(); + borderPanel.setLayout(new BorderLayout()); + borderPanel.setBorder(BorderFactory.createTitledBorder("BorderLayout")); + borderPanel.add(slider1, BorderLayout.CENTER); + borderPanel.setPreferredSize(new Dimension(200, 200)); + + // Try to center using GridBagLayout, with glue on left + // and right to squeeze slider into place + JPanel gridBagPanel = new JPanel(new GridBagLayout()); + gridBagPanel.setBorder(BorderFactory.createTitledBorder("GridBagLayout")); + GridBagConstraints c = new GridBagConstraints(); + c.gridx = 1; + c.fill = GridBagConstraints.VERTICAL; + c.weighty = 1.0; + gridBagPanel.add(slider2, c); + c.gridx = 0; + c.fill = GridBagConstraints.BOTH; + c.weighty = 0.0; + gridBagPanel.add(Box.createHorizontalGlue(), c); + c.gridx = 2; + c.fill = GridBagConstraints.BOTH; + gridBagPanel.add(Box.createHorizontalGlue(), c); + gridBagPanel.setPreferredSize(new Dimension(200, 200)); + + f.add(borderPanel, BorderLayout.WEST); + f.add(gridBagPanel, BorderLayout.EAST); + f.setVisible(true); + }); + + Robot r = new Robot(); + r.setAutoDelay(100); + r.waitForIdle(); + r.delay(1000); + + SwingUtilities.invokeAndWait(() -> { + loc1 = slider1.getLocationOnScreen(); + loc1.setLocation(loc1.x + (slider1.getWidth() / 2), + loc1.y + (slider1.getHeight() / 2)); + + loc2 = slider2.getLocationOnScreen(); + loc2.setLocation(loc2.x + (slider2.getWidth() / 2), + loc2.y + (slider2.getHeight() / 2)); + }); + + if (loc1.y > loc2.y + OFFSET || loc1.y < loc2.y - OFFSET) { + throw new RuntimeException("JSlider position is not aligned!"); + } + } finally { + SwingUtilities.invokeAndWait(() -> { + if (f != null) { + f.dispose(); + } + }); + } + } +} diff -Nru openjdk-17-17.0.17+10/test/jdk/javax/swing/JSlider/bug4382876.java openjdk-17-17.0.18+8/test/jdk/javax/swing/JSlider/bug4382876.java --- openjdk-17-17.0.17+10/test/jdk/javax/swing/JSlider/bug4382876.java 1970-01-01 00:00:00.000000000 +0000 +++ openjdk-17-17.0.18+8/test/jdk/javax/swing/JSlider/bug4382876.java 2026-01-15 15:23:06.000000000 +0000 @@ -0,0 +1,110 @@ +/* + * Copyright (c) 2001, 2025, Oracle and/or its affiliates. All rights reserved. + * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. + * + * This code is free software; you can redistribute it and/or modify it + * under the terms of the GNU General Public License version 2 only, as + * published by the Free Software Foundation. + * + * This code is distributed in the hope that it will be useful, but WITHOUT + * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or + * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License + * version 2 for more details (a copy is included in the LICENSE file that + * accompanied this code). + * + * You should have received a copy of the GNU General Public License version + * 2 along with this work; if not, write to the Free Software Foundation, + * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. + * + * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA + * or visit www.oracle.com if you need additional information or have any + * questions. + */ + +/* + * @test + * @bug 4382876 + * @summary Tests how PgUp and PgDn keys work with JSlider + * @key headful + * @run main bug4382876 + */ + +import java.awt.BorderLayout; +import java.awt.ComponentOrientation; +import java.awt.GraphicsConfiguration; +import java.awt.GraphicsEnvironment; +import java.awt.Robot; +import java.awt.event.KeyEvent; +import java.awt.image.BufferedImage; +import java.io.File; +import java.io.IOException; + +import javax.imageio.ImageIO; +import javax.swing.JFrame; +import javax.swing.JSlider; +import javax.swing.SwingUtilities; + +public class bug4382876 { + private static Robot r; + private static JFrame f; + private static JSlider slider; + private static boolean upFail; + private static boolean downFail; + + public static void main(String[] args) throws Exception { + try { + SwingUtilities.invokeAndWait(() -> { + f = new JFrame("JSlider PageUp/Down Test"); + f.setSize(300, 200); + f.setLocationRelativeTo(null); + f.setVisible(true); + slider = new JSlider(-1000, -900, -1000); + slider.setComponentOrientation(ComponentOrientation.LEFT_TO_RIGHT); + slider.putClientProperty("JSlider.isFilled", Boolean.TRUE); + f.add(slider, BorderLayout.CENTER); + }); + + r = new Robot(); + r.setAutoDelay(100); + r.waitForIdle(); + r.delay(1000); + + r.keyPress(KeyEvent.VK_PAGE_UP); + SwingUtilities.invokeAndWait(() -> { + if (slider.getValue() < -1000) { + System.out.println("PAGE_UP VAL: " + slider.getValue()); + upFail = true; + } + }); + if (upFail) { + writeFailImage(); + throw new RuntimeException("Slider value did NOT change with PAGE_UP"); + } + r.keyPress(KeyEvent.VK_PAGE_DOWN); + SwingUtilities.invokeAndWait(() -> { + if (slider.getValue() > -1000) { + System.out.println("PAGE_DOWN VAL: " + slider.getValue()); + downFail = true; + } + }); + if (downFail) { + writeFailImage(); + throw new RuntimeException("Slider value did NOT change with PAGE_DOWN"); + } + } finally { + SwingUtilities.invokeAndWait(() -> { + if (f != null) { + f.dispose(); + } + }); + } + } + + private static void writeFailImage() throws IOException { + GraphicsConfiguration ge = GraphicsEnvironment + .getLocalGraphicsEnvironment().getDefaultScreenDevice() + .getDefaultConfiguration(); + BufferedImage failImage = r.createScreenCapture(ge.getBounds()); + ImageIO.write(failImage, "png", new File("failImage.png")); + } +} diff -Nru openjdk-17-17.0.17+10/test/jdk/javax/swing/JSlider/bug6524424.java openjdk-17-17.0.18+8/test/jdk/javax/swing/JSlider/bug6524424.java --- openjdk-17-17.0.17+10/test/jdk/javax/swing/JSlider/bug6524424.java 1970-01-01 00:00:00.000000000 +0000 +++ openjdk-17-17.0.18+8/test/jdk/javax/swing/JSlider/bug6524424.java 2026-01-15 15:23:06.000000000 +0000 @@ -0,0 +1,120 @@ +/* + * Copyright (c) 2008, 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 6524424 + * @requires (os.family == "windows") + * @summary JSlider clicking in tracks behavior inconsistent for different tick spacings + * @modules java.desktop/com.sun.java.swing.plaf.windows + * @library /java/awt/regtesthelpers + * @build PassFailJFrame + * @run main/manual bug6524424 + */ + +import java.awt.Component; +import java.awt.GridBagConstraints; +import java.awt.GridBagLayout; +import java.awt.Insets; +import javax.swing.JFrame; +import javax.swing.JPanel; +import javax.swing.JSlider; +import javax.swing.SwingUtilities; +import javax.swing.UIManager; +import javax.swing.UnsupportedLookAndFeelException; + +import com.sun.java.swing.plaf.windows.WindowsLookAndFeel; + +public class bug6524424 { + private static final String INSTRUCTIONS = """ + 1. Select a slider (do the next steps for every slider) + 2. Check that the next keyboard buttons work correctly: + Up, Down, Left, Right, Page Up, Page Down + 3. Press left mouse button on a free space of the slider + check if thumb moves correctly + press Pass else press Fail."""; + + public static void main(String[] args) throws Exception { + PassFailJFrame.builder() + .title("Slider Behavior Instructions") + .instructions(INSTRUCTIONS) + .rows(7) + .columns(30) + .testUI(bug6524424::createTestUI) + .build() + .awaitAndCheck(); + } + + private static JFrame createTestUI() { + try { + UIManager.setLookAndFeel(new WindowsLookAndFeel()); + } catch (UnsupportedLookAndFeelException ex) { + PassFailJFrame.forceFail(ex.toString()); + return null; + } + + TestPanel panel = new TestPanel(); + + JFrame frame = new JFrame("bug6524424"); + + frame.setContentPane(panel); + frame.pack(); + return frame; + } + + private static class TestPanel extends JPanel { + + private TestPanel() { + super(new GridBagLayout()); + + JSlider slider1 = createSlider(1, 2); + JSlider slider2 = createSlider(2, 4); + JSlider slider3 = createSlider(3, 6); + + addComponent(this, slider1); + addComponent(this, slider2); + addComponent(this, slider3); + } + + private JSlider createSlider(int tickMinor, int tickMajor) { + JSlider result = new JSlider(); + + result.setPaintLabels(true); + result.setPaintTicks(true); + result.setSnapToTicks(true); + result.setMinimum(0); + result.setMaximum(12); + result.setMinorTickSpacing(tickMinor); + result.setMajorTickSpacing(tickMajor); + + return result; + } + } + + private static void addComponent(JPanel panel, Component component) { + panel.add(component, new GridBagConstraints(0, + panel.getComponentCount(), 1, 1, + 1, 0, GridBagConstraints.NORTHWEST, GridBagConstraints.HORIZONTAL, + new Insets(0, 0, 0, 0), 0, 0)); + } +} diff -Nru openjdk-17-17.0.17+10/test/jdk/javax/swing/JSplitPane/bug4820080.java openjdk-17-17.0.18+8/test/jdk/javax/swing/JSplitPane/bug4820080.java --- openjdk-17-17.0.17+10/test/jdk/javax/swing/JSplitPane/bug4820080.java 1970-01-01 00:00:00.000000000 +0000 +++ openjdk-17-17.0.18+8/test/jdk/javax/swing/JSplitPane/bug4820080.java 2026-01-15 15:23:06.000000000 +0000 @@ -0,0 +1,94 @@ +/* + * Copyright (c) 2003, 2025, Oracle and/or its affiliates. All rights reserved. + * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. + * + * This code is free software; you can redistribute it and/or modify it + * under the terms of the GNU General Public License version 2 only, as + * published by the Free Software Foundation. + * + * This code is distributed in the hope that it will be useful, but WITHOUT + * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or + * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License + * version 2 for more details (a copy is included in the LICENSE file that + * accompanied this code). + * + * You should have received a copy of the GNU General Public License version + * 2 along with this work; if not, write to the Free Software Foundation, + * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. + * + * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA + * or visit www.oracle.com if you need additional information or have any + * questions. + */ + +import java.awt.Color; +import java.awt.Dimension; +import java.awt.Panel; +import javax.swing.Box; +import javax.swing.BoxLayout; +import javax.swing.JFrame; +import javax.swing.JPanel; +import javax.swing.JSeparator; +import javax.swing.JSplitPane; +import javax.swing.UIManager; + +/* + * @test + * @bug 4820080 7175397 + * @summary RFE: Cannot Change the JSplitPane Divider Color while dragging + * @library /java/awt/regtesthelpers + * @build PassFailJFrame + * @run main/manual bug4820080 + */ + +public class bug4820080 { + private static final String INSTRUCTIONS = """ + Drag the dividers of the splitpanes (both top and bottom). If the divider + color is green while dragging then test passes, otherwise test fails. + """; + + public static void main(String[] args) throws Exception { + PassFailJFrame.builder() + .instructions(INSTRUCTIONS) + .columns(50) + .testUI(bug4820080::createTestUI) + .build() + .awaitAndCheck(); + } + + public static JFrame createTestUI() { + JFrame frame = new JFrame("bug4820080"); + UIManager.put("SplitPaneDivider.draggingColor", Color.GREEN); + + Box box = new Box(BoxLayout.Y_AXIS); + frame.add(box); + + JPanel jleft = new JPanel(); + jleft.setBackground(Color.DARK_GRAY); + jleft.setPreferredSize(new Dimension(100, 100)); + JPanel jright = new JPanel(); + jright.setBackground(Color.DARK_GRAY); + jright.setPreferredSize(new Dimension(100, 100)); + + JSplitPane jsp = new JSplitPane(JSplitPane.HORIZONTAL_SPLIT, jleft, jright); + jsp.setContinuousLayout(false); + box.add(jsp); + + box.add(Box.createVerticalStrut(5)); + box.add(new JSeparator()); + box.add(Box.createVerticalStrut(5)); + + Panel left = new Panel(); + left.setBackground(Color.DARK_GRAY); + left.setPreferredSize(new Dimension(100, 100)); + Panel right = new Panel(); + right.setBackground(Color.DARK_GRAY); + right.setPreferredSize(new Dimension(100, 100)); + + JSplitPane sp = new JSplitPane(JSplitPane.HORIZONTAL_SPLIT, left, right); + sp.setContinuousLayout(false); + box.add(sp); + frame.pack(); + return frame; + } +} diff -Nru openjdk-17-17.0.17+10/test/jdk/javax/swing/JTabbedPane/4287208/bug4287208.java openjdk-17-17.0.18+8/test/jdk/javax/swing/JTabbedPane/4287208/bug4287208.java --- openjdk-17-17.0.17+10/test/jdk/javax/swing/JTabbedPane/4287208/bug4287208.java 1970-01-01 00:00:00.000000000 +0000 +++ openjdk-17-17.0.18+8/test/jdk/javax/swing/JTabbedPane/4287208/bug4287208.java 2026-01-15 15:23:06.000000000 +0000 @@ -0,0 +1,90 @@ +/* + * Copyright (c) 2001, 2025, Oracle and/or its affiliates. All rights reserved. + * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. + * + * This code is free software; you can redistribute it and/or modify it + * under the terms of the GNU General Public License version 2 only, as + * published by the Free Software Foundation. + * + * This code is distributed in the hope that it will be useful, but WITHOUT + * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or + * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License + * version 2 for more details (a copy is included in the LICENSE file that + * accompanied this code). + * + * You should have received a copy of the GNU General Public License version + * 2 along with this work; if not, write to the Free Software Foundation, + * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. + * + * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA + * or visit www.oracle.com if you need additional information or have any + * questions. + */ + +/* + * @test + * @bug 4287208 + * @summary Tests if JTabbedPane's setEnabledAt properly renders bounds of Tabs + * @library /java/awt/regtesthelpers + * @build PassFailJFrame + * @run main/manual bug4287208 +*/ + +import java.awt.BorderLayout; +import java.awt.event.ActionEvent; +import java.awt.event.ActionListener; +import javax.swing.ImageIcon; +import javax.swing.JButton; +import javax.swing.JFrame; +import javax.swing.JPanel; +import javax.swing.JTabbedPane; + +public class bug4287208 implements ActionListener { + + static final String INSTRUCTIONS = """ + There are two tabs in the test window. Press the "Test" button 5 times. + If this causes tabs to overlap at any time, the test FAILS, otherwise + the test PASSES. + """; + + static boolean state = true; + static JTabbedPane jtp; + + public static void main(String[] args) throws Exception { + PassFailJFrame.builder() + .title("bug4287208 Test Instructions") + .instructions(INSTRUCTIONS) + .columns(40) + .testUI(bug4287208::createUI) + .build() + .awaitAndCheck(); + } + + static JFrame createUI() { + JFrame frame = new JFrame("bug4287208"); + + JButton start = new JButton("Test"); + start.addActionListener(new bug4287208()); + JPanel buttonPanel = new JPanel(); + buttonPanel.add(start); + frame.add(buttonPanel,BorderLayout.SOUTH); + + jtp = new JTabbedPane(); + jtp.addTab("Panel One", new JPanel()); + String s = System.getProperty("test.src",".") + + System.getProperty("file.separator") + "duke.gif"; + ImageIcon ii = new ImageIcon(s); + jtp.addTab("Panel Two", ii, new JPanel()); + + frame.add(jtp, BorderLayout.CENTER); + frame.setSize(500, 300); + return frame; + } + + public void actionPerformed(ActionEvent evt) { + jtp.setEnabledAt(0, state); + jtp.setEnabledAt(1, !state); + state = !state; + } + +} Binary files /srv/release.debian.org/tmp/uPhuv2pZsD/openjdk-17-17.0.17+10/test/jdk/javax/swing/JTabbedPane/4287208/duke.gif and /srv/release.debian.org/tmp/x_MuUtmaH2/openjdk-17-17.0.18+8/test/jdk/javax/swing/JTabbedPane/4287208/duke.gif differ diff -Nru openjdk-17-17.0.17+10/test/jdk/javax/swing/JTabbedPane/bug4273320.java openjdk-17-17.0.18+8/test/jdk/javax/swing/JTabbedPane/bug4273320.java --- openjdk-17-17.0.17+10/test/jdk/javax/swing/JTabbedPane/bug4273320.java 1970-01-01 00:00:00.000000000 +0000 +++ openjdk-17-17.0.18+8/test/jdk/javax/swing/JTabbedPane/bug4273320.java 2026-01-15 15:23:06.000000000 +0000 @@ -0,0 +1,90 @@ +/* + * 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 + * 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 4273320 + * @summary JTabbedPane.setTitleAt() should refresh when using HTML text + * @key headful +*/ + +import java.awt.BorderLayout; +import java.awt.Rectangle; +import java.awt.Robot; +import javax.swing.JFrame; +import javax.swing.JPanel; +import javax.swing.JTabbedPane; +import javax.swing.SwingUtilities; +import javax.swing.plaf.TabbedPaneUI; + +public class bug4273320 { + + static JFrame frame; + static volatile JTabbedPane tabs; + + static final String PLAIN = "Plain"; + static final String HTML = "A fairly long HTML text label"; + + public static void main(String[] args) throws Exception { + try { + SwingUtilities.invokeAndWait(bug4273320::createUI); + + Robot robot = new Robot(); + robot.waitForIdle(); + robot.delay(1000); + + TabbedPaneUI ui = tabs.getUI(); + Rectangle origSize = ui.getTabBounds(tabs, 0); + + SwingUtilities.invokeAndWait(() -> { + tabs.setTitleAt(0, HTML); + }); + robot.waitForIdle(); + robot.delay(1000); + + Rectangle newSize = ui.getTabBounds(tabs, 0); + // The tab should be resized larger if the longer HTML text is added + System.out.println("orig = " + origSize.width + " x " + origSize.height); + System.out.println("new = " + newSize.width + " x " + newSize.height); + if (origSize.width >= newSize.width) { + throw new RuntimeException("Tab text is not updated."); + } + } finally { + SwingUtilities.invokeAndWait(() -> { + if (frame != null) { + frame.dispose(); + } + }); + } + } + + static void createUI() { + frame = new JFrame("bug4273320"); + tabs = new JTabbedPane(); + JPanel panel = new JPanel(); + tabs.addTab(PLAIN, panel); + frame.getContentPane().add(tabs, BorderLayout.CENTER); + frame.setSize(500, 300); + frame.setVisible(true); + } +} diff -Nru openjdk-17-17.0.17+10/test/jdk/javax/swing/JTabbedPane/bug4287268.java openjdk-17-17.0.18+8/test/jdk/javax/swing/JTabbedPane/bug4287268.java --- openjdk-17-17.0.17+10/test/jdk/javax/swing/JTabbedPane/bug4287268.java 1970-01-01 00:00:00.000000000 +0000 +++ openjdk-17-17.0.18+8/test/jdk/javax/swing/JTabbedPane/bug4287268.java 2026-01-15 15:23:06.000000000 +0000 @@ -0,0 +1,102 @@ +/* + * 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 + * 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 4287268 + * @summary Tests if setIconAt(index,Icon) does not set Tab's disabled icon + * @key headful +*/ + +import java.awt.BorderLayout; +import java.awt.Color; +import java.awt.Graphics; +import java.awt.Point; +import java.awt.Rectangle; +import java.awt.Robot; +import java.awt.image.BufferedImage; +import javax.swing.ImageIcon; +import javax.swing.JFrame; +import javax.swing.JPanel; +import javax.swing.JTabbedPane; +import javax.swing.SwingUtilities; + +public class bug4287268 { + + static JFrame frame; + static volatile JTabbedPane jtp; + + public static void main(String[] args) throws Exception { + try { + SwingUtilities.invokeAndWait(bug4287268::createUI); + + Robot robot = new Robot(); + robot.waitForIdle(); + robot.delay(1000); + + Point point = jtp.getLocationOnScreen(); + int width = jtp.getWidth(); + int height = jtp.getHeight(); + Rectangle r = new Rectangle(point.x, point.y, width, height); + BufferedImage cap = robot.createScreenCapture(r); + + int red = Color.red.getRGB(); + for (int x = 0; x < cap.getWidth(); x++) { + for (int y = 0; y < cap.getHeight(); y++) { + int rgb = cap.getRGB(x, y); + if (rgb == red) { + try { + javax.imageio.ImageIO.write(cap, "png", new java.io.File("cap.png")); + } catch (Exception ee) { + } + throw new RuntimeException("Test failed : found red"); + } + } + } + } finally { + SwingUtilities.invokeAndWait(() -> { + if (frame != null) { + frame.dispose(); + } + }); + } + } + + static void createUI() { + frame = new JFrame("bug4287268"); + jtp = new JTabbedPane(); + JPanel panel = new JPanel(); + jtp.add("Panel One", panel); + int size = 64; + BufferedImage img = new BufferedImage(size, size, BufferedImage.TYPE_INT_RGB); + Graphics g = img.createGraphics(); + g.setColor(Color.red); + g.fillRect(0, 0, size, size); + ImageIcon ii = new ImageIcon(img); + jtp.setIconAt(0, ii); + jtp.setEnabledAt(0, false); + frame.getContentPane().add(jtp, BorderLayout.CENTER); + frame.pack(); + frame.setVisible(true); + } +} diff -Nru openjdk-17-17.0.17+10/test/jdk/javax/swing/JTabbedPane/bug4362226.java openjdk-17-17.0.18+8/test/jdk/javax/swing/JTabbedPane/bug4362226.java --- openjdk-17-17.0.17+10/test/jdk/javax/swing/JTabbedPane/bug4362226.java 1970-01-01 00:00:00.000000000 +0000 +++ openjdk-17-17.0.18+8/test/jdk/javax/swing/JTabbedPane/bug4362226.java 2026-01-15 15:23:06.000000000 +0000 @@ -0,0 +1,76 @@ +/* + * 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 + * 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 4362226 + * @summary JTabbedPane's HTML title should have proper offsets + * @library /java/awt/regtesthelpers + * @build PassFailJFrame + * @run main/manual bug4362226 +*/ + +import java.awt.BorderLayout; +import javax.swing.JFrame; +import javax.swing.JPanel; +import javax.swing.JTabbedPane; +import javax.swing.UIManager; +import javax.swing.plaf.metal.MetalLookAndFeel; + +public class bug4362226 { + + static final String PLAIN = "Label"; + static final String HTML = "Label"; + + static final String INSTRUCTIONS = """ + The test window contains a JTabbedPane with two tabs. + The titles for both tabs should look similar and drawn with the same fonts. + The text of the tabs should start in a position that is offset from the left + boundary of the tab, so there is clear space between them. + If there is no space, then the test FAILS. + """; + + public static void main(String[] args) throws Exception { + PassFailJFrame.builder() + .title("bug4362226 Test Instructions") + .instructions(INSTRUCTIONS) + .columns(60) + .testUI(bug4362226::createUI) + .build() + .awaitAndCheck(); + } + + static JFrame createUI() { + try { + UIManager.setLookAndFeel(new MetalLookAndFeel()); + } catch (Exception e) { + } + JFrame frame = new JFrame("bug4362226"); + JTabbedPane tabs = new JTabbedPane(); + tabs.addTab(PLAIN, new JPanel()); + tabs.addTab(HTML, new JPanel()); + frame.add(tabs, BorderLayout.CENTER); + frame.setSize(500, 300); + return frame; + } +} diff -Nru openjdk-17-17.0.17+10/test/jdk/javax/swing/JTabbedPane/bug4499556.java openjdk-17-17.0.18+8/test/jdk/javax/swing/JTabbedPane/bug4499556.java --- openjdk-17-17.0.17+10/test/jdk/javax/swing/JTabbedPane/bug4499556.java 2025-10-13 07:48:04.000000000 +0000 +++ openjdk-17-17.0.18+8/test/jdk/javax/swing/JTabbedPane/bug4499556.java 2026-01-15 15:23:06.000000000 +0000 @@ -89,9 +89,10 @@ } static volatile JTabbedPane pane; + static volatile JFrame frame; static JFrame createUI() { - JFrame frame = new JFrame("bug4499556"); + frame = new JFrame("bug4499556"); pane = getTabbedPane(); frame.add(pane); frame.add(getRightPanel(), BorderLayout.EAST); @@ -262,7 +263,7 @@ e.printStackTrace(); return false; } - SwingUtilities.updateComponentTreeUI(pane); + SwingUtilities.updateComponentTreeUI(frame); return true; } diff -Nru openjdk-17-17.0.17+10/test/jdk/javax/swing/JTabbedPane/bug4613811.java openjdk-17-17.0.18+8/test/jdk/javax/swing/JTabbedPane/bug4613811.java --- openjdk-17-17.0.17+10/test/jdk/javax/swing/JTabbedPane/bug4613811.java 1970-01-01 00:00:00.000000000 +0000 +++ openjdk-17-17.0.18+8/test/jdk/javax/swing/JTabbedPane/bug4613811.java 2026-01-15 15:23:06.000000000 +0000 @@ -0,0 +1,82 @@ +/* + * Copyright (c) 2003, 2025, Oracle and/or its affiliates. All rights reserved. + * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. + * + * This code is free software; you can redistribute 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 4613811 + * @summary Scrollable Buttons of JTabbedPane don't + * get enabled or disabled on selecting tab + * @library /java/awt/regtesthelpers + * @build PassFailJFrame + * @run main/manual bug4613811 + */ + +import java.awt.BorderLayout; +import javax.swing.JFrame; +import javax.swing.JLabel; +import javax.swing.JTabbedPane; + +public class bug4613811 { + private static final String INSTRUCTIONS = """ + Select different tabs and check that the scrollable + buttons are correctly enabled and disabled. + + When the very first tab (Tab 1) is fully visible + On macOS: + the left arrow button should NOT be visible. + + On other platforms: + the left arrow button should be disabled. + + If the last tab (Tab 5) is fully visible + On macOS: + the right arrow button should NOT be visible. + + On other platforms: + the right arrow button should be disabled. + + If the above is true press PASS else FAIL. + """; + + public static void main(String[] args) throws Exception { + PassFailJFrame.builder() + .instructions(INSTRUCTIONS) + .columns(30) + .testUI(bug4613811::createAndShowUI) + .build() + .awaitAndCheck(); + } + + private static JFrame createAndShowUI() { + JFrame frame = new JFrame("bug4613811 - JTabbedPane Test"); + final JTabbedPane tabPane = new JTabbedPane(JTabbedPane.TOP, + JTabbedPane.SCROLL_TAB_LAYOUT); + for (int i = 1; i <= 5; i++) { + tabPane.addTab("TabbedPane: Tab " + i, null, new JLabel("Tab " + i)); + } + frame.add(tabPane, BorderLayout.CENTER); + frame.setResizable(false); + frame.setSize(400, 200); + return frame; + } +} diff -Nru openjdk-17-17.0.17+10/test/jdk/javax/swing/JTabbedPane/bug4668865.java openjdk-17-17.0.18+8/test/jdk/javax/swing/JTabbedPane/bug4668865.java --- openjdk-17-17.0.17+10/test/jdk/javax/swing/JTabbedPane/bug4668865.java 1970-01-01 00:00:00.000000000 +0000 +++ openjdk-17-17.0.18+8/test/jdk/javax/swing/JTabbedPane/bug4668865.java 2026-01-15 15:23:06.000000000 +0000 @@ -0,0 +1,112 @@ +/* + * Copyright (c) 2003, 2025, Oracle and/or its affiliates. All rights reserved. + * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. + * + * This code is free software; you can redistribute 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 4668865 + * @summary Tests if JTabbedPane's setEnabledAt properly renders bounds of Tabs + * @library /java/awt/regtesthelpers + * @build PassFailJFrame + * @run main/manual bug4668865 +*/ + +import java.awt.BorderLayout; +import java.awt.event.ActionEvent; +import javax.swing.AbstractAction; +import javax.swing.JButton; +import javax.swing.JFrame; +import javax.swing.JTabbedPane; +import javax.swing.JTextField; + +public class bug4668865 { + + static final String INSTRUCTIONS = """ + This tests that tooltips are shown for all tabs in all orientations, + when it is necessary to scroll to see all the tabs. + Use the buttons to select each orientation (top/bottom/left/right) in turn. + Scroll through the 8 tabs - using the navigation arrows as needed. + Move the mouse over each tab in turn and verify that the matching tooltip is shown + after sufficient hover time. + The test PASSES if the tooltips are shown for all cases, and FAILS otherwise. + """; + + static JTabbedPane tabPane; + + public static void main(String[] args) throws Exception { + PassFailJFrame.builder() + .title("bug4668865 Test Instructions") + .instructions(INSTRUCTIONS) + .columns(50) + .testUI(bug4668865::createUI) + .build() + .awaitAndCheck(); + } + + static JFrame createUI() { + JFrame frame = new JFrame("bug4668865"); + + tabPane = new JTabbedPane(JTabbedPane.TOP, JTabbedPane.SCROLL_TAB_LAYOUT); + for(int i = 1; i < 9; i++) { + tabPane.addTab("Tab" + i, null, new JTextField("Tab" + i), "Tab" + i); + } + frame.add(tabPane, BorderLayout.CENTER); + + JButton top = new JButton(new AbstractAction() { + public void actionPerformed(ActionEvent e) { + tabPane.setTabPlacement(JTabbedPane.TOP); + } + }); + top.setText("Top"); + frame.add(top, BorderLayout.NORTH); + + JButton bottom = new JButton(new AbstractAction() { + public void actionPerformed(ActionEvent e) { + tabPane.setTabPlacement(JTabbedPane.BOTTOM); + } + }); + bottom.setText("Bottom"); + frame.add(bottom, BorderLayout.SOUTH); + + JButton left = new JButton(new AbstractAction() { + public void actionPerformed(ActionEvent e) { + tabPane.setTabPlacement(JTabbedPane.LEFT); + } + }); + + left.setText("Left"); + frame.add(left, BorderLayout.WEST); + + JButton right = new JButton(new AbstractAction() { + public void actionPerformed(ActionEvent e) { + tabPane.setTabPlacement(JTabbedPane.RIGHT); + } + }); + + right.setText("Right"); + frame.add(right, BorderLayout.EAST); + + frame.setSize(400, 400); + return frame; + } + +} diff -Nru openjdk-17-17.0.17+10/test/jdk/javax/swing/JTable/8236907/LastVisibleRow.java openjdk-17-17.0.18+8/test/jdk/javax/swing/JTable/8236907/LastVisibleRow.java --- openjdk-17-17.0.17+10/test/jdk/javax/swing/JTable/8236907/LastVisibleRow.java 1970-01-01 00:00:00.000000000 +0000 +++ openjdk-17-17.0.18+8/test/jdk/javax/swing/JTable/8236907/LastVisibleRow.java 2026-01-15 15:23:06.000000000 +0000 @@ -0,0 +1,221 @@ +/* + * Copyright (c) 2022, Oracle and/or its affiliates. All rights reserved. + * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. + * + * This code is free software; you can redistribute it and/or modify it + * under the terms of the GNU General Public License version 2 only, as + * published by the Free Software Foundation. + * + * This code is distributed in the hope that it will be useful, but WITHOUT + * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or + * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License + * version 2 for more details (a copy is included in the LICENSE file that + * accompanied this code). + * + * You should have received a copy of the GNU General Public License version + * 2 along with this work; if not, write to the Free Software Foundation, + * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. + * + * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA + * or visit www.oracle.com if you need additional information or have any + * questions. + */ +/* + * @test + * @key headful + * @bug 8236907 + * @summary Verifies if JTable last row is visible. + * @run main LastVisibleRow + */ + +import java.awt.BorderLayout; +import java.awt.Container; +import java.awt.Dimension; +import java.awt.event.InputEvent; +import java.awt.image.BufferedImage; +import java.awt.Point; +import java.awt.Rectangle; +import java.awt.Robot; +import java.lang.reflect.InvocationTargetException; + +import javax.print.attribute.HashPrintRequestAttributeSet; +import javax.print.attribute.PrintRequestAttributeSet; + +import javax.swing.BorderFactory; +import javax.swing.JFrame; +import javax.swing.JPanel; +import javax.swing.JTable; +import javax.swing.SwingUtilities; +import javax.swing.WindowConstants; + +public class LastVisibleRow { + static JFrame frame; + static JTable table; + static Robot testRobot; + + public static void main(String[] args) throws Exception { + Point clkPoint; + try { + testRobot = new Robot(); + + SwingUtilities.invokeAndWait(new Runnable() { + + public void run() { + createAndShowGUI(); + } + }); + testRobot.delay(1000); + testRobot.waitForIdle(); + BufferedImage bufferedImageBefore = testRobot.createScreenCapture(getCaptureRect()); + testRobot.delay(1000); + testRobot.waitForIdle(); + clkPoint = getMousePosition(); + mouseEvents(clkPoint); + testRobot.waitForIdle(); + clearSelect(); + testRobot.waitForIdle(); + BufferedImage bufferedImageAfter = testRobot.createScreenCapture(getCaptureRect()); + testRobot.delay(1000); + + if (!compare(bufferedImageBefore, bufferedImageAfter)) { + throw new RuntimeException("Test Case Failed!!"); + } + } finally { + if (frame != null) SwingUtilities.invokeAndWait(() -> frame.dispose()); + } + } + + /* + * + * Get clickable screen point for particular row and column of a table + * param row Row Number + * param column Column Number + * return Point + */ + private static Point getCellClickPoint(final int row, final int column) { + Point result; + + Rectangle rect = table.getCellRect(row, column, false); + Point point = new Point(rect.x + rect.width / 2, + rect.y + rect.height / 2); + SwingUtilities.convertPointToScreen(point, table); + result = point; + + return result; + } + + private static void createAndShowGUI() { + final PrintRequestAttributeSet printReqAttr = new HashPrintRequestAttributeSet(); + printReqAttr.add(javax.print.attribute.standard.OrientationRequested.LANDSCAPE); + frame = new JFrame(); + frame.setDefaultCloseOperation(WindowConstants.EXIT_ON_CLOSE); + Container contentPane = frame.getContentPane(); + JPanel centerPane = new JPanel(new BorderLayout()); + centerPane.setBorder(BorderFactory.createEmptyBorder(10, 10, 10, 10)); + JPanel tablePaneContainer = new JPanel(new BorderLayout()); + JPanel tablePane = new JPanel(new BorderLayout()); + table = new JTable(new Object[][]{{"row_1_col_1", "row_1_col_2", "row_1_col_3"}, {"row_2_col_1", "row_2_col_2", "row_2_col_3"}, {"row_3_col_1", "row_3_col_2", "row_3_col_3"}, {"row_4_col_1", "row_4_col_2", "row_4_col_3"}}, new String[]{"Col1", "Col2", "Col3"}); + table.setPreferredSize(new Dimension(0, (table.getRowHeight() * 3))); + + tablePane.add(table.getTableHeader(), BorderLayout.NORTH); + tablePane.add(table, BorderLayout.CENTER); + tablePaneContainer.add(tablePane, BorderLayout.CENTER); + centerPane.add(tablePaneContainer, BorderLayout.NORTH); + contentPane.add(centerPane, BorderLayout.CENTER); + frame.setSize(400, 120); + frame.setVisible(true); + frame.setLocationRelativeTo(null); + + } + + /* + * + * mouseEvents for last row click + */ + + private static void mouseEvents(Point clkPnt) { + testRobot.mouseMove(clkPnt.x, clkPnt.y); + testRobot.delay(50); + testRobot.mousePress(InputEvent.BUTTON1_DOWN_MASK); + testRobot.delay(50); + testRobot.mouseRelease(InputEvent.BUTTON1_DOWN_MASK); + testRobot.delay(50); + } + /* + * + * getMousePosition Actions for last row click + * returns Point + * throws Exception + */ + + private static Point getMousePosition() throws Exception { + final Point[] clickPoint = new Point[1]; + SwingUtilities.invokeAndWait(new Runnable() { + @Override + public void run() { + clickPoint[0] = getCellClickPoint(2, 0); + } + }); + return clickPoint[0]; + } + + /* + * + * Clears the selected table row + * throws Exception + */ + + private static void clearSelect() throws Exception { + SwingUtilities.invokeAndWait(new Runnable() { + @Override + public void run() { + table.getSelectionModel().clearSelection(); + table.setFocusable(false); + } + }); + } + + /* + * getCaptureRect Method - To Compute the Rectangle for + * Screen Capturing the Last Row for comparison + * return Rectangle + */ + + private static Rectangle getCaptureRect() throws InterruptedException, InvocationTargetException { + final Rectangle[] captureRect = new Rectangle[1]; + SwingUtilities.invokeAndWait(new Runnable() { + @Override + public void run() { + Rectangle cellRect = table.getCellRect(2, 0, true); + Point point = new Point(cellRect.x, cellRect.y); + SwingUtilities.convertPointToScreen(point, table); + + captureRect[0] = new Rectangle(point.x, point.y, table.getColumnCount() * cellRect.width, cellRect.height); + } + }); + return captureRect[0]; + } + + /* + * Compare method - to compare two images. + * param bufferedImage1 Buffered Image Before click + * param bufferedImage2 Buffered Image After click + * return Boolean + */ + + static Boolean compare(BufferedImage bufferedImage1, BufferedImage bufferedImage2) { + if (bufferedImage1.getWidth() == bufferedImage2.getWidth() + && bufferedImage1.getHeight() == bufferedImage2.getHeight()) { + for (int x = 0; x < bufferedImage1.getWidth(); x++) { + for (int y = 0; y < bufferedImage1.getHeight(); y++) { + if (bufferedImage1.getRGB(x, y) != bufferedImage2.getRGB(x, y)) { + return false; + } + } + } + } else { + return false; + } + return true; + } +} diff -Nru openjdk-17-17.0.17+10/test/jdk/javax/swing/JTable/CheckBoxFirstClick.java openjdk-17-17.0.18+8/test/jdk/javax/swing/JTable/CheckBoxFirstClick.java --- openjdk-17-17.0.17+10/test/jdk/javax/swing/JTable/CheckBoxFirstClick.java 1970-01-01 00:00:00.000000000 +0000 +++ openjdk-17-17.0.18+8/test/jdk/javax/swing/JTable/CheckBoxFirstClick.java 2026-01-15 15:23:06.000000000 +0000 @@ -0,0 +1,185 @@ +/* + * Copyright (c) 1998, 2025, Oracle and/or its affiliates. All rights reserved. + * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. + * + * This code is free software; you can redistribute it and/or modify it + * under the terms of the GNU General Public License version 2 only, as + * published by the Free Software Foundation. + * + * This code is distributed in the hope that it will be useful, but WITHOUT + * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or + * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License + * version 2 for more details (a copy is included in the LICENSE file that + * accompanied this code). + * + * You should have received a copy of the GNU General Public License version + * 2 along with this work; if not, write to the Free Software Foundation, + * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. + * + * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA + * or visit www.oracle.com if you need additional information or have any + * questions. + */ + +import java.awt.Color; +import java.awt.Dimension; +import javax.swing.DefaultCellEditor; +import javax.swing.JComboBox; +import javax.swing.JFrame; +import javax.swing.JLabel; +import javax.swing.JScrollPane; +import javax.swing.JTable; +import javax.swing.border.BevelBorder; +import javax.swing.table.AbstractTableModel; +import javax.swing.table.DefaultTableCellRenderer; +import javax.swing.table.TableCellRenderer; +import javax.swing.table.TableColumn; +import javax.swing.table.TableModel; + +/* + * @test + * @bug 4115930 + * @summary Verify checkboxes in the table respond to first click. + * @library /java/awt/regtesthelpers + * @build PassFailJFrame + * @run main/manual CheckBoxFirstClick + */ + +public class CheckBoxFirstClick { + private static final String INSTRUCTIONS = """ + Click over the checkbox in the table. It should change state + on the first click. If not - press 'fail'. + """; + + public static void main(String[] args) throws Exception { + PassFailJFrame.builder() + .instructions(INSTRUCTIONS) + .columns(50) + .testUI(CheckBoxFirstClick::createTestUI) + .build() + .awaitAndCheck(); + } + + public static JFrame createTestUI() { + JFrame frame = new JFrame("ListSizeBug"); + + // Take the dummy data from SwingSet. + final String[] names = {"First Name", "Last Name", "Favorite Color", + "Favorite Number", "Vegetarian"}; + final Object[][] data = { + {"Mark", "Andrews", "Red", 2, true}, + {"Tom", "Ball", "Blue", 99, false}, + {"Alan", "Chung", "Green", 838, false}, + {"Jeff", "Dinkins", "Turquois", 8, true}, + {"Amy", "Fowler", "Yellow", 3, false}, + {"Brian", "Gerhold", "Green", 0, false}, + {"James", "Gosling", "Pink", 21, false}, + {"David", "Karlton", "Red", 1, false}, + {"Dave", "Kloba", "Yellow", 14, false}, + {"Peter", "Korn", "Purple", 12, false}, + {"Phil", "Milne", "Purple", 3, false}, + {"Dave", "Moore", "Green", 88, false}, + {"Hans", "Muller", "Maroon", 5, false}, + {"Rick", "Levenson", "Blue", 2, false}, + {"Tim", "Prinzing", "Blue", 22, false}, + {"Chester", "Rose", "Black", 0, false}, + {"Ray", "Ryan", "Gray", 77, false}, + {"Georges", "Saab", "Red", 4, false}, + {"Willie", "Walker", "Phthalo Blue", 4, false}, + {"Kathy", "Walrath", "Blue", 8, false}, + {"Arnaud", "Weber", "Green", 44, false} + }; + + // Create a model of the data. + TableModel dataModel = new AbstractTableModel() { + // These methods always need to be implemented. + public int getColumnCount() { + return names.length; + } + + public int getRowCount() { + return data.length; + } + + public Object getValueAt(int row, int col) { + return data[row][col]; + } + + // The default implementations of these methods in + // AbstractTableModel would work, but we can refine them. + public String getColumnName(int column) { + return names[column]; + } + + public Class getColumnClass(int c) { + return getValueAt(0, c).getClass(); + } + + public boolean isCellEditable(int row, int col) { + return true; + } + + public void setValueAt(Object aValue, int row, int column) { + System.out.println("Setting value to: " + aValue); + data[row][column] = aValue; + } + }; + + // Create the table + JTable tableView = new JTable(dataModel); + // Turn off auto-resizing so that we can set column sizes programmatically. + // In this mode, all columns will get their preferred widths, as set blow. + tableView.setAutoResizeMode(JTable.AUTO_RESIZE_OFF); + + // Create a combo box to show that you can use one in a table. + JComboBox comboBox = new JComboBox(); + comboBox.addItem("Red"); + comboBox.addItem("Orange"); + comboBox.addItem("Yellow"); + comboBox.addItem("Green"); + comboBox.addItem("Blue"); + comboBox.addItem("Indigo"); + comboBox.addItem("Violet"); + + TableColumn colorColumn = tableView.getColumn("Favorite Color"); + // Use the combo box as the editor in the "Favorite Color" column. + colorColumn.setCellEditor(new DefaultCellEditor(comboBox)); + + // Set a pink background and tooltip for the Color column renderer. + DefaultTableCellRenderer colorColumnRenderer = new DefaultTableCellRenderer(); + colorColumnRenderer.setBackground(Color.pink); + colorColumnRenderer.setToolTipText("Click for combo box"); + colorColumn.setCellRenderer(colorColumnRenderer); + + // Set a tooltip for the header of the colors column. + TableCellRenderer headerRenderer = colorColumn.getHeaderRenderer(); + if (headerRenderer instanceof DefaultTableCellRenderer) + ((DefaultTableCellRenderer) headerRenderer).setToolTipText("Hi Mom!"); + + // Set the width of the "Vegetarian" column. + TableColumn vegetarianColumn = tableView.getColumn("Vegetarian"); + vegetarianColumn.setPreferredWidth(100); + + // Show the values in the "Favorite Number" column in different colors. + TableColumn numbersColumn = tableView.getColumn("Favorite Number"); + DefaultTableCellRenderer numberColumnRenderer = new DefaultTableCellRenderer() { + public void setValue(Object value) { + int cellValue = (value instanceof Number) ? ((Number) value).intValue() : 0; + setForeground((cellValue > 30) ? Color.black : Color.red); + setText((value == null) ? "" : value.toString()); + } + }; + numberColumnRenderer.setHorizontalAlignment(JLabel.RIGHT); + numbersColumn.setCellRenderer(numberColumnRenderer); + numbersColumn.setPreferredWidth(110); + + // Finish setting up the table. + JScrollPane scrollpane = new JScrollPane(tableView); + scrollpane.setBorder(new BevelBorder(BevelBorder.LOWERED)); + scrollpane.setPreferredSize(new Dimension(430, 200)); + + frame.add(scrollpane); + frame.setSize(500, 200); + return frame; + } +} diff -Nru openjdk-17-17.0.17+10/test/jdk/javax/swing/JTable/IllegalStateException.java openjdk-17-17.0.18+8/test/jdk/javax/swing/JTable/IllegalStateException.java --- openjdk-17-17.0.17+10/test/jdk/javax/swing/JTable/IllegalStateException.java 1970-01-01 00:00:00.000000000 +0000 +++ openjdk-17-17.0.18+8/test/jdk/javax/swing/JTable/IllegalStateException.java 2026-01-15 15:23:06.000000000 +0000 @@ -0,0 +1,187 @@ +/* + * Copyright (c) 1998, 2025, Oracle and/or its affiliates. All rights reserved. + * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. + * + * This code is free software; you can redistribute it and/or modify it + * under the terms of the GNU General Public License version 2 only, as + * published by the Free Software Foundation. + * + * This code is distributed in the hope that it will be useful, but WITHOUT + * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or + * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License + * version 2 for more details (a copy is included in the LICENSE file that + * accompanied this code). + * + * You should have received a copy of the GNU General Public License version + * 2 along with this work; if not, write to the Free Software Foundation, + * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. + * + * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA + * or visit www.oracle.com if you need additional information or have any + * questions. + */ + +import java.awt.Color; +import java.awt.Dimension; +import javax.swing.DefaultCellEditor; +import javax.swing.JComboBox; +import javax.swing.JFrame; +import javax.swing.JLabel; +import javax.swing.JScrollPane; +import javax.swing.JTable; +import javax.swing.border.BevelBorder; +import javax.swing.table.AbstractTableModel; +import javax.swing.table.DefaultTableCellRenderer; +import javax.swing.table.TableCellRenderer; +import javax.swing.table.TableColumn; +import javax.swing.table.TableModel; + +/* + * @test + * @bug 4133143 + * @summary Illegal State exception in ComboBox editor in table + * @library /java/awt/regtesthelpers + * @build PassFailJFrame + * @run main/manual IllegalStateException + */ + +public class IllegalStateException { + private static final String INSTRUCTIONS = """ + Click on a cell in the first column, delete the contents but leave the editor with focus. + Click on the third column popping up a combo box. + Verify that the text editor loses focus. + If it does, press "pass", otherwise press "fail". + """; + + public static void main(String[] args) throws Exception { + PassFailJFrame.builder() + .instructions(INSTRUCTIONS) + .columns(50) + .testUI(IllegalStateException::createTestUI) + .build() + .awaitAndCheck(); + } + + public static JFrame createTestUI() { + JFrame frame = new JFrame("IllegalStateException"); + + // Take the dummy data from SwingSet. + final String[] names = {"First Name", "Last Name", "Favorite Color", + "Favorite Number", "Vegetarian"}; + final Object[][] data = { + {"Mark", "Andrews", "Red", 2, true}, + {"Tom", "Ball", "Blue", 99, false}, + {"Alan", "Chung", "Green", 838, false}, + {"Jeff", "Dinkins", "Turquois", 8, true}, + {"Amy", "Fowler", "Yellow", 3, false}, + {"Brian", "Gerhold", "Green", 0, false}, + {"James", "Gosling", "Pink", 21, false}, + {"David", "Karlton", "Red", 1, false}, + {"Dave", "Kloba", "Yellow", 14, false}, + {"Peter", "Korn", "Purple", 12, false}, + {"Phil", "Milne", "Purple", 3, false}, + {"Dave", "Moore", "Green", 88, false}, + {"Hans", "Muller", "Maroon", 5, false}, + {"Rick", "Levenson", "Blue", 2, false}, + {"Tim", "Prinzing", "Blue", 22, false}, + {"Chester", "Rose", "Black", 0, false}, + {"Ray", "Ryan", "Gray", 77, false}, + {"Georges", "Saab", "Red", 4, false}, + {"Willie", "Walker", "Phthalo Blue", 4, false}, + {"Kathy", "Walrath", "Blue", 8, false}, + {"Arnaud", "Weber", "Green", 44, false} + }; + + // Create a model of the data. + TableModel dataModel = new AbstractTableModel() { + // These methods always need to be implemented. + public int getColumnCount() { + return names.length; + } + + public int getRowCount() { + return data.length; + } + + public Object getValueAt(int row, int col) { + return data[row][col]; + } + + // The default implementations of these methods in + // AbstractTableModel would work, but we can refine them. + public String getColumnName(int column) { + return names[column]; + } + + public Class getColumnClass(int c) { + return getValueAt(0, c).getClass(); + } + + public boolean isCellEditable(int row, int col) { + return true; + } + + public void setValueAt(Object aValue, int row, int column) { + System.out.println("Setting value to: " + aValue); + data[row][column] = aValue; + } + }; + + // Create the table + JTable tableView = new JTable(dataModel); + // Turn off auto-resizing so that we can set column sizes programmatically. + // In this mode, all columns will get their preferred widths, as set blow. + tableView.setAutoResizeMode(JTable.AUTO_RESIZE_OFF); + + // Create a combo box to show that you can use one in a table. + JComboBox comboBox = new JComboBox(); + comboBox.addItem("Red"); + comboBox.addItem("Orange"); + comboBox.addItem("Yellow"); + comboBox.addItem("Green"); + comboBox.addItem("Blue"); + comboBox.addItem("Indigo"); + comboBox.addItem("Violet"); + + TableColumn colorColumn = tableView.getColumn("Favorite Color"); + // Use the combo box as the editor in the "Favorite Color" column. + colorColumn.setCellEditor(new DefaultCellEditor(comboBox)); + + // Set a pink background and tooltip for the Color column renderer. + DefaultTableCellRenderer colorColumnRenderer = new DefaultTableCellRenderer(); + colorColumnRenderer.setBackground(Color.pink); + colorColumnRenderer.setToolTipText("Click for combo box"); + colorColumn.setCellRenderer(colorColumnRenderer); + + // Set a tooltip for the header of the colors column. + TableCellRenderer headerRenderer = colorColumn.getHeaderRenderer(); + if (headerRenderer instanceof DefaultTableCellRenderer) + ((DefaultTableCellRenderer) headerRenderer).setToolTipText("Hi Mom!"); + + // Set the width of the "Vegetarian" column. + TableColumn vegetarianColumn = tableView.getColumn("Vegetarian"); + vegetarianColumn.setPreferredWidth(100); + + // Show the values in the "Favorite Number" column in different colors. + TableColumn numbersColumn = tableView.getColumn("Favorite Number"); + DefaultTableCellRenderer numberColumnRenderer = new DefaultTableCellRenderer() { + public void setValue(Object value) { + int cellValue = (value instanceof Number) ? ((Number) value).intValue() : 0; + setForeground((cellValue > 30) ? Color.black : Color.red); + setText((value == null) ? "" : value.toString()); + } + }; + numberColumnRenderer.setHorizontalAlignment(JLabel.RIGHT); + numbersColumn.setCellRenderer(numberColumnRenderer); + numbersColumn.setPreferredWidth(110); + + // Finish setting up the table. + JScrollPane scrollpane = new JScrollPane(tableView); + scrollpane.setBorder(new BevelBorder(BevelBorder.LOWERED)); + scrollpane.setPreferredSize(new Dimension(430, 200)); + + frame.add(scrollpane); + frame.setSize(500, 200); + return frame; + } +} diff -Nru openjdk-17-17.0.17+10/test/jdk/javax/swing/JTable/InternationalCharacters.java openjdk-17-17.0.18+8/test/jdk/javax/swing/JTable/InternationalCharacters.java --- openjdk-17-17.0.17+10/test/jdk/javax/swing/JTable/InternationalCharacters.java 1970-01-01 00:00:00.000000000 +0000 +++ openjdk-17-17.0.18+8/test/jdk/javax/swing/JTable/InternationalCharacters.java 2026-01-15 15:23:06.000000000 +0000 @@ -0,0 +1,172 @@ +/* + * Copyright (c) 1998, 2025, Oracle and/or its affiliates. All rights reserved. + * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. + * + * This code is free software; you can redistribute it and/or modify it + * under the terms of the GNU General Public License version 2 only, as + * published by the Free Software Foundation. + * + * This code is distributed in the hope that it will be useful, but WITHOUT + * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or + * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License + * version 2 for more details (a copy is included in the LICENSE file that + * accompanied this code). + * + * You should have received a copy of the GNU General Public License version + * 2 along with this work; if not, write to the Free Software Foundation, + * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. + * + * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA + * or visit www.oracle.com if you need additional information or have any + * questions. + */ + +import java.awt.Color; +import java.awt.Dimension; +import java.awt.event.WindowAdapter; +import java.awt.event.WindowEvent; +import java.awt.event.WindowListener; +import javax.swing.DefaultCellEditor; +import javax.swing.JComboBox; +import javax.swing.JFrame; +import javax.swing.JLabel; +import javax.swing.JScrollPane; +import javax.swing.JTable; +import javax.swing.border.BevelBorder; +import javax.swing.table.AbstractTableModel; +import javax.swing.table.DefaultTableCellRenderer; +import javax.swing.table.TableCellRenderer; +import javax.swing.table.TableColumn; +import javax.swing.table.TableModel; + +/* + * @test + * @bug 4179066 + * @summary Tests that JTable prints AltGr characters (~\@|{}[]²µ³) + * @library /java/awt/regtesthelpers + * @build PassFailJFrame + * @run main/manual InternationalCharacters + */ + +public class InternationalCharacters { + private static final String INSTRUCTIONS = """ + Double-click an entry in the JTable. + Press Alt-Gr or Option with any key to type an international character. + Verify that the international character appears in the table. + If it does, press "pass", otherwise press "fail". + """; + + public static void main(String[] args) throws Exception { + PassFailJFrame.builder() + .instructions(INSTRUCTIONS) + .columns(50) + .testUI(InternationalCharacters::createTestUI) + .build() + .awaitAndCheck(); + } + + public static JFrame createTestUI() { + JFrame frame = new JFrame("InternationalCharacters test"); + // Take the dummy data from SwingSet. + final String[] names = {"First Name", "Last Name", "Favorite Color", + "Favorite Number", "Vegetarian"}; + final Object[][] data = { + {"Mark", "Andrews", "Red", 2, true}, + {"Tom", "Ball", "Blue", 99, false}, + {"Alan", "Chung", "Green", 838, false}, + {"Jeff", "Dinkins", "Turquois", 8, true}, + {"Amy", "Fowler", "Yellow", 3, false}, + {"Brian", "Gerhold", "Green", 0, false}, + {"James", "Gosling", "Pink", 21, false}, + {"David", "Karlton", "Red", 1, false}, + {"Dave", "Kloba", "Yellow", 14, false}, + {"Peter", "Korn", "Purple", 12, false}, + {"Phil", "Milne", "Purple", 3, false}, + {"Dave", "Moore", "Green", 88, false}, + {"Hans", "Muller", "Maroon", 5, false}, + {"Rick", "Levenson", "Blue", 2, false}, + {"Tim", "Prinzing", "Blue", 22, false}, + {"Chester", "Rose", "Black", 0, false}, + {"Ray", "Ryan", "Gray", 77, false}, + {"Georges", "Saab", "Red", 4, false}, + {"Willie", "Walker", "Phthalo Blue", 4, false}, + {"Kathy", "Walrath", "Blue", 8, false}, + {"Arnaud", "Weber", "Green", 44, false} + }; + + // Create a model of the data. + TableModel dataModel = new AbstractTableModel() { + // These methods always need to be implemented. + public int getColumnCount() { return names.length; } + public int getRowCount() { return data.length;} + public Object getValueAt(int row, int col) {return data[row][col];} + + // The default implementations of these methods in + // AbstractTableModel would work, but we can refine them. + public String getColumnName(int column) {return names[column];} + public Class getColumnClass(int c) {return getValueAt(0, c).getClass();} + public boolean isCellEditable(int row, int col) {return true;} + public void setValueAt(Object aValue, int row, int column) { + System.out.println("Setting value to: " + aValue); + data[row][column] = aValue; + } + }; + + // Create the table + JTable tableView = new JTable(dataModel); + // Turn off auto-resizing so that we can set column sizes programmatically. + // In this mode, all columns will get their preferred widths, as set blow. + tableView.setAutoResizeMode(JTable.AUTO_RESIZE_OFF); + + // Create a combo box to show that you can use one in a table. + JComboBox comboBox = new JComboBox(); + comboBox.addItem("Red"); + comboBox.addItem("Orange"); + comboBox.addItem("Yellow"); + comboBox.addItem("Green"); + comboBox.addItem("Blue"); + comboBox.addItem("Indigo"); + comboBox.addItem("Violet"); + + TableColumn colorColumn = tableView.getColumn("Favorite Color"); + // Use the combo box as the editor in the "Favorite Color" column. + colorColumn.setCellEditor(new DefaultCellEditor(comboBox)); + + // Set a pink background and tooltip for the Color column renderer. + DefaultTableCellRenderer colorColumnRenderer = new DefaultTableCellRenderer(); + colorColumnRenderer.setBackground(Color.pink); + colorColumnRenderer.setToolTipText("Click for combo box"); + colorColumn.setCellRenderer(colorColumnRenderer); + + // Set a tooltip for the header of the colors column. + TableCellRenderer headerRenderer = colorColumn.getHeaderRenderer(); + if (headerRenderer instanceof DefaultTableCellRenderer) + ((DefaultTableCellRenderer)headerRenderer).setToolTipText("Hi Mom!"); + + // Set the width of the "Vegetarian" column. + TableColumn vegetarianColumn = tableView.getColumn("Vegetarian"); + vegetarianColumn.setPreferredWidth(100); + + // Show the values in the "Favorite Number" column in different colors. + TableColumn numbersColumn = tableView.getColumn("Favorite Number"); + DefaultTableCellRenderer numberColumnRenderer = new DefaultTableCellRenderer() { + public void setValue(Object value) { + int cellValue = (value instanceof Number) ? ((Number)value).intValue() : 0; + setForeground((cellValue > 30) ? Color.black : Color.red); + setText((value == null) ? "" : value.toString()); + } + }; + numberColumnRenderer.setHorizontalAlignment(JLabel.RIGHT); + numbersColumn.setCellRenderer(numberColumnRenderer); + numbersColumn.setPreferredWidth(110); + + // Finish setting up the table. + JScrollPane scrollpane = new JScrollPane(tableView); + scrollpane.setBorder(new BevelBorder(BevelBorder.LOWERED)); + scrollpane.setPreferredSize(new Dimension(430, 200)); + + frame.add(scrollpane); + frame.setSize(500, 200); + return frame; + } +} diff -Nru openjdk-17-17.0.17+10/test/jdk/javax/swing/JTable/JTableScrollPrintTest.java openjdk-17-17.0.18+8/test/jdk/javax/swing/JTable/JTableScrollPrintTest.java --- openjdk-17-17.0.17+10/test/jdk/javax/swing/JTable/JTableScrollPrintTest.java 1970-01-01 00:00:00.000000000 +0000 +++ openjdk-17-17.0.18+8/test/jdk/javax/swing/JTable/JTableScrollPrintTest.java 2026-01-15 15:23:06.000000000 +0000 @@ -0,0 +1,180 @@ +/* + * Copyright (c) 2023, 2024, Oracle and/or its affiliates. All rights reserved. + * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. + * + * This code is free software; you can redistribute it and/or modify it + * under the terms of the GNU General Public License version 2 only, as + * published by the Free Software Foundation. + * + * This code is distributed in the hope that it will be useful, but WITHOUT + * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or + * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License + * version 2 for more details (a copy is included in the LICENSE file that + * accompanied this code). + * + * You should have received a copy of the GNU General Public License version + * 2 along with this work; if not, write to the Free Software Foundation, + * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. + * + * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA + * or visit www.oracle.com if you need additional information or have any + * questions. + */ + +import java.awt.Component; +import java.awt.Graphics; +import java.awt.Graphics2D; +import java.awt.print.PageFormat; +import java.awt.print.Paper; +import java.awt.print.Printable; +import java.awt.print.PrinterException; +import java.awt.print.PrinterJob; + +import javax.swing.BoxLayout; +import javax.swing.JFrame; +import javax.swing.JPanel; +import javax.swing.JScrollPane; +import javax.swing.JTable; +import javax.swing.JViewport; +import javax.swing.table.DefaultTableModel; + +/* + * @test + * @key headful + * @bug 8210807 8322140 8322135 + * @library /java/awt/regtesthelpers + * @build PassFailJFrame + * @summary Test to check if JTable can be printed when JScrollPane added to it. + * @run main/manual JTableScrollPrintTest + */ + +public class JTableScrollPrintTest { + public static void main(String[] args) throws Exception { + String INSTRUCTIONS = """ + Instructions to Test: + 1. Print table onto Paper/PDF, using the Print Dialog. + 2. If entire table is printed, then the Test is PASS. + 3. If table is partially printed without table cells, + then the Test is FAIL. + """; + PassFailJFrame.builder() + .title("Test Instructions") + .instructions(INSTRUCTIONS) + .rows(6) + .columns(35) + .testUI(JTableScrollPrintTest::initialize) + .build() + .awaitAndCheck(); + } + + public static JFrame initialize() { + TestTable testTable = new TestTable(true); + JFrame frame = new JFrame("JTable Print Test"); + PassFailJFrame.addTestWindow(frame); + PassFailJFrame.positionTestWindow(frame, PassFailJFrame.Position.VERTICAL); + frame.add(testTable); + frame.pack(); + frame.setVisible(true); + PrintUtilities printerJob = new PrintUtilities(testTable); + printerJob.print("Test BackingStore Image Print"); + return frame; + } + + public static class TestTable extends JPanel { + public TestTable(Boolean useScrollPane) { + + setLayout(new BoxLayout(this, BoxLayout.Y_AXIS)); + + DefaultTableModel model = new DefaultTableModel(); + model.addColumn("Column 1"); + model.addColumn("Column 2"); + model.addColumn("Column 3"); + model.addColumn("Column 4"); + + for (int row = 1; row <= 5; row++) { + model.addRow(new Object[]{ + "R" + row + " C1", "R" + row + " C2", "R" + row + " C3", "R" + row + " C4"}); + } + + JTable table = new JTable(model); + + if (useScrollPane) { + JScrollPane sp = new JScrollPane(table, + JScrollPane.VERTICAL_SCROLLBAR_ALWAYS, + JScrollPane.HORIZONTAL_SCROLLBAR_AS_NEEDED); + sp.getViewport().setScrollMode(JViewport.BACKINGSTORE_SCROLL_MODE); + add(sp); + } else { + add(table.getTableHeader()); + add(table); + } + } + } + + static class PrintUtilities implements Printable { + private final Component componentToBePrinted; + + public void printComponent(Component c, String jobname) { + new PrintUtilities(c).print(jobname); + } + + public PrintUtilities(Component componentToBePrinted) { + this.componentToBePrinted = componentToBePrinted; + } + + public void print(String jobname) { + PrinterJob printJob = PrinterJob.getPrinterJob(); + PageFormat pf = printJob.defaultPage(); + pf.setOrientation(PageFormat.PORTRAIT); + + // set margins to 1/2" + Paper p = new Paper(); + p.setImageableArea(36, 36, p.getWidth() - 72, p.getHeight() - 72); + pf.setPaper(p); + + printJob.setPrintable(this, pf); + printJob.setJobName(jobname); + + if (printJob.printDialog()) { + try { + printJob.print(); + } catch (PrinterException pe) { + System.out.println("Error printing: " + pe); + } + } + } + + public int print(Graphics g, PageFormat pageFormat, int pageIndex) { + if (pageIndex > 0) { + return NO_SUCH_PAGE; + } else { + Graphics2D g2d = (Graphics2D)g; + g2d.translate(pageFormat.getImageableX(), pageFormat.getImageableY()); + Component c = componentToBePrinted; + c.setSize(c.getPreferredSize()); + + double panelX = c.getWidth(); + double panelY = c.getHeight(); + float imageableX = (float) pageFormat.getImageableWidth() - 1; + float imageableY = (float) pageFormat.getImageableHeight() - 1; + + double xscale = imageableX/panelX; + double yscale = imageableY/panelY; + double optimalScale; + if (xscale < yscale) { + optimalScale = xscale; + } else { + optimalScale = yscale; + } + + if (optimalScale > 1) { + optimalScale = 1; + } + + g2d.scale(optimalScale, optimalScale); + c.paint(g2d); + return PAGE_EXISTS; + } + } + } +} diff -Nru openjdk-17-17.0.17+10/test/jdk/javax/swing/JTable/NullTableHeader.java openjdk-17-17.0.18+8/test/jdk/javax/swing/JTable/NullTableHeader.java --- openjdk-17-17.0.17+10/test/jdk/javax/swing/JTable/NullTableHeader.java 1970-01-01 00:00:00.000000000 +0000 +++ openjdk-17-17.0.18+8/test/jdk/javax/swing/JTable/NullTableHeader.java 2026-01-15 15:23:06.000000000 +0000 @@ -0,0 +1,44 @@ +/* + * Copyright (c) 1998, 2025, Oracle and/or its affiliates. All rights reserved. + * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. + * + * This code is free software; you can redistribute 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.swing.JFrame; +import javax.swing.JTable; +import javax.swing.SwingUtilities; + +/* + * @test + * @bug 4129409 + * @summary Tests that JTable.setTableHeader(null) doesn't break AutoResize + * @key headful + * @run main NullTableHeader + */ + +public class NullTableHeader { + public static void main(String[] args) throws Exception { + SwingUtilities.invokeAndWait(() -> { + JTable tableView = new JTable(); + tableView.setTableHeader(null); + tableView.setAutoResizeMode(JTable.AUTO_RESIZE_OFF); + }); + } +} diff -Nru openjdk-17-17.0.17+10/test/jdk/javax/swing/JTable/PrintAllPagesTest.java openjdk-17-17.0.18+8/test/jdk/javax/swing/JTable/PrintAllPagesTest.java --- openjdk-17-17.0.17+10/test/jdk/javax/swing/JTable/PrintAllPagesTest.java 1970-01-01 00:00:00.000000000 +0000 +++ openjdk-17-17.0.18+8/test/jdk/javax/swing/JTable/PrintAllPagesTest.java 2026-01-15 15:23:06.000000000 +0000 @@ -0,0 +1,114 @@ +/* + * Copyright (c) 2022, 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 8257810 8322135 + * @library /java/awt/regtesthelpers + * @build PassFailJFrame + * @summary Verifies if all pages are printed if scrollRectToVisible is set. + * @run main/manual PrintAllPagesTest + */ +import java.awt.print.PrinterJob; +import java.awt.print.PrinterException; +import javax.swing.JFrame; +import javax.swing.JScrollPane; +import javax.swing.JTable; +import javax.swing.SwingUtilities; +import javax.swing.table.AbstractTableModel; +import javax.swing.table.TableModel; +import javax.swing.WindowConstants; + +public class PrintAllPagesTest { + static JFrame f; + static JTable table; + + static final String INSTRUCTIONS = """ + Note: You must have a printer installed for this test. + If printer is not available, the test passes automatically. + + A JTable with 1000 rows and a print dialog will be shown. + If only 1 page is printed, + then press fail else press pass. + """; + + public static void main(String[] args) throws Exception { + + PrinterJob pj = PrinterJob.getPrinterJob(); + if (pj.getPrintService() == null) { + System.out.println("Printer not configured or available." + + " Test cannot continue."); + PassFailJFrame.forcePass(); + } + + PassFailJFrame passFailJFrame = new PassFailJFrame(INSTRUCTIONS); + + SwingUtilities.invokeAndWait(() -> { + printAllPagesTest(); + // add the test frame to dispose + PassFailJFrame.addTestWindow(f); + + // Arrange the test instruction frame and test frame side by side + PassFailJFrame.positionTestWindow(f, PassFailJFrame.Position.HORIZONTAL); + f.setVisible(true); + + boolean ret; + try { + ret = table.print(); + } catch (PrinterException ex) { + ret = false; + } + if (!ret) { + PassFailJFrame.forceFail("Printing cancelled/failed"); + } + }); + passFailJFrame.awaitAndCheck(); + } + + + private static void printAllPagesTest() { + TableModel dataModel = new AbstractTableModel() { + @Override + public int getColumnCount() { + return 10; + } + + @Override + public int getRowCount() { + return 1000; + } + + @Override + public Object getValueAt(int row, int col) { + return Integer.valueOf(0 == col ? row + 1 : row * col); + } + }; + table = new JTable(dataModel); + JScrollPane scrollpane = new JScrollPane(table); + table.scrollRectToVisible(table.getCellRect(table.getRowCount() - 1, + 0, false)); + + f = new JFrame("Table test"); + f.add(scrollpane); + f.setSize(500, 400); + } +} diff -Nru openjdk-17-17.0.17+10/test/jdk/javax/swing/JTable/ShiftClick.java openjdk-17-17.0.18+8/test/jdk/javax/swing/JTable/ShiftClick.java --- openjdk-17-17.0.17+10/test/jdk/javax/swing/JTable/ShiftClick.java 1970-01-01 00:00:00.000000000 +0000 +++ openjdk-17-17.0.18+8/test/jdk/javax/swing/JTable/ShiftClick.java 2026-01-15 15:23:06.000000000 +0000 @@ -0,0 +1,187 @@ +/* + * Copyright (c) 1999, 2025, Oracle and/or its affiliates. All rights reserved. + * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. + * + * This code is free software; you can redistribute it and/or modify it + * under the terms of the GNU General Public License version 2 only, as + * published by the Free Software Foundation. + * + * This code is distributed in the hope that it will be useful, but WITHOUT + * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or + * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License + * version 2 for more details (a copy is included in the LICENSE file that + * accompanied this code). + * + * You should have received a copy of the GNU General Public License version + * 2 along with this work; if not, write to the Free Software Foundation, + * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. + * + * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA + * or visit www.oracle.com if you need additional information or have any + * questions. + */ + +import java.awt.Color; +import java.awt.Dimension; +import javax.swing.DefaultCellEditor; +import javax.swing.JComboBox; +import javax.swing.JFrame; +import javax.swing.JLabel; +import javax.swing.JScrollPane; +import javax.swing.JTable; +import javax.swing.border.BevelBorder; +import javax.swing.table.AbstractTableModel; +import javax.swing.table.DefaultTableCellRenderer; +import javax.swing.table.TableCellRenderer; +import javax.swing.table.TableColumn; +import javax.swing.table.TableModel; + +/* + * @test + * @bug 4201917 + * @summary Shift Click in table before making selection + * @library /java/awt/regtesthelpers + * @build PassFailJFrame + * @run main/manual ShiftClick + */ + +public class ShiftClick { + private static final String INSTRUCTIONS = """ + Shift click in the table. Check that all cells + from the first through where you clicked are selected. + If the cells are selected, press pass, otherwise fail. + """; + + public static void main(String[] args) throws Exception { + PassFailJFrame.builder() + .instructions(INSTRUCTIONS) + .columns(50) + .testUI(ShiftClick::createTestUI) + .logArea(6) + .build() + .awaitAndCheck(); + } + + public static JFrame createTestUI() { + JFrame frame = new JFrame("ShiftClick"); + + // Take the dummy data from SwingSet. + final String[] names = {"First Name", "Last Name", "Favorite Color", + "Favorite Number", "Vegetarian"}; + final Object[][] data = { + {"Mark", "Andrews", "Red", 2, true}, + {"Tom", "Ball", "Blue", 99, false}, + {"Alan", "Chung", "Green", 838, false}, + {"Jeff", "Dinkins", "Turquois", 8, true}, + {"Amy", "Fowler", "Yellow", 3, false}, + {"Brian", "Gerhold", "Green", 0, false}, + {"James", "Gosling", "Pink", 21, false}, + {"David", "Karlton", "Red", 1, false}, + {"Dave", "Kloba", "Yellow", 14, false}, + {"Peter", "Korn", "Purple", 12, false}, + {"Phil", "Milne", "Purple", 3, false}, + {"Dave", "Moore", "Green", 88, false}, + {"Hans", "Muller", "Maroon", 5, false}, + {"Rick", "Levenson", "Blue", 2, false}, + {"Tim", "Prinzing", "Blue", 22, false}, + {"Chester", "Rose", "Black", 0, false}, + {"Ray", "Ryan", "Gray", 77, false}, + {"Georges", "Saab", "Red", 4, false}, + {"Willie", "Walker", "Phthalo Blue", 4, false}, + {"Kathy", "Walrath", "Blue", 8, false}, + {"Arnaud", "Weber", "Green", 44, false} + }; + + // Create a model of the data. + TableModel dataModel = new AbstractTableModel() { + // These methods always need to be implemented. + public int getColumnCount() { + return names.length; + } + + public int getRowCount() { + return data.length; + } + + public Object getValueAt(int row, int col) { + return data[row][col]; + } + + // The default implementations of these methods in + // AbstractTableModel would work, but we can refine them. + public String getColumnName(int column) { + return names[column]; + } + + public Class getColumnClass(int c) { + return getValueAt(0, c).getClass(); + } + + public boolean isCellEditable(int row, int col) { + return true; + } + + public void setValueAt(Object aValue, int row, int column) { + System.out.println("Setting value to: " + aValue); + data[row][column] = aValue; + } + }; + + // Create the table + JTable tableView = new JTable(dataModel); + // Turn off auto-resizing so that we can set column sizes programmatically. + // In this mode, all columns will get their preferred widths, as set blow. + tableView.setAutoResizeMode(JTable.AUTO_RESIZE_OFF); + + // Create a combo box to show that you can use one in a table. + JComboBox comboBox = new JComboBox(); + comboBox.addItem("Red"); + comboBox.addItem("Orange"); + comboBox.addItem("Yellow"); + comboBox.addItem("Green"); + comboBox.addItem("Blue"); + comboBox.addItem("Indigo"); + comboBox.addItem("Violet"); + + TableColumn colorColumn = tableView.getColumn("Favorite Color"); + // Use the combo box as the editor in the "Favorite Color" column. + colorColumn.setCellEditor(new DefaultCellEditor(comboBox)); + + // Set a pink background and tooltip for the Color column renderer. + DefaultTableCellRenderer colorColumnRenderer = new DefaultTableCellRenderer(); + colorColumnRenderer.setBackground(Color.pink); + colorColumnRenderer.setToolTipText("Click for combo box"); + colorColumn.setCellRenderer(colorColumnRenderer); + + // Set a tooltip for the header of the colors column. + TableCellRenderer headerRenderer = colorColumn.getHeaderRenderer(); + if (headerRenderer instanceof DefaultTableCellRenderer) + ((DefaultTableCellRenderer) headerRenderer).setToolTipText("Hi Mom!"); + + // Set the width of the "Vegetarian" column. + TableColumn vegetarianColumn = tableView.getColumn("Vegetarian"); + vegetarianColumn.setPreferredWidth(100); + + // Show the values in the "Favorite Number" column in different colors. + TableColumn numbersColumn = tableView.getColumn("Favorite Number"); + DefaultTableCellRenderer numberColumnRenderer = new DefaultTableCellRenderer() { + public void setValue(Object value) { + int cellValue = (value instanceof Number) ? ((Number) value).intValue() : 0; + setForeground((cellValue > 30) ? Color.black : Color.red); + setText((value == null) ? "" : value.toString()); + } + }; + numberColumnRenderer.setHorizontalAlignment(JLabel.RIGHT); + numbersColumn.setCellRenderer(numberColumnRenderer); + numbersColumn.setPreferredWidth(110); + + // Finish setting up the table. + JScrollPane scrollpane = new JScrollPane(tableView); + scrollpane.setBorder(new BevelBorder(BevelBorder.LOWERED)); + scrollpane.setPreferredSize(new Dimension(430, 200)); + + frame.add(scrollpane); + frame.setSize(500, 200); + return frame; + } +} diff -Nru openjdk-17-17.0.17+10/test/jdk/javax/swing/JTable/bug4118307.java openjdk-17-17.0.18+8/test/jdk/javax/swing/JTable/bug4118307.java --- openjdk-17-17.0.17+10/test/jdk/javax/swing/JTable/bug4118307.java 1970-01-01 00:00:00.000000000 +0000 +++ openjdk-17-17.0.18+8/test/jdk/javax/swing/JTable/bug4118307.java 2026-01-15 15:23:06.000000000 +0000 @@ -0,0 +1,182 @@ +/* + * Copyright (c) 1998, 2025, Oracle and/or its affiliates. All rights reserved. + * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. + * + * This code is free software; you can redistribute it and/or modify it + * under the terms of the GNU General Public License version 2 only, as + * published by the Free Software Foundation. + * + * This code is distributed in the hope that it will be useful, but WITHOUT + * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or + * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License + * version 2 for more details (a copy is included in the LICENSE file that + * accompanied this code). + * + * You should have received a copy of the GNU General Public License version + * 2 along with this work; if not, write to the Free Software Foundation, + * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. + * + * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA + * or visit www.oracle.com if you need additional information or have any + * questions. + */ + +import java.awt.BorderLayout; +import java.awt.Component; +import java.awt.Point; +import java.awt.Robot; +import java.awt.event.InputEvent; +import javax.swing.JFrame; +import javax.swing.JScrollPane; +import javax.swing.JTable; +import javax.swing.SwingUtilities; +import javax.swing.table.AbstractTableModel; +import javax.swing.table.TableCellRenderer; +import javax.swing.table.TableModel; + +/* + * @test + * @bug 4118307 + * @summary Tests that JTable's cell editor for Number and Date work correctly + * @key headful + * @run main bug4118307 + */ + +public class bug4118307 { + static JFrame frame; + static MyTable tbl; + static Point tableLoc; + static Point p; + private static volatile boolean flag; + static final String[] columnNames = {"Integer", "Double"}; + static final Object[][] data = { + {5, 3.14}, + {10, 2.71}, + {70, 3.14}, + {200, 2.71}, + }; + + public static void main(String[] args) throws Exception { + try { + Robot robot = new Robot(); + robot.setAutoDelay(250); + SwingUtilities.invokeAndWait(() -> createTestUI()); + robot.waitForIdle(); + robot.delay(1000); + + SwingUtilities.invokeAndWait(() -> { + tableLoc = tbl.getLocationOnScreen(); + p = tbl.getCellRect(0, 0, true).getLocation(); + }); + robot.waitForIdle(); + + robot.mouseMove(tableLoc.x + p.x + 10, tableLoc.y + p.y + 10); + robot.waitForIdle(); + + robot.mousePress(InputEvent.BUTTON1_DOWN_MASK); + robot.mouseRelease(InputEvent.BUTTON1_DOWN_MASK); + robot.mousePress(InputEvent.BUTTON1_DOWN_MASK); + robot.mouseRelease(InputEvent.BUTTON1_DOWN_MASK); + robot.waitForIdle(); + + SwingUtilities.invokeAndWait(() -> + p = tbl.getCellRect(1, 1, true).getLocation()); + robot.waitForIdle(); + + robot.mouseMove(tableLoc.x + p.x + 10, tableLoc.y + p.y + 10); + robot.waitForIdle(); + + robot.mousePress(InputEvent.BUTTON1_DOWN_MASK); + robot.mouseRelease(InputEvent.BUTTON1_DOWN_MASK); + robot.mousePress(InputEvent.BUTTON1_DOWN_MASK); + robot.mouseRelease(InputEvent.BUTTON1_DOWN_MASK); + robot.waitForIdle(); + + SwingUtilities.invokeAndWait(() -> + p = tbl.getCellRect(1, 0, true).getLocation()); + robot.waitForIdle(); + + robot.mouseMove(tableLoc.x + p.x + 10, tableLoc.y + p.y + 10); + robot.waitForIdle(); + + robot.mousePress(InputEvent.BUTTON1_DOWN_MASK); + robot.mouseRelease(InputEvent.BUTTON1_DOWN_MASK); + robot.mousePress(InputEvent.BUTTON1_DOWN_MASK); + robot.mouseRelease(InputEvent.BUTTON1_DOWN_MASK); + robot.waitForIdle(); + robot.delay(5000); + + if (!flag) { + throw new RuntimeException("Test Failed."); + } + } finally { + SwingUtilities.invokeAndWait(() -> { + if (frame != null) { + frame.dispose(); + } + }); + } + } + + public static void createTestUI() { + frame = new JFrame("bug4118307"); + MyTableModel myModel = new MyTableModel(); + tbl = new MyTable(myModel); + JScrollPane sp = new JScrollPane(tbl); + flag = true; + + frame.add(sp, BorderLayout.CENTER); + frame.pack(); + frame.setLocationRelativeTo(null); + frame.setVisible(true); + } + + static class MyTable extends JTable { + public MyTable(TableModel tm) { + super(tm); + } + + public Component prepareRenderer(TableCellRenderer rend, int row, int col) { + try { + return super.prepareRenderer(rend, row, col); + } catch (Exception e) { + e.printStackTrace(); + flag = false; + return null; + } + } + } + + static class MyTableModel extends AbstractTableModel { + public int getColumnCount() { + return columnNames.length; + } + + public int getRowCount() { + return data.length; + } + + @Override + public String getColumnName(int col) { + return columnNames[col]; + } + + public Object getValueAt(int row, int col) { + return data[row][col]; + } + + public Class getColumnClass(int c) { + return getValueAt(0, c).getClass(); + } + + @Override + public boolean isCellEditable(int row, int col) { + return true; + } + + @Override + public void setValueAt(Object value, int row, int col) { + data[row][col] = value; + } + } +} diff -Nru openjdk-17-17.0.17+10/test/jdk/javax/swing/JTable/bug4128506.java openjdk-17-17.0.18+8/test/jdk/javax/swing/JTable/bug4128506.java --- openjdk-17-17.0.17+10/test/jdk/javax/swing/JTable/bug4128506.java 1970-01-01 00:00:00.000000000 +0000 +++ openjdk-17-17.0.18+8/test/jdk/javax/swing/JTable/bug4128506.java 2026-01-15 15:23:06.000000000 +0000 @@ -0,0 +1,84 @@ +/* + * Copyright (c) 1998, 2025, Oracle and/or its affiliates. All rights reserved. + * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. + * + * This code is free software; you can redistribute 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.swing.JFrame; +import javax.swing.JScrollPane; +import javax.swing.JTable; +import javax.swing.table.AbstractTableModel; +import javax.swing.table.TableModel; + +/* + * @test + * @bug 4128506 + * @summary Tests that JTable with AUTO_RESIZE_ALL_COLUMNS correctly compute width of columns + * @library /java/awt/regtesthelpers + * @build PassFailJFrame + * @run main/manual bug4128506 + */ + +public class bug4128506 { + private static final String INSTRUCTIONS = """ + If the columns of JTable have the same width the test passes, else test fails. + """; + + public static void main(String[] args) throws Exception { + PassFailJFrame.builder() + .instructions(INSTRUCTIONS) + .columns(50) + .testUI(bug4128506::createTestUI) + .build() + .awaitAndCheck(); + } + + public static JFrame createTestUI() { + final Object[][] data = { + {"cell_1_1", "cell_1_2", "cell_1_3"}, + {"cell_2_1", "cell_2_2", "cell_2_3"}, + {"cell_3_1", "cell_3_2", "cell_3_3"}, + {"cell_4_1", "cell_4_2", "cell_4_3"}, + }; + + TableModel dataModel = new AbstractTableModel() { + public int getColumnCount() { + return 3; + } + + public int getRowCount() { + return data.length; + } + + public Object getValueAt(int row, int col) { + return data[row][col]; + } + }; + + JFrame frame = new JFrame("bug4128506"); + JTable tableView = new JTable(dataModel); + tableView.setAutoResizeMode(JTable.AUTO_RESIZE_ALL_COLUMNS); + tableView.getColumnModel().getColumn(1).setMinWidth(5); + JScrollPane scrollpane = new JScrollPane(tableView); + frame.add(scrollpane); + frame.pack(); + return frame; + } +} diff -Nru openjdk-17-17.0.17+10/test/jdk/javax/swing/JTable/bug4129401.java openjdk-17-17.0.18+8/test/jdk/javax/swing/JTable/bug4129401.java --- openjdk-17-17.0.17+10/test/jdk/javax/swing/JTable/bug4129401.java 1970-01-01 00:00:00.000000000 +0000 +++ openjdk-17-17.0.18+8/test/jdk/javax/swing/JTable/bug4129401.java 2026-01-15 15:23:06.000000000 +0000 @@ -0,0 +1,87 @@ +/* + * Copyright (c) 1999, 2025, Oracle and/or its affiliates. All rights reserved. + * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. + * + * This code is free software; you can redistribute 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.swing.DefaultCellEditor; +import javax.swing.JComboBox; +import javax.swing.JFrame; +import javax.swing.JScrollPane; +import javax.swing.JTable; +import javax.swing.table.TableColumn; + +/* + * @test + * @bug 4129401 + * @summary Tests that keystroking for combobox cell editor in JTable works + * @library /java/awt/regtesthelpers + * @build PassFailJFrame + * @run main/manual bug4129401 + */ + +public class bug4129401 { + private static final String INSTRUCTIONS = """ + 1. Move the mouse cursor to the cell "CELL 2 1", + which contains JComboBox and click left mouse button + to drop down combobox list. + 2. Change selected item in the combobox list + using up and down arrows. + 3. Press Esc. JComboBox drop down list should hide. + If all was successful then test passes, else test fails. + """; + + public static void main(String[] args) throws Exception { + PassFailJFrame.builder() + .instructions(INSTRUCTIONS) + .columns(50) + .testUI(bug4129401::createTestUI) + .build() + .awaitAndCheck(); + } + + public static JFrame createTestUI() { + Object data[][] = new Object[4][2]; + JComboBox cb = new JComboBox(); + cb.addItem("Item1"); + cb.addItem("Item2"); + cb.addItem("Item3"); + cb.addItem("Item4"); + data[0][0] = "CELL 0 0"; + data[0][1] = "CELL 0 1"; + data[1][0] = "CELL 1 0"; + data[1][1] = "CELL 1 1"; + data[2][0] = "CELL 2 0"; + data[2][1] = "CELL 2 1"; + data[3][0] = "CELL 3 0"; + data[3][1] = "CELL 3 1"; + String[] str = {"Column 0", "Column 1"}; + JTable tbl = new JTable(data, str); + JScrollPane sp = new JScrollPane(tbl); + + TableColumn col = tbl.getColumn("Column 1"); + col.setCellEditor(new DefaultCellEditor(cb)); + + JFrame f = new JFrame("4129401 test"); + f.getContentPane().add(sp); + f.setBounds(100, 100, 300, 300); + return f; + } +} diff -Nru openjdk-17-17.0.17+10/test/jdk/javax/swing/JTable/bug4138158.java openjdk-17-17.0.18+8/test/jdk/javax/swing/JTable/bug4138158.java --- openjdk-17-17.0.17+10/test/jdk/javax/swing/JTable/bug4138158.java 1970-01-01 00:00:00.000000000 +0000 +++ openjdk-17-17.0.18+8/test/jdk/javax/swing/JTable/bug4138158.java 2026-01-15 15:23:06.000000000 +0000 @@ -0,0 +1,62 @@ +/* + * Copyright (c) 1998, 2025, Oracle and/or its affiliates. All rights reserved. + * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. + * + * This code is free software; you can redistribute 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.swing.JFrame; +import javax.swing.JScrollPane; +import javax.swing.JTable; + +/* + * @test + * @bug 4138158 + * @summary Tests that setAutoscrolls(false) locks autoscroll + * @library /java/awt/regtesthelpers + * @build PassFailJFrame + * @run main/manual bug4138158 + */ + +public class bug4138158 { + private static final String INSTRUCTIONS = """ + Move mouse to beginning of table, press left mouse button and drag mouse down + below the frame. If the table isn't scrolled down then test passes. + If the table is scrolled then test fails. + """; + + public static void main(String[] args) throws Exception { + PassFailJFrame.builder() + .instructions(INSTRUCTIONS) + .columns(50) + .testUI(bug4138158::createTestUI) + .build() + .awaitAndCheck(); + } + + public static JFrame createTestUI() { + JFrame frame = new JFrame("bug4138158"); + JTable table = new JTable(20, 3); + table.setAutoscrolls(false); + JScrollPane sp = new JScrollPane(table); + frame.add(sp); + frame.setSize(200, 200); + return frame; + } +} diff -Nru openjdk-17-17.0.17+10/test/jdk/javax/swing/JTable/bug4139910.java openjdk-17-17.0.18+8/test/jdk/javax/swing/JTable/bug4139910.java --- openjdk-17-17.0.17+10/test/jdk/javax/swing/JTable/bug4139910.java 1970-01-01 00:00:00.000000000 +0000 +++ openjdk-17-17.0.18+8/test/jdk/javax/swing/JTable/bug4139910.java 2026-01-15 15:23:06.000000000 +0000 @@ -0,0 +1,68 @@ +/* + * Copyright (c) 1998, 2025, Oracle and/or its affiliates. All rights reserved. + * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. + * + * This code is free software; you can redistribute 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.swing.JFrame; +import javax.swing.JScrollPane; +import javax.swing.JTable; +import javax.swing.table.DefaultTableModel; + +/* + * @test + * @bug 4139910 + * @summary Column resize mouse pointer doesn't display in non-resizable JTable. + * @library /java/awt/regtesthelpers + * @build PassFailJFrame + * @run main/manual bug4139910 + */ + +public class bug4139910 { + private static final String INSTRUCTIONS = """ + Move mouse pointer to the position between "A" and "B" headers. + If mouse pointer does not change its shape then test passes. If + it does then test fails. + """; + + public static void main(String[] args) throws Exception { + PassFailJFrame.builder() + .instructions(INSTRUCTIONS) + .columns(50) + .testUI(bug4139910::createTestUI) + .build() + .awaitAndCheck(); + } + + public static JFrame createTestUI() { + JFrame frame = new JFrame("bug4139910"); + + String[] colName = {"A", "B"}; + JTable tbl = new JTable(new DefaultTableModel(colName, 6)); + tbl.setAutoResizeMode(JTable.AUTO_RESIZE_OFF); + tbl.getTableHeader().setReorderingAllowed(false); + tbl.getTableHeader().setResizingAllowed(false); + JScrollPane sp = new JScrollPane(tbl); + frame.add(sp); + + frame.pack(); + return frame; + } +} diff -Nru openjdk-17-17.0.17+10/test/jdk/javax/swing/JTable/bug4188504.java openjdk-17-17.0.18+8/test/jdk/javax/swing/JTable/bug4188504.java --- openjdk-17-17.0.17+10/test/jdk/javax/swing/JTable/bug4188504.java 1970-01-01 00:00:00.000000000 +0000 +++ openjdk-17-17.0.18+8/test/jdk/javax/swing/JTable/bug4188504.java 2026-01-15 15:23:06.000000000 +0000 @@ -0,0 +1,71 @@ +/* + * Copyright (c) 1999, 2025, Oracle and/or its affiliates. All rights reserved. + * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. + * + * This code is free software; you can redistribute 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 4188504 + * @summary setResizable for specified column. + * @library /java/awt/regtesthelpers + * @build PassFailJFrame + * @run main/manual bug4188504 + */ + +import javax.swing.JFrame; +import javax.swing.JScrollPane; +import javax.swing.JTable; + +public class bug4188504 { + private static final String INSTRUCTIONS = """ + 1. A table is displayed with 3 columns - A, B, C. + + 2. Try to resize second column of table (Move mouse to the position + between "B" and "C" headers, press left mouse button and move to + right/left). + PLEASE NOTE: You may be able to swap the columns but make sure the + width of column B stays the same. + + 3. If the second column does not change its width then press PASS + otherwise press FAIL. + """; + + public static void main(String[] args) throws Exception { + PassFailJFrame.builder() + .title("Test Instructions") + .instructions(INSTRUCTIONS) + .columns(40) + .testUI(createAndShowUI()) + .build() + .awaitAndCheck(); + } + + private static JFrame createAndShowUI() { + JFrame jFrame = new JFrame("bug4188504"); + JTable tableView = new JTable(4, 3); + tableView.setAutoResizeMode(JTable.AUTO_RESIZE_OFF); + tableView.getColumnModel().getColumn(1).setResizable(false); + + jFrame.add(new JScrollPane(tableView)); + jFrame.setSize(300, 150); + return jFrame; + } +} diff -Nru openjdk-17-17.0.17+10/test/jdk/javax/swing/JTable/bug4190222.java openjdk-17-17.0.18+8/test/jdk/javax/swing/JTable/bug4190222.java --- openjdk-17-17.0.17+10/test/jdk/javax/swing/JTable/bug4190222.java 1970-01-01 00:00:00.000000000 +0000 +++ openjdk-17-17.0.18+8/test/jdk/javax/swing/JTable/bug4190222.java 2026-01-15 15:23:06.000000000 +0000 @@ -0,0 +1,103 @@ +/* + * Copyright (c) 1998, 2025, Oracle and/or its affiliates. All rights reserved. + * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. + * + * This code is free software; you can redistribute it and/or modify it + * under the terms of the GNU General Public License version 2 only, as + * published by the Free Software Foundation. + * + * This code is distributed in the hope that it will be useful, but WITHOUT + * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or + * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License + * version 2 for more details (a copy is included in the LICENSE file that + * accompanied this code). + * + * You should have received a copy of the GNU General Public License version + * 2 along with this work; if not, write to the Free Software Foundation, + * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. + * + * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA + * or visit www.oracle.com if you need additional information or have any + * questions. + */ + +import java.awt.Dimension; +import java.awt.Robot; +import java.util.Vector; +import javax.swing.JFrame; +import javax.swing.JPanel; +import javax.swing.JScrollPane; +import javax.swing.JTable; +import javax.swing.SwingUtilities; +import javax.swing.table.DefaultTableModel; + +/* + * @test + * @bug 4190222 + * @summary Setting data vector on the model correctly repaint table + * @key headful + * @run main bug4190222 + */ + +public class bug4190222 { + static JFrame frame; + static DefaultTableModel dtm; + static JTable tbl; + + static Vector data; + static Vector colNames; + + public static void main(String[] args) throws Exception { + try { + Robot robot = new Robot(); + robot.setAutoDelay(250); + + SwingUtilities.invokeAndWait(() -> createTestUI()); + robot.waitForIdle(); + robot.delay(1000); + + SwingUtilities.invokeAndWait(() -> { + Dimension preResize = tbl.getSize(); + dtm.setDataVector(data, colNames); + + if (!preResize.equals(tbl.getSize())) { + throw new RuntimeException("Size of table changed after resizing."); + } + }); + } finally { + SwingUtilities.invokeAndWait(() -> { + if (frame != null) { + frame.dispose(); + } + }); + } + } + + public static void createTestUI() { + frame = new JFrame("bug4190222"); + + data = new Vector(1, 1); + colNames = new Vector(3); + for (int i = 1; i < 4; i++) { + Vector row = new Vector(1, 1); + row.addElement("Row " + i + ", Col 1"); + row.addElement("Row " + i + ", Col 2"); + row.addElement("Row " + i + ", Col 3"); + data.addElement(row); + } + colNames.addElement("Col 1"); + colNames.addElement("Col 2"); + colNames.addElement("Col 3"); + + dtm = new DefaultTableModel(data, colNames); + tbl = new JTable(dtm); + JScrollPane scrollPane = new JScrollPane(tbl); + frame.add("Center", scrollPane); + JPanel panel = new JPanel(); + frame.add("South", panel); + + frame.pack(); + frame.setLocationRelativeTo(null); + frame.setVisible(true); + } +} diff -Nru openjdk-17-17.0.17+10/test/jdk/javax/swing/JTable/bug4193727.java openjdk-17-17.0.18+8/test/jdk/javax/swing/JTable/bug4193727.java --- openjdk-17-17.0.17+10/test/jdk/javax/swing/JTable/bug4193727.java 1970-01-01 00:00:00.000000000 +0000 +++ openjdk-17-17.0.18+8/test/jdk/javax/swing/JTable/bug4193727.java 2026-01-15 15:23:06.000000000 +0000 @@ -0,0 +1,135 @@ +/* + * Copyright (c) 1998, 2025, Oracle and/or its affiliates. All rights reserved. + * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. + * + * This code is free software; you can redistribute it and/or modify it + * under the terms of the GNU General Public License version 2 only, as + * published by the Free Software Foundation. + * + * This code is distributed in the hope that it will be useful, but WITHOUT + * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or + * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License + * version 2 for more details (a copy is included in the LICENSE file that + * accompanied this code). + * + * You should have received a copy of the GNU General Public License version + * 2 along with this work; if not, write to the Free Software Foundation, + * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. + * + * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA + * or visit www.oracle.com if you need additional information or have any + * questions. + */ + +import java.awt.BorderLayout; +import java.awt.Component; +import java.awt.FontMetrics; +import java.util.Vector; +import javax.swing.JButton; +import javax.swing.JFrame; +import javax.swing.JPanel; +import javax.swing.JScrollPane; +import javax.swing.JTable; +import javax.swing.SwingUtilities; +import javax.swing.table.TableCellRenderer; +import javax.swing.table.TableColumn; + +/* + * @test + * @bug 4193727 + * @summary Tests that resizing JTable via TableColumn's + * setWidth(int) repaints correctly + * @library /java/awt/regtesthelpers + * @build PassFailJFrame + * @run main/manual bug4193727 + */ + +public class bug4193727 { + static EnhancedJTable tblResults; + static JButton bTest = new JButton("Resize"); + + private static final String INSTRUCTIONS = """ + Push button "Resize". + If either of the following happen, test fails: + 1) The size of the columns change + 2) The JTable is not repainted correctly + + Otherwise test passes. + """; + + public static void main(String[] args) throws Exception { + PassFailJFrame.builder() + .instructions(INSTRUCTIONS) + .columns(50) + .testUI(bug4193727::createTestUI) + .build() + .awaitAndCheck(); + } + + public static JFrame createTestUI() { + JFrame frame = new JFrame("bug4193727"); + Vector v = new Vector(); + Vector data = new Vector(); + Vector cols = new Vector(); + + cols.add("Name"); + cols.add("Address"); + data.add("Steve"); + data.add("100 East Main Street"); + v.add(data); + + data.add("Richard"); + data.add("99 Main Road"); + v.add(data); + + frame.setLayout(new BorderLayout()); + tblResults = new EnhancedJTable(v, cols); + MyTableHeader mth = new MyTableHeader(); + for (int i = 0; i < tblResults.getColumnCount(); i++) + tblResults.getColumnModel().getColumn(i).setHeaderRenderer(mth.getTHR()); + tblResults.setAutoResizeMode(EnhancedJTable.AUTO_RESIZE_OFF); + + JScrollPane pane = new JScrollPane(tblResults); + frame.add(pane, BorderLayout.CENTER); + JPanel panel = new JPanel(); + panel.add(bTest); + frame.add(panel, BorderLayout.EAST); + bTest.addActionListener(e -> tblResults.autoSizeColumns()); + frame.setSize(300, 200); + return frame; + } +} + +class MyTableHeader extends TableColumn { + public TableCellRenderer getTHR() { + return createDefaultHeaderRenderer(); + } +} + +class EnhancedJTable extends JTable { + public EnhancedJTable(Vector data, Vector colNames) { + super(data, colNames); + } + + public synchronized void autoSizeColumns() { + setAutoResizeMode(AUTO_RESIZE_OFF); + int colcnt = getColumnCount(); + int rowcnt = getRowCount(); + + for (int i = 0; i < colcnt; i++) { + // get the max column width needed + Component cell = getColumnModel().getColumn(i).getHeaderRenderer() + .getTableCellRendererComponent(this, null, false, false, -1, i); + FontMetrics fm = cell.getFontMetrics(cell.getFont()); + int max = SwingUtilities.computeStringWidth(fm, getColumnModel().getColumn(i).getHeaderValue() + .toString() + " "); + for (int j = 0; j < rowcnt; j++) { + // add 2 spaces to account for gutter + int width = SwingUtilities.computeStringWidth(fm, getValueAt(j, i).toString() + " "); + if (max < width) max = width; + } + // set the new column width + getColumnModel().getColumn(i).setWidth(max); + } + } +} diff -Nru openjdk-17-17.0.17+10/test/jdk/javax/swing/JTable/bug4224179.java openjdk-17-17.0.18+8/test/jdk/javax/swing/JTable/bug4224179.java --- openjdk-17-17.0.17+10/test/jdk/javax/swing/JTable/bug4224179.java 1970-01-01 00:00:00.000000000 +0000 +++ openjdk-17-17.0.18+8/test/jdk/javax/swing/JTable/bug4224179.java 2026-01-15 15:23:06.000000000 +0000 @@ -0,0 +1,74 @@ +/* + * Copyright (c) 1999, 2025, Oracle and/or its affiliates. All rights reserved. + * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. + * + * This code is free software; you can redistribute it and/or modify it + * under the terms of the GNU General Public License version 2 only, as + * published by the Free Software Foundation. + * + * This code is distributed in the hope that it will be useful, but WITHOUT + * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or + * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License + * version 2 for more details (a copy is included in the LICENSE file that + * accompanied this code). + * + * You should have received a copy of the GNU General Public License version + * 2 along with this work; if not, write to the Free Software Foundation, + * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. + * + * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA + * or visit www.oracle.com if you need additional information or have any + * questions. + */ + +import java.awt.BorderLayout; +import java.awt.Dimension; +import javax.swing.JFrame; +import javax.swing.JScrollPane; +import javax.swing.JTable; + +/* + * @test + * @bug 4224179 + * @summary Tests if Table default cell editor doesn't handle % (percent) character correctly + * @library /java/awt/regtesthelpers + * @build PassFailJFrame + * @run main/manual bug4224179 + */ + +public class bug4224179 { + private static final String INSTRUCTIONS = """ + 1. Click ONCE on the center cell ("Huml") + 2. Type the following symbols one after another: a%b + + If the center cell doesn't read "Humla%b" the test fails. + + 3. After the above, press the ESCAPE key and note that the cell + reverts back to "Huml" + 4. Do the stuff in part 1 again + 5. Press the ESCAPE key + + If the center cell now reads "Huml" as it initially was, + the test passed and fails otherwise. + """; + + public static void main(String[] args) throws Exception { + PassFailJFrame.builder() + .instructions(INSTRUCTIONS) + .columns(50) + .testUI(bug4224179::createTestUI) + .build() + .awaitAndCheck(); + } + + public static JFrame createTestUI() { + JFrame frame = new JFrame("bug4224179"); + JTable table = new JTable(3, 3); + table.setValueAt("Huml", 1, 1); + table.setPreferredScrollableViewportSize(new Dimension(500, 70)); + JScrollPane scrollPane = new JScrollPane(table); + frame.add(scrollPane, BorderLayout.CENTER); + frame.pack(); + return frame; + } +} diff -Nru openjdk-17-17.0.17+10/test/jdk/javax/swing/JTable/bug4226181.java openjdk-17-17.0.18+8/test/jdk/javax/swing/JTable/bug4226181.java --- openjdk-17-17.0.17+10/test/jdk/javax/swing/JTable/bug4226181.java 1970-01-01 00:00:00.000000000 +0000 +++ openjdk-17-17.0.18+8/test/jdk/javax/swing/JTable/bug4226181.java 2026-01-15 15:23:06.000000000 +0000 @@ -0,0 +1,87 @@ +/* + * Copyright (c) 1998, 2025, Oracle and/or its affiliates. All rights reserved. + * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. + * + * This code is free software; you can redistribute it and/or modify it + * under the terms of the GNU General Public License version 2 only, as + * published by the Free Software Foundation. + * + * This code is distributed in the hope that it will be useful, but WITHOUT + * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or + * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License + * version 2 for more details (a copy is included in the LICENSE file that + * accompanied this code). + * + * You should have received a copy of the GNU General Public License version + * 2 along with this work; if not, write to the Free Software Foundation, + * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. + * + * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA + * or visit www.oracle.com if you need additional information or have any + * questions. + */ + +import java.awt.BorderLayout; +import java.awt.GridLayout; +import javax.swing.JButton; +import javax.swing.JFrame; +import javax.swing.JLabel; +import javax.swing.JPanel; +import javax.swing.JTable; +import javax.swing.table.AbstractTableModel; + +/* + * @test + * @bug 4226181 + * @summary Tests that JTable setModel() correctly re-sizes and counts columns + * @library /java/awt/regtesthelpers + * @build PassFailJFrame + * @run main/manual bug4226181 + */ + +public class bug4226181 { + private static final String INSTRUCTIONS = """ + Take a look at the table and remember the number of columns you see. + Now press the "setModel" button. If the number of columns has changed, + then test fails, otherwise it passes. + """; + + public static void main(String[] args) throws Exception { + PassFailJFrame.builder() + .instructions(INSTRUCTIONS) + .columns(50) + .testUI(bug4226181::createTestUI) + .build() + .awaitAndCheck(); + } + + static class TestModel extends AbstractTableModel { + public int getRowCount() { + return 5; + } + + public int getColumnCount() { + return 7; + } + + public Object getValueAt(int row, int column) { + return row + ":" + column; + } + } + + public static JFrame createTestUI() { + JFrame frame = new JFrame("bug4226181"); + TestModel testModel = new TestModel(); + final JTable t = new JTable(testModel); + JButton b = new JButton("setModel"); + b.addActionListener(ae -> t.setModel(new TestModel())); + t.setCellSelectionEnabled(true); + JPanel p1 = new JPanel(new GridLayout(1, 2)); + p1.add(new JLabel("dummy")); + p1.add(t); + frame.add(p1); + frame.add(b, BorderLayout.SOUTH); + frame.pack(); + return frame; + } +} diff -Nru openjdk-17-17.0.17+10/test/jdk/javax/swing/JTable/bug4239157.java openjdk-17-17.0.18+8/test/jdk/javax/swing/JTable/bug4239157.java --- openjdk-17-17.0.17+10/test/jdk/javax/swing/JTable/bug4239157.java 1970-01-01 00:00:00.000000000 +0000 +++ openjdk-17-17.0.18+8/test/jdk/javax/swing/JTable/bug4239157.java 2026-01-15 15:23:06.000000000 +0000 @@ -0,0 +1,85 @@ +/* + * Copyright (c) 1998, 2025, Oracle and/or its affiliates. All rights reserved. + * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. + * + * This code is free software; you can redistribute 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.swing.DefaultCellEditor; +import javax.swing.JFrame; +import javax.swing.JTable; +import javax.swing.JTextField; +import javax.swing.table.TableCellEditor; +import javax.swing.table.TableColumn; + +/* + * @test + * @bug 4239157 + * @summary Tests that JTable performs cell validation properly + * (i.e. does not accept entries for which stopCellEditing() + * returns false) + * @library /java/awt/regtesthelpers + * @build PassFailJFrame + * @run main/manual bug4239157 + */ + +public class bug4239157 { + private static final String INSTRUCTIONS = """ + You see a JTable having one row and two columns. + Click in the very first cell (where "click here" is displayed). + Edit its content (e.g. type some letters) and press right arrow key. + The edited cell should stay active, its content shouldn't change. + The right cell (that with text "inactive forever") shouldn't become active. + The same should be true when you press Tab key. + If it is so, test passes, otherwise it fails. + """; + + public static void main(String[] args) throws Exception { + PassFailJFrame.builder() + .instructions(INSTRUCTIONS) + .columns(50) + .testUI(bug4239157::createTestUI) + .build() + .awaitAndCheck(); + } + + public static JFrame createTestUI() { + JFrame frame = new JFrame("bug4239157"); + JTable table = new JTable(new Object[][]{{"click here", + "inactive forever"}}, + new Object[]{"1", "2"}); + frame.add("Center", table); + TableColumn column = table.getColumn("1"); + TableCellEditor editor = new TestEditor(new JTextField()); + column.setCellEditor(editor); + + frame.pack(); + return frame; + } + + static class TestEditor extends DefaultCellEditor { + public TestEditor(JTextField tf) { + super(tf); + } + + public boolean stopCellEditing() { + return false; + } + } +} diff -Nru openjdk-17-17.0.17+10/test/jdk/javax/swing/JTable/bug4242631.java openjdk-17-17.0.18+8/test/jdk/javax/swing/JTable/bug4242631.java --- openjdk-17-17.0.17+10/test/jdk/javax/swing/JTable/bug4242631.java 1970-01-01 00:00:00.000000000 +0000 +++ openjdk-17-17.0.18+8/test/jdk/javax/swing/JTable/bug4242631.java 2026-01-15 15:23:06.000000000 +0000 @@ -0,0 +1,144 @@ +/* + * Copyright (c) 1998, 2025, Oracle and/or its affiliates. All rights reserved. + * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. + * + * This code is free software; you can redistribute it and/or modify it + * under the terms of the GNU General Public License version 2 only, as + * published by the Free Software Foundation. + * + * This code is distributed in the hope that it will be useful, but WITHOUT + * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or + * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License + * version 2 for more details (a copy is included in the LICENSE file that + * accompanied this code). + * + * You should have received a copy of the GNU General Public License version + * 2 along with this work; if not, write to the Free Software Foundation, + * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. + * + * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA + * or visit www.oracle.com if you need additional information or have any + * questions. + */ + +import java.awt.GridBagConstraints; +import java.awt.GridBagLayout; +import java.awt.Insets; +import java.util.ArrayList; +import javax.swing.JButton; +import javax.swing.JFrame; +import javax.swing.JScrollPane; +import javax.swing.JTable; +import javax.swing.table.AbstractTableModel; + +/* + * @test + * @bug 4242631 + * @summary Tests that JTable repaints itself correctly after a record + * has been removed and added to the table model. + * @library /java/awt/regtesthelpers + * @build PassFailJFrame + * @run main/manual bug4242631 + */ + +public class bug4242631 { + private static JButton addButton; + private static JButton removeButton; + private static JButton bothButton; + private static SimpleTableModel tableModel; + + private static final String INSTRUCTIONS = """ + Press Add button to add a record to the table. The record added should + have number 0. Then press Remove/Add button some times. The record number + should increase as you press. If it does not, test fails. + """; + + public static void main(String[] args) throws Exception { + PassFailJFrame.builder() + .instructions(INSTRUCTIONS) + .columns(50) + .testUI(bug4242631::createTestUI) + .build() + .awaitAndCheck(); + } + + public static JFrame createTestUI() { + JFrame frame = new JFrame("bug4242631"); + GridBagLayout grid = new GridBagLayout(); + + frame.setLayout(grid); + GridBagConstraints c = new GridBagConstraints(); + c.insets = new Insets(2, 2, 2, 2); + + // Add button. + c.gridx = 0; + c.gridy = 0; + grid.setConstraints(addButton = new JButton("Add"), c); + frame.add(addButton); + + // Edit button. + c.gridx = 1; + c.gridy = 0; + grid.setConstraints(removeButton = new JButton("Remove"), c); + frame.add(removeButton); + + // Remove button. + c.gridx = 2; + c.gridy = 0; + grid.setConstraints(bothButton = new JButton("Remove/Add"), c); + frame.add(bothButton); + + // Table. + c.gridx = 0; + c.gridy = 1; + c.gridwidth = 6; + c.gridheight = 0; + c.anchor = GridBagConstraints.CENTER; + c.fill = GridBagConstraints.BOTH; + c.weightx = 1.0; + c.weighty = 1.0; + JScrollPane scroll = null; + tableModel = new SimpleTableModel(); + grid.setConstraints(scroll = new JScrollPane(new JTable(tableModel)), c); + frame.add(scroll); + + // Create some action listeners. + addButton.addActionListener(event -> tableModel.addRow()); + removeButton.addActionListener(event -> tableModel.removeRow()); + bothButton.addActionListener(event -> tableModel.removeThenAddRow()); + + frame.pack(); + return frame; + } + + static class SimpleTableModel extends AbstractTableModel { + int counter = 0; + ArrayList list = new ArrayList(); + + public SimpleTableModel() {} + public int getColumnCount() { return 1; } + public int getRowCount() { return list.size(); } + + public Object getValueAt(int row, int col) { + String str = (String) list.get(row); + return str;// + "." + col; + } + + public void addRow() { + list.add("" + counter++); + fireTableRowsInserted(list.size() - 1, list.size() - 1); + } + + public void removeRow() { + if (list.size() == 0) return; + list.remove(list.size() - 1); + fireTableRowsDeleted(list.size(), list.size()); + } + + public void removeThenAddRow() { + if (list.size() == 0) return; + removeRow(); + addRow(); + } + } +} diff -Nru openjdk-17-17.0.17+10/test/jdk/javax/swing/JTableHeader/6884066/bug6884066.java openjdk-17-17.0.18+8/test/jdk/javax/swing/JTableHeader/6884066/bug6884066.java --- openjdk-17-17.0.17+10/test/jdk/javax/swing/JTableHeader/6884066/bug6884066.java 2025-10-13 07:48:04.000000000 +0000 +++ openjdk-17-17.0.18+8/test/jdk/javax/swing/JTableHeader/6884066/bug6884066.java 2026-01-15 15:23:06.000000000 +0000 @@ -1,5 +1,5 @@ /* - * Copyright (c) 2010, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2010, 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 @@ -23,56 +23,74 @@ /* @test - @key headful + @key headful @bug 6884066 @summary JTableHeader listens mouse in disabled state and doesn't work when not attached to a table - @author Alexander Potochkin @run main bug6884066 */ -import javax.swing.*; +import java.awt.event.InputEvent; +import java.awt.Point; +import java.awt.Robot; +import javax.swing.JFrame; +import javax.swing.JTable; import javax.swing.table.JTableHeader; import javax.swing.table.TableColumnModel; import javax.swing.table.TableColumn; -import java.awt.*; -import java.awt.event.InputEvent; +import javax.swing.SwingUtilities; +import javax.swing.UIManager; public class bug6884066 { + private static JFrame frame; private static JTableHeader header; + private static volatile Point point; public static void main(String[] args) throws Exception { + try { + UIManager.setLookAndFeel(UIManager.getSystemLookAndFeelClassName()); - UIManager.setLookAndFeel(UIManager.getSystemLookAndFeelClassName()); - - Robot robot = new Robot(); - robot.setAutoDelay(20); - SwingUtilities.invokeAndWait(new Runnable() { - public void run() { - // just to quickly grab a column model - JTable table = new JTable(10, 5); - header = new JTableHeader(table.getColumnModel()); - checkColumn(0, "A"); - JFrame frame = new JFrame("standalone header"); - frame.add(header); - frame.pack(); - frame.setVisible(true); - frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE); + Robot robot = new Robot(); + robot.setAutoDelay(100); + SwingUtilities.invokeAndWait(new Runnable() { + public void run() { + // just to quickly grab a column model + JTable table = new JTable(10, 5); + header = new JTableHeader(table.getColumnModel()); + checkColumn(0, "A"); + frame = new JFrame("standalone header"); + frame.add(header); + frame.pack(); + frame.setLocationRelativeTo(null); + frame.setVisible(true); + frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE); + } + }); + robot.waitForIdle(); + robot.delay(1000); + SwingUtilities.invokeAndWait(() -> { + point = header.getLocationOnScreen(); + }); + robot.mouseMove(point.x + 3, point.y + 3); + robot.waitForIdle(); + robot.mousePress(InputEvent.BUTTON1_DOWN_MASK); + for (int i = 0; i < header.getWidth() - 3; i++) { + robot.mouseMove(point.x + i, point.y + 3); } - }); - robot.waitForIdle(); - Point point = header.getLocationOnScreen(); - robot.mouseMove(point.x + 3, point.y + 3); - robot.mousePress(InputEvent.BUTTON1_MASK); - for (int i = 0; i < header.getWidth() - 3; i++) { - robot.mouseMove(point.x + i, point.y + 3); + robot.mouseRelease(InputEvent.BUTTON1_DOWN_MASK); + robot.waitForIdle(); + SwingUtilities.invokeAndWait(new Runnable() { + public void run() { + TableColumnModel model = header.getColumnModel(); + checkColumn(model.getColumnCount() - 1, "A"); + } + }); + } finally { + SwingUtilities.invokeAndWait(() -> { + if (frame != null) { + frame.dispose(); + } + }); } - robot.mouseRelease(InputEvent.BUTTON1_MASK); - SwingUtilities.invokeAndWait(new Runnable() { - public void run() { - TableColumnModel model = header.getColumnModel(); - checkColumn(model.getColumnCount() - 1, "A"); - } - }); } private static void checkColumn(int index, String str) { diff -Nru openjdk-17-17.0.17+10/test/jdk/javax/swing/JTextField/bug4232716.java openjdk-17-17.0.18+8/test/jdk/javax/swing/JTextField/bug4232716.java --- openjdk-17-17.0.17+10/test/jdk/javax/swing/JTextField/bug4232716.java 1970-01-01 00:00:00.000000000 +0000 +++ openjdk-17-17.0.18+8/test/jdk/javax/swing/JTextField/bug4232716.java 2026-01-15 15:23:06.000000000 +0000 @@ -0,0 +1,81 @@ +/* + * Copyright (c) 1999, 2025, Oracle and/or its affiliates. All rights reserved. + * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. + * + * This code is free software; you can redistribute 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 4232716 + * @key headful + * @summary Tests if creates a maximized JTextField + * @run main bug4232716 + */ + +import java.awt.Component; +import java.awt.Container; +import java.awt.Robot; +import javax.swing.JEditorPane; +import javax.swing.JFrame; +import javax.swing.JTextField; +import javax.swing.SwingUtilities; + +public class bug4232716 { + + private static JFrame frame; + private static JEditorPane e; + + public static void main(String[] args) throws Exception { + Robot robot = new Robot(); + try { + SwingUtilities.invokeAndWait(() -> { + frame = new JFrame("bug4232716"); + String html =" Test " + + "
" + + "
"; + e = new JEditorPane("text/html", html); + e.setEditable(false); + frame.add(e); + frame.setSize(400, 300); + frame.setLocationRelativeTo(null); + frame.setVisible(true); + }); + robot.waitForIdle(); + robot.delay(1000); + + Container c = (Container)e.getComponent(0); + Component swingComponent = c.getComponent(0); + System.out.println(swingComponent); + if (swingComponent instanceof JTextField tf) { + System.out.println(tf.getWidth()); + System.out.println(frame.getWidth()); + if (swingComponent.getWidth() > (frame.getWidth() * 0.75)) { + throw new RuntimeException("textfield width almost same as frame width"); + } + } + } finally { + SwingUtilities.invokeAndWait(() -> { + if (frame != null) { + frame.dispose(); + } + }); + } + } +} diff -Nru openjdk-17-17.0.17+10/test/jdk/javax/swing/JTextField/bug5027332.java openjdk-17-17.0.18+8/test/jdk/javax/swing/JTextField/bug5027332.java --- openjdk-17-17.0.17+10/test/jdk/javax/swing/JTextField/bug5027332.java 1970-01-01 00:00:00.000000000 +0000 +++ openjdk-17-17.0.18+8/test/jdk/javax/swing/JTextField/bug5027332.java 2026-01-15 15:23:06.000000000 +0000 @@ -0,0 +1,70 @@ +/* + * Copyright (c) 2004, 2025, Oracle and/or its affiliates. All rights reserved. + * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. + * + * This code is free software; you can redistribute 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 5027332 + * @library /java/awt/regtesthelpers + * @build PassFailJFrame + * @summary Tests that textfield caret is placed slightly off textfield borders + * @run main/manual bug5027332 + */ + +import java.awt.BorderLayout; + +import javax.swing.JFrame; +import javax.swing.JPanel; +import javax.swing.JTextField; +import javax.swing.UIManager; + +public class bug5027332 { + + private static final String INSTRUCTIONS = """ + Click into the text field so that caret appears inside. + The caret should be placed slightly off text field borders, + so that it can be easily distinguished from the border. + Test fails if the caret touches the border."""; + + public static void main(String[] args) throws Exception { + UIManager.setLookAndFeel(UIManager.getSystemLookAndFeelClassName()); + + PassFailJFrame.builder() + .title("bug5027332 Instructions") + .instructions(INSTRUCTIONS) + .rows(6) + .columns(35) + .testUI(bug5027332::createTestUI) + .build() + .awaitAndCheck(); + } + + private static JFrame createTestUI() { + JFrame frame = new JFrame("bug5027332"); + JTextField t = new JTextField(10); + JPanel p = new JPanel(); + p.add(t, BorderLayout.CENTER); + frame.setContentPane(p); + frame.pack(); + return frame; + } +} diff -Nru openjdk-17-17.0.17+10/test/jdk/javax/swing/JToggleButton/4128979/bug4128979.html openjdk-17-17.0.18+8/test/jdk/javax/swing/JToggleButton/4128979/bug4128979.html --- openjdk-17-17.0.17+10/test/jdk/javax/swing/JToggleButton/4128979/bug4128979.html 2025-10-13 07:48:04.000000000 +0000 +++ openjdk-17-17.0.18+8/test/jdk/javax/swing/JToggleButton/4128979/bug4128979.html 1970-01-01 00:00:00.000000000 +0000 @@ -1,41 +0,0 @@ - - - -This test requires Windows look and feel, just press Pass if you -run it not on Windows. - -When the test starts you'll see toggle buttons in three rows -two of which are toolbars. - -Make these buttons pressed, their background color must change -to halftones between the button background colors and the ToggleButton -highlight color (it is shown in the square below). - -If the background color does not change correctly for at least one button, -the test fails. - - - - - diff -Nru openjdk-17-17.0.17+10/test/jdk/javax/swing/JToggleButton/4128979/bug4128979.java openjdk-17-17.0.18+8/test/jdk/javax/swing/JToggleButton/4128979/bug4128979.java --- openjdk-17-17.0.17+10/test/jdk/javax/swing/JToggleButton/4128979/bug4128979.java 2025-10-13 07:48:04.000000000 +0000 +++ openjdk-17-17.0.18+8/test/jdk/javax/swing/JToggleButton/4128979/bug4128979.java 1970-01-01 00:00:00.000000000 +0000 @@ -1,143 +0,0 @@ -/* - * Copyright (c) 1998, 2021, Oracle and/or its affiliates. All rights reserved. - * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. - * - * This code is free software; you can redistribute it and/or modify it - * under the terms of the GNU General Public License version 2 only, as - * published by the Free Software Foundation. - * - * This code is distributed in the hope that it will be useful, but WITHOUT - * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or - * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License - * version 2 for more details (a copy is included in the LICENSE file that - * accompanied this code). - * - * You should have received a copy of the GNU General Public License version - * 2 along with this work; if not, write to the Free Software Foundation, - * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. - * - * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA - * or visit www.oracle.com if you need additional information or have any - * questions. - */ - -/* @test - @bug 4128979 - @requires (os.family == "windows") - @summary Tests that background changes correctly in WinLF for JToggleButton when pressed - @key headful - @run applet/manual=yesno bug4128979.html -*/ - -import javax.swing.BorderFactory; -import javax.swing.BoxLayout; -import javax.swing.Icon; -import javax.swing.JApplet; -import javax.swing.JFrame; -import javax.swing.JLabel; -import javax.swing.JOptionPane; -import javax.swing.JPanel; -import javax.swing.JToggleButton; -import javax.swing.JToolBar; -import javax.swing.UIManager; -import javax.swing.UnsupportedLookAndFeelException; -import javax.swing.WindowConstants; -import java.awt.BorderLayout; -import java.awt.Color; -import java.awt.Component; -import java.awt.ComponentOrientation; -import java.awt.Container; -import java.awt.FlowLayout; -import java.awt.Graphics; - -public class bug4128979 extends JApplet { - - public static void main(String[] args) { - JApplet applet = new bug4128979(); - applet.init(); - applet.start(); - - JFrame frame = new JFrame("Test window"); - frame.setDefaultCloseOperation(WindowConstants.EXIT_ON_CLOSE); - frame.setLayout(new BorderLayout()); - frame.add(applet, BorderLayout.CENTER); - frame.setSize(600, 240); - frame.setVisible(true); - } - - public void init() { - try { - UIManager.setLookAndFeel("com.sun.java.swing.plaf.windows.WindowsClassicLookAndFeel"); - } catch (UnsupportedLookAndFeelException e) { - JOptionPane.showMessageDialog(this, - "This test requires Windows look and feel, so just press Pass\n as "+ - " this look and feel is unsupported on this platform.", - "Unsupported LF", JOptionPane.ERROR_MESSAGE); - return; - } catch (Exception e) { - throw new RuntimeException("Couldn't set look and feel"); - } - - setLayout(new FlowLayout()); - JPanel p = new JPanel(); - p.setLayout(new BoxLayout(p, BoxLayout.Y_AXIS)); - - JPanel p1 = new JPanel(); - addButtons(p1); - p.add(p1); - - JToolBar tb1 = new JToolBar(); - addButtons(tb1); - p.add(tb1); - - JToolBar tb2 = new JToolBar(); - tb2.setRollover(true); - addButtons(tb2); - p.add(tb2); - - JLabel label = new JLabel("ToggleButton.highlight color: "); - label.setComponentOrientation( ComponentOrientation.RIGHT_TO_LEFT); - label.setIcon(new Icon() { - public void paintIcon(Component c, Graphics g, int x, int y) { - g.setColor(UIManager.getColor("ToggleButton.highlight")); - g.fillRect(x, y, 49, 49); - g.setColor(new Color(~UIManager.getColor("ToggleButton.highlight").getRGB())); - g.drawRect(x, y, 49, 49); - } - - public int getIconWidth() { - return 50; - } - - public int getIconHeight() { - return 50; - } - }); - add(p); - add(label); - } - - static void addButtons(Container c) { - c.setLayout(new FlowLayout()); - - c.add(new JToggleButton("DefaultBorder")); - - JToggleButton cbut = new JToggleButton("DefaultBorder"); - cbut.setBackground(Color.red); - c.add(cbut); - cbut = new JToggleButton("DefaultBorder"); - cbut.setBackground(Color.green); - c.add(cbut); - cbut = new JToggleButton("DefaultBorder"); - cbut.setBackground(Color.blue); - c.add(cbut); - - JToggleButton but3 = new JToggleButton("LineBorder"); - but3.setBorder(BorderFactory.createLineBorder(Color.red)); - c.add(but3); - - JToggleButton but4 = new JToggleButton("null border"); - but4.setBorder(null); - c.add(but4); - } -} diff -Nru openjdk-17-17.0.17+10/test/jdk/javax/swing/JToggleButton/bug4128979.java openjdk-17-17.0.18+8/test/jdk/javax/swing/JToggleButton/bug4128979.java --- openjdk-17-17.0.17+10/test/jdk/javax/swing/JToggleButton/bug4128979.java 1970-01-01 00:00:00.000000000 +0000 +++ openjdk-17-17.0.18+8/test/jdk/javax/swing/JToggleButton/bug4128979.java 2026-01-15 15:23:06.000000000 +0000 @@ -0,0 +1,149 @@ +/* + * Copyright (c) 1998, 2024, Oracle and/or its affiliates. All rights reserved. + * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. + * + * This code is free software; you can redistribute it and/or modify it + * under the terms of the GNU General Public License version 2 only, as + * published by the Free Software Foundation. + * + * This code is distributed in the hope that it will be useful, but WITHOUT + * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or + * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License + * version 2 for more details (a copy is included in the LICENSE file that + * accompanied this code). + * + * You should have received a copy of the GNU General Public License version + * 2 along with this work; if not, write to the Free Software Foundation, + * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. + * + * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA + * or visit www.oracle.com if you need additional information or have any + * questions. + */ + +import java.awt.Color; +import java.awt.Component; +import java.awt.ComponentOrientation; +import java.awt.Container; +import java.awt.FlowLayout; +import java.awt.Graphics; + +import javax.swing.BorderFactory; +import javax.swing.BoxLayout; +import javax.swing.Icon; +import javax.swing.JFrame; +import javax.swing.JLabel; +import javax.swing.JPanel; +import javax.swing.JToggleButton; +import javax.swing.JToolBar; +import javax.swing.UIManager; + +import jtreg.SkippedException; +import sun.awt.OSInfo; + +/* @test + * @bug 4128979 + * @requires (os.family == "windows") + * @modules java.desktop/sun.awt + * @library /java/awt/regtesthelpers /test/lib + * @build PassFailJFrame jtreg.SkippedException + * @summary Tests that background changes correctly in WinLF for JToggleButton when pressed + * @run main/manual bug4128979 + */ + +public class bug4128979 { + private static final String INSTRUCTIONS = """ + When the test starts, toggle buttons are visible in three rows + two of which are toolbars. + + Press these buttons, their background color must change + to half tones between the button background colors and the ToggleButton + highlight color (it is shown in the square below). + + If the background color does not change correctly for at least one button, + the test fails."""; + + public static void main(String[] args) throws Exception { + if (OSInfo.getOSType() != OSInfo.OSType.WINDOWS) { + throw new SkippedException("This test is for Windows only"); + } + UIManager.setLookAndFeel("com.sun.java.swing.plaf.windows.WindowsClassicLookAndFeel"); + PassFailJFrame.builder() + .title("JToggleButton Instructions") + .instructions(INSTRUCTIONS) + .rows(15) + .columns(60) + .testUI(bug4128979::createAndShowUI) + .build() + .awaitAndCheck(); + } + + public static JFrame createAndShowUI() { + JFrame frame = new JFrame("JToggleButton's Background Color Test"); + frame.setLayout(new FlowLayout()); + + JPanel p = new JPanel(); + p.setLayout(new BoxLayout(p, BoxLayout.Y_AXIS)); + + JPanel p1 = new JPanel(); + addButtons(p1); + p.add(p1); + + JToolBar tb1 = new JToolBar(); + addButtons(tb1); + p.add(tb1); + + JToolBar tb2 = new JToolBar(); + tb2.setRollover(true); + addButtons(tb2); + p.add(tb2); + + JLabel label = new JLabel("ToggleButton.highlight color: "); + label.setComponentOrientation( ComponentOrientation.RIGHT_TO_LEFT); + label.setIcon(new Icon() { + public void paintIcon(Component c, Graphics g, int x, int y) { + g.setColor(UIManager.getColor("ToggleButton.highlight")); + g.fillRect(x, y, 49, 49); + g.setColor(new Color(~UIManager.getColor("ToggleButton.highlight").getRGB())); + g.drawRect(x, y, 49, 49); + } + + public int getIconWidth() { + return 50; + } + + public int getIconHeight() { + return 50; + } + }); + + frame.getContentPane().add(p); + frame.getContentPane().add(label); + frame.setSize(600, 250); + return frame; + } + + static void addButtons(Container c) { + c.setLayout(new FlowLayout()); + + c.add(new JToggleButton("DefaultBorder")); + + JToggleButton cbut = new JToggleButton("DefaultBorder"); + cbut.setBackground(Color.red); + c.add(cbut); + cbut = new JToggleButton("DefaultBorder"); + cbut.setBackground(Color.green); + c.add(cbut); + cbut = new JToggleButton("DefaultBorder"); + cbut.setBackground(Color.blue); + c.add(cbut); + + JToggleButton but3 = new JToggleButton("LineBorder"); + but3.setBorder(BorderFactory.createLineBorder(Color.red)); + c.add(but3); + + JToggleButton but4 = new JToggleButton("null border"); + but4.setBorder(null); + c.add(but4); + } +} diff -Nru openjdk-17-17.0.17+10/test/jdk/javax/swing/JToolTip/TooltipTest.java openjdk-17-17.0.18+8/test/jdk/javax/swing/JToolTip/TooltipTest.java --- openjdk-17-17.0.17+10/test/jdk/javax/swing/JToolTip/TooltipTest.java 1970-01-01 00:00:00.000000000 +0000 +++ openjdk-17-17.0.18+8/test/jdk/javax/swing/JToolTip/TooltipTest.java 2026-01-15 15:23:06.000000000 +0000 @@ -0,0 +1,90 @@ +/* + * Copyright (c) 1999, 2025, Oracle and/or its affiliates. All rights reserved. + * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. + * + * This code is free software; you can redistribute 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 4207474 4218495 4375928 + * @summary Tests various tooltip issues: HTML tooltips, long tooltip text + * and mnemonic keys displayed in tooltips + * @library /java/awt/regtesthelpers + * @build PassFailJFrame + * @run main/manual TooltipTest + */ + +import java.awt.FlowLayout; +import java.awt.event.KeyEvent; +import javax.swing.JButton; +import javax.swing.JComponent; +import javax.swing.JPanel; +import javax.swing.UIManager; + +public class TooltipTest { + private static final String INSTRUCTIONS = """ + 1. Move the mouse over the button labeled "Red tip" and let it stay + still in order to test HTML in JToolTip. If the tooltip has some + text which is red then test passes, otherwise it fails (bug 4207474). + + 2. Move the mouse over the button labeled "Long tip". + If the last letter of the tooltip appears clipped, + then the test fails. If you can see the entire last character, + then the test passes (bug 4218495). + + 3. Verify that "M" is underlined on the button labeled "Mnemonic" + Move the mouse pointer over the button labeled "Mnemonic" and look + at tooltip when it appears. It should read "hint". + If the above is true test passes else test fails (bug 4375928). + """; + + public static void main(String[] args) throws Exception { + UIManager.setLookAndFeel("javax.swing.plaf.metal.MetalLookAndFeel"); + + PassFailJFrame.builder() + .title("TooltipTest Instructions") + .instructions(INSTRUCTIONS) + .columns(40) + .testUI(TooltipTest::createTestUI) + .build() + .awaitAndCheck(); + } + + private static JComponent createTestUI() { + JPanel panel = new JPanel(); + panel.setLayout(new FlowLayout()); + + JButton b = new JButton("Red tip"); + b.setToolTipText("
Here is some " + + "red text.
"); + panel.add(b); + + b = new JButton("Long tip"); + b.setToolTipText("Is the last letter clipped?"); + panel.add(b); + + b = new JButton("Mnemonic"); + b.setMnemonic(KeyEvent.VK_M); + b.setToolTipText("hint"); + panel.add(b); + + return panel; + } +} diff -Nru openjdk-17-17.0.17+10/test/jdk/javax/swing/JToolTip/bug4225314.java openjdk-17-17.0.18+8/test/jdk/javax/swing/JToolTip/bug4225314.java --- openjdk-17-17.0.17+10/test/jdk/javax/swing/JToolTip/bug4225314.java 1970-01-01 00:00:00.000000000 +0000 +++ openjdk-17-17.0.18+8/test/jdk/javax/swing/JToolTip/bug4225314.java 2026-01-15 15:23:06.000000000 +0000 @@ -0,0 +1,72 @@ +/* + * Copyright (c) 1999, 2025, Oracle and/or its affiliates. All rights reserved. + * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. + * + * This code is free software; you can redistribute 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 4225314 + * @summary Tests that tooltip is painted properly when it has thick border + * @library /java/awt/regtesthelpers + * @build PassFailJFrame + * @run main/manual bug4225314 + */ + +import java.awt.Color; +import java.awt.FlowLayout; +import javax.swing.JComponent; +import javax.swing.JPanel; +import javax.swing.JToolTip; +import javax.swing.border.LineBorder; + +public class bug4225314 { + private static final String INSTRUCTIONS = """ + The word "Tooltip" in both tooltips should not be clipped by the + black border and be fully visible for this test to pass. + """; + + public static void main(String[] args) throws Exception { + PassFailJFrame.builder() + .title("bug4225314 Instructions") + .instructions(INSTRUCTIONS) + .columns(40) + .testUI(bug4225314::createTestUI) + .build() + .awaitAndCheck(); + } + + private static JComponent createTestUI() { + JToolTip tt1 = new JToolTip(); + tt1.setTipText("Tooltip"); + tt1.setBorder(new LineBorder(Color.BLACK, 10)); + + JToolTip tt2 = new JToolTip(); + tt2.setTipText("Tooltip"); + tt2.setBorder(new LineBorder(Color.BLACK, 10)); + + JPanel panel = new JPanel(); + panel.setLayout(new FlowLayout()); + panel.add(tt1); + panel.add(tt2); + + return panel; + } +} diff -Nru openjdk-17-17.0.17+10/test/jdk/javax/swing/JToolTip/bug4255441.java openjdk-17-17.0.18+8/test/jdk/javax/swing/JToolTip/bug4255441.java --- openjdk-17-17.0.17+10/test/jdk/javax/swing/JToolTip/bug4255441.java 1970-01-01 00:00:00.000000000 +0000 +++ openjdk-17-17.0.18+8/test/jdk/javax/swing/JToolTip/bug4255441.java 2026-01-15 15:23:06.000000000 +0000 @@ -0,0 +1,64 @@ +/* + * 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 + * 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 4255441 + * @summary Tests that tooltip appears inside AWT Frame + * @library /java/awt/regtesthelpers + * @build PassFailJFrame + * @run main/manual bug4255441 + */ + +import java.awt.FlowLayout; +import java.awt.Frame; +import javax.swing.JButton; + +public class bug4255441 { + private static final String INSTRUCTIONS = """ + Move mouse pointer inside the button. + If a tooltip with "Tooltip text" appears, the test passes. + """; + + private static Frame createTestUI() { + Frame fr = new Frame("bug4255441"); + fr.setLayout(new FlowLayout()); + + JButton bt = new JButton("Button"); + bt.setToolTipText("Tooltip text"); + fr.add(bt); + + fr.setSize(200, 200); + return fr; + } + + public static void main(String[] argv) throws Exception { + PassFailJFrame.builder() + .title("bug4255441 Instructions") + .instructions(INSTRUCTIONS) + .columns(40) + .testUI(bug4255441::createTestUI) + .build() + .awaitAndCheck(); + } +} diff -Nru openjdk-17-17.0.17+10/test/jdk/javax/swing/JViewport/ScrollRectToVisibleTest3.java openjdk-17-17.0.18+8/test/jdk/javax/swing/JViewport/ScrollRectToVisibleTest3.java --- openjdk-17-17.0.17+10/test/jdk/javax/swing/JViewport/ScrollRectToVisibleTest3.java 1970-01-01 00:00:00.000000000 +0000 +++ openjdk-17-17.0.18+8/test/jdk/javax/swing/JViewport/ScrollRectToVisibleTest3.java 2026-01-15 15:23:06.000000000 +0000 @@ -0,0 +1,165 @@ +/* + * Copyright (c) 1999, 2025, Oracle and/or its affiliates. All rights reserved. + * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. + * + * This code is free software; you can redistribute it and/or modify it + * under the terms of the GNU General Public License version 2 only, as + * published by the Free Software Foundation. + * + * This code is distributed in the hope that it will be useful, but WITHOUT + * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or + * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License + * version 2 for more details (a copy is included in the LICENSE file that + * accompanied this code). + * + * You should have received a copy of the GNU General Public License version + * 2 along with this work; if not, write to the Free Software Foundation, + * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. + * + * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA + * or visit www.oracle.com if you need additional information or have any + * questions. + */ + +/* + * @test + * @key headful + * @bug 4217252 + * @summary Verify that scrolling beyond the visible region and scrolling + * a component smaller than the viewport is not allowed. + * @library /javax/swing/regtesthelpers + * @build Util + * @run main/othervm -Dsun.java2d.uiScale=1 ScrollRectToVisibleTest3 + */ + +import java.awt.BorderLayout; +import java.awt.Component; +import java.awt.Dimension; +import java.awt.Point; +import java.awt.Rectangle; +import java.awt.Robot; +import java.awt.event.MouseAdapter; +import java.awt.event.MouseEvent; +import javax.swing.JButton; +import javax.swing.JFrame; +import javax.swing.JScrollPane; +import javax.swing.JTable; +import javax.swing.SwingUtilities; +import javax.swing.table.AbstractTableModel; + +public class ScrollRectToVisibleTest3 { + private static JFrame frame; + private static JTable table; + private static JButton scrollButton; + private static volatile int clickCount = 0; + private static final String[] EXPECTED_TEXT = {"99 x 0", "98 x 0", + "97 x 0", "96 x 0"}; + public static void main(String[] args) throws Exception { + Robot robot = new Robot(); + robot.setAutoWaitForIdle(true); + + SwingUtilities.invokeAndWait(ScrollRectToVisibleTest3::createTestUI); + robot.waitForIdle(); + robot.delay(1000); + + Rectangle frameBounds = Util.invokeOnEDT(() -> getComponentBounds(frame)); + robot.delay(100); + Point scrollBtnLoc = Util.getCenterPoint(scrollButton); + + robot.mouseMove(scrollBtnLoc.x, scrollBtnLoc.y); + robot.mousePress(MouseEvent.BUTTON1_DOWN_MASK); + robot.mouseRelease(MouseEvent.BUTTON1_DOWN_MASK); + robot.mousePress(MouseEvent.BUTTON1_DOWN_MASK); + robot.mouseRelease(MouseEvent.BUTTON1_DOWN_MASK); + robot.delay(50); + + int rowHeight = Util.invokeOnEDT(() -> table.getRowHeight()); + for (int i = 1; i <= 4; i++) { + robot.mouseMove(frameBounds.x + 50, + frameBounds.y + frameBounds.height - (rowHeight * i + 2)); + robot.delay(300); + robot.mousePress(MouseEvent.BUTTON1_DOWN_MASK); + robot.mouseRelease(MouseEvent.BUTTON1_DOWN_MASK); + // 500 ms delay added so that current mouseClicked event + // is processed successfully before proceeding to the next + robot.delay(500); + } + if (clickCount != 4) { + throw new RuntimeException("Test Failed! Expected 4 mouse clicks" + + " but got " + clickCount); + } + } + + private static void createTestUI() { + frame = new JFrame("ScrollRectToVisibleTest3"); + table = new JTable(new TestModel()); + table.addMouseListener(new MouseAdapter() { + @Override + public void mouseClicked(MouseEvent e) { + JTable testTable = (JTable) e.getComponent(); + int row = testTable.getSelectedRow(); + int column = testTable.getSelectedColumn(); + String cellContent = testTable.getValueAt(row, column).toString(); + if (!EXPECTED_TEXT[clickCount].equals(cellContent)) { + throw new RuntimeException(("Test failed! Table Cell Content" + + " at (row %d , col %d)\n Expected: %s vs Actual: %s") + .formatted(row, column, + EXPECTED_TEXT[clickCount], cellContent)); + } + clickCount++; + } + }); + + scrollButton = new JButton("Scroll"); + scrollButton.addActionListener(ae -> { + Rectangle bounds = table.getBounds(); + bounds.y = bounds.height + table.getRowHeight(); + bounds.height = table.getRowHeight(); + System.out.println("scrolling: " + bounds); + table.scrollRectToVisible(bounds); + System.out.println("bounds: " + table.getVisibleRect()); + }); + + frame.add(scrollButton, BorderLayout.NORTH); + frame.add(new JScrollPane(table), BorderLayout.CENTER); + frame.setSize(400, 300); + frame.setLocationRelativeTo(null); + frame.setVisible(true); + } + + + private static class TestModel extends AbstractTableModel { + @Override + public String getColumnName(int column) { + return Integer.toString(column); + } + + @Override + public int getRowCount() { + return 100; + } + + @Override + public int getColumnCount() { + return 5; + } + + @Override + public Object getValueAt(int row, int col) { + return row + " x " + col; + } + + @Override + public boolean isCellEditable(int row, int column) { return false; } + + @Override + public void setValueAt(Object value, int row, int col) { + } + } + + private static Rectangle getComponentBounds(Component c) { + Point locationOnScreen = c.getLocationOnScreen(); + Dimension size = c.getSize(); + return new Rectangle(locationOnScreen, size); + } +} diff -Nru openjdk-17-17.0.17+10/test/jdk/javax/swing/JViewport/SetViewRepaint.java openjdk-17-17.0.18+8/test/jdk/javax/swing/JViewport/SetViewRepaint.java --- openjdk-17-17.0.17+10/test/jdk/javax/swing/JViewport/SetViewRepaint.java 1970-01-01 00:00:00.000000000 +0000 +++ openjdk-17-17.0.18+8/test/jdk/javax/swing/JViewport/SetViewRepaint.java 2026-01-15 15:23:06.000000000 +0000 @@ -0,0 +1,114 @@ +/* + * Copyright (c) 1999, 2025, Oracle and/or its affiliates. All rights reserved. + * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. + * + * This code is free software; you can redistribute 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 4128110 + * @summary Verify that JViewport.setViewportView() and JScrollPane.setViewport() + * force a re-layout and a repaint. + * @library /java/awt/regtesthelpers + * @build PassFailJFrame + * @run main/manual SetViewRepaint + */ + +import java.awt.BorderLayout; +import java.awt.Color; +import java.awt.GridLayout; +import java.awt.event.ActionListener; +import javax.swing.JButton; +import javax.swing.JFrame; +import javax.swing.JLabel; +import javax.swing.JList; +import javax.swing.JPanel; +import javax.swing.JScrollPane; +import javax.swing.JViewport; + +public class SetViewRepaint { + private static final String INSTRUCTIONS = """ + Verify the following two cases: + + 1) Press "JViewport.setViewportView()" button and verify that + the blue label is replaced by a scrolling list. + + 2) Press "JScrollPane.setViewport()" button and verify that + the red label is replaced by a scrolling list as well. + + In either case the display should update automatically after + pressing the button. + + If the above is true, press PASS else press FAIL. + """; + + public static void main(String[] args) throws Exception { + PassFailJFrame.builder() + .instructions(INSTRUCTIONS) + .columns(30) + .testUI(SetViewRepaint::createTestUI) + .build() + .awaitAndCheck(); + } + + private static JFrame createTestUI() { + JFrame frame = new JFrame("SetViewRepaint"); + JPanel p1 = new JPanel(new BorderLayout()); + JPanel p2 = new JPanel(new BorderLayout()); + + JLabel label1 = new ColorLabel(Color.BLUE, "Blue Label"); + final JList list1 = new JList(new String[]{"one", "two", "three", "four"}); + final JScrollPane sp1 = new JScrollPane(label1); + ActionListener doSetViewportView = e -> sp1.setViewportView(list1); + JButton b1 = new JButton("JViewport.setViewportView()"); + b1.addActionListener(doSetViewportView); + p1.add(sp1, BorderLayout.CENTER); + p1.add(b1, BorderLayout.SOUTH); + + JLabel label2 = new ColorLabel(Color.RED, "Red Label"); + final JList list2 = new JList(new String[]{"five", "six", "seven", "eight"}); + final JScrollPane sp2 = new JScrollPane(label2); + ActionListener doSetViewport = e -> { + JViewport vp = new JViewport(); + vp.setView(list2); + sp2.setViewport(vp); + }; + JButton b2 = new JButton("JScrollPane.setViewport()"); + b2.addActionListener(doSetViewport); + p2.add(sp2, BorderLayout.CENTER); + p2.add(b2, BorderLayout.SOUTH); + frame.setLayout(new GridLayout(1, 2)); + frame.add(p1); + frame.add(p2); + frame.setResizable(false); + frame.setSize(500, 120); + return frame; + } + + private static class ColorLabel extends JLabel { + ColorLabel(Color color, String text) { + super(text); + setForeground(Color.WHITE); + setBackground(color); + setOpaque(true); + setHorizontalAlignment(CENTER); + } + } +} diff -Nru openjdk-17-17.0.17+10/test/jdk/javax/swing/JWindow/bug4251781.java openjdk-17-17.0.18+8/test/jdk/javax/swing/JWindow/bug4251781.java --- openjdk-17-17.0.17+10/test/jdk/javax/swing/JWindow/bug4251781.java 1970-01-01 00:00:00.000000000 +0000 +++ openjdk-17-17.0.18+8/test/jdk/javax/swing/JWindow/bug4251781.java 2026-01-15 15:23:06.000000000 +0000 @@ -0,0 +1,76 @@ +/* + * 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 + * 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 4251781 + * @summary Tests that JWindow repaint is optimized (background is not + cleared). + * @library /java/awt/regtesthelpers + * @build PassFailJFrame + * @run main/manual bug4251781 + */ + +import java.awt.Color; +import java.awt.Container; +import javax.swing.JButton; +import javax.swing.JMenuItem; +import javax.swing.JPopupMenu; +import javax.swing.JWindow; + +public class bug4251781 { + private static final String INSTRUCTIONS = """ + Press the button at the bottom-right corner of the gray + window with the mouse. + If the window DOES NOT flicker when you press and/or release + the mouse button press PASS else FAIL. + """; + + public static void main(String[] args) throws Exception { + PassFailJFrame.builder() + .instructions(INSTRUCTIONS) + .columns(40) + .testUI(bug4251781::createAndShowUI) + .build() + .awaitAndCheck(); + } + + private static JWindow createAndShowUI() { + JWindow w = new JWindow(); + final Container pane = w.getContentPane(); + pane.setLayout(null); + pane.setBackground(Color.GRAY.darker()); + + final JPopupMenu popup = new JPopupMenu(); + popup.add(new JMenuItem("item 1")); + popup.add(new JMenuItem("exit")); + + JButton b = new JButton("menu"); + b.setBounds(350, 250, 50, 50); + b.addActionListener(ev -> popup.show(pane, 0, 0)); + pane.add(b); + + w.setSize(400, 300); + return w; + } +} diff -Nru openjdk-17-17.0.17+10/test/jdk/javax/swing/SwingUtilities/bug4967768.java openjdk-17-17.0.18+8/test/jdk/javax/swing/SwingUtilities/bug4967768.java --- openjdk-17-17.0.17+10/test/jdk/javax/swing/SwingUtilities/bug4967768.java 2025-10-13 07:48:04.000000000 +0000 +++ openjdk-17-17.0.18+8/test/jdk/javax/swing/SwingUtilities/bug4967768.java 2026-01-15 15:23:06.000000000 +0000 @@ -37,13 +37,19 @@ public class bug4967768 { private static final String INSTRUCTIONS = """ - When the test starts you'll see a button "Oops" - with the "p" letter underlined at the bottom - of the instruction frame. + When the test starts you'll see a button "Oops". + + For Windows and GTK Look and Feel, you will need to + press the ALT key to make the mnemonic visible. + Once the ALT key is pressed, the letter "p" will be + underlined at the bottom of the instruction frame. Ensure the underline cuts through the descender of letter "p", i.e. the underline is painted not below the letter but below the baseline. + + Press Pass if you see the expected behaviour else + press Fail. """; public static void main(String[] args) throws Exception { diff -Nru openjdk-17-17.0.17+10/test/jdk/javax/swing/ToolTipManager/bug4250178.java openjdk-17-17.0.18+8/test/jdk/javax/swing/ToolTipManager/bug4250178.java --- openjdk-17-17.0.17+10/test/jdk/javax/swing/ToolTipManager/bug4250178.java 1970-01-01 00:00:00.000000000 +0000 +++ openjdk-17-17.0.18+8/test/jdk/javax/swing/ToolTipManager/bug4250178.java 2026-01-15 15:23:06.000000000 +0000 @@ -0,0 +1,66 @@ +/* + * Copyright (c) 2003, 2025, Oracle and/or its affiliates. All rights reserved. + * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. + * + * This code is free software; you can redistribute 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 4250178 + * @summary Tooltip in incorrect location on ToolBar + * @library /java/awt/regtesthelpers + * @build PassFailJFrame + * @run main/manual bug4250178 + */ + +import javax.swing.JButton; +import javax.swing.JFrame; +import javax.swing.ToolTipManager; + +public class bug4250178 { + private static final String INSTRUCTIONS = """ + Click somewhere in the test UI frame to make it focused. + Move mouse to the bottom right corner of the button in this frame + and wait until tooltip appears. + + If the tooltip fits into the frame OR partially covered by the mouse + cursor then test fails. Otherwise test passes. + """; + + public static void main(String[] args) throws Exception { + PassFailJFrame.builder() + .title("Test Instructions") + .instructions(INSTRUCTIONS) + .columns(35) + .testUI(bug4250178::createAndShowUI) + .build() + .awaitAndCheck(); + } + + private static JFrame createAndShowUI() { + JFrame fr = new JFrame("bug4250178"); + JButton button = new JButton("Button"); + button.setToolTipText("ToolTip"); + ToolTipManager.sharedInstance().setLightWeightPopupEnabled(true); + fr.add(button); + fr.setSize(250, 100); + return fr; + } +} diff -Nru openjdk-17-17.0.17+10/test/jdk/javax/swing/ToolTipManager/bug4294808.java openjdk-17-17.0.18+8/test/jdk/javax/swing/ToolTipManager/bug4294808.java --- openjdk-17-17.0.17+10/test/jdk/javax/swing/ToolTipManager/bug4294808.java 1970-01-01 00:00:00.000000000 +0000 +++ openjdk-17-17.0.18+8/test/jdk/javax/swing/ToolTipManager/bug4294808.java 2026-01-15 15:23:06.000000000 +0000 @@ -0,0 +1,64 @@ +/* + * 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 + * 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 4294808 + * @summary Tooltip blinking. + * @library /java/awt/regtesthelpers + * @build PassFailJFrame + * @run main/manual bug4294808 + */ + +import java.awt.Dimension; +import javax.swing.JButton; +import javax.swing.JComponent; + +public class bug4294808 { + private static final String INSTRUCTIONS = """ + Move mouse cursor to the button named "Tooltip Button" + at the bottom of the instruction window and wait until + tooltip has appeared. + + If tooltip appears and eventually disappears without + rapid blinking then press PASS else FAIL. + """; + + + public static void main(String[] args) throws Exception { + PassFailJFrame.builder() + .title("bug4294808 Test Instructions") + .instructions(INSTRUCTIONS) + .columns(35) + .splitUIBottom(bug4294808::createAndShowUI) + .build() + .awaitAndCheck(); + } + + private static JComponent createAndShowUI() { + JButton bt = new JButton("Tooltip Button"); + bt.setToolTipText("Long tooltip text here"); + bt.setPreferredSize(new Dimension(200, 60)); + return bt; + } +} diff -Nru openjdk-17-17.0.17+10/test/jdk/javax/swing/ToolTipManager/bug6178004.java openjdk-17-17.0.18+8/test/jdk/javax/swing/ToolTipManager/bug6178004.java --- openjdk-17-17.0.17+10/test/jdk/javax/swing/ToolTipManager/bug6178004.java 1970-01-01 00:00:00.000000000 +0000 +++ openjdk-17-17.0.18+8/test/jdk/javax/swing/ToolTipManager/bug6178004.java 2026-01-15 15:23:06.000000000 +0000 @@ -0,0 +1,152 @@ +/* + * Copyright (c) 2006, 2025, Oracle and/or its affiliates. All rights reserved. + * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. + * + * This code is free software; you can redistribute 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 4148057 6178004 + * @summary REGRESSION: setToolTipText does not work if the + * component is not focused + * @library /java/awt/regtesthelpers + * @build PassFailJFrame + * @run main/manual bug6178004 + */ + +import java.awt.Point; +import java.awt.Window; +import java.awt.event.MouseEvent; +import java.util.List; +import javax.swing.ButtonGroup; +import javax.swing.JButton; +import javax.swing.JCheckBoxMenuItem; +import javax.swing.JFrame; +import javax.swing.JMenu; +import javax.swing.JMenuBar; +import javax.swing.LookAndFeel; +import javax.swing.SwingUtilities; +import javax.swing.ToolTipManager; +import javax.swing.UIManager; + +public class bug6178004 { + private static JFrame frame1; + private static JFrame frame2; + private static final int SIZE = 300; + + private static final String INSTRUCTIONS = """ + You can change Look And Feel using the menu "Change LaF". + + Make sure that Frame2 or instruction window is active. + Move mouse over the button inside "Frame 1". + If tooltip is NOT shown or Frame 1 jumped on top of + the Frame2, press FAIL. + + For Metal/Windows LaF: + Tooltips are shown only if one of the frames (or the instruction + window) is active. To test it click on any other application to + make frames and instruction window inactive and then verify that + tooltips are not shown any more. + + For Motif/GTK/Nimbus/Aqua LaF: + Tooltips should be shown for all frames irrespective of whether + the application is active or inactive. + + Note: Tooltip for Frame1 is always shown at the top-left corner. + Tooltips could be shown partly covered by another frame. + + If above is true press PASS else FAIL. + """; + + public static void main(String[] args) throws Exception { + PassFailJFrame.builder() + .title("bug6178004 Test Instructions") + .instructions(INSTRUCTIONS) + .testTimeOut(10) + .columns(40) + .testUI(createAndShowUI()) + .positionTestUI(bug6178004::positionTestWindows) + .build() + .awaitAndCheck(); + } + + private static List createAndShowUI() { + ToolTipManager.sharedInstance().setInitialDelay(0); + + frame1 = new JFrame("bug6178004 Frame1"); + frame1.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE); + JButton button = new JButton("Test") { + public Point getToolTipLocation(MouseEvent event) { + return new Point(10, 10); + } + }; + button.setToolTipText("Tooltip-1"); + frame1.add(button); + frame1.setSize(SIZE, SIZE); + + frame2 = new JFrame("bug6178004 Frame2"); + frame2.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE); + JButton button2 = new JButton("Click me") ; + button2.setToolTipText("Tooltip-2"); + frame2.add(button2); + frame2.setSize(SIZE, SIZE); + + JMenuBar bar = new JMenuBar(); + JMenu lafMenu = new JMenu("Change LaF"); + ButtonGroup lafGroup = new ButtonGroup(); + + LookAndFeel currentLaf = UIManager.getLookAndFeel(); + UIManager.LookAndFeelInfo[] lafs = UIManager.getInstalledLookAndFeels(); + for (final UIManager.LookAndFeelInfo lafInfo : lafs) { + JCheckBoxMenuItem lafItem = new JCheckBoxMenuItem(lafInfo.getName()); + lafItem.addActionListener(e -> setLaF(lafInfo.getClassName())); + if (lafInfo.getClassName().equals(currentLaf.getClass().getName())) { + lafItem.setSelected(true); + } + + lafGroup.add(lafItem); + lafMenu.add(lafItem); + } + + bar.add(lafMenu); + frame2.setJMenuBar(bar); + return List.of(frame1, frame2); + } + + private static void setLaF(String laf) { + try { + UIManager.setLookAndFeel(laf); + SwingUtilities.updateComponentTreeUI(frame1); + SwingUtilities.updateComponentTreeUI(frame2); + } catch (Exception e) { + e.printStackTrace(); + } + } + + // custom window layout required for this test + private static void positionTestWindows(List testWindows, + PassFailJFrame.InstructionUI instructionUI) { + int gap = 5; + int x = instructionUI.getLocation().x + instructionUI.getSize().width + gap; + // the two test frames need to overlap for this test + testWindows.get(0).setLocation(x, instructionUI.getLocation().y); + testWindows.get(1).setLocation((x + SIZE / 2), instructionUI.getLocation().y); + } +} diff -Nru openjdk-17-17.0.17+10/test/jdk/javax/swing/border/EtchedBorder/ScaledEtchedBorderTest.java openjdk-17-17.0.18+8/test/jdk/javax/swing/border/EtchedBorder/ScaledEtchedBorderTest.java --- openjdk-17-17.0.17+10/test/jdk/javax/swing/border/EtchedBorder/ScaledEtchedBorderTest.java 2025-10-13 07:48:04.000000000 +0000 +++ openjdk-17-17.0.18+8/test/jdk/javax/swing/border/EtchedBorder/ScaledEtchedBorderTest.java 2026-01-15 15:23:06.000000000 +0000 @@ -1,5 +1,5 @@ /* - * Copyright (c) 2022, 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 @@ -23,7 +23,6 @@ import java.awt.BorderLayout; import java.awt.Color; -import java.awt.Component; import java.awt.Dimension; import java.awt.Graphics2D; import java.awt.Point; @@ -31,30 +30,36 @@ import java.io.File; import java.io.IOException; import java.util.ArrayList; +import java.util.Arrays; +import java.util.Collection; import java.util.List; import javax.imageio.ImageIO; -import javax.swing.BorderFactory; import javax.swing.Box; -import javax.swing.BoxLayout; +import javax.swing.JComponent; import javax.swing.JFrame; import javax.swing.JPanel; import javax.swing.SwingUtilities; +import static javax.swing.BorderFactory.createEmptyBorder; +import static javax.swing.BorderFactory.createEtchedBorder; + /* * @test - * @bug 8279614 + * @bug 8279614 8294921 * @summary The left line of the TitledBorder is not painted on 150 scale factor * @requires (os.family == "windows") * @run main ScaledEtchedBorderTest */ - public class ScaledEtchedBorderTest { - public static final Dimension SIZE = new Dimension(120, 20); + private static final Dimension SIZE = new Dimension(125, 25); - public static Color highlight = Color.RED; - public static Color shadow = Color.BLUE; + private static final Color OUTER_COLOR = Color.BLACK; + private static final Color INSIDE_COLOR = Color.WHITE; + private static final Color HIGHLIGHT = Color.RED; + private static final Color SHADOW = Color.BLUE; + private static final Color TRANSPARENT_COLOR = new Color(0x00000000, true); private static final double[] scales = {1.00, 1.25, 1.50, 1.75, 2.00, 2.50, 3.00}; @@ -66,165 +71,256 @@ new ArrayList<>(4); public static void main(String[] args) throws Exception { - boolean showFrame = args.length > 0 && "-show".equals(args[0]); - SwingUtilities.invokeAndWait(() -> testScaling(showFrame)); + Collection params = Arrays.asList(args); + final boolean showFrame = params.contains("-show"); + final boolean saveImages = params.contains("-save"); + SwingUtilities.invokeAndWait(() -> testScaling(showFrame, saveImages)); } - private static void testScaling(boolean show) { - createGUI(show); + private static void testScaling(boolean showFrame, boolean saveImages) { + JComponent content = createUI(); + if (showFrame) { + showFrame(content); + } + + paintToImages(content, saveImages); + verifyBorderRendering(saveImages); + } - for (int i = 0; i < scales.length; i++) { + private static void verifyBorderRendering(final boolean saveImages) { + String errorMessage = null; + int errorCount = 0; + for (int i = 0; i < images.size(); i++) { BufferedImage img = images.get(i); double scaling = scales[i]; - System.out.println("Testing scaling: " + scaling); + try { + int thickness = (int) Math.floor(scaling); + checkVerticalBorders(SIZE.width / 2, thickness, img); - // checking vertical border - int x = SIZE.width / 2; - checkVerticalBorder(x, img, scaling); - - for (Point p : panelLocations) { - int y = (int) (p.y * scaling) + SIZE.height / 2; - checkHorizontalBorder(y, img, scaling); - } - } - } - - private static void checkHorizontalBorder(int y, BufferedImage img, double scaling) { - int thickness = 0; - boolean checkShadow = false; - boolean checkHighlight = false; - for (int x = 0; x < img.getWidth(); x++) { - int color = img.getRGB(x, y); - if (!checkHighlight && !checkShadow) { - if (color == shadow.getRGB()) { - checkHighlight = true; - thickness++; - } else if (color == highlight.getRGB()) { - throw new RuntimeException("Horizontal Border was clipped or overdrawn."); + for (Point p : panelLocations) { + int y = (int) (p.y * scaling) + SIZE.height / 2; + checkHorizontalBorder(y, thickness, img); } - } else if (checkHighlight) { - if (color == shadow.getRGB()) { - thickness++; - } else if (color == highlight.getRGB()) { - verifyThickness(x, y, thickness, scaling, "Horizontal"); - checkHighlight = false; - checkShadow = true; - thickness = 1; - } else { - throw new RuntimeException("Horizontal Border has empty space between highlight and shadow."); + } catch (Error e) { + if (errorMessage == null) { + errorMessage = e.getMessage(); } - } else { - if (color == shadow.getRGB()) { - throw new RuntimeException("Border colors reversed."); - } else if (color == highlight.getRGB()) { - thickness++; - } else { - verifyThickness(x, y, thickness, scaling, "Horizontal"); - checkShadow = false; - thickness = 0; + errorCount++; + + System.err.printf("Scaling: %.2f\n", scaling); + e.printStackTrace(); + + // Save the image if it wasn't already saved + if (!saveImages) { + saveImage(img, getImageFileName(scaling)); } } } - } - private static void verifyThickness(int x, int y, int thickness, double scaling, String orientation) { - int expected = (int) Math.floor(scaling); - if (thickness != expected) { - throw new RuntimeException("Unexpected " + orientation + " Border thickness at x:" - + x + " y: " + y + ". Expected: " + expected + " Actual: " + thickness); + if (errorCount > 0) { + throw new Error("Test failed: " + + errorCount + " error(s) detected - " + + errorMessage); } } - private static void checkVerticalBorder(int x, BufferedImage img, double scaling) { - int thickness = 0; - boolean checkShadow = false; - boolean checkHighlight = false; - for (int y = 0; y < img.getHeight(); y++) { - int color = img.getRGB(x, y); - if (!checkHighlight && !checkShadow) { - if (color == shadow.getRGB()) { - checkHighlight = true; - thickness++; - } else if (color == highlight.getRGB()) { - throw new RuntimeException("Vertical Border was clipped or overdrawn."); - } - } else if (checkHighlight) { - if (color == shadow.getRGB()) { - thickness++; - } else if (color == highlight.getRGB()) { - verifyThickness(x, y, thickness, scaling, "Vertical"); - checkHighlight = false; - checkShadow = true; - thickness = 1; - } else { - throw new RuntimeException("Vertical Border has empty space between highlight and shadow."); - } - } else { - if (color == shadow.getRGB()) { - throw new RuntimeException("Border colors reversed."); - } else if (color == highlight.getRGB()) { - thickness++; - } else { - verifyThickness(x, y, thickness, scaling, "Vertical"); - checkShadow = false; - thickness = 0; + private static void checkVerticalBorders(final int x, + final int thickness, + final BufferedImage img) { + checkBorder(x, 0, + 0, 1, + thickness, img); + } + + private static void checkHorizontalBorder(final int y, + final int thickness, + final BufferedImage img) { + checkBorder(0, y, + 1, 0, + thickness, img); + } + + private enum State { + BACKGROUND, + LEFT_SHADOW, LEFT_HIGHLIGHT, + INSIDE, + RIGHT_SHADOW, RIGHT_HIGHLIGHT + } + + private static void checkBorder(final int xStart, final int yStart, + final int xStep, final int yStep, + final int thickness, + final BufferedImage img) { + final int width = img.getWidth(); + final int height = img.getHeight(); + + State state = State.BACKGROUND; + int borderThickness = 0; + + int x = xStart; + int y = yStart; + do { + do { + final int color = img.getRGB(x, y); + switch (state) { + case BACKGROUND: + if (color == SHADOW.getRGB()) { + state = State.LEFT_SHADOW; + borderThickness = 1; + } else if (color != OUTER_COLOR.getRGB() + && color != TRANSPARENT_COLOR.getRGB()) { + throwUnexpectedColor(x, y, color); + } + break; + + case LEFT_SHADOW: + if (color == SHADOW.getRGB()) { + borderThickness++; + } else if (color == HIGHLIGHT.getRGB()) { + if (borderThickness != thickness) { + throwWrongThickness(thickness, borderThickness, x, y); + } + borderThickness = 1; + state = State.LEFT_HIGHLIGHT; + } else { + throwUnexpectedColor(x, y, color); + } + break; + + case LEFT_HIGHLIGHT: + if (color == HIGHLIGHT.getRGB()) { + borderThickness++; + } else if (color == INSIDE_COLOR.getRGB()) { + if (borderThickness != thickness) { + throwWrongThickness(thickness, borderThickness, x, y); + } + borderThickness = 0; + state = State.INSIDE; + } else { + throwUnexpectedColor(x, y, color); + } + break; + + case INSIDE: + if (color == SHADOW.getRGB()) { + state = State.RIGHT_SHADOW; + borderThickness = 1; + } else if (color != INSIDE_COLOR.getRGB()) { + throwUnexpectedColor(x, y, color); + } + break; + + case RIGHT_SHADOW: + if (color == SHADOW.getRGB()) { + borderThickness++; + } else if (color == HIGHLIGHT.getRGB()) { + if (borderThickness != thickness) { + throwWrongThickness(thickness, borderThickness, x, y); + } + borderThickness = 1; + state = State.RIGHT_HIGHLIGHT; + } else { + throwUnexpectedColor(x, y, color); + } + break; + + case RIGHT_HIGHLIGHT: + if (color == HIGHLIGHT.getRGB()) { + borderThickness++; + } else if (color == OUTER_COLOR.getRGB()) { + if (borderThickness != thickness) { + throwWrongThickness(thickness, borderThickness, x, y); + } + borderThickness = 0; + state = State.BACKGROUND; + } else { + throwUnexpectedColor(x, y, color); + } + break; } - } - } + } while (yStep > 0 && ((y += yStep) < height)); + } while (xStep > 0 && ((x += xStep) < width)); + } + + private static void throwWrongThickness(int thickness, int borderThickness, + int x, int y) { + throw new Error( + String.format("Wrong border thickness at %d, %d: %d vs %d", + x, y, borderThickness, thickness)); + } + + private static void throwUnexpectedColor(int x, int y, int color) { + throw new Error( + String.format("Unexpected color at %d, %d: %08x", + x, y, color)); } - private static void createGUI(boolean show) { - // Render content panel - JPanel contentPanel = new JPanel(); - contentPanel.setLayout(new BoxLayout(contentPanel, BoxLayout.Y_AXIS)); + private static JComponent createUI() { + Box contentPanel = Box.createVerticalBox(); + contentPanel.setBackground(OUTER_COLOR); Dimension childSize = null; for (int i = 0; i < 4; i++) { + JComponent filler = new JPanel(null); + filler.setBackground(INSIDE_COLOR); + filler.setPreferredSize(SIZE); + filler.setBounds(i, 0, SIZE.width, SIZE.height); + filler.setBorder(createEtchedBorder(HIGHLIGHT, SHADOW)); + JPanel childPanel = new JPanel(new BorderLayout()); - childPanel.setBorder(BorderFactory.createCompoundBorder( - BorderFactory.createEmptyBorder(0, i, 4, 4), - BorderFactory.createEtchedBorder(highlight, shadow))); - childPanel.add(Box.createRigidArea(SIZE), BorderLayout.CENTER); + childPanel.setBorder(createEmptyBorder(0, i, 4, 4)); + childPanel.add(filler, BorderLayout.CENTER); + childPanel.setBackground(OUTER_COLOR); contentPanel.add(childPanel); if (childSize == null) { childSize = childPanel.getPreferredSize(); } - childPanel.setBounds(0, childSize.height * i, childSize.width, childSize.height); + childPanel.setBounds(0, childSize.height * i, + childSize.width, childSize.height); + + panelLocations.add(childPanel.getLocation()); } contentPanel.setSize(childSize.width, childSize.height * 4); + return contentPanel; + } + + private static void showFrame(final JComponent content) { + JFrame frame = new JFrame("Scaled Etched Border Test"); + frame.setDefaultCloseOperation(JFrame.DISPOSE_ON_CLOSE); + frame.getContentPane().add(content, BorderLayout.CENTER); + frame.pack(); + frame.setLocationRelativeTo(null); + frame.setVisible(true); + } + + private static void paintToImages(final JComponent content, + final boolean saveImages) { for (double scaling : scales) { - // Create BufferedImage - BufferedImage buff = new BufferedImage((int) Math.ceil(contentPanel.getWidth() * scaling), - (int) Math.ceil(contentPanel.getHeight() * scaling), - BufferedImage.TYPE_INT_ARGB); - Graphics2D graph = buff.createGraphics(); - graph.scale(scaling, scaling); - // Painting panel onto BufferedImage - contentPanel.paint(graph); - graph.dispose(); - // Save each image ? -- Here it's useful for debugging - saveImage(buff, String.format("test%.2f.png", scaling)); - images.add(buff); - } - // Save coordinates of the panels - for (Component comp : contentPanel.getComponents()) { - panelLocations.add(comp.getLocation()); - } + BufferedImage image = + new BufferedImage((int) Math.ceil(content.getWidth() * scaling), + (int) Math.ceil(content.getHeight() * scaling), + BufferedImage.TYPE_INT_ARGB); + + Graphics2D g2d = image.createGraphics(); + g2d.scale(scaling, scaling); + content.paint(g2d); + g2d.dispose(); - if (show) { - JFrame frame = new JFrame("Swing Test"); - frame.setDefaultCloseOperation(JFrame.DISPOSE_ON_CLOSE); - frame.getContentPane().add(contentPanel, BorderLayout.CENTER); - frame.pack(); - frame.setLocationRelativeTo(null); - frame.setVisible(true); + if (saveImages) { + saveImage(image, getImageFileName(scaling)); + } + images.add(image); } } + private static String getImageFileName(final double scaling) { + return String.format("test%.2f.png", scaling); + } + private static void saveImage(BufferedImage image, String filename) { try { ImageIO.write(image, "png", new File(filename)); diff -Nru openjdk-17-17.0.17+10/test/jdk/javax/swing/border/LineBorder/ScaledLineBorderTest.java openjdk-17-17.0.18+8/test/jdk/javax/swing/border/LineBorder/ScaledLineBorderTest.java --- openjdk-17-17.0.17+10/test/jdk/javax/swing/border/LineBorder/ScaledLineBorderTest.java 2025-10-13 07:48:04.000000000 +0000 +++ openjdk-17-17.0.18+8/test/jdk/javax/swing/border/LineBorder/ScaledLineBorderTest.java 2026-01-15 15:23:06.000000000 +0000 @@ -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 @@ -23,7 +23,6 @@ import java.awt.BorderLayout; import java.awt.Color; -import java.awt.Component; import java.awt.Dimension; import java.awt.Graphics2D; import java.awt.Point; @@ -43,15 +42,18 @@ import javax.swing.JPanel; import javax.swing.SwingUtilities; +import static sun.java2d.pipe.Region.clipRound; + /* * @test - * @bug 8282958 + * @bug 8282958 8349188 * @summary Verify LineBorder edges have the same width * @requires (os.family == "windows") + * @modules java.desktop/sun.java2d.pipe * @run main ScaledLineBorderTest */ public class ScaledLineBorderTest { - private static final Dimension SIZE = new Dimension(120, 25); + private static final Dimension SIZE = new Dimension(250, 50); private static final Color OUTER_COLOR = Color.BLACK; private static final Color BORDER_COLOR = Color.RED; @@ -60,12 +62,19 @@ private static final double[] scales = {1.00, 1.25, 1.50, 1.75, 2.00, 2.50, 3.00}; + private static final int[] thickness = {1, 4, 10, 15}; - private static final List images = - new ArrayList<>(scales.length); + private record TestImage(BufferedImage image, + List panelLocations, + double scale, + int thickness) { + } + + private record TestUI(JComponent content, + List panelLocations, + int thickness) { + } - private static final List panelLocations = - new ArrayList<>(4); public static void main(String[] args) throws Exception { Collection params = Arrays.asList(args); @@ -75,29 +84,38 @@ } private static void testScaling(boolean showFrame, boolean saveImages) { - JComponent content = createUI(); - if (showFrame) { - showFrame(content); + for (int thickness : thickness) { + TestUI testUI = createUI(thickness); + if (showFrame) { + showFrame(testUI.content); + } + + List images = paintToImages(testUI, saveImages); + verifyBorderRendering(images, saveImages); + } + + if (errorCount > 0) { + throw new Error("Test failed: " + + errorCount + " error(s) detected - " + + errorMessage); } - paintToImages(content, saveImages); - verifyBorderRendering(saveImages); } - private static void verifyBorderRendering(final boolean saveImages) { - String errorMessage = null; - int errorCount = 0; - for (int i = 0; i < images.size(); i++) { - BufferedImage img = images.get(i); - double scaling = scales[i]; - try { - int thickness = (int) Math.floor(scaling); + private static String errorMessage = null; + private static int errorCount = 0; - checkVerticalBorders(SIZE.width / 2, thickness, img); + private static void verifyBorderRendering(final List images, + final boolean saveImages) { + for (TestImage test : images) { + final BufferedImage img = test.image; + final int effectiveThickness = clipRound(test.thickness * test.scale); + try { + checkVerticalBorders((int) (SIZE.width * test.scale / 2), effectiveThickness, img); - for (Point p : panelLocations) { - int y = (int) (p.y * scaling) + SIZE.height / 2; - checkHorizontalBorder(y, thickness, img); + for (Point p : test.panelLocations) { + int y = (int) ((p.y + (SIZE.height / 2)) * test.scale); + checkHorizontalBorder(y, effectiveThickness, img); } } catch (Error e) { if (errorMessage == null) { @@ -105,21 +123,13 @@ } errorCount++; - System.err.printf("Scaling: %.2f\n", scaling); + System.err.printf("Scale: %.2f; thickness: %d, effective: %d\n", + test.scale, test.thickness, effectiveThickness); e.printStackTrace(); - // Save the image if it wasn't already saved - if (!saveImages) { - saveImage(img, getImageFileName(scaling)); - } + saveImage(img, getImageFileName(test.scale, test.thickness)); } } - - if (errorCount > 0) { - throw new Error("Test failed: " - + errorCount + " error(s) detected - " - + errorMessage); - } } private static void checkVerticalBorders(final int x, @@ -138,6 +148,10 @@ thickness, img); } + private enum State { + BACKGROUND, LEFT, INSIDE, RIGHT + } + private static void checkBorder(final int xStart, final int yStart, final int xStep, final int yStep, final int thickness, @@ -204,10 +218,6 @@ } while (xStep > 0 && ((x += xStep) < width)); } - private enum State { - BACKGROUND, LEFT, INSIDE, RIGHT - } - private static void throwWrongThickness(int thickness, int borderThickness, int x, int y) { throw new Error( @@ -221,17 +231,19 @@ x, y, color)); } - private static JComponent createUI() { + private static TestUI createUI(int thickness) { Box contentPanel = Box.createVerticalBox(); contentPanel.setBackground(OUTER_COLOR); + List panelLocations = new ArrayList<>(4); + Dimension childSize = null; for (int i = 0; i < 4; i++) { JComponent filler = new JPanel(null); filler.setBackground(INSIDE_COLOR); filler.setPreferredSize(SIZE); filler.setBounds(i, 0, SIZE.width, SIZE.height); - filler.setBorder(BorderFactory.createLineBorder(BORDER_COLOR)); + filler.setBorder(BorderFactory.createLineBorder(BORDER_COLOR, thickness)); JPanel childPanel = new JPanel(new BorderLayout()); childPanel.setBorder(BorderFactory.createEmptyBorder(0, i, 4, 4)); @@ -243,16 +255,13 @@ childSize = childPanel.getPreferredSize(); } childPanel.setBounds(0, childSize.height * i, childSize.width, childSize.height); + + panelLocations.add(childPanel.getLocation()); } contentPanel.setSize(childSize.width, childSize.height * 4); - // Save coordinates of the panels - for (Component comp : contentPanel.getComponents()) { - panelLocations.add(comp.getLocation()); - } - - return contentPanel; + return new TestUI(contentPanel, panelLocations, thickness); } private static void showFrame(JComponent content) { @@ -264,28 +273,33 @@ frame.setVisible(true); } - private static void paintToImages(final JComponent content, - final boolean saveImages) { - for (double scaling : scales) { + private static List paintToImages(final TestUI testUI, + final boolean saveImages) { + final List images = new ArrayList<>(scales.length); + final JComponent content = testUI.content; + for (double scale : scales) { BufferedImage image = - new BufferedImage((int) Math.ceil(content.getWidth() * scaling), - (int) Math.ceil(content.getHeight() * scaling), + new BufferedImage((int) Math.ceil(content.getWidth() * scale), + (int) Math.ceil(content.getHeight() * scale), BufferedImage.TYPE_INT_ARGB); Graphics2D g2d = image.createGraphics(); - g2d.scale(scaling, scaling); + g2d.scale(scale, scale); content.paint(g2d); g2d.dispose(); if (saveImages) { - saveImage(image, getImageFileName(scaling)); + saveImage(image, getImageFileName(scale, testUI.thickness)); } - images.add(image); + images.add(new TestImage(image, testUI.panelLocations, + scale, testUI.thickness)); } + return images; } - private static String getImageFileName(final double scaling) { - return String.format("test%.2f.png", scaling); + private static String getImageFileName(final double scaling, + final int thickness) { + return String.format("test%02d@%.2f.png", thickness, scaling); } private static void saveImage(BufferedImage image, String filename) { diff -Nru openjdk-17-17.0.17+10/test/jdk/javax/swing/border/LineBorder/ScaledTextFieldBorderTest.java openjdk-17-17.0.18+8/test/jdk/javax/swing/border/LineBorder/ScaledTextFieldBorderTest.java --- openjdk-17-17.0.17+10/test/jdk/javax/swing/border/LineBorder/ScaledTextFieldBorderTest.java 2025-10-13 07:48:04.000000000 +0000 +++ openjdk-17-17.0.18+8/test/jdk/javax/swing/border/LineBorder/ScaledTextFieldBorderTest.java 2026-01-15 15:23:06.000000000 +0000 @@ -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 @@ -23,7 +23,6 @@ import java.awt.BorderLayout; import java.awt.Color; -import java.awt.Component; import java.awt.Dimension; import java.awt.Graphics2D; import java.awt.Point; @@ -45,12 +44,15 @@ import javax.swing.SwingUtilities; import javax.swing.border.LineBorder; +import static sun.java2d.pipe.Region.clipRound; + /* * @test - * @bug 8282958 + * @bug 8282958 8349188 * @summary Verify all the borders are rendered consistently for a JTextField * in Windows LaF which uses LineBorder * @requires (os.family == "windows") + * @modules java.desktop/sun.java2d.pipe * @run main ScaledTextFieldBorderTest */ public class ScaledTextFieldBorderTest { @@ -93,7 +95,7 @@ BufferedImage img = images.get(i); double scaling = scales[i]; try { - int thickness = (int) Math.floor(scaling); + int thickness = clipRound(scaling); checkVerticalBorders(textFieldSize.width / 2, thickness, img); diff -Nru openjdk-17-17.0.17+10/test/jdk/javax/swing/border/TransparentTitleTest.java openjdk-17-17.0.18+8/test/jdk/javax/swing/border/TransparentTitleTest.java --- openjdk-17-17.0.17+10/test/jdk/javax/swing/border/TransparentTitleTest.java 1970-01-01 00:00:00.000000000 +0000 +++ openjdk-17-17.0.18+8/test/jdk/javax/swing/border/TransparentTitleTest.java 2026-01-15 15:23:06.000000000 +0000 @@ -0,0 +1,122 @@ +/* + * Copyright (c) 1999, 2025, Oracle and/or its affiliates. All rights reserved. + * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. + * + * This code is free software; you can redistribute 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 4154572 + * @summary Tests that the area behind a TitledBorder's title string is transparent, + * allowing the component's background to show through + * @library /java/awt/regtesthelpers + * @build PassFailJFrame + * @run main/manual TransparentTitleTest + */ + +import java.awt.GridLayout; +import java.awt.Dimension; +import java.awt.Graphics; +import java.awt.Color; +import java.awt.image.BufferedImage; +import javax.swing.ImageIcon; +import javax.swing.JFrame; +import javax.swing.JPanel; +import javax.swing.border.TitledBorder; +import javax.swing.border.LineBorder; + +public class TransparentTitleTest { + private static final String INSTRUCTIONS = """ + If all panels are correctly painted such that the title of the + border allows the underlying panel image (green rectangle) + to show through the background of the text, + then this test passes; else it fails. + """; + + public static void main(String[] args) throws Exception { + PassFailJFrame.builder() + .title("TransparentTitleTest Instructions") + .instructions(INSTRUCTIONS) + .columns(40) + .testUI(TransparentTitleTest::createTestUI) + .build() + .awaitAndCheck(); + } + + private static JFrame createTestUI() { + JFrame frame = new JFrame("TransparentTitleTest"); + + frame.setLayout(new GridLayout(3, 6, 5, 5)); + + frame.add(new ImagePanel(TitledBorder.TOP, TitledBorder.LEFT)); + frame.add(new ImagePanel(TitledBorder.TOP, TitledBorder.CENTER)); + frame.add(new ImagePanel(TitledBorder.TOP, TitledBorder.RIGHT)); + frame.add(new ImagePanel(TitledBorder.ABOVE_TOP, TitledBorder.LEFT)); + frame.add(new ImagePanel(TitledBorder.ABOVE_TOP, TitledBorder.CENTER)); + frame.add(new ImagePanel(TitledBorder.ABOVE_TOP, TitledBorder.RIGHT)); + frame.add(new ImagePanel(TitledBorder.BELOW_TOP, TitledBorder.LEFT)); + frame.add(new ImagePanel(TitledBorder.BELOW_TOP, TitledBorder.CENTER)); + frame.add(new ImagePanel(TitledBorder.BELOW_TOP, TitledBorder.RIGHT)); + frame.add(new ImagePanel(TitledBorder.BOTTOM, TitledBorder.LEFT)); + frame.add(new ImagePanel(TitledBorder.BOTTOM, TitledBorder.CENTER)); + frame.add(new ImagePanel(TitledBorder.BOTTOM, TitledBorder.RIGHT)); + frame.add(new ImagePanel(TitledBorder.ABOVE_BOTTOM, TitledBorder.LEFT)); + frame.add(new ImagePanel(TitledBorder.ABOVE_BOTTOM, TitledBorder.CENTER)); + frame.add(new ImagePanel(TitledBorder.ABOVE_BOTTOM, TitledBorder.RIGHT)); + frame.add(new ImagePanel(TitledBorder.BELOW_BOTTOM, TitledBorder.LEFT)); + frame.add(new ImagePanel(TitledBorder.BELOW_BOTTOM, TitledBorder.CENTER)); + frame.add(new ImagePanel(TitledBorder.BELOW_BOTTOM, TitledBorder.RIGHT)); + + frame.pack(); + return frame; + } +} + +class ImagePanel extends JPanel { + + private final ImageIcon imageIcon; + + private static final BufferedImage bufferedImage = + new BufferedImage(128, 128, BufferedImage.TYPE_INT_ARGB); + + static { + Graphics g = bufferedImage.getGraphics(); + g.setColor(Color.GREEN); + g.fillRect(0, 0, 128, 128); + } + + public ImagePanel(int titlePos, int titleJust) { + imageIcon = new ImageIcon(bufferedImage); + + TitledBorder b = new TitledBorder(new LineBorder(Color.black,3), "title text"); + b.setTitlePosition(titlePos); + b.setTitleJustification(titleJust); + b.setTitleColor(Color.black); + setBorder(b); + } + + public Dimension getPreferredSize() { + return new Dimension(imageIcon.getIconWidth(), imageIcon.getIconHeight()); + } + + public void paintComponent(Graphics g) { + imageIcon.paintIcon(this, g, 0, 0); + } +} diff -Nru openjdk-17-17.0.17+10/test/jdk/javax/swing/plaf/basic/BasicTableHeaderUI/6394566/bug6394566.java openjdk-17-17.0.18+8/test/jdk/javax/swing/plaf/basic/BasicTableHeaderUI/6394566/bug6394566.java --- openjdk-17-17.0.17+10/test/jdk/javax/swing/plaf/basic/BasicTableHeaderUI/6394566/bug6394566.java 1970-01-01 00:00:00.000000000 +0000 +++ openjdk-17-17.0.18+8/test/jdk/javax/swing/plaf/basic/BasicTableHeaderUI/6394566/bug6394566.java 2026-01-15 15:23:06.000000000 +0000 @@ -0,0 +1,73 @@ +/* + * Copyright (c) 2006, 2021, Oracle and/or its affiliates. All rights reserved. + * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. + * + * This code is free software; you can redistribute it and/or modify it + * under the terms of the GNU General Public License version 2 only, as + * published by the Free Software Foundation. + * + * This code is distributed in the hope that it will be useful, but WITHOUT + * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or + * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License + * version 2 for more details (a copy is included in the LICENSE file that + * accompanied this code). + * + * You should have received a copy of the GNU General Public License version + * 2 along with this work; if not, write to the Free Software Foundation, + * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. + * + * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA + * or visit www.oracle.com if you need additional information or have any + * questions. + */ +/* + * @test + * @bug 6394566 + * @key headful + * @summary Tests that ESC moves the focus from the header to the table + * @library ../../../../regtesthelpers + * @build SwingTestHelper JRobot + * @run main bug6394566 + */ + +import java.awt.Component; +import java.awt.event.KeyEvent; +import java.awt.event.FocusEvent; +import javax.swing.JScrollPane; +import javax.swing.JTable; +import javax.swing.table.JTableHeader; +import javax.swing.table.DefaultTableModel; + +public class bug6394566 extends SwingTestHelper { + private JTable table; + private JTableHeader header; + + public static void main(String[] args) throws Throwable { + new bug6394566().run(args); + } + + protected Component createContentPane() { + table = new JTable(new DefaultTableModel(2, 2)); + header = table.getTableHeader(); + return new JScrollPane(table); + } + + public void onEDT10() { + // Give the table the focus. + requestAndWaitForFocus(table); + } + + //First, give the header focus using F8 on the JTable. + //This will fail prior to mustang b72. + public void onEDT20() { + waitForEvent(header, FocusEvent.FOCUS_GAINED); //set up focus listener + robot.hitKey(KeyEvent.VK_F8); + } + + //Next, give the table back the focus using ESC. + //This will fail prior to the build with this bugfix. + public void onEDT30() { + waitForEvent(table, FocusEvent.FOCUS_GAINED); //set up focus listener + robot.hitKey(KeyEvent.VK_ESCAPE); + } +} diff -Nru openjdk-17-17.0.17+10/test/jdk/javax/swing/plaf/basic/BasicTextUI/PasswordSelectionWordTest.java openjdk-17-17.0.18+8/test/jdk/javax/swing/plaf/basic/BasicTextUI/PasswordSelectionWordTest.java --- openjdk-17-17.0.17+10/test/jdk/javax/swing/plaf/basic/BasicTextUI/PasswordSelectionWordTest.java 1970-01-01 00:00:00.000000000 +0000 +++ openjdk-17-17.0.18+8/test/jdk/javax/swing/plaf/basic/BasicTextUI/PasswordSelectionWordTest.java 2026-01-15 15:23:06.000000000 +0000 @@ -0,0 +1,94 @@ +/* + * 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 + * @key headful + * @bug 4231444 8354646 + * @summary Password fields' ActionMap needs to replace + * DefaultEditorKit.selectWordAction with + * DefaultEditorKit.selectLineAction. + * + * @run main PasswordSelectionWordTest + */ + +import javax.swing.Action; +import javax.swing.JPasswordField; +import javax.swing.SwingUtilities; +import javax.swing.UIManager; +import javax.swing.UnsupportedLookAndFeelException; +import javax.swing.plaf.basic.BasicTextUI; +import javax.swing.text.DefaultEditorKit; +import java.awt.event.ActionEvent; + +public class PasswordSelectionWordTest { + public static void main(String[] args) throws Exception { + for (UIManager.LookAndFeelInfo laf : + UIManager.getInstalledLookAndFeels()) { + System.out.println("Testing LAF: " + laf.getClassName()); + SwingUtilities.invokeAndWait(() -> { + if (setLookAndFeel(laf)) { + runTest(); + } + }); + } + } + + private static boolean setLookAndFeel(UIManager.LookAndFeelInfo laf) { + try { + UIManager.setLookAndFeel(laf.getClassName()); + return true; + } catch (UnsupportedLookAndFeelException e) { + System.err.println("Skipping unsupported look and feel:"); + e.printStackTrace(); + return false; + } catch (Exception e) { + throw new RuntimeException(e); + } + } + + private static void runTest() { + String str = "one two three"; + JPasswordField field = new JPasswordField(str); + if (!(field.getUI() instanceof BasicTextUI)) { + throw new RuntimeException("Unexpected condition: JPasswordField UI was " + field.getUI()); + } + System.out.println("Testing " + field.getUI()); + + // do something (anything) to initialize the Views: + field.setSize(100, 100); + field.addNotify(); + + Action action = field.getActionMap().get( + DefaultEditorKit.selectWordAction); + action.actionPerformed(new ActionEvent(field, 0, "")); + int selectionStart = field.getSelectionStart(); + int selectionEnd = field.getSelectionEnd(); + System.out.println("selectionStart = " + selectionStart); + System.out.println("selectionEnd = " + selectionEnd); + if (selectionStart != 0 || selectionEnd != str.length()) { + throw new RuntimeException("selectionStart = " + selectionStart + + " and selectionEnd = " + selectionEnd); + } + } +} diff -Nru openjdk-17-17.0.17+10/test/jdk/javax/swing/plaf/metal/MetalIconFactory/bug4952462.java openjdk-17-17.0.18+8/test/jdk/javax/swing/plaf/metal/MetalIconFactory/bug4952462.java --- openjdk-17-17.0.17+10/test/jdk/javax/swing/plaf/metal/MetalIconFactory/bug4952462.java 2025-10-13 07:48:04.000000000 +0000 +++ openjdk-17-17.0.18+8/test/jdk/javax/swing/plaf/metal/MetalIconFactory/bug4952462.java 2026-01-15 15:23:06.000000000 +0000 @@ -29,7 +29,7 @@ * @modules java.desktop/sun.awt * @library /test/lib * @key headful - * @run main bug4952462 + * @run main/othervm -Dsun.java2d.uiScale=1 bug4952462 */ import java.awt.Color; @@ -41,10 +41,8 @@ import javax.swing.JRadioButton; import javax.swing.SwingUtilities; import javax.swing.UIManager; -import javax.swing.plaf.metal.MetalTheme; - -import jtreg.SkippedException; -import sun.awt.AppContext; +import javax.swing.plaf.metal.MetalLookAndFeel; +import javax.swing.plaf.metal.OceanTheme; public class bug4952462 { private static JFrame frame; @@ -52,41 +50,35 @@ public static void main(String[] args) throws Exception { try { + MetalLookAndFeel.setCurrentTheme(new OceanTheme()); UIManager.setLookAndFeel("javax.swing.plaf.metal.MetalLookAndFeel"); + Robot r = new Robot(); + SwingUtilities.invokeAndWait(() -> { + frame = new JFrame("Metal JRadioButton Foreground Color Test"); + frame.getContentPane().setLayout(new FlowLayout()); + rb = new JRadioButton("RadioButton", true); + rb.setEnabled(false); + rb.setForeground(Color.RED); + frame.getContentPane().add(rb); + frame.setSize(250, 100); + frame.setLocationRelativeTo(null); + frame.setVisible(true); + }); - MetalTheme theme = (MetalTheme) AppContext.getAppContext().get("currentMetalTheme"); - if (theme == null || !"Ocean".equals(theme.getName())) { - throw new SkippedException("Current theme is not Ocean. Test is " + - "only for Metal's Ocean theme. Skipping test."); - } else { - Robot r = new Robot(); - SwingUtilities.invokeAndWait(() -> { - frame = new JFrame("Metal JRadioButton Foreground Color Test"); - frame.getContentPane().setLayout(new FlowLayout()); - rb = new JRadioButton("RadioButton", true); - rb.setEnabled(false); - rb.setForeground(Color.RED); - frame.getContentPane().add(rb); - frame.setSize(250, 100); - frame.setLocationRelativeTo(null); - frame.setVisible(true); - }); - - r.waitForIdle(); - r.delay(500); - - SwingUtilities.invokeAndWait(() -> { - Point p = rb.getLocationOnScreen(); - for (int i = 0; i < 50; i++) { - Color c = r.getPixelColor(p.x + 10 + i, p.y + (rb.getHeight() / 2)); - System.out.println(c); - if (c.getRed() > 200 && c.getBlue() < 200 && c.getGreen() < 200) { - throw new RuntimeException("Test failed. Radiobutton is red " + - "and not grey."); - } + r.waitForIdle(); + r.delay(500); + + SwingUtilities.invokeAndWait(() -> { + Point p = rb.getLocationOnScreen(); + for (int i = 0; i < 50; i++) { + Color c = r.getPixelColor(p.x + 10 + i, p.y + (rb.getHeight() / 2)); + System.out.println(c); + if (c.getRed() > 200 && c.getBlue() < 80 && c.getGreen() < 80) { + throw new RuntimeException("Test failed. Radiobutton is red " + + "and not grey."); } - }); - } + } + }); } finally { SwingUtilities.invokeAndWait(() -> { if (frame != null) { diff -Nru openjdk-17-17.0.17+10/test/jdk/javax/swing/plaf/windows/bug4991587.java openjdk-17-17.0.18+8/test/jdk/javax/swing/plaf/windows/bug4991587.java --- openjdk-17-17.0.17+10/test/jdk/javax/swing/plaf/windows/bug4991587.java 1970-01-01 00:00:00.000000000 +0000 +++ openjdk-17-17.0.18+8/test/jdk/javax/swing/plaf/windows/bug4991587.java 2026-01-15 15:23:06.000000000 +0000 @@ -0,0 +1,95 @@ +/* + * Copyright (c) 2004, 2025, Oracle and/or its affiliates. All rights reserved. + * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. + * + * This code is free software; you can redistribute 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 4991587 + * @requires (os.family == "windows") + * @summary Tests that disabled JButton text is positioned properly in Windows L&F + * @modules java.desktop/com.sun.java.swing.plaf.windows + * @library /java/awt/regtesthelpers + * @build PassFailJFrame + * @run main/manual bug4991587 + */ + +import java.awt.Color; +import java.awt.FlowLayout; +import java.awt.Graphics; +import java.awt.Rectangle; + +import javax.swing.AbstractButton; +import javax.swing.JButton; +import javax.swing.JFrame; +import javax.swing.UIManager; + +import com.sun.java.swing.plaf.windows.WindowsButtonUI; + +public class bug4991587 { + static final String INSTRUCTIONS = """ + There are two buttons: enabled (left) and disabled (right). + Ensure that the disabled button text is painted entirely + inside the blue bounding rectangle, just like the enabled + button (use it as an example of how this should look like). + """; + + public static void main(String[] args) throws Exception { + UIManager.setLookAndFeel("com.sun.java.swing.plaf.windows.WindowsLookAndFeel"); + PassFailJFrame.builder() + .title("bug4991587 Test Instructions") + .instructions(INSTRUCTIONS) + .columns(50) + .testUI(bug4991587::createUI) + .build() + .awaitAndCheck(); + } + + static JFrame createUI() { + JFrame f = new JFrame("Disabled JButton Text Test"); + f.setLayout(new FlowLayout()); + f.setSize(400, 100); + + JButton button1 = new JButton("\u0114 Enabled JButton"); + button1.setUI(new MyButtonUI()); + f.add(button1); + + JButton button2 = new JButton("\u0114 Disabled JButton"); + button2.setEnabled(false); + button2.setUI(new MyButtonUI()); + f.add(button2); + + return f; + } + + static class MyButtonUI extends WindowsButtonUI { + protected void paintText(Graphics g, AbstractButton b, + Rectangle textRect, String text) { + g.setColor(Color.blue); + g.drawRect(textRect.x, + textRect.y, + textRect.width + 1, // add 1 for the shadow, otherwise it + // will be painted over the textRect + textRect.height); + super.paintText(g, b, textRect, text); + } + } +} diff -Nru openjdk-17-17.0.17+10/test/jdk/javax/swing/text/BoxView/BaselineTest.java openjdk-17-17.0.18+8/test/jdk/javax/swing/text/BoxView/BaselineTest.java --- openjdk-17-17.0.17+10/test/jdk/javax/swing/text/BoxView/BaselineTest.java 1970-01-01 00:00:00.000000000 +0000 +++ openjdk-17-17.0.18+8/test/jdk/javax/swing/text/BoxView/BaselineTest.java 2026-01-15 15:23:06.000000000 +0000 @@ -0,0 +1,182 @@ +/* + * Copyright (c) 2002, 2025, Oracle and/or its affiliates. All rights reserved. + * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. + * + * This code is free software; you can redistribute it and/or modify it + * under the terms of the GNU General Public License version 2 only, as + * published by the Free Software Foundation. + * + * This code is distributed in the hope that it will be useful, but WITHOUT + * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or + * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License + * version 2 for more details (a copy is included in the LICENSE file that + * accompanied this code). + * + * You should have received a copy of the GNU General Public License version + * 2 along with this work; if not, write to the Free Software Foundation, + * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. + * + * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA + * or visit www.oracle.com if you need additional information or have any + * questions. + */ + +/* @test + * @bug 4519537 4522866 + * @summary Tests that text and components in paragraph views line up at their baselines. + * @library /java/awt/regtesthelpers + * @build PassFailJFrame + * @run main/manual BaselineTest + */ + +import java.awt.Color; +import java.awt.Dimension; +import java.awt.Font; +import java.awt.Graphics; +import java.awt.GridLayout; + +import javax.swing.JFrame; +import javax.swing.JLabel; +import javax.swing.JScrollPane; +import javax.swing.JTextPane; + +import javax.swing.text.ComponentView; +import javax.swing.text.BadLocationException; +import javax.swing.text.Document; +import javax.swing.text.Element; +import javax.swing.text.SimpleAttributeSet; +import javax.swing.text.StyleConstants; +import javax.swing.text.StyledEditorKit; +import javax.swing.text.View; +import javax.swing.text.ViewFactory; + +public class BaselineTest { + + static final String INSTRUCTIONS = """ + Test that components displayed in a JTextPane properly respect their vertical alignment. + There are two text panes, stacked vertically with similar content except the bottom components are taller. + The content consists of a leading and trailing text string, with pink coloured components between. + The text string content means the strings 'Default Size Text' and 'Large Size Text'. + Text content baseline is at the bottom of CAPITAL letters in the text. + Each pink component has a string displaying its alignment setting in the range 0.0 to 1.0 + NB: The position of the strings "align = 0.0" etc is not important, it is the component position that matters. + 0.0 means it should be aligned with its top at the text content baseline, + 1.0 means it should be aligned with its bottom at the text content baseline. + A value in between will be a proportional alignment, eg 0.5 is centered on the text content baseline + If the content displays as described, the test PASSES. + """; + + public static void main(String[] args) throws Exception { + PassFailJFrame.builder() + .title("BaselineTest Test Instructions") + .instructions(INSTRUCTIONS) + .columns(60) + .rows(12) + .testUI(BaselineTest::createUI) + .positionTestUIBottomRowCentered() + .build() + .awaitAndCheck(); + } + + public static JFrame createUI() { + JFrame frame = new JFrame("BaselineTest"); + frame.setLayout(new GridLayout(2, 1)); + + JTextPane prefPane = new JTextPane(); + initJTextPane(prefPane); + frame.add(new JScrollPane(prefPane)); + + JTextPane variablePane = new JTextPane(); + variablePane.setEditorKit(new CustomEditorKit()); + initJTextPane(variablePane); + frame.add(new JScrollPane(variablePane)); + frame.setSize(800, 400); + return frame; + } + + static void initJTextPane(JTextPane tp) { + + try { + Document doc = tp.getDocument(); + + doc.insertString(0, " Default Size Text ", null); + tp.setCaretPosition(doc.getLength()); + tp.insertComponent(new PaintLabel(0.0f)); + tp.insertComponent(new PaintLabel(0.2f)); + tp.insertComponent(new PaintLabel(0.5f)); + tp.insertComponent(new PaintLabel(0.7f)); + tp.insertComponent(new PaintLabel(1.0f)); + SimpleAttributeSet set = new SimpleAttributeSet(); + StyleConstants.setFontSize(set, 20); + tp.setCaretPosition(doc.getLength()); + doc.insertString(doc.getLength(), " Large Size Text ", set); + } catch (BadLocationException ble) { + throw new RuntimeException(ble); + } + } + + static class PaintLabel extends JLabel { + + private int pref = 40; + private int min = pref - 30; + private int max = pref + 30; + + public PaintLabel(float align) { + + setAlignmentY(align); + String alignStr = String.valueOf(align); + + setText("align = " + alignStr); + setOpaque(true); + setBackground(Color.PINK); + } + + public Dimension getMinimumSize() { + return new Dimension(super.getMinimumSize().width, min); + } + + public Dimension getPreferredSize() { + return new Dimension(super.getPreferredSize().width, pref); + } + + public Dimension getMaximumSize() { + return new Dimension(super.getMaximumSize().width, max); + } + + public void paintComponent(Graphics g) { + g.setColor(Color.PINK); + g.fillRect(0, 0, getWidth(), getHeight()); + int y = (int)(getAlignmentY() * getHeight()); + g.setColor(Color.BLACK); + g.drawLine(0, y, getWidth(), y); + g.drawString(getText(), 0, 10); + } + } + + static class CustomComponentView extends ComponentView { + + public CustomComponentView(Element elem) { + super(elem); + } + + public int getResizeWeight(int axis) { + return 1; + } +} + + static class CustomEditorKit extends StyledEditorKit implements ViewFactory { + + public View create(Element elem) { + if (StyleConstants.ComponentElementName.equals(elem.getName())) { + return new CustomComponentView(elem); + } else { + return super.getViewFactory().create(elem); + } + } + + public ViewFactory getViewFactory() { + return this; + } +} + +} diff -Nru openjdk-17-17.0.17+10/test/jdk/javax/swing/text/DefaultEditorKit/4278839/bug4278839.java openjdk-17-17.0.18+8/test/jdk/javax/swing/text/DefaultEditorKit/4278839/bug4278839.java --- openjdk-17-17.0.17+10/test/jdk/javax/swing/text/DefaultEditorKit/4278839/bug4278839.java 2025-10-13 07:48:04.000000000 +0000 +++ openjdk-17-17.0.18+8/test/jdk/javax/swing/text/DefaultEditorKit/4278839/bug4278839.java 2026-01-15 15:23:06.000000000 +0000 @@ -49,6 +49,7 @@ private static JFrame frame; public static void main(String[] args) throws Exception { + int caret; try { robo = new Robot(); @@ -61,24 +62,67 @@ clickMouse(); robo.waitForIdle(); + robo.delay(250); area.setCaretPosition(0); robo.waitForIdle(); + robo.delay(250); - passed &= moveCaret(true) == 1; - passed &= moveCaret(true) == 5; - passed &= moveCaret(true) == 8; - passed &= moveCaret(true) == 9; - passed &= moveCaret(true) == 13; - passed &= moveCaret(true) == 16; - passed &= moveCaret(true) == 17; - passed &= moveCaret(false) == 16; - passed &= moveCaret(false) == 13; - passed &= moveCaret(false) == 9; - passed &= moveCaret(false) == 8; - passed &= moveCaret(false) == 5; - passed &= moveCaret(false) == 1; - passed &= moveCaret(false) == 0; + passed &= (caret = moveCaret(true)) == 1; + System.out.println(" passed " + passed + + " Expected position 1 actual position " + caret); + + passed &= (caret = moveCaret(true)) == 5; + System.out.println(" passed " + passed + + " Expected position 5 actual position " + caret); + + passed &= (caret = moveCaret(true)) == 8; + System.out.println(" passed " + passed + + " Expected position 8 actual position " + caret); + + passed &= (caret = moveCaret(true)) == 9; + System.out.println(" passed " + passed + + " Expected position 9 actual position " + caret); + + passed &= (caret = moveCaret(true)) == 13; + System.out.println(" passed " + passed + + " Expected position 13 actual position " + caret); + + passed &= (caret = moveCaret(true)) == 16; + System.out.println(" passed " + passed + + " Expected position 16 actual position " + caret); + + passed &= (caret = moveCaret(true)) == 17; + System.out.println(" passed " + passed + + " Expected position 17 actual position " + caret); + + passed &= (caret = moveCaret(false)) == 16; + System.out.println(" passed " + passed + + " Expected position 16 actual position " + caret); + + passed &= (caret = moveCaret(false)) == 13; + System.out.println(" passed " + passed + + " Expected position 13 actual position " + caret); + + passed &= (caret = moveCaret(false)) == 9; + System.out.println(" passed " + passed + + " Expected position 9 actual position " + caret); + + passed &= (caret = moveCaret(false)) == 8; + System.out.println(" passed " + passed + + " Expected position 8 actual position " + caret); + + passed &= (caret = moveCaret(false)) == 5; + System.out.println(" passed " + passed + + " Expected position 5 actual position " + caret); + + passed &= (caret = moveCaret(false)) == 1; + System.out.println(" passed " + passed + + " Expected position 1 actual position " + caret); + + passed &= (caret = moveCaret(false)) == 0; + System.out.println(" passed " + passed + + " Expected position 0 actual position " + caret); } catch (Exception e) { throw new RuntimeException("Test failed because of an exception:", @@ -98,6 +142,7 @@ Util.hitKeys(robo, getCtrlKey(), right ? KeyEvent.VK_RIGHT : KeyEvent.VK_LEFT); robo.waitForIdle(); + robo.delay(250); final int[] result = new int[1]; diff -Nru openjdk-17-17.0.17+10/test/jdk/javax/swing/text/GlyphView/bug4188841.java openjdk-17-17.0.18+8/test/jdk/javax/swing/text/GlyphView/bug4188841.java --- openjdk-17-17.0.17+10/test/jdk/javax/swing/text/GlyphView/bug4188841.java 1970-01-01 00:00:00.000000000 +0000 +++ openjdk-17-17.0.18+8/test/jdk/javax/swing/text/GlyphView/bug4188841.java 2026-01-15 15:23:06.000000000 +0000 @@ -0,0 +1,93 @@ +/* + * Copyright (c) 2003, 2025, Oracle and/or its affiliates. All rights reserved. + * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. + * + * This code is free software; you can redistribute 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 4188841 + * @summary Tests a JTextPane wrapping issue + * @library /java/awt/regtesthelpers + * @build PassFailJFrame + * @run main/manual bug4188841 +*/ + +import java.awt.Dimension; +import javax.swing.JFrame; +import javax.swing.JScrollPane; +import javax.swing.JTextPane; + +public class bug4188841 { + + static final String INSTRUCTIONS = """ + The text pane contains the phrase "the quick brown fox jumps over the lazy dog", + all the words are separated by tabs. When the test starts, the whole phrase should + appear on one line. If it is wrapped along two or more lines, the test FAILS. + + Otherwise, place the text caret in the very end of the line (e.g. by clicking + in the line and hitting End). Press Enter twice. The text should appear as one + line at all times. If the text wraps when you press Enter, the test FAILS. + """; + + static class NoWrapTextPane extends JTextPane { + + public boolean getScrollableTracksViewportWidth() { + //should not allow text to be wrapped + return false; + } + + public void setSize(Dimension d) { + // don't let the Textpane get sized smaller than its parent + if (d.width < getParent().getSize().width) { + super.setSize(getParent().getSize()); + } + else { + super.setSize(d); + } + } + } + + static JFrame createUI() { + + JFrame frame = new JFrame("bug4188841"); + + NoWrapTextPane nwp = new NoWrapTextPane(); + nwp.setText("the\tquick\tbrown\tfox\tjumps\tover\tthe\tlazy\tdog!"); + nwp.setCaretPosition(nwp.getText().length()); + + JScrollPane scrollPane = new JScrollPane(nwp, + JScrollPane.VERTICAL_SCROLLBAR_AS_NEEDED, + JScrollPane.HORIZONTAL_SCROLLBAR_ALWAYS); + + frame.add(scrollPane); + frame.setSize(400, 300); + return frame; + } + + public static void main(String args[]) throws Exception { + PassFailJFrame.builder() + .title("Test Instructions") + .instructions(INSTRUCTIONS) + .columns(60) + .testUI(bug4188841::createUI) + .build() + .awaitAndCheck(); + } +} diff -Nru openjdk-17-17.0.17+10/test/jdk/javax/swing/text/html/FormView/4473401/bug4473401.java openjdk-17-17.0.18+8/test/jdk/javax/swing/text/html/FormView/4473401/bug4473401.java --- openjdk-17-17.0.17+10/test/jdk/javax/swing/text/html/FormView/4473401/bug4473401.java 1970-01-01 00:00:00.000000000 +0000 +++ openjdk-17-17.0.18+8/test/jdk/javax/swing/text/html/FormView/4473401/bug4473401.java 2026-01-15 15:23:06.000000000 +0000 @@ -0,0 +1,90 @@ +/* + * Copyright (c) 2003, 2025, Oracle and/or its affiliates. All rights reserved. + * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. + * + * This code is free software; you can redistribute 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 4473401 + * @summary Tests if FormSubmitEvent is submitted correctly. + * @library /java/awt/regtesthelpers + * @build PassFailJFrame + * @run main/manual bug4473401 +*/ + +import java.io.File; +import javax.swing.JEditorPane; +import javax.swing.JFrame; +import javax.swing.event.HyperlinkEvent; +import javax.swing.event.HyperlinkListener; +import javax.swing.text.html.FormSubmitEvent; +import javax.swing.text.html.HTMLEditorKit; + +public class bug4473401 implements HyperlinkListener { + + static final String INSTRUCTIONS = """ + The test window displays an HTML frameset with a frame + on the left and another to the right. + Push the 'Submit Query' button in the left frame to perform testing. + The window should be updated to have only one frame with the + message 'If you see this page the test PASSED'. + If it appears, PASS the test, otherwise FAIL the test. + """; + + static JEditorPane jep; + static JFrame createUI() { + + JFrame frame = new JFrame("bug4473401"); + jep = new JEditorPane(); + jep.addHyperlinkListener(new bug4473401()); + HTMLEditorKit kit = new HTMLEditorKit(); + kit.setAutoFormSubmission(false); + jep.setEditorKit(kit); + jep.setEditable(false); + + try { + File file = new File(System.getProperty("test.src", "."), "frameset.html"); + System.out.println(file.toURI().toURL()); + jep.setPage(file.toURL()); + } catch (Exception e) { + throw new RuntimeException(e); + } + + frame.add(jep); + frame.setSize(500, 500); + return frame; + } + + public void hyperlinkUpdate(HyperlinkEvent e) { + if (e instanceof FormSubmitEvent) { + jep.setText("If you see this page the test PASSED"); + } + } + + public static void main(String args[]) throws Exception { + PassFailJFrame.builder() + .title("Test Instructions") + .instructions(INSTRUCTIONS) + .columns(40) + .testUI(bug4473401::createUI) + .build() + .awaitAndCheck(); + } +} diff -Nru openjdk-17-17.0.17+10/test/jdk/javax/swing/text/html/FormView/4473401/frame1.html openjdk-17-17.0.18+8/test/jdk/javax/swing/text/html/FormView/4473401/frame1.html --- openjdk-17-17.0.17+10/test/jdk/javax/swing/text/html/FormView/4473401/frame1.html 1970-01-01 00:00:00.000000000 +0000 +++ openjdk-17-17.0.18+8/test/jdk/javax/swing/text/html/FormView/4473401/frame1.html 2026-01-15 15:23:06.000000000 +0000 @@ -0,0 +1,9 @@ + + +Push the Submit query button +
+
+ +
+ + diff -Nru openjdk-17-17.0.17+10/test/jdk/javax/swing/text/html/FormView/4473401/frame2.html openjdk-17-17.0.18+8/test/jdk/javax/swing/text/html/FormView/4473401/frame2.html --- openjdk-17-17.0.17+10/test/jdk/javax/swing/text/html/FormView/4473401/frame2.html 1970-01-01 00:00:00.000000000 +0000 +++ openjdk-17-17.0.18+8/test/jdk/javax/swing/text/html/FormView/4473401/frame2.html 2026-01-15 15:23:06.000000000 +0000 @@ -0,0 +1,4 @@ + + + + diff -Nru openjdk-17-17.0.17+10/test/jdk/javax/swing/text/html/FormView/4473401/frameresult.html openjdk-17-17.0.18+8/test/jdk/javax/swing/text/html/FormView/4473401/frameresult.html --- openjdk-17-17.0.17+10/test/jdk/javax/swing/text/html/FormView/4473401/frameresult.html 1970-01-01 00:00:00.000000000 +0000 +++ openjdk-17-17.0.18+8/test/jdk/javax/swing/text/html/FormView/4473401/frameresult.html 2026-01-15 15:23:06.000000000 +0000 @@ -0,0 +1,5 @@ + + +If you see this page the test FAILED. + + diff -Nru openjdk-17-17.0.17+10/test/jdk/javax/swing/text/html/FormView/4473401/frameset.html openjdk-17-17.0.18+8/test/jdk/javax/swing/text/html/FormView/4473401/frameset.html --- openjdk-17-17.0.17+10/test/jdk/javax/swing/text/html/FormView/4473401/frameset.html 1970-01-01 00:00:00.000000000 +0000 +++ openjdk-17-17.0.18+8/test/jdk/javax/swing/text/html/FormView/4473401/frameset.html 2026-01-15 15:23:06.000000000 +0000 @@ -0,0 +1,11 @@ + + + + Manual test for bug 4463014 + + + + + + + \ No newline at end of file diff -Nru openjdk-17-17.0.17+10/test/jdk/javax/swing/text/html/FormView/bug4529702.java openjdk-17-17.0.18+8/test/jdk/javax/swing/text/html/FormView/bug4529702.java --- openjdk-17-17.0.17+10/test/jdk/javax/swing/text/html/FormView/bug4529702.java 1970-01-01 00:00:00.000000000 +0000 +++ openjdk-17-17.0.18+8/test/jdk/javax/swing/text/html/FormView/bug4529702.java 2026-01-15 15:23:06.000000000 +0000 @@ -0,0 +1,62 @@ +/* + * Copyright (c) 2002, 2025, Oracle and/or its affiliates. All rights reserved. + * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. + * + * This code is free software; you can redistribute it and/or modify it + * under the terms of the GNU General Public License version 2 only, as + * published by the Free Software Foundation. + * + * This code is distributed in the hope that it will be useful, but WITHOUT + * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or + * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License + * version 2 for more details (a copy is included in the LICENSE file that + * accompanied this code). + * + * You should have received a copy of the GNU General Public License version + * 2 along with this work; if not, write to the Free Software Foundation, + * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. + * + * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA + * or visit www.oracle.com if you need additional information or have any + * questions. + */ + +/* @test + * @bug 4529702 + * @summary Test that radio buttons with different names should be selectable at the same time + * @library /java/awt/regtesthelpers + * @build PassFailJFrame + * @run main/manual bug4529702 +*/ + +import javax.swing.JFrame; +import javax.swing.JTextPane; + +public class bug4529702 { + + static final String INSTRUCTIONS = """ + There are two rows of radio buttons, each row having two buttons. + If you can select radio buttons from the first and the second rows + at the same time the test PASSES otherwise the test FAILS. + """; + + static JFrame createUI() { + JFrame frame = new JFrame("bug4529702"); + JTextPane jtp = new JTextPane(); + jtp.setContentType("text/html"); + jtp.setText("

" + + "
"); + frame.add(jtp); + frame.setSize(200, 200); + return frame; + } + + public static void main(String[] args) throws Exception { + PassFailJFrame.builder() + .instructions(INSTRUCTIONS) + .columns(40) + .testUI(bug4529702::createUI) + .build() + .awaitAndCheck(); + } +} diff -Nru openjdk-17-17.0.17+10/test/jdk/javax/swing/text/html/FrameSetView/4890934/bug4890934.java openjdk-17-17.0.18+8/test/jdk/javax/swing/text/html/FrameSetView/4890934/bug4890934.java --- openjdk-17-17.0.17+10/test/jdk/javax/swing/text/html/FrameSetView/4890934/bug4890934.java 1970-01-01 00:00:00.000000000 +0000 +++ openjdk-17-17.0.18+8/test/jdk/javax/swing/text/html/FrameSetView/4890934/bug4890934.java 2026-01-15 15:23:06.000000000 +0000 @@ -0,0 +1,91 @@ +/* + * Copyright (c) 2003, 2025, Oracle and/or its affiliates. All rights reserved. + * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. + * + * This code is free software; you can redistribute 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 4890934 + * @summary Tests if JEditor Pane updates the correct frame when using + * @library /java/awt/regtesthelpers + * @build PassFailJFrame + * @run main/manual bug4890934 +*/ + +import java.io.File; +import javax.swing.JEditorPane; +import javax.swing.JFrame; +import javax.swing.event.HyperlinkEvent; +import javax.swing.event.HyperlinkListener; +import javax.swing.text.html.HTMLDocument; +import javax.swing.text.html.HTMLEditorKit; +import javax.swing.text.html.HTMLFrameHyperlinkEvent; + +public class bug4890934 implements HyperlinkListener { + + static final String INSTRUCTIONS = """ + The test window displays an HTML frameset with a frame + on the left and another to the right. + Click the link in the left frame which should change the view. + The resulting page will tell you if the test PASSED or FAILED. + """; + + static JFrame createUI() { + + JFrame frame = new JFrame("bug4890934"); + JEditorPane jep = new JEditorPane(); + jep.setEditorKit(new HTMLEditorKit()); + jep.setEditable(false); + jep.addHyperlinkListener(new bug4890934()); + + try { + File file = new File(System.getProperty("test.src", "."), "frameset.html"); + System.out.println(file.toURI().toURL()); + jep.setPage(file.toURL()); + } catch (Exception e) { + throw new RuntimeException(e); + } + + frame.add(jep); + frame.setSize(600, 300); + return frame; + } + + public void hyperlinkUpdate(HyperlinkEvent e) { + if (e.getEventType() == HyperlinkEvent.EventType.ACTIVATED) { + JEditorPane pane = (JEditorPane) e.getSource(); + if (e instanceof HTMLFrameHyperlinkEvent) { + HTMLFrameHyperlinkEvent evt = (HTMLFrameHyperlinkEvent)e; + HTMLDocument doc = (HTMLDocument)pane.getDocument(); + doc.processHTMLFrameHyperlinkEvent(evt); + } + } + } + + public static void main(String args[]) throws Exception { + PassFailJFrame.builder() + .title("Test Instructions") + .instructions(INSTRUCTIONS) + .columns(40) + .testUI(bug4890934::createUI) + .build() + .awaitAndCheck(); + } +} diff -Nru openjdk-17-17.0.17+10/test/jdk/javax/swing/text/html/FrameSetView/4890934/frame1.html openjdk-17-17.0.18+8/test/jdk/javax/swing/text/html/FrameSetView/4890934/frame1.html --- openjdk-17-17.0.17+10/test/jdk/javax/swing/text/html/FrameSetView/4890934/frame1.html 1970-01-01 00:00:00.000000000 +0000 +++ openjdk-17-17.0.18+8/test/jdk/javax/swing/text/html/FrameSetView/4890934/frame1.html 2026-01-15 15:23:06.000000000 +0000 @@ -0,0 +1,8 @@ + + + + + + a link + + diff -Nru openjdk-17-17.0.17+10/test/jdk/javax/swing/text/html/FrameSetView/4890934/frame2.html openjdk-17-17.0.18+8/test/jdk/javax/swing/text/html/FrameSetView/4890934/frame2.html --- openjdk-17-17.0.17+10/test/jdk/javax/swing/text/html/FrameSetView/4890934/frame2.html 1970-01-01 00:00:00.000000000 +0000 +++ openjdk-17-17.0.18+8/test/jdk/javax/swing/text/html/FrameSetView/4890934/frame2.html 2026-01-15 15:23:06.000000000 +0000 @@ -0,0 +1,4 @@ + + + + diff -Nru openjdk-17-17.0.17+10/test/jdk/javax/swing/text/html/FrameSetView/4890934/frameresult.html openjdk-17-17.0.18+8/test/jdk/javax/swing/text/html/FrameSetView/4890934/frameresult.html --- openjdk-17-17.0.17+10/test/jdk/javax/swing/text/html/FrameSetView/4890934/frameresult.html 1970-01-01 00:00:00.000000000 +0000 +++ openjdk-17-17.0.18+8/test/jdk/javax/swing/text/html/FrameSetView/4890934/frameresult.html 2026-01-15 15:23:06.000000000 +0000 @@ -0,0 +1,7 @@ + + +If you see this text in the RIGHT frame the test PASSED. +

If you see this text in the LEFT frame the test FAILED. + + + diff -Nru openjdk-17-17.0.17+10/test/jdk/javax/swing/text/html/FrameSetView/4890934/frameset.html openjdk-17-17.0.18+8/test/jdk/javax/swing/text/html/FrameSetView/4890934/frameset.html --- openjdk-17-17.0.17+10/test/jdk/javax/swing/text/html/FrameSetView/4890934/frameset.html 1970-01-01 00:00:00.000000000 +0000 +++ openjdk-17-17.0.18+8/test/jdk/javax/swing/text/html/FrameSetView/4890934/frameset.html 2026-01-15 15:23:06.000000000 +0000 @@ -0,0 +1,11 @@ + + + + Manual test for bug 4463014 + + + + + + + diff -Nru openjdk-17-17.0.17+10/test/jdk/jdk/internal/platform/docker/GetFreeSwapSpaceSize.java openjdk-17-17.0.18+8/test/jdk/jdk/internal/platform/docker/GetFreeSwapSpaceSize.java --- openjdk-17-17.0.17+10/test/jdk/jdk/internal/platform/docker/GetFreeSwapSpaceSize.java 2025-10-13 07:48:04.000000000 +0000 +++ openjdk-17-17.0.18+8/test/jdk/jdk/internal/platform/docker/GetFreeSwapSpaceSize.java 2026-01-15 15:23:06.000000000 +0000 @@ -1,5 +1,5 @@ /* - * Copyright (C) 2020, 2022 THL A29 Limited, a Tencent company. All rights reserved. + * Copyright (C) 2020, 2022, Tencent. All rights reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * * This code is free software; you can redistribute it and/or modify it diff -Nru openjdk-17-17.0.17+10/test/jdk/jdk/internal/platform/docker/MetricsMemoryTester.java openjdk-17-17.0.18+8/test/jdk/jdk/internal/platform/docker/MetricsMemoryTester.java --- openjdk-17-17.0.17+10/test/jdk/jdk/internal/platform/docker/MetricsMemoryTester.java 2025-10-13 07:48:04.000000000 +0000 +++ openjdk-17-17.0.18+8/test/jdk/jdk/internal/platform/docker/MetricsMemoryTester.java 2026-01-15 15:23:06.000000000 +0000 @@ -1,5 +1,5 @@ /* - * Copyright (c) 2018, 2020, 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 @@ -48,6 +48,8 @@ case "softlimit": testMemorySoftLimit(args[1]); break; + default: + throw new RuntimeException("unknown args: " + args[0] + " for MetricsMemoryTester"); } } @@ -68,7 +70,7 @@ // We need swap to execute this test or will SEGV if (memAndSwapLimit <= memLimit) { - System.out.println("No swap memory limits, test case skipped"); + System.out.println("No swap memory limits. Ignoring test!"); } else { long count = Metrics.systemMetrics().getMemoryFailCount(); diff -Nru openjdk-17-17.0.17+10/test/jdk/jdk/internal/platform/docker/TestDockerBasic.java openjdk-17-17.0.18+8/test/jdk/jdk/internal/platform/docker/TestDockerBasic.java --- openjdk-17-17.0.17+10/test/jdk/jdk/internal/platform/docker/TestDockerBasic.java 2025-10-13 07:48:04.000000000 +0000 +++ openjdk-17-17.0.18+8/test/jdk/jdk/internal/platform/docker/TestDockerBasic.java 2026-01-15 15:23:06.000000000 +0000 @@ -1,5 +1,6 @@ /* * Copyright (c) 2022, Red Hat, Inc. + * Copyright (c) 2024, Oracle and/or its affiliates. All rights reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * * This code is free software; you can redistribute it and/or modify it @@ -26,7 +27,7 @@ * @bug 8293540 * @summary Verify that -XshowSettings:system works * @key cgroups - * @requires docker.support + * @requires container.support * @library /test/lib * @run main/timeout=360 TestDockerBasic */ diff -Nru openjdk-17-17.0.17+10/test/jdk/jdk/internal/platform/docker/TestDockerCpuMetrics.java openjdk-17-17.0.18+8/test/jdk/jdk/internal/platform/docker/TestDockerCpuMetrics.java --- openjdk-17-17.0.17+10/test/jdk/jdk/internal/platform/docker/TestDockerCpuMetrics.java 2025-10-13 07:48:04.000000000 +0000 +++ openjdk-17-17.0.18+8/test/jdk/jdk/internal/platform/docker/TestDockerCpuMetrics.java 2026-01-15 15:23:06.000000000 +0000 @@ -1,5 +1,5 @@ /* - * Copyright (c) 2018, 2020, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2018, 2024, Oracle and/or its affiliates. All rights reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * * This code is free software; you can redistribute it and/or modify it @@ -34,7 +34,7 @@ * @test * @key cgroups * @summary Test JDK Metrics class when running inside docker container - * @requires docker.support + * @requires container.support * @library /test/lib * @modules java.base/jdk.internal.platform * @build MetricsCpuTester diff -Nru openjdk-17-17.0.17+10/test/jdk/jdk/internal/platform/docker/TestDockerMemoryMetrics.java openjdk-17-17.0.18+8/test/jdk/jdk/internal/platform/docker/TestDockerMemoryMetrics.java --- openjdk-17-17.0.17+10/test/jdk/jdk/internal/platform/docker/TestDockerMemoryMetrics.java 2025-10-13 07:48:04.000000000 +0000 +++ openjdk-17-17.0.18+8/test/jdk/jdk/internal/platform/docker/TestDockerMemoryMetrics.java 2026-01-15 15:23:06.000000000 +0000 @@ -1,5 +1,5 @@ /* - * Copyright (c) 2018, 2021, 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 @@ -27,12 +27,13 @@ import jdk.test.lib.containers.docker.DockerRunOptions; import jdk.test.lib.containers.docker.DockerTestUtils; import jdk.test.lib.process.OutputAnalyzer; +import jtreg.SkippedException; /* * @test * @key cgroups * @summary Test JDK Metrics class when running inside docker container - * @requires docker.support + * @requires container.support * @library /test/lib * @modules java.base/jdk.internal.platform * @build MetricsMemoryTester @@ -75,7 +76,7 @@ } testOomKillFlag("100m", true); - testMemoryFailCount("64m"); + testMemoryFailCount("128m"); testMemorySoftLimit("500m","200m"); @@ -111,18 +112,22 @@ // Check whether swapping really works for this test // On some systems there is no swap space enabled. And running - // 'java -Xms{mem-limit} -Xmx{mem-limit} -version' would fail due to swap space size being 0. + // 'java -Xms{mem-limit} -Xmx{mem-limit} -XX:+AlwaysPreTouch -version' + // would fail due to swap space size being 0. Note that when swap is + // properly enabled on the system the container gets the same amount + // of swap as is configured for memory. Thus, 2x{mem-limit} is the actual + // memory and swap bound for this pre-test. DockerRunOptions preOpts = new DockerRunOptions(imageName, "/jdk/bin/java", "-version"); preOpts.addDockerOpts("--volume", Utils.TEST_CLASSES + ":/test-classes/") .addDockerOpts("--memory=" + value) + .addJavaOpts("-XX:+AlwaysPreTouch") .addJavaOpts("-Xms" + value) .addJavaOpts("-Xmx" + value); OutputAnalyzer oa = DockerTestUtils.dockerRunJava(preOpts); String output = oa.getOutput(); if (!output.contains("version")) { - System.out.println("Swapping doesn't work for this test."); - return; + throw new SkippedException("Swapping doesn't work for this test."); } DockerRunOptions opts = @@ -136,8 +141,7 @@ oa = DockerTestUtils.dockerRunJava(opts); output = oa.getOutput(); if (output.contains("Ignoring test")) { - System.out.println("Ignored by the tester"); - return; + throw new SkippedException("Ignored by the tester"); } oa.shouldHaveExitValue(0).shouldContain("TEST PASSED!!!"); } diff -Nru openjdk-17-17.0.17+10/test/jdk/jdk/internal/platform/docker/TestGetFreeSwapSpaceSize.java openjdk-17-17.0.18+8/test/jdk/jdk/internal/platform/docker/TestGetFreeSwapSpaceSize.java --- openjdk-17-17.0.17+10/test/jdk/jdk/internal/platform/docker/TestGetFreeSwapSpaceSize.java 2025-10-13 07:48:04.000000000 +0000 +++ openjdk-17-17.0.18+8/test/jdk/jdk/internal/platform/docker/TestGetFreeSwapSpaceSize.java 2026-01-15 15:23:06.000000000 +0000 @@ -1,5 +1,6 @@ /* - * Copyright (C) 2020, 2022 THL A29 Limited, a Tencent company. All rights reserved. + * Copyright (C) 2020, 2022, Tencent. All rights reserved. + * Copyright (c) 2024, Oracle and/or its affiliates. All rights reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * * This code is free software; you can redistribute it and/or modify it @@ -25,7 +26,7 @@ * @test * @key cgroups * @bug 8242480 - * @requires docker.support + * @requires container.support * @library /test/lib * @build GetFreeSwapSpaceSize * @run driver TestGetFreeSwapSpaceSize diff -Nru openjdk-17-17.0.17+10/test/jdk/jdk/internal/platform/docker/TestLimitsUpdating.java openjdk-17-17.0.18+8/test/jdk/jdk/internal/platform/docker/TestLimitsUpdating.java --- openjdk-17-17.0.17+10/test/jdk/jdk/internal/platform/docker/TestLimitsUpdating.java 2025-10-13 07:48:04.000000000 +0000 +++ openjdk-17-17.0.18+8/test/jdk/jdk/internal/platform/docker/TestLimitsUpdating.java 2026-01-15 15:23:06.000000000 +0000 @@ -1,5 +1,6 @@ /* * Copyright (c) 2023, Red Hat, Inc. + * Copyright (c) 2024, Oracle and/or its affiliates. All rights reserved. * * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * @@ -28,7 +29,7 @@ * @bug 8308090 * @key cgroups * @summary Test container limits updating as they get updated at runtime without restart - * @requires docker.support + * @requires container.support * @library /test/lib * @modules java.base/jdk.internal.platform * @build LimitUpdateChecker diff -Nru openjdk-17-17.0.17+10/test/jdk/jdk/internal/platform/docker/TestPidsLimit.java openjdk-17-17.0.18+8/test/jdk/jdk/internal/platform/docker/TestPidsLimit.java --- openjdk-17-17.0.17+10/test/jdk/jdk/internal/platform/docker/TestPidsLimit.java 2025-10-13 07:48:04.000000000 +0000 +++ openjdk-17-17.0.18+8/test/jdk/jdk/internal/platform/docker/TestPidsLimit.java 2026-01-15 15:23:06.000000000 +0000 @@ -1,5 +1,5 @@ /* - * Copyright (c) 2021, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2021, 2024, Oracle and/or its affiliates. All rights reserved. * Copyright (c) 2021 SAP SE. All rights reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * @@ -27,7 +27,7 @@ * @key cgroups * @summary Test JDK Metrics class when running inside a docker container with limited pids * @bug 8266490 - * @requires docker.support + * @requires container.support * @library /test/lib * @build TestPidsLimit * @run driver TestPidsLimit diff -Nru openjdk-17-17.0.17+10/test/jdk/jdk/internal/platform/docker/TestSystemMetrics.java openjdk-17-17.0.18+8/test/jdk/jdk/internal/platform/docker/TestSystemMetrics.java --- openjdk-17-17.0.17+10/test/jdk/jdk/internal/platform/docker/TestSystemMetrics.java 2025-10-13 07:48:04.000000000 +0000 +++ openjdk-17-17.0.18+8/test/jdk/jdk/internal/platform/docker/TestSystemMetrics.java 2026-01-15 15:23:06.000000000 +0000 @@ -1,5 +1,5 @@ /* - * Copyright (c) 2018, 2022, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2018, 2024, Oracle and/or its affiliates. All rights reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * * This code is free software; you can redistribute it and/or modify it @@ -25,7 +25,7 @@ * @test * @key cgroups * @summary Test JDK Metrics class when running inside docker container - * @requires docker.support + * @requires container.support * @library /test/lib * @modules java.base/jdk.internal.platform * @run main TestSystemMetrics diff -Nru openjdk-17-17.0.17+10/test/jdk/jdk/internal/platform/docker/TestUseContainerSupport.java openjdk-17-17.0.18+8/test/jdk/jdk/internal/platform/docker/TestUseContainerSupport.java --- openjdk-17-17.0.17+10/test/jdk/jdk/internal/platform/docker/TestUseContainerSupport.java 2025-10-13 07:48:04.000000000 +0000 +++ openjdk-17-17.0.18+8/test/jdk/jdk/internal/platform/docker/TestUseContainerSupport.java 2026-01-15 15:23:06.000000000 +0000 @@ -1,5 +1,6 @@ /* * Copyright (c) 2020, Red Hat, Inc. + * Copyright (c) 2024, Oracle and/or its affiliates. All rights reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * * This code is free software; you can redistribute it and/or modify it @@ -24,7 +25,7 @@ /* * @test * @summary UseContainerSupport flag should reflect Metrics being available - * @requires docker.support + * @requires container.support * @library /test/lib * @modules java.base/jdk.internal.platform * @build CheckUseContainerSupport diff -Nru openjdk-17-17.0.17+10/test/jdk/jdk/jfr/event/compiler/TestCompilerCompile.java openjdk-17-17.0.18+8/test/jdk/jdk/jfr/event/compiler/TestCompilerCompile.java --- openjdk-17-17.0.17+10/test/jdk/jdk/jfr/event/compiler/TestCompilerCompile.java 2025-10-13 07:48:04.000000000 +0000 +++ openjdk-17-17.0.18+8/test/jdk/jdk/jfr/event/compiler/TestCompilerCompile.java 2026-01-15 15:23:06.000000000 +0000 @@ -1,5 +1,5 @@ /* - * Copyright (c) 2013, 2022, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2013, 2024, Oracle and/or its affiliates. All rights reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * * This code is free software; you can redistribute it and/or modify it @@ -41,7 +41,7 @@ * @test * @key jfr * @requires vm.hasJFR - * @requires vm.compMode!="Xint" + * @requires vm.compMode == "Xmixed" * @library /test/lib * @build jdk.test.whitebox.WhiteBox * @run driver jdk.test.lib.helpers.ClassFileInstaller jdk.test.whitebox.WhiteBox diff -Nru openjdk-17-17.0.17+10/test/jdk/jdk/jfr/event/compiler/TestCompilerInlining.java openjdk-17-17.0.18+8/test/jdk/jdk/jfr/event/compiler/TestCompilerInlining.java --- openjdk-17-17.0.17+10/test/jdk/jdk/jfr/event/compiler/TestCompilerInlining.java 2025-10-13 07:48:04.000000000 +0000 +++ openjdk-17-17.0.18+8/test/jdk/jdk/jfr/event/compiler/TestCompilerInlining.java 2026-01-15 15:23:06.000000000 +0000 @@ -47,7 +47,7 @@ * @key jfr * @summary Verifies that corresponding JFR events are emitted in case of inlining. * @requires vm.hasJFR - * + * @requires vm.compMode == "Xmixed" * @requires vm.opt.Inline == true | vm.opt.Inline == null * @library /test/lib * @modules java.base/jdk.internal.org.objectweb.asm diff -Nru openjdk-17-17.0.17+10/test/jdk/jdk/jfr/event/compiler/TestDeoptimization.java openjdk-17-17.0.18+8/test/jdk/jdk/jfr/event/compiler/TestDeoptimization.java --- openjdk-17-17.0.17+10/test/jdk/jdk/jfr/event/compiler/TestDeoptimization.java 2025-10-13 07:48:04.000000000 +0000 +++ openjdk-17-17.0.18+8/test/jdk/jdk/jfr/event/compiler/TestDeoptimization.java 2026-01-15 15:23:06.000000000 +0000 @@ -1,5 +1,5 @@ /* - * Copyright (c) 2019, 2022, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2019, 2024, Oracle and/or its affiliates. All rights reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * * This code is free software; you can redistribute it and/or modify it @@ -51,7 +51,7 @@ * @key jfr * @summary sanity test for Deoptimization event, depends on Compilation event * @requires vm.hasJFR - * @requires vm.compMode != "Xint" + * @requires vm.compMode == "Xmixed" * @requires vm.flavor == "server" & (vm.opt.TieredStopAtLevel == 4 | vm.opt.TieredStopAtLevel == null) * @library /test/lib * @build jdk.test.whitebox.WhiteBox diff -Nru openjdk-17-17.0.17+10/test/jdk/jdk/jfr/event/os/TestCPULoad.java openjdk-17-17.0.18+8/test/jdk/jdk/jfr/event/os/TestCPULoad.java --- openjdk-17-17.0.17+10/test/jdk/jdk/jfr/event/os/TestCPULoad.java 2025-10-13 07:48:04.000000000 +0000 +++ openjdk-17-17.0.18+8/test/jdk/jdk/jfr/event/os/TestCPULoad.java 2026-01-15 15:23:06.000000000 +0000 @@ -1,5 +1,5 @@ /* - * Copyright (c) 2013, 2018, 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,6 @@ import jdk.test.lib.jfr.EventNames; import jdk.test.lib.jfr.Events; - /** * @test * @key jfr @@ -41,13 +40,32 @@ public class TestCPULoad { private final static String EVENT_NAME = EventNames.CPULoad; + public static boolean isPrime(int num) { + if (num <= 1) return false; + for (int i = 2; i <= Math.sqrt(num); i++) { + if (num % i == 0) return false; + } + return true; + } + + public static int burnCpuCycles(int limit) { + int primeCount = 0; + for (int i = 2; i < limit; i++) { + if (isPrime(i)) { + primeCount++; + } + } + return primeCount; + } + public static void main(String[] args) throws Throwable { Recording recording = new Recording(); recording.enable(EVENT_NAME); recording.start(); - // Need to sleep so a time delta can be calculated - Thread.sleep(100); + // burn some cycles to check increase of CPU related counters + int pn = burnCpuCycles(2500000); recording.stop(); + System.out.println("Found " + pn + " primes while burning cycles"); List events = Events.fromRecording(recording); if (events.isEmpty()) { diff -Nru openjdk-17-17.0.17+10/test/jdk/jdk/modules/incubator/ServiceBinding.java openjdk-17-17.0.18+8/test/jdk/jdk/modules/incubator/ServiceBinding.java --- openjdk-17-17.0.17+10/test/jdk/jdk/modules/incubator/ServiceBinding.java 2025-10-13 07:48:04.000000000 +0000 +++ openjdk-17-17.0.18+8/test/jdk/jdk/modules/incubator/ServiceBinding.java 2026-01-15 15:23:06.000000000 +0000 @@ -1,5 +1,5 @@ /* - * Copyright (c) 2019, Oracle and/or its affiliates. All rights reserved. + * 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 @@ -24,9 +24,11 @@ /** * @test * @bug 8233922 - * @modules java.base/jdk.internal.module + * @modules java.base/jdk.internal.org.objectweb.asm + * java.base/jdk.internal.org.objectweb.asm.commons + * java.base/jdk.internal.module * @library /test/lib - * @build ServiceBinding TestBootLayer + * @build ServiceBinding TestBootLayer jdk.test.lib.util.ModuleInfoWriter * @run testng ServiceBinding * @summary Test service binding with incubator modules */ @@ -43,17 +45,16 @@ import java.util.Set; import java.util.stream.Collectors; import java.util.stream.Stream; -import java.util.stream.Stream; import static java.lang.module.ModuleDescriptor.newModule; -import jdk.internal.module.ModuleInfoWriter; import jdk.internal.module.ModuleResolution; import org.testng.annotations.Test; import jdk.test.lib.process.ProcessTools; import jdk.test.lib.process.OutputAnalyzer; +import jdk.test.lib.util.ModuleInfoWriter; @Test public class ServiceBinding { diff -Nru openjdk-17-17.0.17+10/test/jdk/sun/awt/font/TestDevTransform.java openjdk-17-17.0.18+8/test/jdk/sun/awt/font/TestDevTransform.java --- openjdk-17-17.0.17+10/test/jdk/sun/awt/font/TestDevTransform.java 2025-10-13 07:48:04.000000000 +0000 +++ openjdk-17-17.0.18+8/test/jdk/sun/awt/font/TestDevTransform.java 2026-01-15 15:23:06.000000000 +0000 @@ -1,5 +1,5 @@ /* - * Copyright (c) 1999, 2024, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 1999, 2025, Oracle and/or its affiliates. All rights reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * * This code is free software; you can redistribute it and/or modify it @@ -22,9 +22,31 @@ */ /* - * @test + * @test id=dialog_double * @bug 4269775 8341535 * @summary Check that different text rendering APIs agree + * @run main/othervm TestDevTransform DIALOG DOUBLE + */ + +/* + * @test id=dialog_float + * @bug 4269775 8341535 + * @summary Check that different text rendering APIs agree + * @run main/othervm TestDevTransform DIALOG FLOAT + */ + +/* + * @test id=monospaced_double + * @bug 4269775 8341535 + * @summary Check that different text rendering APIs agree + * @run main/othervm TestDevTransform MONOSPACED DOUBLE + */ + +/* + * @test id=monospaced_float + * @bug 4269775 8341535 + * @summary Check that different text rendering APIs agree + * @run main/othervm TestDevTransform MONOSPACED FLOAT */ /** @@ -66,6 +88,8 @@ static String test = "This is only a test"; static double angle = Math.PI / 6.0; // Rotate 30 degrees static final int W = 400, H = 400; + static boolean useDialog; + static boolean useDouble; static void draw(Graphics2D g2d, TextLayout layout, float x, float y, float scalex) { @@ -101,9 +125,19 @@ g2d.setColor(Color.white); g2d.fillRect(0, 0, W, H); g2d.setColor(Color.black); - g2d.scale(1.481f, 1.481); // Convert to 108 dpi + if (useDouble) { + g2d.scale(1.481, 1.481); // Convert to 108 dpi + } else { + g2d.scale(1.481f, 1.481f); // Convert to 108 dpi + } g2d.addRenderingHints(hints); - Font font = new Font(Font.DIALOG, Font.PLAIN, 12); + String name; + if (useDialog) { + name = Font.DIALOG; + } else { + name = Font.MONOSPACED; + } + Font font = new Font(name, Font.PLAIN, 12); g2d.setFont(font); } @@ -135,6 +169,12 @@ } public static void main(String args[]) throws Exception { + if (args[0].equals("DIALOG")) { + useDialog = true; + } + if (args[1].equals("DOUBLE")) { + useDouble = true; + } BufferedImage tl_Image = new BufferedImage(W, H, BufferedImage.TYPE_INT_RGB); { diff -Nru openjdk-17-17.0.17+10/test/jdk/sun/jvmstat/monitor/MonitoredVm/MonitorVmStartTerminate.java openjdk-17-17.0.18+8/test/jdk/sun/jvmstat/monitor/MonitoredVm/MonitorVmStartTerminate.java --- openjdk-17-17.0.17+10/test/jdk/sun/jvmstat/monitor/MonitoredVm/MonitorVmStartTerminate.java 2025-10-13 07:48:04.000000000 +0000 +++ openjdk-17-17.0.18+8/test/jdk/sun/jvmstat/monitor/MonitoredVm/MonitorVmStartTerminate.java 2026-01-15 15:23:06.000000000 +0000 @@ -1,5 +1,5 @@ /* - * Copyright (c) 2004, 2023, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2004, 2025, Oracle and/or its affiliates. All rights reserved. * 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,6 +74,7 @@ public final class MonitorVmStartTerminate { private static final int PROCESS_COUNT = 10; + private static final int ARGS_ATTEMPTS = 10; public static void main(String... args) throws Exception { @@ -175,8 +176,6 @@ } } - private static final int ARGS_ATTEMPTS = 3; - private boolean hasMainArgs(Integer id, String args) { VmIdentifier vmid = null; try { @@ -204,7 +203,10 @@ } catch (MonitorException e) { // Process probably not running or not ours, e.g. // sun.jvmstat.monitor.MonitorException: Could not attach to PID - System.out.println("hasMainArgs(" + id + "): " + e); + // Only log if something else, to avoid filling log: + if (!e.getMessage().contains("Could not attach")) { + System.out.println("hasMainArgs(" + id + "): " + e); + } } } return false; @@ -249,23 +251,15 @@ } private static void waitForRemoval(Path path) { - String timeoutFactorText = System.getProperty("test.timeout.factor", "1.0"); - double timeoutFactor = Double.parseDouble(timeoutFactorText); - long timeoutNanos = 1000_000_000L*(long)(1000*timeoutFactor); long start = System.nanoTime(); + System.out.println("Waiting for " + path + " to be removed"); while (true) { long now = System.nanoTime(); long waited = now - start; - System.out.println("Waiting for " + path + " to be removed, " + waited + " ns"); if (!Files.exists(path)) { + System.out.println("waitForRemoval: " + path + " has been removed in " + waited + " ns"); return; } - if (waited > timeoutNanos) { - System.out.println("Start: " + start); - System.out.println("Now: " + now); - System.out.println("Process timed out after " + waited + " ns. Abort."); - System.exit(1); - } takeNap(); } } diff -Nru openjdk-17-17.0.17+10/test/jdk/sun/management/jmxremote/bootstrap/AbstractFilePermissionTest.java openjdk-17-17.0.18+8/test/jdk/sun/management/jmxremote/bootstrap/AbstractFilePermissionTest.java --- openjdk-17-17.0.17+10/test/jdk/sun/management/jmxremote/bootstrap/AbstractFilePermissionTest.java 2025-10-13 07:48:04.000000000 +0000 +++ openjdk-17-17.0.18+8/test/jdk/sun/management/jmxremote/bootstrap/AbstractFilePermissionTest.java 2026-01-15 15:23:06.000000000 +0000 @@ -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 @@ -35,7 +35,6 @@ import java.nio.file.attribute.PosixFilePermission; import java.util.ArrayList; import java.util.Arrays; -import java.util.Collections; import java.util.HashSet; import java.util.List; import java.util.Set; @@ -47,7 +46,6 @@ * @author Taras Ledkov */ public abstract class AbstractFilePermissionTest { - private final String TEST_CLASS_PATH = System.getProperty("test.class.path"); protected final String TEST_CLASSES = System.getProperty("test.classes"); protected final FileSystem FS = FileSystems.getDefault(); private int MAX_GET_FREE_PORT_TRIES = 10; @@ -169,11 +167,8 @@ final String pp = "-Dcom.sun.management.jmxremote.port=" + jdk.test.lib.Utils.getFreePort(); List command = new ArrayList<>(); - Collections.addAll(command, jdk.test.lib.Utils.getTestJavaOpts()); command.add(mp); command.add(pp); - command.add("-cp"); - command.add(TEST_CLASSES); command.add(className); ProcessBuilder processBuilder = ProcessTools.createTestJavaProcessBuilder(command); diff -Nru openjdk-17-17.0.17+10/test/jdk/sun/management/jmxremote/bootstrap/JMXInterfaceBindingTest.java openjdk-17-17.0.18+8/test/jdk/sun/management/jmxremote/bootstrap/JMXInterfaceBindingTest.java --- openjdk-17-17.0.17+10/test/jdk/sun/management/jmxremote/bootstrap/JMXInterfaceBindingTest.java 2025-10-13 07:48:04.000000000 +0000 +++ openjdk-17-17.0.18+8/test/jdk/sun/management/jmxremote/bootstrap/JMXInterfaceBindingTest.java 2026-01-15 15:23:06.000000000 +0000 @@ -1,5 +1,6 @@ /* * Copyright (c) 2015, Red Hat Inc + * 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 @@ -205,6 +206,7 @@ // This is needed for testing on loopback args.add("-Djava.rmi.server.hostname=" + address); if (useSSL) { + args.add("-Djdk.rmi.ssl.client.enableEndpointIdentification=false"); args.add("-Dcom.sun.management.jmxremote.registry.ssl=true"); args.add("-Djavax.net.ssl.keyStore=" + KEYSTORE_LOC); args.add("-Djavax.net.ssl.trustStore=" + TRUSTSTORE_LOC); diff -Nru openjdk-17-17.0.17+10/test/jdk/sun/management/jmxremote/bootstrap/LocalManagementTest.java openjdk-17-17.0.18+8/test/jdk/sun/management/jmxremote/bootstrap/LocalManagementTest.java --- openjdk-17-17.0.17+10/test/jdk/sun/management/jmxremote/bootstrap/LocalManagementTest.java 2025-10-13 07:48:04.000000000 +0000 +++ openjdk-17-17.0.18+8/test/jdk/sun/management/jmxremote/bootstrap/LocalManagementTest.java 2026-01-15 15:23:06.000000000 +0000 @@ -1,5 +1,5 @@ /* - * Copyright (c) 2013, 2023, 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 @@ -24,12 +24,10 @@ import java.lang.reflect.Method; import java.lang.reflect.Modifier; import java.util.ArrayList; -import java.util.Collections; import java.util.List; import java.util.concurrent.atomic.AtomicReference; import jdk.test.lib.process.ProcessTools; -import jdk.test.lib.Utils; /** * @test @@ -48,7 +46,6 @@ * @run main/othervm/timeout=300 LocalManagementTest */ public class LocalManagementTest { - private static final String TEST_CLASSPATH = System.getProperty("test.class.path"); public static void main(String[] args) throws Exception { int failures = 0; @@ -99,16 +96,13 @@ private static boolean doTest(String testId, String arg) throws Exception { List args = new ArrayList<>(); args.add("-XX:+UsePerfData"); - Collections.addAll(args, Utils.getTestJavaOpts()); - args.add("-cp"); - args.add(TEST_CLASSPATH); if (arg != null) { args.add(arg); } args.add("TestApplication"); ProcessBuilder server = ProcessTools.createTestJavaProcessBuilder( - args.toArray(new String[args.size()]) + args.toArray(new String[0]) ); Process serverPrc = null, clientPrc = null; @@ -134,8 +128,6 @@ System.out.println(" shutdown port : " + port.get()); ProcessBuilder client = ProcessTools.createTestJavaProcessBuilder( - "-cp", - TEST_CLASSPATH, "--add-exports", "jdk.management.agent/jdk.internal.agent=ALL-UNNAMED", "TestManager", String.valueOf(serverPrc.pid()), diff -Nru openjdk-17-17.0.17+10/test/jdk/sun/management/jmxremote/bootstrap/RmiBootstrapTest.java openjdk-17-17.0.18+8/test/jdk/sun/management/jmxremote/bootstrap/RmiBootstrapTest.java --- openjdk-17-17.0.17+10/test/jdk/sun/management/jmxremote/bootstrap/RmiBootstrapTest.java 2025-10-13 07:48:04.000000000 +0000 +++ openjdk-17-17.0.18+8/test/jdk/sun/management/jmxremote/bootstrap/RmiBootstrapTest.java 2026-01-15 15:23:06.000000000 +0000 @@ -1,5 +1,5 @@ /* - * Copyright (c) 2003, 2022, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2003, 2025, Oracle and/or its affiliates. All rights reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * * This code is free software; you can redistribute it and/or modify it @@ -168,6 +168,7 @@ final List credentialFiles = prepareTestFiles(args[0]); Security.setProperty("jdk.tls.disabledAlgorithms", ""); + System.setProperty("jdk.rmi.ssl.client.enableEndpointIdentification", "false"); try { MAX_GET_FREE_PORT_TRIES = Integer.parseInt(System.getProperty("test.getfreeport.max.tries", "10")); diff -Nru openjdk-17-17.0.17+10/test/jdk/sun/management/jmxremote/bootstrap/RmiRegistrySslTest.java openjdk-17-17.0.18+8/test/jdk/sun/management/jmxremote/bootstrap/RmiRegistrySslTest.java --- openjdk-17-17.0.17+10/test/jdk/sun/management/jmxremote/bootstrap/RmiRegistrySslTest.java 2025-10-13 07:48:04.000000000 +0000 +++ openjdk-17-17.0.18+8/test/jdk/sun/management/jmxremote/bootstrap/RmiRegistrySslTest.java 2026-01-15 15:23:06.000000000 +0000 @@ -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 @@ -28,7 +28,6 @@ import java.io.BufferedReader; import java.io.BufferedWriter; import java.io.IOException; -import java.net.BindException; import java.nio.charset.Charset; import java.nio.file.FileSystem; import java.nio.file.FileSystems; @@ -180,12 +179,10 @@ initTestEnvironment(); List command = new ArrayList<>(); - Collections.addAll(command, Utils.getTestJavaOpts()); + command.add("-Djdk.rmi.ssl.client.enableEndpointIdentification=false"); command.add("-Dtest.src=" + TEST_SRC); command.add("-Dtest.rmi.port=" + port); command.addAll(Arrays.asList(args)); - command.add("-cp"); - command.add(TEST_CLASS_PATH); command.add(className); ProcessBuilder processBuilder = ProcessTools.createTestJavaProcessBuilder(command); diff -Nru openjdk-17-17.0.17+10/test/jdk/sun/net/www/protocol/file/FileURLTest.java openjdk-17-17.0.18+8/test/jdk/sun/net/www/protocol/file/FileURLTest.java --- openjdk-17-17.0.17+10/test/jdk/sun/net/www/protocol/file/FileURLTest.java 2025-10-13 07:48:04.000000000 +0000 +++ openjdk-17-17.0.18+8/test/jdk/sun/net/www/protocol/file/FileURLTest.java 2026-01-15 15:23:06.000000000 +0000 @@ -1,5 +1,5 @@ /* - * Copyright (c) 2001, 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 @@ -25,6 +25,7 @@ * @test * @bug 4474391 * @summary url: file:///D|/Projects/tmp/test.html: urlConnection.getInputStream() broken. + * @requires os.family == "windows" */ import java.io.*; import java.net.*; @@ -33,10 +34,7 @@ public static void main(String [] args) { - String name = System.getProperty("os.name"); - if (name.startsWith("Windows")) { String urlStr = "file:///C|/nonexisted.txt"; - try { URL url = new URL(urlStr); URLConnection urlConnection = url.openConnection(); @@ -49,6 +47,5 @@ throw new RuntimeException("Can't handle '|' in place of ':' in file urls"); } } - } } } diff -Nru openjdk-17-17.0.17+10/test/jdk/sun/net/www/protocol/https/HttpsURLConnection/IPIdentities.java openjdk-17-17.0.18+8/test/jdk/sun/net/www/protocol/https/HttpsURLConnection/IPIdentities.java --- openjdk-17-17.0.17+10/test/jdk/sun/net/www/protocol/https/HttpsURLConnection/IPIdentities.java 2025-10-13 07:48:04.000000000 +0000 +++ openjdk-17-17.0.18+8/test/jdk/sun/net/www/protocol/https/HttpsURLConnection/IPIdentities.java 2026-01-15 15:23:06.000000000 +0000 @@ -34,379 +34,41 @@ * @author Xuelei Fan */ -import java.net.*; -import java.util.*; -import java.io.*; -import javax.net.ssl.*; -import java.security.Security; + +import java.io.PrintStream; +import java.net.InetAddress; +import java.net.InetSocketAddress; +import java.net.Proxy; +import java.net.URL; +import java.security.KeyPair; +import java.security.KeyPairGenerator; import java.security.KeyStore; -import java.security.KeyFactory; +import java.security.SecureRandom; +import java.security.Security; +import java.security.cert.X509Certificate; + import java.security.cert.Certificate; -import java.security.cert.CertificateFactory; -import java.security.spec.*; -import java.security.interfaces.*; import java.math.BigInteger; import jdk.test.lib.net.URIBuilder; - -/* - * Certificates and key used in the test. - * - * TLS server certificate: - * server private key: - * -----BEGIN RSA PRIVATE KEY----- - * Proc-Type: 4,ENCRYPTED - * DEK-Info: DES-EDE3-CBC,D9AE407F6D0E389A - * - * WPrA7TFol/cQCcp9oHnXWNpYlvRbbIcQj0m+RKT2Iuzfus+DHt3Zadf8nJpKfX2e - * h2rnhlzCN9M7djRDooZKDOPCsdBn51Au7HlZF3S3Opgo7D8XFM1a8t1Je4ke14oI - * nw6QKYsBblRziPnP2PZ0zvX24nOv7bbY8beynlJHGs00VWSFdoH2DS0aE1p6D+3n - * ptJuJ75dVfZFK4X7162APlNXevX8D6PEQpSiRw1rjjGGcnvQ4HdWk3BxDVDcCNJb - * Y1aGNRxsjTDvPi3R9Qx2M+W03QzEPx4SR3ZHVskeSJHaetM0TM/w/45Paq4GokXP - * ZeTnbEx1xmjkA7h+t4doLL4watx5F6yLsJzu8xB3lt/1EtmkYtLz1t7X4BetPAXz - * zS69X/VwhKfsOI3qXBWuL2oHPyhDmT1gcaUQwEPSV6ogHEEQEDXdiUS8heNK13KF - * TCQYFkETvV2BLxUhV1hypPzRQ6tUpJiAbD5KmoK2lD9slshG2QtvKQq0/bgkDY5J - * LhDHV2dtcZ3kDPkkZXpbcJQvoeH3d09C5sIsuTFo2zgNR6oETHUc5TzP6FY2YYRa - * QcK5HcmtsRRiXFm01ac+aMejJUIujjFt84SiKWT/73vC8AmY4tYcJBLjCg4XIxSH - * fdDFLL1YZENNO5ivlp8mdiHqcawx+36L7DrEZQ8RZt6cqST5t/+XTdM74s6k81GT - * pNsa82P2K2zmIUZ/DL2mKjW1vfRByw1NQFEBkN3vdyZxYfM/JyUzX4hbjXBEkh9Q - * QYrcwLKLjis2QzSvK04B3bvRzRb+4ocWiso8ZPAXAIxZFBWDpTMM2A== - * -----END RSA PRIVATE KEY----- - * - * -----BEGIN RSA PRIVATE KEY----- - * MIICXAIBAAKBgQClrFscN6LdmYktsnm4j9VIpecchBeNaZzGrG358h0fORna03Ie - * buxEzHCk3LoAMPagTz1UemFqzFfQCn+VKBg/mtmU8hvIJIh+/p0PPftXUwizIDPU - * PxdHFNHN6gjYDnVOr77M0uyvqXpJ38LZrLgkQJCmA1Yq0DAFQCxPq9l0iQIDAQAB - * AoGAbqcbg1E1mkR99uOJoNeQYKFOJyGiiXTMnXV1TseC4+PDfQBU7Dax35GcesBi - * CtapIpFKKS5D+ozY6b7ZT8ojxuQ/uHLPAvz0WDR3ds4iRF8tyu71Q1ZHcQsJa17y - * yO7UbkSSKn/Mp9Rb+/dKqftUGNXVFLqgHBOzN2s3We3bbbECQQDYBPKOg3hkaGHo - * OhpHKqtQ6EVkldihG/3i4WejRonelXN+HRh1KrB2HBx0M8D/qAzP1i3rNSlSHer4 - * 59YRTJnHAkEAxFX/sVYSn07BHv9Zhn6XXct/Cj43z/tKNbzlNbcxqQwQerw3IH51 - * 8UH2YOA+GD3lXbKp+MytoFLWv8zg4YT/LwJAfqan75Z1R6lLffRS49bIiq8jwE16 - * rTrUJ+kv8jKxMqc9B3vXkxpsS1M/+4E8bqgAmvpgAb8xcsvHsBd9ErdukQJBAKs2 - * j67W75BrPjBI34pQ1LEfp56IGWXOrq1kF8IbCjxv3+MYRT6Z6UJFkpRymNPNDjsC - * dgUYgITiGJHUGXuw3lMCQHEHqo9ZtXz92yFT+VhsNc29B8m/sqUJdtCcMd/jGpAF - * u6GHufjqIZBpQsk63wbwESAPZZ+kk1O1kS5GIRLX608= - * -----END RSA PRIVATE KEY----- - * - * Private-Key: (1024 bit) - * modulus: - * 00:a5:ac:5b:1c:37:a2:dd:99:89:2d:b2:79:b8:8f: - * d5:48:a5:e7:1c:84:17:8d:69:9c:c6:ac:6d:f9:f2: - * 1d:1f:39:19:da:d3:72:1e:6e:ec:44:cc:70:a4:dc: - * ba:00:30:f6:a0:4f:3d:54:7a:61:6a:cc:57:d0:0a: - * 7f:95:28:18:3f:9a:d9:94:f2:1b:c8:24:88:7e:fe: - * 9d:0f:3d:fb:57:53:08:b3:20:33:d4:3f:17:47:14: - * d1:cd:ea:08:d8:0e:75:4e:af:be:cc:d2:ec:af:a9: - * 7a:49:df:c2:d9:ac:b8:24:40:90:a6:03:56:2a:d0: - * 30:05:40:2c:4f:ab:d9:74:89 - * publicExponent: 65537 (0x10001) - * privateExponent: - * 6e:a7:1b:83:51:35:9a:44:7d:f6:e3:89:a0:d7:90: - * 60:a1:4e:27:21:a2:89:74:cc:9d:75:75:4e:c7:82: - * e3:e3:c3:7d:00:54:ec:36:b1:df:91:9c:7a:c0:62: - * 0a:d6:a9:22:91:4a:29:2e:43:fa:8c:d8:e9:be:d9: - * 4f:ca:23:c6:e4:3f:b8:72:cf:02:fc:f4:58:34:77: - * 76:ce:22:44:5f:2d:ca:ee:f5:43:56:47:71:0b:09: - * 6b:5e:f2:c8:ee:d4:6e:44:92:2a:7f:cc:a7:d4:5b: - * fb:f7:4a:a9:fb:54:18:d5:d5:14:ba:a0:1c:13:b3: - * 37:6b:37:59:ed:db:6d:b1 - * prime1: - * 00:d8:04:f2:8e:83:78:64:68:61:e8:3a:1a:47:2a: - * ab:50:e8:45:64:95:d8:a1:1b:fd:e2:e1:67:a3:46: - * 89:de:95:73:7e:1d:18:75:2a:b0:76:1c:1c:74:33: - * c0:ff:a8:0c:cf:d6:2d:eb:35:29:52:1d:ea:f8:e7: - * d6:11:4c:99:c7 - * prime2: - * 00:c4:55:ff:b1:56:12:9f:4e:c1:1e:ff:59:86:7e: - * 97:5d:cb:7f:0a:3e:37:cf:fb:4a:35:bc:e5:35:b7: - * 31:a9:0c:10:7a:bc:37:20:7e:75:f1:41:f6:60:e0: - * 3e:18:3d:e5:5d:b2:a9:f8:cc:ad:a0:52:d6:bf:cc: - * e0:e1:84:ff:2f - * exponent1: - * 7e:a6:a7:ef:96:75:47:a9:4b:7d:f4:52:e3:d6:c8: - * 8a:af:23:c0:4d:7a:ad:3a:d4:27:e9:2f:f2:32:b1: - * 32:a7:3d:07:7b:d7:93:1a:6c:4b:53:3f:fb:81:3c: - * 6e:a8:00:9a:fa:60:01:bf:31:72:cb:c7:b0:17:7d: - * 12:b7:6e:91 - * exponent2: - * 00:ab:36:8f:ae:d6:ef:90:6b:3e:30:48:df:8a:50: - * d4:b1:1f:a7:9e:88:19:65:ce:ae:ad:64:17:c2:1b: - * 0a:3c:6f:df:e3:18:45:3e:99:e9:42:45:92:94:72: - * 98:d3:cd:0e:3b:02:76:05:18:80:84:e2:18:91:d4: - * 19:7b:b0:de:53 - * coefficient: - * 71:07:aa:8f:59:b5:7c:fd:db:21:53:f9:58:6c:35: - * cd:bd:07:c9:bf:b2:a5:09:76:d0:9c:31:df:e3:1a: - * 90:05:bb:a1:87:b9:f8:ea:21:90:69:42:c9:3a:df: - * 06:f0:11:20:0f:65:9f:a4:93:53:b5:91:2e:46:21: - * 12:d7:eb:4f - * - * - * server certificate: - * Data: - * Version: 3 (0x2) - * Serial Number: 7 (0x7) - * Signature Algorithm: md5WithRSAEncryption - * Issuer: C=US, ST=Some-State, L=Some-City, O=Some-Org - * Validity - * Not Before: Dec 8 03:27:57 2008 GMT - * Not After : Aug 25 03:27:57 2028 GMT - * Subject: C=US, ST=Some-State, L=Some-City, O=Some-Org, OU=SSL-Server, CN=localhost - * Subject Public Key Info: - * Public Key Algorithm: rsaEncryption - * RSA Public Key: (1024 bit) - * Modulus (1024 bit): - * 00:a5:ac:5b:1c:37:a2:dd:99:89:2d:b2:79:b8:8f: - * d5:48:a5:e7:1c:84:17:8d:69:9c:c6:ac:6d:f9:f2: - * 1d:1f:39:19:da:d3:72:1e:6e:ec:44:cc:70:a4:dc: - * ba:00:30:f6:a0:4f:3d:54:7a:61:6a:cc:57:d0:0a: - * 7f:95:28:18:3f:9a:d9:94:f2:1b:c8:24:88:7e:fe: - * 9d:0f:3d:fb:57:53:08:b3:20:33:d4:3f:17:47:14: - * d1:cd:ea:08:d8:0e:75:4e:af:be:cc:d2:ec:af:a9: - * 7a:49:df:c2:d9:ac:b8:24:40:90:a6:03:56:2a:d0: - * 30:05:40:2c:4f:ab:d9:74:89 - * Exponent: 65537 (0x10001) - * X509v3 extensions: - * X509v3 Basic Constraints: - * CA:FALSE - * X509v3 Key Usage: - * Digital Signature, Non Repudiation, Key Encipherment - * X509v3 Subject Key Identifier: - * ED:6E:DB:F4:B5:56:C8:FB:1A:06:61:3F:0F:08:BB:A6:04:D8:16:54 - * X509v3 Authority Key Identifier: - * keyid:FA:B9:51:BF:4C:E7:D9:86:98:33:F9:E7:CB:1E:F1:33:49:F7:A8:14 - * - * X509v3 Subject Alternative Name: critical - * IP Address:127.0.0.1 - * Signature Algorithm: md5WithRSAEncryption - * - * -----BEGIN CERTIFICATE----- - * MIICnzCCAgigAwIBAgIBBzANBgkqhkiG9w0BAQQFADBJMQswCQYDVQQGEwJVUzET - * MBEGA1UECBMKU29tZS1TdGF0ZTESMBAGA1UEBxMJU29tZS1DaXR5MREwDwYDVQQK - * EwhTb21lLU9yZzAeFw0wODEyMDgwMzI3NTdaFw0yODA4MjUwMzI3NTdaMHIxCzAJ - * BgNVBAYTAlVTMRMwEQYDVQQIEwpTb21lLVN0YXRlMRIwEAYDVQQHEwlTb21lLUNp - * dHkxETAPBgNVBAoTCFNvbWUtT3JnMRMwEQYDVQQLEwpTU0wtU2VydmVyMRIwEAYD - * VQQDEwlsb2NhbGhvc3QwgZ8wDQYJKoZIhvcNAQEBBQADgY0AMIGJAoGBAKWsWxw3 - * ot2ZiS2yebiP1Uil5xyEF41pnMasbfnyHR85GdrTch5u7ETMcKTcugAw9qBPPVR6 - * YWrMV9AKf5UoGD+a2ZTyG8gkiH7+nQ89+1dTCLMgM9Q/F0cU0c3qCNgOdU6vvszS - * 7K+peknfwtmsuCRAkKYDVirQMAVALE+r2XSJAgMBAAGjbjBsMAkGA1UdEwQCMAAw - * CwYDVR0PBAQDAgXgMB0GA1UdDgQWBBTtbtv0tVbI+xoGYT8PCLumBNgWVDAfBgNV - * HSMEGDAWgBT6uVG/TOfZhpgz+efLHvEzSfeoFDASBgNVHREBAf8ECDAGhwR/AAAB - * MA0GCSqGSIb3DQEBBAUAA4GBAFJjItCtCBZcjD69wdqfIbKmRFa6eJAjR6LcoDva - * cKC/sDOLelpspiZ66Zb0Xdv5qQ7QrfOXt3K8QqJKRMdZLF9WfUfy0gJDM32ub91h - * pu+TmcGPs+6RdrAQcuvU1ZDV9X8SMj7BtKaim4d5sqFw1npncKiA5xFn8vOYwdun - * nZif - * -----END CERTIFICATE----- - * - * - * TLS client certificate: - * client private key: - * ----BEGIN RSA PRIVATE KEY----- - * Proc-Type: 4,ENCRYPTED - * DEK-Info: DES-EDE3-CBC,FA2A435CD35A9390 - * - * Z+Y2uaETbsUWIyJUyVu1UV2G4rgFYJyACZT6Tp1KjRtxflSh2kXkJ9MpuXMXA0V4 - * Yy3fDzPqCL9NJmQAYRlAx/W/+j4F5EyMWDIx8fUxzONRZyoiwF7jLm+KscAfv6Pf - * q7ItWOdj3z7IYrwlB8YIGd3F2cDKT3S+lYRk7rKb/qT7itbuHnY4Ardh3yl+MZak - * jBp+ELUlRsUqSr1V0LoM+0rCCykarpyfhpxEcqsrl0v9Cyi5uhU50/oKv5zql3SH - * l2ImgDjp3batAs8+Bd4NF2aqi0a7Hy44JUHxRm4caZryU/i/D9N1MbuM6882HLat - * 5N0G+NaIUfywa8mjwq2D5aiit18HqKA6XeRRYeJ5Dvu9DCO4GeFSwcUFIBMI0L46 - * 7s114+oDodg57pMgITi+04vmUxvqlN9aiyd7f5Fgd7PeHGeOdbMz1NaJLJaPI9++ - * NakK8eK9iwT/Gdq0Uap5/CHW7vCT5PO+h3HY0STH0lWStXhdWnFO04zTdywsbSp+ - * DLpHeFT66shfeUlxR0PsCbG9vPRt/QmGLeYQZITppWo/ylSq4j+pRIuXvuWHdBRN - * rTZ8QF4Y7AxQUXVz1j1++s6ZMHTzaK2i9HrhmDs1MbJl+QwWre3Xpv3LvTVz3k5U - * wX8kuY1m3STt71QCaRWENq5sRaMImLxZbxc/ivFl9RAzUqo4NCxLod/QgA4iLqtO - * ztnlpzwlC/F8HbQ1oqYWwnZAPhzU/cULtstl+Yrws2c2atO323LbPXZqbASySgig - * sNpFXQMObdfP6LN23bY+1SvtK7V4NUTNhpdIc6INQAQ= - * -----END RSA PRIVATE KEY----- - * - * -----BEGIN RSA PRIVATE KEY----- - * MIICWwIBAAKBgQC78EA2rCZUTvSjWgAvaSFvuXo6k+yi9uGOx2PYLxIwmS6w8o/4 - * Jy0keCiE9wG/jUR53TvSVfPOPLJbIX3v/TNKsaP/xsibuQ98QTWX+ds6BWAFFa9Z - * F5KjEK0WHOQHU6+odqJWKpLT+SjgeM9eH0irXBnd4WdDunWN9YKsQ5JEGwIDAQAB - * AoGAEbdqNj0wN85hnWyEi/ObJU8UyKTdL9eaF72QGfcF/fLSxfd3vurihIeXOkGW - * tpn4lIxYcVGM9CognhqgJpl11jFTQzn1KqZ+NEJRKkCHA4hDabKJbSC9fXHvRwrf - * BsFpZqgiNxp3HseUTiwnaUVeyPgMt/jAj5nB5Sib+UyUxrECQQDnNQBiF2aifEg6 - * zbJOOC7he5CHAdkFxSxWVFVHL6EfXfqdLVkUohMbgZv+XxyIeU2biOExSg49Kds3 - * FOKgTau1AkEA0Bd1haj6QuCo8I0AXm2WO+MMTZMTvtHD/bGjKNM+fT4I8rKYnQRX - * 1acHdqS9Xx2rNJqZgkMmpESIdPR2fc4yjwJALFeM6EMmqvj8/VIf5UJ/Mz14fXwM - * PEARfckUxd9LnnFutCBTWlKvKXJVEZb6KO5ixPaegc57Jp3Vbh3yTN44lQJADD/1 - * SSMDaIB1MYP7a5Oj7m6VQNPRq8AJe5vDcRnOae0G9dKRrVyeFxO4GsHj6/+BHp2j - * P8nYMn9eURQ7DXjf/QJAAQzMlWnKGSO8pyTDtnQx3hRMoUkOEhmNq4bQhLkYqtnY - * FcqpUQ2qMjW+NiNWk5HnTrMS3L9EdJobMUzaNZLy4w== - * -----END RSA PRIVATE KEY----- - * - * Private-Key: (1024 bit) - * modulus: - * 00:bb:f0:40:36:ac:26:54:4e:f4:a3:5a:00:2f:69: - * 21:6f:b9:7a:3a:93:ec:a2:f6:e1:8e:c7:63:d8:2f: - * 12:30:99:2e:b0:f2:8f:f8:27:2d:24:78:28:84:f7: - * 01:bf:8d:44:79:dd:3b:d2:55:f3:ce:3c:b2:5b:21: - * 7d:ef:fd:33:4a:b1:a3:ff:c6:c8:9b:b9:0f:7c:41: - * 35:97:f9:db:3a:05:60:05:15:af:59:17:92:a3:10: - * ad:16:1c:e4:07:53:af:a8:76:a2:56:2a:92:d3:f9: - * 28:e0:78:cf:5e:1f:48:ab:5c:19:dd:e1:67:43:ba: - * 75:8d:f5:82:ac:43:92:44:1b - * publicExponent: 65537 (0x10001) - * privateExponent: - * 11:b7:6a:36:3d:30:37:ce:61:9d:6c:84:8b:f3:9b: - * 25:4f:14:c8:a4:dd:2f:d7:9a:17:bd:90:19:f7:05: - * fd:f2:d2:c5:f7:77:be:ea:e2:84:87:97:3a:41:96: - * b6:99:f8:94:8c:58:71:51:8c:f4:2a:20:9e:1a:a0: - * 26:99:75:d6:31:53:43:39:f5:2a:a6:7e:34:42:51: - * 2a:40:87:03:88:43:69:b2:89:6d:20:bd:7d:71:ef: - * 47:0a:df:06:c1:69:66:a8:22:37:1a:77:1e:c7:94: - * 4e:2c:27:69:45:5e:c8:f8:0c:b7:f8:c0:8f:99:c1: - * e5:28:9b:f9:4c:94:c6:b1 - * prime1: - * 00:e7:35:00:62:17:66:a2:7c:48:3a:cd:b2:4e:38: - * 2e:e1:7b:90:87:01:d9:05:c5:2c:56:54:55:47:2f: - * a1:1f:5d:fa:9d:2d:59:14:a2:13:1b:81:9b:fe:5f: - * 1c:88:79:4d:9b:88:e1:31:4a:0e:3d:29:db:37:14: - * e2:a0:4d:ab:b5 - * prime2: - * 00:d0:17:75:85:a8:fa:42:e0:a8:f0:8d:00:5e:6d: - * 96:3b:e3:0c:4d:93:13:be:d1:c3:fd:b1:a3:28:d3: - * 3e:7d:3e:08:f2:b2:98:9d:04:57:d5:a7:07:76:a4: - * bd:5f:1d:ab:34:9a:99:82:43:26:a4:44:88:74:f4: - * 76:7d:ce:32:8f - * exponent1: - * 2c:57:8c:e8:43:26:aa:f8:fc:fd:52:1f:e5:42:7f: - * 33:3d:78:7d:7c:0c:3c:40:11:7d:c9:14:c5:df:4b: - * 9e:71:6e:b4:20:53:5a:52:af:29:72:55:11:96:fa: - * 28:ee:62:c4:f6:9e:81:ce:7b:26:9d:d5:6e:1d:f2: - * 4c:de:38:95 - * exponent2: - * 0c:3f:f5:49:23:03:68:80:75:31:83:fb:6b:93:a3: - * ee:6e:95:40:d3:d1:ab:c0:09:7b:9b:c3:71:19:ce: - * 69:ed:06:f5:d2:91:ad:5c:9e:17:13:b8:1a:c1:e3: - * eb:ff:81:1e:9d:a3:3f:c9:d8:32:7f:5e:51:14:3b: - * 0d:78:df:fd - * coefficient: - * 01:0c:cc:95:69:ca:19:23:bc:a7:24:c3:b6:74:31: - * de:14:4c:a1:49:0e:12:19:8d:ab:86:d0:84:b9:18: - * aa:d9:d8:15:ca:a9:51:0d:aa:32:35:be:36:23:56: - * 93:91:e7:4e:b3:12:dc:bf:44:74:9a:1b:31:4c:da: - * 35:92:f2:e3 - * - * client certificate: - * Data: - * Version: 3 (0x2) - * Serial Number: 6 (0x6) - * Signature Algorithm: md5WithRSAEncryption - * Issuer: C=US, ST=Some-State, L=Some-City, O=Some-Org - * Validity - * Not Before: Dec 8 03:27:34 2008 GMT - * Not After : Aug 25 03:27:34 2028 GMT - * Subject: C=US, ST=Some-State, L=Some-City, O=Some-Org, OU=SSL-Client, CN=localhost - * Subject Public Key Info: - * Public Key Algorithm: rsaEncryption - * RSA Public Key: (1024 bit) - * Modulus (1024 bit): - * 00:bb:f0:40:36:ac:26:54:4e:f4:a3:5a:00:2f:69: - * 21:6f:b9:7a:3a:93:ec:a2:f6:e1:8e:c7:63:d8:2f: - * 12:30:99:2e:b0:f2:8f:f8:27:2d:24:78:28:84:f7: - * 01:bf:8d:44:79:dd:3b:d2:55:f3:ce:3c:b2:5b:21: - * 7d:ef:fd:33:4a:b1:a3:ff:c6:c8:9b:b9:0f:7c:41: - * 35:97:f9:db:3a:05:60:05:15:af:59:17:92:a3:10: - * ad:16:1c:e4:07:53:af:a8:76:a2:56:2a:92:d3:f9: - * 28:e0:78:cf:5e:1f:48:ab:5c:19:dd:e1:67:43:ba: - * 75:8d:f5:82:ac:43:92:44:1b - * Exponent: 65537 (0x10001) - * X509v3 extensions: - * X509v3 Basic Constraints: - * CA:FALSE - * X509v3 Key Usage: - * Digital Signature, Non Repudiation, Key Encipherment - * X509v3 Subject Key Identifier: - * CD:BB:C8:85:AA:91:BD:FD:1D:BE:CD:67:7C:FF:B3:E9:4C:A8:22:E6 - * X509v3 Authority Key Identifier: - * keyid:FA:B9:51:BF:4C:E7:D9:86:98:33:F9:E7:CB:1E:F1:33:49:F7:A8:14 - * - * X509v3 Subject Alternative Name: critical - * IP Address:127.0.0.1 - * Signature Algorithm: md5WithRSAEncryption - * - * -----BEGIN CERTIFICATE----- - * MIICnzCCAgigAwIBAgIBBjANBgkqhkiG9w0BAQQFADBJMQswCQYDVQQGEwJVUzET - * MBEGA1UECBMKU29tZS1TdGF0ZTESMBAGA1UEBxMJU29tZS1DaXR5MREwDwYDVQQK - * EwhTb21lLU9yZzAeFw0wODEyMDgwMzI3MzRaFw0yODA4MjUwMzI3MzRaMHIxCzAJ - * BgNVBAYTAlVTMRMwEQYDVQQIEwpTb21lLVN0YXRlMRIwEAYDVQQHEwlTb21lLUNp - * dHkxETAPBgNVBAoTCFNvbWUtT3JnMRMwEQYDVQQLEwpTU0wtQ2xpZW50MRIwEAYD - * VQQDEwlsb2NhbGhvc3QwgZ8wDQYJKoZIhvcNAQEBBQADgY0AMIGJAoGBALvwQDas - * JlRO9KNaAC9pIW+5ejqT7KL24Y7HY9gvEjCZLrDyj/gnLSR4KIT3Ab+NRHndO9JV - * 8848slshfe/9M0qxo//GyJu5D3xBNZf52zoFYAUVr1kXkqMQrRYc5AdTr6h2olYq - * ktP5KOB4z14fSKtcGd3hZ0O6dY31gqxDkkQbAgMBAAGjbjBsMAkGA1UdEwQCMAAw - * CwYDVR0PBAQDAgXgMB0GA1UdDgQWBBTNu8iFqpG9/R2+zWd8/7PpTKgi5jAfBgNV - * HSMEGDAWgBT6uVG/TOfZhpgz+efLHvEzSfeoFDASBgNVHREBAf8ECDAGhwR/AAAB - * MA0GCSqGSIb3DQEBBAUAA4GBACjj9PS+W6XOF7toFMwMOv/AemZeBOpcEF1Ei1Hx - * HjvB6EOHkMY8tFm5OPzkiWiK3+s3awpSW0jWdzMYwrQJ3/klMsPDpI7PEuirqwHP - * i5Wyl/vk7jmfWVcBO9MVhPUo4BYl4vS9aj6JA5QbkbkB95LOgT/BowY0WmHeVsXC - * I9aw - * -----END CERTIFICATE----- - * - * - * - * Trusted CA certificate: - * Certificate: - * Data: - * Version: 3 (0x2) - * Serial Number: 0 (0x0) - * Signature Algorithm: md5WithRSAEncryption - * Issuer: C=US, ST=Some-State, L=Some-City, O=Some-Org - * Validity - * Not Before: Dec 8 02:43:36 2008 GMT - * Not After : Aug 25 02:43:36 2028 GMT - * Subject: C=US, ST=Some-State, L=Some-City, O=Some-Org - * Subject Public Key Info: - * Public Key Algorithm: rsaEncryption - * RSA Public Key: (1024 bit) - * Modulus (1024 bit): - * 00:cb:c4:38:20:07:be:88:a7:93:b0:a1:43:51:2d: - * d7:8e:85:af:54:dd:ad:a2:7b:23:5b:cf:99:13:53: - * 99:45:7d:ee:6d:ba:2d:bf:e3:ad:6e:3d:9f:1a:f9: - * 03:97:e0:17:55:ae:11:26:57:de:01:29:8e:05:3f: - * 21:f7:e7:36:e8:2e:37:d7:48:ac:53:d6:60:0e:c7: - * 50:6d:f6:c5:85:f7:8b:a6:c5:91:35:72:3c:94:ee: - * f1:17:f0:71:e3:ec:1b:ce:ca:4e:40:42:b0:6d:ee: - * 6a:0e:d6:e5:ad:3c:0f:c9:ba:82:4f:78:f8:89:97: - * 89:2a:95:12:4c:d8:09:2a:e9 - * Exponent: 65537 (0x10001) - * X509v3 extensions: - * X509v3 Subject Key Identifier: - * FA:B9:51:BF:4C:E7:D9:86:98:33:F9:E7:CB:1E:F1:33:49:F7:A8:14 - * X509v3 Authority Key Identifier: - * keyid:FA:B9:51:BF:4C:E7:D9:86:98:33:F9:E7:CB:1E:F1:33:49:F7:A8:14 - * DirName:/C=US/ST=Some-State/L=Some-City/O=Some-Org - * serial:00 - * - * X509v3 Basic Constraints: - * CA:TRUE - * Signature Algorithm: md5WithRSAEncryption - * - * -----BEGIN CERTIFICATE----- - * MIICrDCCAhWgAwIBAgIBADANBgkqhkiG9w0BAQQFADBJMQswCQYDVQQGEwJVUzET - * MBEGA1UECBMKU29tZS1TdGF0ZTESMBAGA1UEBxMJU29tZS1DaXR5MREwDwYDVQQK - * EwhTb21lLU9yZzAeFw0wODEyMDgwMjQzMzZaFw0yODA4MjUwMjQzMzZaMEkxCzAJ - * BgNVBAYTAlVTMRMwEQYDVQQIEwpTb21lLVN0YXRlMRIwEAYDVQQHEwlTb21lLUNp - * dHkxETAPBgNVBAoTCFNvbWUtT3JnMIGfMA0GCSqGSIb3DQEBAQUAA4GNADCBiQKB - * gQDLxDggB76Ip5OwoUNRLdeOha9U3a2ieyNbz5kTU5lFfe5tui2/461uPZ8a+QOX - * 4BdVrhEmV94BKY4FPyH35zboLjfXSKxT1mAOx1Bt9sWF94umxZE1cjyU7vEX8HHj - * 7BvOyk5AQrBt7moO1uWtPA/JuoJPePiJl4kqlRJM2Akq6QIDAQABo4GjMIGgMB0G - * A1UdDgQWBBT6uVG/TOfZhpgz+efLHvEzSfeoFDBxBgNVHSMEajBogBT6uVG/TOfZ - * hpgz+efLHvEzSfeoFKFNpEswSTELMAkGA1UEBhMCVVMxEzARBgNVBAgTClNvbWUt - * U3RhdGUxEjAQBgNVBAcTCVNvbWUtQ2l0eTERMA8GA1UEChMIU29tZS1PcmeCAQAw - * DAYDVR0TBAUwAwEB/zANBgkqhkiG9w0BAQQFAAOBgQBcIm534U123Hz+rtyYO5uA - * ofd81G6FnTfEAV8Kw9fGyyEbQZclBv34A9JsFKeMvU4OFIaixD7nLZ/NZ+IWbhmZ - * LovmJXyCkOufea73pNiZ+f/4/ScZaIlM/PRycQSqbFNd4j9Wott+08qxHPLpsf3P - * 6Mvf0r1PNTY2hwTJLJmKtg== - * -----END CERTIFICATE--- - */ +import jdk.test.lib.security.CertificateBuilder; +import jdk.test.lib.security.CertificateBuilder.KeyUsage; +import sun.security.x509.AuthorityKeyIdentifierExtension; +import sun.security.x509.GeneralName; +import sun.security.x509.GeneralNames; +import sun.security.x509.KeyIdentifier; +import sun.security.x509.SerialNumber; +import sun.security.x509.X500Name; + +import javax.net.ssl.HttpsURLConnection; +import javax.net.ssl.KeyManagerFactory; +import javax.net.ssl.SSLContext; +import javax.net.ssl.SSLServerSocket; +import javax.net.ssl.SSLServerSocketFactory; +import javax.net.ssl.SSLSocket; +import javax.net.ssl.TrustManagerFactory; public class IPIdentities { - static Map cookies; - ServerSocket ss; /* * ============================================================= @@ -421,208 +83,14 @@ */ static boolean separateServerThread = true; - /* - * Where do we find the keystores? - */ - static String trusedCertStr = - "-----BEGIN CERTIFICATE-----\n" + - "MIICrDCCAhWgAwIBAgIBADANBgkqhkiG9w0BAQQFADBJMQswCQYDVQQGEwJVUzET\n" + - "MBEGA1UECBMKU29tZS1TdGF0ZTESMBAGA1UEBxMJU29tZS1DaXR5MREwDwYDVQQK\n" + - "EwhTb21lLU9yZzAeFw0wODEyMDgwMjQzMzZaFw0yODA4MjUwMjQzMzZaMEkxCzAJ\n" + - "BgNVBAYTAlVTMRMwEQYDVQQIEwpTb21lLVN0YXRlMRIwEAYDVQQHEwlTb21lLUNp\n" + - "dHkxETAPBgNVBAoTCFNvbWUtT3JnMIGfMA0GCSqGSIb3DQEBAQUAA4GNADCBiQKB\n" + - "gQDLxDggB76Ip5OwoUNRLdeOha9U3a2ieyNbz5kTU5lFfe5tui2/461uPZ8a+QOX\n" + - "4BdVrhEmV94BKY4FPyH35zboLjfXSKxT1mAOx1Bt9sWF94umxZE1cjyU7vEX8HHj\n" + - "7BvOyk5AQrBt7moO1uWtPA/JuoJPePiJl4kqlRJM2Akq6QIDAQABo4GjMIGgMB0G\n" + - "A1UdDgQWBBT6uVG/TOfZhpgz+efLHvEzSfeoFDBxBgNVHSMEajBogBT6uVG/TOfZ\n" + - "hpgz+efLHvEzSfeoFKFNpEswSTELMAkGA1UEBhMCVVMxEzARBgNVBAgTClNvbWUt\n" + - "U3RhdGUxEjAQBgNVBAcTCVNvbWUtQ2l0eTERMA8GA1UEChMIU29tZS1PcmeCAQAw\n" + - "DAYDVR0TBAUwAwEB/zANBgkqhkiG9w0BAQQFAAOBgQBcIm534U123Hz+rtyYO5uA\n" + - "ofd81G6FnTfEAV8Kw9fGyyEbQZclBv34A9JsFKeMvU4OFIaixD7nLZ/NZ+IWbhmZ\n" + - "LovmJXyCkOufea73pNiZ+f/4/ScZaIlM/PRycQSqbFNd4j9Wott+08qxHPLpsf3P\n" + - "6Mvf0r1PNTY2hwTJLJmKtg==\n" + - "-----END CERTIFICATE-----"; - - static String serverCertStr = - "-----BEGIN CERTIFICATE-----\n" + - "MIICnzCCAgigAwIBAgIBBzANBgkqhkiG9w0BAQQFADBJMQswCQYDVQQGEwJVUzET\n" + - "MBEGA1UECBMKU29tZS1TdGF0ZTESMBAGA1UEBxMJU29tZS1DaXR5MREwDwYDVQQK\n" + - "EwhTb21lLU9yZzAeFw0wODEyMDgwMzI3NTdaFw0yODA4MjUwMzI3NTdaMHIxCzAJ\n" + - "BgNVBAYTAlVTMRMwEQYDVQQIEwpTb21lLVN0YXRlMRIwEAYDVQQHEwlTb21lLUNp\n" + - "dHkxETAPBgNVBAoTCFNvbWUtT3JnMRMwEQYDVQQLEwpTU0wtU2VydmVyMRIwEAYD\n" + - "VQQDEwlsb2NhbGhvc3QwgZ8wDQYJKoZIhvcNAQEBBQADgY0AMIGJAoGBAKWsWxw3\n" + - "ot2ZiS2yebiP1Uil5xyEF41pnMasbfnyHR85GdrTch5u7ETMcKTcugAw9qBPPVR6\n" + - "YWrMV9AKf5UoGD+a2ZTyG8gkiH7+nQ89+1dTCLMgM9Q/F0cU0c3qCNgOdU6vvszS\n" + - "7K+peknfwtmsuCRAkKYDVirQMAVALE+r2XSJAgMBAAGjbjBsMAkGA1UdEwQCMAAw\n" + - "CwYDVR0PBAQDAgXgMB0GA1UdDgQWBBTtbtv0tVbI+xoGYT8PCLumBNgWVDAfBgNV\n" + - "HSMEGDAWgBT6uVG/TOfZhpgz+efLHvEzSfeoFDASBgNVHREBAf8ECDAGhwR/AAAB\n" + - "MA0GCSqGSIb3DQEBBAUAA4GBAFJjItCtCBZcjD69wdqfIbKmRFa6eJAjR6LcoDva\n" + - "cKC/sDOLelpspiZ66Zb0Xdv5qQ7QrfOXt3K8QqJKRMdZLF9WfUfy0gJDM32ub91h\n" + - "pu+TmcGPs+6RdrAQcuvU1ZDV9X8SMj7BtKaim4d5sqFw1npncKiA5xFn8vOYwdun\n" + - "nZif\n" + - "-----END CERTIFICATE-----"; - - static String clientCertStr = - "-----BEGIN CERTIFICATE-----\n" + - "MIICnzCCAgigAwIBAgIBBjANBgkqhkiG9w0BAQQFADBJMQswCQYDVQQGEwJVUzET\n" + - "MBEGA1UECBMKU29tZS1TdGF0ZTESMBAGA1UEBxMJU29tZS1DaXR5MREwDwYDVQQK\n" + - "EwhTb21lLU9yZzAeFw0wODEyMDgwMzI3MzRaFw0yODA4MjUwMzI3MzRaMHIxCzAJ\n" + - "BgNVBAYTAlVTMRMwEQYDVQQIEwpTb21lLVN0YXRlMRIwEAYDVQQHEwlTb21lLUNp\n" + - "dHkxETAPBgNVBAoTCFNvbWUtT3JnMRMwEQYDVQQLEwpTU0wtQ2xpZW50MRIwEAYD\n" + - "VQQDEwlsb2NhbGhvc3QwgZ8wDQYJKoZIhvcNAQEBBQADgY0AMIGJAoGBALvwQDas\n" + - "JlRO9KNaAC9pIW+5ejqT7KL24Y7HY9gvEjCZLrDyj/gnLSR4KIT3Ab+NRHndO9JV\n" + - "8848slshfe/9M0qxo//GyJu5D3xBNZf52zoFYAUVr1kXkqMQrRYc5AdTr6h2olYq\n" + - "ktP5KOB4z14fSKtcGd3hZ0O6dY31gqxDkkQbAgMBAAGjbjBsMAkGA1UdEwQCMAAw\n" + - "CwYDVR0PBAQDAgXgMB0GA1UdDgQWBBTNu8iFqpG9/R2+zWd8/7PpTKgi5jAfBgNV\n" + - "HSMEGDAWgBT6uVG/TOfZhpgz+efLHvEzSfeoFDASBgNVHREBAf8ECDAGhwR/AAAB\n" + - "MA0GCSqGSIb3DQEBBAUAA4GBACjj9PS+W6XOF7toFMwMOv/AemZeBOpcEF1Ei1Hx\n" + - "HjvB6EOHkMY8tFm5OPzkiWiK3+s3awpSW0jWdzMYwrQJ3/klMsPDpI7PEuirqwHP\n" + - "i5Wyl/vk7jmfWVcBO9MVhPUo4BYl4vS9aj6JA5QbkbkB95LOgT/BowY0WmHeVsXC\n" + - "I9aw\n" + - "-----END CERTIFICATE-----"; - - - static byte serverPrivateExponent[] = { - (byte)0x6e, (byte)0xa7, (byte)0x1b, (byte)0x83, - (byte)0x51, (byte)0x35, (byte)0x9a, (byte)0x44, - (byte)0x7d, (byte)0xf6, (byte)0xe3, (byte)0x89, - (byte)0xa0, (byte)0xd7, (byte)0x90, (byte)0x60, - (byte)0xa1, (byte)0x4e, (byte)0x27, (byte)0x21, - (byte)0xa2, (byte)0x89, (byte)0x74, (byte)0xcc, - (byte)0x9d, (byte)0x75, (byte)0x75, (byte)0x4e, - (byte)0xc7, (byte)0x82, (byte)0xe3, (byte)0xe3, - (byte)0xc3, (byte)0x7d, (byte)0x00, (byte)0x54, - (byte)0xec, (byte)0x36, (byte)0xb1, (byte)0xdf, - (byte)0x91, (byte)0x9c, (byte)0x7a, (byte)0xc0, - (byte)0x62, (byte)0x0a, (byte)0xd6, (byte)0xa9, - (byte)0x22, (byte)0x91, (byte)0x4a, (byte)0x29, - (byte)0x2e, (byte)0x43, (byte)0xfa, (byte)0x8c, - (byte)0xd8, (byte)0xe9, (byte)0xbe, (byte)0xd9, - (byte)0x4f, (byte)0xca, (byte)0x23, (byte)0xc6, - (byte)0xe4, (byte)0x3f, (byte)0xb8, (byte)0x72, - (byte)0xcf, (byte)0x02, (byte)0xfc, (byte)0xf4, - (byte)0x58, (byte)0x34, (byte)0x77, (byte)0x76, - (byte)0xce, (byte)0x22, (byte)0x44, (byte)0x5f, - (byte)0x2d, (byte)0xca, (byte)0xee, (byte)0xf5, - (byte)0x43, (byte)0x56, (byte)0x47, (byte)0x71, - (byte)0x0b, (byte)0x09, (byte)0x6b, (byte)0x5e, - (byte)0xf2, (byte)0xc8, (byte)0xee, (byte)0xd4, - (byte)0x6e, (byte)0x44, (byte)0x92, (byte)0x2a, - (byte)0x7f, (byte)0xcc, (byte)0xa7, (byte)0xd4, - (byte)0x5b, (byte)0xfb, (byte)0xf7, (byte)0x4a, - (byte)0xa9, (byte)0xfb, (byte)0x54, (byte)0x18, - (byte)0xd5, (byte)0xd5, (byte)0x14, (byte)0xba, - (byte)0xa0, (byte)0x1c, (byte)0x13, (byte)0xb3, - (byte)0x37, (byte)0x6b, (byte)0x37, (byte)0x59, - (byte)0xed, (byte)0xdb, (byte)0x6d, (byte)0xb1 - }; - - static byte serverModulus[] = { - (byte)0x00, - (byte)0xa5, (byte)0xac, (byte)0x5b, (byte)0x1c, - (byte)0x37, (byte)0xa2, (byte)0xdd, (byte)0x99, - (byte)0x89, (byte)0x2d, (byte)0xb2, (byte)0x79, - (byte)0xb8, (byte)0x8f, (byte)0xd5, (byte)0x48, - (byte)0xa5, (byte)0xe7, (byte)0x1c, (byte)0x84, - (byte)0x17, (byte)0x8d, (byte)0x69, (byte)0x9c, - (byte)0xc6, (byte)0xac, (byte)0x6d, (byte)0xf9, - (byte)0xf2, (byte)0x1d, (byte)0x1f, (byte)0x39, - (byte)0x19, (byte)0xda, (byte)0xd3, (byte)0x72, - (byte)0x1e, (byte)0x6e, (byte)0xec, (byte)0x44, - (byte)0xcc, (byte)0x70, (byte)0xa4, (byte)0xdc, - (byte)0xba, (byte)0x00, (byte)0x30, (byte)0xf6, - (byte)0xa0, (byte)0x4f, (byte)0x3d, (byte)0x54, - (byte)0x7a, (byte)0x61, (byte)0x6a, (byte)0xcc, - (byte)0x57, (byte)0xd0, (byte)0x0a, (byte)0x7f, - (byte)0x95, (byte)0x28, (byte)0x18, (byte)0x3f, - (byte)0x9a, (byte)0xd9, (byte)0x94, (byte)0xf2, - (byte)0x1b, (byte)0xc8, (byte)0x24, (byte)0x88, - (byte)0x7e, (byte)0xfe, (byte)0x9d, (byte)0x0f, - (byte)0x3d, (byte)0xfb, (byte)0x57, (byte)0x53, - (byte)0x08, (byte)0xb3, (byte)0x20, (byte)0x33, - (byte)0xd4, (byte)0x3f, (byte)0x17, (byte)0x47, - (byte)0x14, (byte)0xd1, (byte)0xcd, (byte)0xea, - (byte)0x08, (byte)0xd8, (byte)0x0e, (byte)0x75, - (byte)0x4e, (byte)0xaf, (byte)0xbe, (byte)0xcc, - (byte)0xd2, (byte)0xec, (byte)0xaf, (byte)0xa9, - (byte)0x7a, (byte)0x49, (byte)0xdf, (byte)0xc2, - (byte)0xd9, (byte)0xac, (byte)0xb8, (byte)0x24, - (byte)0x40, (byte)0x90, (byte)0xa6, (byte)0x03, - (byte)0x56, (byte)0x2a, (byte)0xd0, (byte)0x30, - (byte)0x05, (byte)0x40, (byte)0x2c, (byte)0x4f, - (byte)0xab, (byte)0xd9, (byte)0x74, (byte)0x89 - }; - - static byte clientPrivateExponent[] = { - (byte)0x11, (byte)0xb7, (byte)0x6a, (byte)0x36, - (byte)0x3d, (byte)0x30, (byte)0x37, (byte)0xce, - (byte)0x61, (byte)0x9d, (byte)0x6c, (byte)0x84, - (byte)0x8b, (byte)0xf3, (byte)0x9b, (byte)0x25, - (byte)0x4f, (byte)0x14, (byte)0xc8, (byte)0xa4, - (byte)0xdd, (byte)0x2f, (byte)0xd7, (byte)0x9a, - (byte)0x17, (byte)0xbd, (byte)0x90, (byte)0x19, - (byte)0xf7, (byte)0x05, (byte)0xfd, (byte)0xf2, - (byte)0xd2, (byte)0xc5, (byte)0xf7, (byte)0x77, - (byte)0xbe, (byte)0xea, (byte)0xe2, (byte)0x84, - (byte)0x87, (byte)0x97, (byte)0x3a, (byte)0x41, - (byte)0x96, (byte)0xb6, (byte)0x99, (byte)0xf8, - (byte)0x94, (byte)0x8c, (byte)0x58, (byte)0x71, - (byte)0x51, (byte)0x8c, (byte)0xf4, (byte)0x2a, - (byte)0x20, (byte)0x9e, (byte)0x1a, (byte)0xa0, - (byte)0x26, (byte)0x99, (byte)0x75, (byte)0xd6, - (byte)0x31, (byte)0x53, (byte)0x43, (byte)0x39, - (byte)0xf5, (byte)0x2a, (byte)0xa6, (byte)0x7e, - (byte)0x34, (byte)0x42, (byte)0x51, (byte)0x2a, - (byte)0x40, (byte)0x87, (byte)0x03, (byte)0x88, - (byte)0x43, (byte)0x69, (byte)0xb2, (byte)0x89, - (byte)0x6d, (byte)0x20, (byte)0xbd, (byte)0x7d, - (byte)0x71, (byte)0xef, (byte)0x47, (byte)0x0a, - (byte)0xdf, (byte)0x06, (byte)0xc1, (byte)0x69, - (byte)0x66, (byte)0xa8, (byte)0x22, (byte)0x37, - (byte)0x1a, (byte)0x77, (byte)0x1e, (byte)0xc7, - (byte)0x94, (byte)0x4e, (byte)0x2c, (byte)0x27, - (byte)0x69, (byte)0x45, (byte)0x5e, (byte)0xc8, - (byte)0xf8, (byte)0x0c, (byte)0xb7, (byte)0xf8, - (byte)0xc0, (byte)0x8f, (byte)0x99, (byte)0xc1, - (byte)0xe5, (byte)0x28, (byte)0x9b, (byte)0xf9, - (byte)0x4c, (byte)0x94, (byte)0xc6, (byte)0xb1 - }; - - static byte clientModulus[] = { - (byte)0x00, - (byte)0xbb, (byte)0xf0, (byte)0x40, (byte)0x36, - (byte)0xac, (byte)0x26, (byte)0x54, (byte)0x4e, - (byte)0xf4, (byte)0xa3, (byte)0x5a, (byte)0x00, - (byte)0x2f, (byte)0x69, (byte)0x21, (byte)0x6f, - (byte)0xb9, (byte)0x7a, (byte)0x3a, (byte)0x93, - (byte)0xec, (byte)0xa2, (byte)0xf6, (byte)0xe1, - (byte)0x8e, (byte)0xc7, (byte)0x63, (byte)0xd8, - (byte)0x2f, (byte)0x12, (byte)0x30, (byte)0x99, - (byte)0x2e, (byte)0xb0, (byte)0xf2, (byte)0x8f, - (byte)0xf8, (byte)0x27, (byte)0x2d, (byte)0x24, - (byte)0x78, (byte)0x28, (byte)0x84, (byte)0xf7, - (byte)0x01, (byte)0xbf, (byte)0x8d, (byte)0x44, - (byte)0x79, (byte)0xdd, (byte)0x3b, (byte)0xd2, - (byte)0x55, (byte)0xf3, (byte)0xce, (byte)0x3c, - (byte)0xb2, (byte)0x5b, (byte)0x21, (byte)0x7d, - (byte)0xef, (byte)0xfd, (byte)0x33, (byte)0x4a, - (byte)0xb1, (byte)0xa3, (byte)0xff, (byte)0xc6, - (byte)0xc8, (byte)0x9b, (byte)0xb9, (byte)0x0f, - (byte)0x7c, (byte)0x41, (byte)0x35, (byte)0x97, - (byte)0xf9, (byte)0xdb, (byte)0x3a, (byte)0x05, - (byte)0x60, (byte)0x05, (byte)0x15, (byte)0xaf, - (byte)0x59, (byte)0x17, (byte)0x92, (byte)0xa3, - (byte)0x10, (byte)0xad, (byte)0x16, (byte)0x1c, - (byte)0xe4, (byte)0x07, (byte)0x53, (byte)0xaf, - (byte)0xa8, (byte)0x76, (byte)0xa2, (byte)0x56, - (byte)0x2a, (byte)0x92, (byte)0xd3, (byte)0xf9, - (byte)0x28, (byte)0xe0, (byte)0x78, (byte)0xcf, - (byte)0x5e, (byte)0x1f, (byte)0x48, (byte)0xab, - (byte)0x5c, (byte)0x19, (byte)0xdd, (byte)0xe1, - (byte)0x67, (byte)0x43, (byte)0xba, (byte)0x75, - (byte)0x8d, (byte)0xf5, (byte)0x82, (byte)0xac, - (byte)0x43, (byte)0x92, (byte)0x44, (byte)0x1b - }; + static X509Certificate trustedCert; + + static X509Certificate serverCert; + + static X509Certificate clientCert; + + static KeyPair serverKeys; + static KeyPair clientKeys; static char passphrase[] = "passphrase".toCharArray(); @@ -639,7 +107,7 @@ /* * Turn on SSL debugging? */ - static boolean debug = false; + static boolean debug = Boolean.getBoolean("test.debug"); private SSLServerSocket sslServerSocket = null; @@ -650,8 +118,8 @@ * to avoid infinite hangs. */ void doServerSide() throws Exception { - SSLContext context = getSSLContext(trusedCertStr, serverCertStr, - serverModulus, serverPrivateExponent, passphrase); + SSLContext context = getSSLContext(trustedCert, serverCert, + serverKeys, passphrase); SSLServerSocketFactory sslssf = context.getServerSocketFactory(); // doClientSide() connects to the loopback address @@ -706,8 +174,8 @@ void doClientSide() throws Exception { SSLContext reservedSSLContext = SSLContext.getDefault(); try { - SSLContext context = getSSLContext(trusedCertStr, clientCertStr, - clientModulus, clientPrivateExponent, passphrase); + SSLContext context = getSSLContext(trustedCert, clientCert, + clientKeys, passphrase); SSLContext.setDefault(context); /* @@ -755,6 +223,65 @@ volatile Exception serverException = null; volatile Exception clientException = null; + private static X509Certificate createTrustedCert(KeyPair caKeys) throws Exception { + SecureRandom random = new SecureRandom(); + + KeyIdentifier kid = new KeyIdentifier(caKeys.getPublic()); + GeneralNames gns = new GeneralNames(); + GeneralName name = new GeneralName(new X500Name( + "O=Some-Org, L=Some-City, ST=Some-State, C=US")); + gns.add(name); + BigInteger serialNumber = BigInteger.valueOf(random.nextLong(1000000)+1); + return CertificateBuilder.newCertificateBuilder( + "O=Some-Org, L=Some-City, ST=Some-State, C=US", + caKeys.getPublic(), caKeys.getPublic()) + .setSerialNumber(serialNumber) + .addExtension(new AuthorityKeyIdentifierExtension(kid, gns, + new SerialNumber(serialNumber))) + .addBasicConstraintsExt(true, true, -1) + .setOneHourValidity() + .build(null, caKeys.getPrivate(), "MD5WithRSA"); + } + + private static void setupCertificates() throws Exception { + KeyPairGenerator kpg = KeyPairGenerator.getInstance("RSA"); + KeyPair caKeys = kpg.generateKeyPair(); + serverKeys = kpg.generateKeyPair(); + clientKeys = kpg.generateKeyPair(); + + trustedCert = createTrustedCert(caKeys); + if (debug) { + System.out.println("----------- Trusted Cert -----------"); + CertificateBuilder.printCertificate(trustedCert, System.out); + } + + serverCert = CertificateBuilder.newCertificateBuilder( + "O=Some-Org, L=Some-City, ST=Some-State, C=US", + serverKeys.getPublic(), caKeys.getPublic(), + KeyUsage.DIGITAL_SIGNATURE, KeyUsage.NONREPUDIATION, KeyUsage.KEY_ENCIPHERMENT) + .addBasicConstraintsExt(false, false, -1) + .addExtension(CertificateBuilder.createIPSubjectAltNameExt(true, "127.0.0.1")) + .setOneHourValidity() + .build(trustedCert, caKeys.getPrivate(), "MD5WithRSA"); + if (debug) { + System.out.println("----------- Server Cert -----------"); + CertificateBuilder.printCertificate(serverCert, System.out); + } + + clientCert = CertificateBuilder.newCertificateBuilder( + "CN=localhost, OU=SSL-Client, O=Some-Org, L=Some-City, ST=Some-State, C=US", + clientKeys.getPublic(), caKeys.getPublic(), + KeyUsage.DIGITAL_SIGNATURE, KeyUsage.NONREPUDIATION, KeyUsage.KEY_ENCIPHERMENT) + .addExtension(CertificateBuilder.createIPSubjectAltNameExt(true, "127.0.0.1")) + .addBasicConstraintsExt(false, false, -1) + .setOneHourValidity() + .build(trustedCert, caKeys.getPrivate(), "MD5WithRSA"); + if (debug) { + System.out.println("----------- Client Cert -----------"); + CertificateBuilder.printCertificate(clientCert, System.out); + } + } + public static void main(String args[]) throws Exception { // MD5 is used in this test case, don't disable MD5 algorithm. Security.setProperty("jdk.certpath.disabledAlgorithms", @@ -762,8 +289,11 @@ Security.setProperty("jdk.tls.disabledAlgorithms", "SSLv3, RC4, DH keySize < 768"); - if (debug) + if (debug) { System.setProperty("javax.net.debug", "all"); + } + + setupCertificates(); /* * Start the tests. @@ -855,45 +385,23 @@ } // get the ssl context - private static SSLContext getSSLContext(String trusedCertStr, - String keyCertStr, byte[] modulus, - byte[] privateExponent, char[] passphrase) throws Exception { - - // generate certificate from cert string - CertificateFactory cf = CertificateFactory.getInstance("X.509"); - - ByteArrayInputStream is = - new ByteArrayInputStream(trusedCertStr.getBytes()); - Certificate trusedCert = cf.generateCertificate(is); - is.close(); + private static SSLContext getSSLContext(X509Certificate trustedCert, + X509Certificate keyCert, KeyPair key, char[] passphrase) throws Exception { // create a key store - KeyStore ks = KeyStore.getInstance("JKS"); + KeyStore ks = KeyStore.getInstance("PKCS12"); ks.load(null, null); // import the trused cert - ks.setCertificateEntry("RSA Export Signer", trusedCert); - - if (keyCertStr != null) { - // generate the private key. - RSAPrivateKeySpec priKeySpec = new RSAPrivateKeySpec( - new BigInteger(modulus), - new BigInteger(privateExponent)); - KeyFactory kf = KeyFactory.getInstance("RSA"); - RSAPrivateKey priKey = - (RSAPrivateKey)kf.generatePrivate(priKeySpec); - - // generate certificate chain - is = new ByteArrayInputStream(keyCertStr.getBytes()); - Certificate keyCert = cf.generateCertificate(is); - is.close(); + ks.setCertificateEntry("RSA Export Signer", trustedCert); + if (keyCert != null) { Certificate[] chain = new Certificate[2]; chain[0] = keyCert; - chain[1] = trusedCert; + chain[1] = trustedCert; // import the key entry. - ks.setKeyEntry("Whatever", priKey, passphrase, chain); + ks.setKeyEntry("Whatever", key.getPrivate(), passphrase, chain); } // create SSL context @@ -902,7 +410,7 @@ SSLContext ctx = SSLContext.getInstance("TLSv1.2"); - if (keyCertStr != null) { + if (keyCert != null) { KeyManagerFactory kmf = KeyManagerFactory.getInstance("SunX509"); kmf.init(ks, passphrase); diff -Nru openjdk-17-17.0.17+10/test/jdk/sun/net/www/protocol/https/HttpsURLConnection/TEST.properties openjdk-17-17.0.18+8/test/jdk/sun/net/www/protocol/https/HttpsURLConnection/TEST.properties --- openjdk-17-17.0.17+10/test/jdk/sun/net/www/protocol/https/HttpsURLConnection/TEST.properties 1970-01-01 00:00:00.000000000 +0000 +++ openjdk-17-17.0.18+8/test/jdk/sun/net/www/protocol/https/HttpsURLConnection/TEST.properties 2026-01-15 15:23:06.000000000 +0000 @@ -0,0 +1,3 @@ +modules = \ + java.base/sun.security.util \ + java.base/sun.security.x509 diff -Nru openjdk-17-17.0.17+10/test/jdk/sun/security/krb5/Krb5NameEquals.java openjdk-17-17.0.18+8/test/jdk/sun/security/krb5/Krb5NameEquals.java --- openjdk-17-17.0.17+10/test/jdk/sun/security/krb5/Krb5NameEquals.java 2025-10-13 07:48:04.000000000 +0000 +++ openjdk-17-17.0.18+8/test/jdk/sun/security/krb5/Krb5NameEquals.java 2026-01-15 15:23:06.000000000 +0000 @@ -1,5 +1,5 @@ /* - * Copyright (c) 2007, 2011, 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 @@ -22,57 +22,65 @@ */ /* + * @test * @bug 4634392 - * @summary JDK code doesn't respect contract for equals and hashCode + * @summary Ensure the GSSName has the correct impl which respects + * the contract for equals and hashCode across different configurations. + * @library /test/lib * @author Andrew Fan + * + * @run main/othervm -Djava.security.krb5.realm=R -Djava.security.krb5.kdc=127.0.0.1 Krb5NameEquals + * @run main/othervm -Dsun.security.jgss.native=true Krb5NameEquals */ -import org.ietf.jgss.*; +import jtreg.SkippedException; +import org.ietf.jgss.GSSManager; +import org.ietf.jgss.GSSName; +import org.ietf.jgss.Oid; public class Krb5NameEquals { - private static String NAME_STR1 = "service@localhost"; - private static String NAME_STR2 = "service2@localhost"; + private static final String NAME_STR1 = "service@localhost"; + private static final String NAME_STR2 = "service2@localhost"; private static final Oid MECH; static { - Oid temp = null; try { - temp = new Oid("1.2.840.113554.1.2.2"); // KRB5 + MECH = new Oid("1.2.840.113554.1.2.2"); // KRB5 } catch (Exception e) { // should never happen + throw new RuntimeException("Exception initialising Oid", e); } - MECH = temp; } public static void main(String[] argv) throws Exception { - GSSManager mgr = GSSManager.getInstance(); + final GSSManager mgr = GSSManager.getInstance(); + + // Checking if native GSS is installed, throwing skip exception if it's not. + if (Boolean.getBoolean("sun.security.jgss.native")) { + final var mechs = mgr.getMechs(); + if (mechs == null || mechs.length == 0) { + throw new SkippedException("NativeGSS not supported"); + } + } - boolean result = true; // Create GSSName and check their equals(), hashCode() impl - GSSName name1 = mgr.createName(NAME_STR1, - GSSName.NT_HOSTBASED_SERVICE, MECH); - GSSName name2 = mgr.createName(NAME_STR2, - GSSName.NT_HOSTBASED_SERVICE, MECH); - GSSName name3 = mgr.createName(NAME_STR1, - GSSName.NT_HOSTBASED_SERVICE, MECH); - - if (!name1.equals(name1) || !name1.equals(name3) || - !name1.equals((Object) name1) || - !name1.equals((Object) name3)) { - System.out.println("Error: should be the same name"); - result = false; + final GSSName name1 = mgr.createName(NAME_STR1, + GSSName.NT_HOSTBASED_SERVICE, MECH); + final GSSName name2 = mgr.createName(NAME_STR2, + GSSName.NT_HOSTBASED_SERVICE, MECH); + final GSSName name3 = mgr.createName(NAME_STR1, + GSSName.NT_HOSTBASED_SERVICE, MECH); + + if (!name1.equals(name3) || !name1.equals((Object) name3)) { + throw new RuntimeException("Error: should be the same name"); } else if (name1.hashCode() != name3.hashCode()) { - System.out.println("Error: should have same hash"); - result = false; + throw new RuntimeException("Error: should have same hash"); } if (name1.equals(name2) || name1.equals((Object) name2)) { - System.out.println("Error: should be different names"); - result = false; + throw new RuntimeException("Error: should be different names"); } - if (result) { - System.out.println("Done"); - } else System.exit(1); + System.out.println("Done"); } } diff -Nru openjdk-17-17.0.17+10/test/jdk/sun/security/krb5/MicroTime.java openjdk-17-17.0.18+8/test/jdk/sun/security/krb5/MicroTime.java --- openjdk-17-17.0.17+10/test/jdk/sun/security/krb5/MicroTime.java 2025-10-13 07:48:04.000000000 +0000 +++ openjdk-17-17.0.18+8/test/jdk/sun/security/krb5/MicroTime.java 2026-01-15 15:23:06.000000000 +0000 @@ -1,5 +1,5 @@ /* - * Copyright (c) 2010, 2013, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2010, 2025, Oracle and/or its affiliates. All rights reserved. * 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,9 +44,10 @@ count++; } } - // We believe a nice KerberosTime can at least tell the - // difference of 100 musec. - if (count < 10000) { + // Before JDK-6882687, KerberosTime was measured in milliseconds. + // Now it's in microseconds. We should be able to record more than + // 1000 distinct KerberosTime values within one second. + if (count < 1001) { throw new Exception("What? only " + (1000000/count) + " musec precision?"); } diff -Nru openjdk-17-17.0.17+10/test/jdk/sun/security/krb5/auto/SaslBasic.java openjdk-17-17.0.18+8/test/jdk/sun/security/krb5/auto/SaslBasic.java --- openjdk-17-17.0.17+10/test/jdk/sun/security/krb5/auto/SaslBasic.java 2025-10-13 07:48:04.000000000 +0000 +++ openjdk-17-17.0.18+8/test/jdk/sun/security/krb5/auto/SaslBasic.java 2026-01-15 15:23:06.000000000 +0000 @@ -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 @@ -32,12 +32,11 @@ * @run main/othervm -Djdk.net.hosts.file=TestHosts SaslBasic unbound auth-conf * @run main/othervm -Djdk.net.hosts.file=TestHosts SaslBasic bound auth */ -import java.io.IOException; +import static jdk.test.lib.Asserts.assertEquals; + import java.util.Arrays; import java.util.HashMap; import javax.security.auth.callback.Callback; -import javax.security.auth.callback.CallbackHandler; -import javax.security.auth.callback.UnsupportedCallbackException; import javax.security.sasl.*; // The basic krb5 test skeleton you can copy from @@ -61,15 +60,12 @@ srvprops.put(Sasl.QOP, "auth,auth-int,auth-conf"); SaslServer ss = Sasl.createSaslServer("GSSAPI", "server", bound? name: null, srvprops, - new CallbackHandler() { - public void handle(Callback[] callbacks) - throws IOException, UnsupportedCallbackException { - for (Callback cb : callbacks) { - if (cb instanceof RealmCallback) { - ((RealmCallback) cb).setText(OneKDC.REALM); - } else if (cb instanceof AuthorizeCallback) { - ((AuthorizeCallback) cb).setAuthorized(true); - } + callbacks -> { + for (Callback cb : callbacks) { + if (cb instanceof RealmCallback) { + ((RealmCallback) cb).setText(OneKDC.REALM); + } else if (cb instanceof AuthorizeCallback) { + ((AuthorizeCallback) cb).setAuthorized(true); } } }); @@ -89,28 +85,85 @@ String boundName = (String)ss.getNegotiatedProperty( Sasl.BOUND_SERVER_NAME); if (!boundName.equals(name)) { - throw new Exception("Wrong bound server name"); + throw new RuntimeException("Wrong bound server name"); } } Object key = ss.getNegotiatedProperty( "com.sun.security.jgss.inquiretype.krb5_get_session_key"); if (key == null) { - throw new Exception("Extended negotiated property not read"); + throw new RuntimeException("Extended negotiated property not read"); } if (args[1].equals("auth")) { // 8170732. These are the maximum size bytes after jgss/krb5 wrap. if (lastClientToken[17] != 0 || lastClientToken[18] != 0 || lastClientToken[19] != 0) { - throw new Exception("maximum size for auth must be 0"); + throw new RuntimeException("maximum size for auth must be 0"); } + testWrapUnwrapNoSecLayer(sc, ss); } else { - byte[] hello = "hello".getBytes(); - token = sc.wrap(hello, 0, hello.length); - token = ss.unwrap(token, 0, token.length); - if (!Arrays.equals(hello, token)) { - throw new Exception("Message altered"); - } + testWrapUnwrapWithSecLayer(sc, ss); + } + } + + private static void testWrapUnwrapWithSecLayer(SaslClient sc, SaslServer ss) + throws SaslException { + byte[] token; + byte[] hello = "hello".getBytes(); + + // test client wrap and server unwrap + token = sc.wrap(hello, 0, hello.length); + token = ss.unwrap(token, 0, token.length); + + if (!Arrays.equals(hello, token)) { + throw new RuntimeException("Client message altered"); + } + + // test server wrap and client unwrap + token = ss.wrap(hello, 0, hello.length); + token = sc.unwrap(token, 0, token.length); + + if (!Arrays.equals(hello, token)) { + throw new RuntimeException("Server message altered"); + } + } + + private static void testWrapUnwrapNoSecLayer(SaslClient sc, SaslServer ss) + throws SaslException { + byte[] clntBuf = new byte[]{0, 1, 2, 3}; + byte[] srvBuf = new byte[]{10, 11, 12, 13}; + String expectedError = "No security layer negotiated"; + + try { + sc.wrap(clntBuf, 0, clntBuf.length); + throw new RuntimeException( + "client wrap should not be allowed w/no security layer"); + } catch (IllegalStateException e) { + assertEquals(expectedError, e.getMessage()); + } + + try { + ss.wrap(srvBuf, 0, srvBuf.length); + throw new RuntimeException( + "server wrap should not be allowed w/no security layer"); + } catch (IllegalStateException e) { + assertEquals(expectedError, e.getMessage()); + } + + try { + sc.unwrap(clntBuf, 0, clntBuf.length); + throw new RuntimeException( + "client unwrap should not be allowed w/no security layer"); + } catch (IllegalStateException e) { + assertEquals(expectedError, e.getMessage()); + } + + try { + ss.unwrap(srvBuf, 0, srvBuf.length); + throw new RuntimeException( + "server unwrap should not be allowed w/no security layer"); + } catch (IllegalStateException e) { + assertEquals(expectedError, e.getMessage()); } } } diff -Nru openjdk-17-17.0.17+10/test/jdk/sun/security/krb5/runNameEquals.sh openjdk-17-17.0.18+8/test/jdk/sun/security/krb5/runNameEquals.sh --- openjdk-17-17.0.17+10/test/jdk/sun/security/krb5/runNameEquals.sh 2025-10-13 07:48:04.000000000 +0000 +++ openjdk-17-17.0.18+8/test/jdk/sun/security/krb5/runNameEquals.sh 1970-01-01 00:00:00.000000000 +0000 @@ -1,127 +0,0 @@ -# -# Copyright (c) 2009, 2024, Oracle and/or its affiliates. All rights reserved. -# DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. -# -# This code is free software; you can redistribute it and/or modify it -# 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 6317711 6944847 8024046 -# @summary Ensure the GSSName has the correct impl which respects -# the contract for equals and hashCode across different configurations. - -# set a few environment variables so that the shell-script can run stand-alone -# in the source directory - -if [ "${TESTSRC}" = "" ] ; then - TESTSRC="." -fi - -if [ "${TESTCLASSES}" = "" ] ; then - TESTCLASSES="." -fi - -if [ "${TESTJAVA}" = "" ] ; then - echo "TESTJAVA not set. Test cannot execute." - echo "FAILED!!!" - exit 1 -fi - -if [ "${COMPILEJAVA}" = "" ]; then - COMPILEJAVA="${TESTJAVA}" -fi - -NATIVE=false - -# set platform-dependent variables -OS=`uname -s` -case "$OS" in - Linux | Darwin ) - PATHSEP=":" - FILESEP="/" - NATIVE=true - # Not all *nix has native GSS libs installed - krb5-config --libs 2> /dev/null - if [ $? != 0 ]; then - # Fedora has a different path - /usr/kerberos/bin/krb5-config --libs 2> /dev/null - if [ $? != 0 ]; then - NATIVE=false - fi - fi - ;; - AIX ) - PATHSEP=":" - FILESEP="/" - ;; - CYGWIN* ) - PATHSEP=";" - FILESEP="/" - ;; - Windows* ) - PATHSEP=";" - FILESEP="\\" - ;; - * ) - echo "Unrecognized system!" - exit 1; - ;; -esac - -TEST=Krb5NameEquals - -${COMPILEJAVA}${FILESEP}bin${FILESEP}javac ${TESTJAVACOPTS} ${TESTTOOLVMOPTS} \ - -d ${TESTCLASSES}${FILESEP} \ - ${TESTSRC}${FILESEP}${TEST}.java - -EXIT_STATUS=0 - -if [ "${NATIVE}" = "true" ] ; then - echo "Testing native provider" - ${TESTJAVA}${FILESEP}bin${FILESEP}java ${TESTVMOPTS} ${TESTJAVAOPTS} \ - -classpath ${TESTCLASSES} \ - -Dsun.security.jgss.native=true \ - ${TEST} - if [ $? != 0 ] ; then - echo "Native provider fails" - EXIT_STATUS=1 - if [ "$OS" = "Linux" -a `arch` = "x86_64" ]; then - ${TESTJAVA}${FILESEP}bin${FILESEP}java -XshowSettings:properties -version 2> allprop - cat allprop | grep sun.arch.data.model | grep 32 - if [ "$?" = "0" ]; then - echo "Running 32-bit JDK on 64-bit Linux. Maybe only 64-bit library is installed." - echo "Please manually check if this is the case. Treated as PASSED now." - EXIT_STATUS=0 - fi - fi - fi -fi - -echo "Testing java provider" -${TESTJAVA}${FILESEP}bin${FILESEP}java ${TESTVMOPTS} ${TESTJAVAOPTS} \ - -classpath ${TESTCLASSES} \ - -Djava.security.krb5.realm=R \ - -Djava.security.krb5.kdc=127.0.0.1 \ - ${TEST} -if [ $? != 0 ] ; then - echo "Java provider fails" - EXIT_STATUS=1 -fi - -exit ${EXIT_STATUS} diff -Nru openjdk-17-17.0.17+10/test/jdk/sun/security/pkcs11/KeyAgreement/SupportedDHKeys.java openjdk-17-17.0.18+8/test/jdk/sun/security/pkcs11/KeyAgreement/SupportedDHKeys.java --- openjdk-17-17.0.17+10/test/jdk/sun/security/pkcs11/KeyAgreement/SupportedDHKeys.java 2025-10-13 07:48:04.000000000 +0000 +++ openjdk-17-17.0.18+8/test/jdk/sun/security/pkcs11/KeyAgreement/SupportedDHKeys.java 2026-01-15 15:23:06.000000000 +0000 @@ -1,5 +1,5 @@ /* - * Copyright (c) 2016, 2020, 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 @@ -31,6 +31,8 @@ * @run main/othervm -Djava.security.manager=allow SupportedDHKeys sm */ +import jtreg.SkippedException; + import java.math.BigInteger; import java.security.KeyPair; import java.security.KeyPairGenerator; @@ -63,8 +65,7 @@ @Override public void main(Provider provider) throws Exception { if (provider.getService("KeyPairGenerator", "DiffieHellman") == null) { - System.out.println("No support of DH KeyPairGenerator, skipping"); - return; + throw new SkippedException("No support of DH KeyPairGenerator, skipping"); } for (SupportedKeySize keySize : SupportedKeySize.values()) { diff -Nru openjdk-17-17.0.17+10/test/jdk/sun/security/pkcs11/KeyAgreement/TestDH.java openjdk-17-17.0.18+8/test/jdk/sun/security/pkcs11/KeyAgreement/TestDH.java --- openjdk-17-17.0.17+10/test/jdk/sun/security/pkcs11/KeyAgreement/TestDH.java 2025-10-13 07:48:04.000000000 +0000 +++ openjdk-17-17.0.18+8/test/jdk/sun/security/pkcs11/KeyAgreement/TestDH.java 2026-01-15 15:23:06.000000000 +0000 @@ -1,5 +1,5 @@ /* - * Copyright (c) 2003, 2024, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2003, 2025, Oracle and/or its affiliates. All rights reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * * This code is free software; you can redistribute it and/or modify it @@ -39,14 +39,14 @@ import javax.crypto.KeyAgreement; import javax.crypto.SecretKey; import jdk.test.lib.security.SecurityUtils; +import jtreg.SkippedException; public class TestDH extends PKCS11Test { @Override public void main(Provider p) throws Exception { if (p.getService("KeyAgreement", "DH") == null) { - System.out.println("DH not supported, skipping"); - return; + throw new SkippedException("DH not supported, skipping"); } String kpgAlgorithm = "DH"; KeyPairGenerator kpg = KeyPairGenerator.getInstance(kpgAlgorithm, p); diff -Nru openjdk-17-17.0.17+10/test/jdk/sun/security/pkcs11/KeyAgreement/TestInterop.java openjdk-17-17.0.18+8/test/jdk/sun/security/pkcs11/KeyAgreement/TestInterop.java --- openjdk-17-17.0.17+10/test/jdk/sun/security/pkcs11/KeyAgreement/TestInterop.java 2025-10-13 07:48:04.000000000 +0000 +++ openjdk-17-17.0.18+8/test/jdk/sun/security/pkcs11/KeyAgreement/TestInterop.java 2026-01-15 15:23:06.000000000 +0000 @@ -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 @@ -41,6 +41,7 @@ import javax.crypto.spec.DHPublicKeySpec; import jdk.test.lib.security.DiffieHellmanGroup; import jdk.test.lib.security.SecurityUtils; +import jtreg.SkippedException; public class TestInterop extends PKCS11Test { @@ -77,8 +78,7 @@ @Override public void main(Provider prov) throws Exception { if (prov.getService("KeyAgreement", "DH") == null) { - System.out.println("DH not supported, skipping"); - return; + throw new SkippedException("DH not supported, skipping"); } try { System.out.println("testing generateSecret()"); diff -Nru openjdk-17-17.0.17+10/test/jdk/sun/security/pkcs11/KeyAgreement/TestShort.java openjdk-17-17.0.18+8/test/jdk/sun/security/pkcs11/KeyAgreement/TestShort.java --- openjdk-17-17.0.17+10/test/jdk/sun/security/pkcs11/KeyAgreement/TestShort.java 2025-10-13 07:48:04.000000000 +0000 +++ openjdk-17-17.0.18+8/test/jdk/sun/security/pkcs11/KeyAgreement/TestShort.java 2026-01-15 15:23:06.000000000 +0000 @@ -1,5 +1,5 @@ /* - * Copyright (c) 2003, 2018, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2003, 2025, Oracle and/or its affiliates. All rights reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * * This code is free software; you can redistribute it and/or modify it @@ -32,6 +32,8 @@ * @run main/othervm -Djava.security.manager=allow TestShort sm */ +import jtreg.SkippedException; + import java.math.BigInteger; import java.security.KeyFactory; import java.security.PrivateKey; @@ -91,12 +93,10 @@ @Override public void main(Provider provider) throws Exception { if (provider.getService("KeyAgreement", "DH") == null) { - System.out.println("DH not supported, skipping"); - return; + throw new SkippedException("DH not supported, skipping"); } + try { - DHPublicKeySpec publicSpec; - DHPrivateKeySpec privateSpec; KeyFactory kf = KeyFactory.getInstance("DH", provider); KeyAgreement ka = KeyAgreement.getInstance("DH", provider); @@ -107,7 +107,7 @@ ka.init(pr1); ka.doPhase(pu2, true); byte[] n2 = ka.generateSecret(); - if (Arrays.equals(s2, n2) == false) { + if (!Arrays.equals(s2, n2)) { throw new Exception("mismatch 2"); } System.out.println("short ok"); @@ -115,7 +115,7 @@ ka.init(pr1); ka.doPhase(pu3, true); byte[] n3 = ka.generateSecret(); - if (Arrays.equals(s3, n3) == false) { + if (!Arrays.equals(s3, n3)) { throw new Exception("mismatch 3"); } System.out.println("normal ok"); @@ -124,27 +124,6 @@ ex.printStackTrace(); throw ex; } - -/* - KeyPairGenerator kpg = KeyPairGenerator.getInstance("DH", provider); - kpg.initialize(512); -// KeyPair kp1 = kpg.generateKeyPair(); -// System.out.println(kp1.getPublic()); -// System.out.println(kp1.getPrivate()); - while (true) { - KeyAgreement ka = KeyAgreement.getInstance("DH", provider); - ka.init(pr1); - KeyPair kp2 = kpg.generateKeyPair(); - ka.doPhase(kp2.getPublic(), true); - byte[] sec = ka.generateSecret(); - if (sec.length == 64) { - System.out.println(kp2.getPrivate()); - System.out.println(kp2.getPublic()); - System.out.println(toString(sec)); - break; - } - } -/**/ } public static void main(String[] args) throws Exception { diff -Nru openjdk-17-17.0.17+10/test/jdk/sun/security/pkcs11/KeyAgreement/UnsupportedDHKeys.java openjdk-17-17.0.18+8/test/jdk/sun/security/pkcs11/KeyAgreement/UnsupportedDHKeys.java --- openjdk-17-17.0.17+10/test/jdk/sun/security/pkcs11/KeyAgreement/UnsupportedDHKeys.java 2025-10-13 07:48:04.000000000 +0000 +++ openjdk-17-17.0.18+8/test/jdk/sun/security/pkcs11/KeyAgreement/UnsupportedDHKeys.java 2026-01-15 15:23:06.000000000 +0000 @@ -1,5 +1,5 @@ /* - * Copyright (c) 2016, 2018, 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 @@ -31,6 +31,8 @@ * @run main/othervm -Djava.security.manager=allow UnsupportedDHKeys sm */ +import jtreg.SkippedException; + import java.security.InvalidParameterException; import java.security.KeyPairGenerator; import java.security.Provider; @@ -60,8 +62,7 @@ @Override public void main(Provider provider) throws Exception { if (provider.getService("KeyPairGenerator", "DiffieHellman") == null) { - System.out.println("No supported of DH KeyPairGenerator, skipping"); - return; + throw new SkippedException("DH (DiffieHellman) is not supported in KeyPairGenerator, skipping"); } for (UnsupportedKeySize keySize : UnsupportedKeySize.values()) { diff -Nru openjdk-17-17.0.17+10/test/jdk/sun/security/pkcs11/KeyGenerator/DESParity.java openjdk-17-17.0.18+8/test/jdk/sun/security/pkcs11/KeyGenerator/DESParity.java --- openjdk-17-17.0.17+10/test/jdk/sun/security/pkcs11/KeyGenerator/DESParity.java 2025-10-13 07:48:04.000000000 +0000 +++ openjdk-17-17.0.18+8/test/jdk/sun/security/pkcs11/KeyGenerator/DESParity.java 2026-01-15 15:23:06.000000000 +0000 @@ -1,5 +1,5 @@ /* - * Copyright (c) 2003, 2018, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2003, 2025, Oracle and/or its affiliates. All rights reserved. * 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,8 @@ * @run main/othervm -Djava.security.manager=allow DESParity sm */ +import jtreg.SkippedException; + import java.security.Provider; import java.util.Random; import javax.crypto.SecretKey; @@ -46,8 +48,7 @@ @Override public void main(Provider p) throws Exception { if (p.getService("SecretKeyFactory", "DES") == null) { - System.out.println("Not supported by provider, skipping"); - return; + throw new SkippedException("Not supported by provider, skipping"); } Random random = new Random(); SecretKeyFactory kf; @@ -58,7 +59,7 @@ random.nextBytes(b); SecretKeySpec spec = new SecretKeySpec(b, "DES"); SecretKey key = kf.generateSecret(spec); - if (DESKeySpec.isParityAdjusted(key.getEncoded(), 0) == false) { + if (!DESKeySpec.isParityAdjusted(key.getEncoded(), 0)) { throw new Exception("DES key not parity adjusted"); } } @@ -69,7 +70,7 @@ random.nextBytes(b); SecretKeySpec spec = new SecretKeySpec(b, "DESede"); SecretKey key = kf.generateSecret(spec); - if (DESedeKeySpec.isParityAdjusted(key.getEncoded(), 0) == false) { + if (!DESedeKeySpec.isParityAdjusted(key.getEncoded(), 0)) { throw new Exception("DESede key not parity adjusted"); } } diff -Nru openjdk-17-17.0.17+10/test/jdk/sun/security/pkcs11/KeyGenerator/TestChaCha20.java openjdk-17-17.0.18+8/test/jdk/sun/security/pkcs11/KeyGenerator/TestChaCha20.java --- openjdk-17-17.0.17+10/test/jdk/sun/security/pkcs11/KeyGenerator/TestChaCha20.java 2025-10-13 07:48:04.000000000 +0000 +++ openjdk-17-17.0.18+8/test/jdk/sun/security/pkcs11/KeyGenerator/TestChaCha20.java 2026-01-15 15:23:06.000000000 +0000 @@ -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 @@ -29,6 +29,8 @@ * @library /test/lib .. * @run main/othervm TestChaCha20 */ +import jtreg.SkippedException; + import java.security.Provider; import java.security.InvalidAlgorithmParameterException; import java.security.InvalidParameterException; @@ -54,8 +56,7 @@ try { kg = KeyGenerator.getInstance(ALGO, p); } catch (NoSuchAlgorithmException nsae) { - System.out.println("Skip; no support for " + ALGO); - return; + throw new SkippedException("Skip; no support for " + ALGO, nsae); } try { diff -Nru openjdk-17-17.0.17+10/test/jdk/sun/security/pkcs11/KeyGenerator/TestKeyGenerator.java openjdk-17-17.0.18+8/test/jdk/sun/security/pkcs11/KeyGenerator/TestKeyGenerator.java --- openjdk-17-17.0.17+10/test/jdk/sun/security/pkcs11/KeyGenerator/TestKeyGenerator.java 2025-10-13 07:48:04.000000000 +0000 +++ openjdk-17-17.0.18+8/test/jdk/sun/security/pkcs11/KeyGenerator/TestKeyGenerator.java 2026-01-15 15:23:06.000000000 +0000 @@ -1,5 +1,5 @@ /* - * Copyright (c) 2003, 2020, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2003, 2025, Oracle and/or its affiliates. All rights reserved. * 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 -Nru openjdk-17-17.0.17+10/test/jdk/sun/security/pkcs11/KeyPairGenerator/TestDH2048.java openjdk-17-17.0.18+8/test/jdk/sun/security/pkcs11/KeyPairGenerator/TestDH2048.java --- openjdk-17-17.0.17+10/test/jdk/sun/security/pkcs11/KeyPairGenerator/TestDH2048.java 2025-10-13 07:48:04.000000000 +0000 +++ openjdk-17-17.0.18+8/test/jdk/sun/security/pkcs11/KeyPairGenerator/TestDH2048.java 2026-01-15 15:23:06.000000000 +0000 @@ -1,5 +1,5 @@ /* - * Copyright (c) 2013, 2018, 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 @@ -32,6 +32,8 @@ * @run main/othervm -Djava.security.manager=allow TestDH2048 sm */ +import jtreg.SkippedException; + import java.security.InvalidParameterException; import java.security.KeyPair; import java.security.KeyPairGenerator; @@ -51,8 +53,7 @@ @Override public void main(Provider p) throws Exception { if (p.getService("KeyPairGenerator", "DH") == null) { - System.out.println("KPG for DH not supported, skipping"); - return; + throw new SkippedException("KPG for DH not supported, skipping"); } KeyPairGenerator kpg = KeyPairGenerator.getInstance("DH", p); kpg.initialize(512); diff -Nru openjdk-17-17.0.17+10/test/jdk/sun/security/pkcs11/KeyStore/ClientAuth.java openjdk-17-17.0.18+8/test/jdk/sun/security/pkcs11/KeyStore/ClientAuth.java --- openjdk-17-17.0.17+10/test/jdk/sun/security/pkcs11/KeyStore/ClientAuth.java 2025-10-13 07:48:04.000000000 +0000 +++ openjdk-17-17.0.18+8/test/jdk/sun/security/pkcs11/KeyStore/ClientAuth.java 2026-01-15 15:23:06.000000000 +0000 @@ -1,5 +1,5 @@ /* - * Copyright (c) 2003, 2023, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2003, 2025, Oracle and/or its affiliates. All rights reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * * This code is free software; you can redistribute it and/or modify it @@ -260,8 +260,7 @@ try { javax.crypto.Cipher.getInstance("RSA/ECB/PKCS1Padding", p); } catch (GeneralSecurityException e) { - System.out.println("Not supported by provider, skipping"); - return; + throw new SkippedException("Not supported by provider, skipping"); } this.provider = p; diff -Nru openjdk-17-17.0.17+10/test/jdk/sun/security/pkcs11/PKCS11Test.java openjdk-17-17.0.18+8/test/jdk/sun/security/pkcs11/PKCS11Test.java --- openjdk-17-17.0.17+10/test/jdk/sun/security/pkcs11/PKCS11Test.java 2025-10-13 07:48:04.000000000 +0000 +++ openjdk-17-17.0.18+8/test/jdk/sun/security/pkcs11/PKCS11Test.java 2026-01-15 15:23:06.000000000 +0000 @@ -77,7 +77,7 @@ // Version of the NSS artifact. This coincides with the version of // the NSS version - private static final String NSS_BUNDLE_VERSION = "3.107"; + private static final String NSS_BUNDLE_VERSION = "3.111"; private static final String NSSLIB = "jpg.tests.jdk.nsslib"; static double nss_version = -1; diff -Nru openjdk-17-17.0.17+10/test/jdk/sun/security/pkcs11/SecretKeyFactory/TestGeneral.java openjdk-17-17.0.18+8/test/jdk/sun/security/pkcs11/SecretKeyFactory/TestGeneral.java --- openjdk-17-17.0.17+10/test/jdk/sun/security/pkcs11/SecretKeyFactory/TestGeneral.java 2025-10-13 07:48:04.000000000 +0000 +++ openjdk-17-17.0.18+8/test/jdk/sun/security/pkcs11/SecretKeyFactory/TestGeneral.java 2026-01-15 15:23:06.000000000 +0000 @@ -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 @@ -30,10 +30,14 @@ * @run main/othervm TestGeneral */ +import jtreg.SkippedException; + import java.security.NoSuchAlgorithmException; import java.security.Provider; import java.security.SecureRandom; +import java.util.ArrayList; import java.util.Arrays; +import java.util.List; import javax.crypto.SecretKeyFactory; import javax.crypto.SecretKey; import javax.crypto.spec.SecretKeySpec; @@ -57,8 +61,11 @@ try { skf = SecretKeyFactory.getInstance(algorithm, p); } catch (NoSuchAlgorithmException e) { - System.out.println("Not supported, skipping: " + e); - return; + throw new SkippedException("[algorithm: " + algorithm + + ", key: " + key.getAlgorithm() + "]" + + ", provider: " + p.getName() + "]" + + ", expectedTestResult: " + expected + "]" + + "Not supported, skipping: " + e); } try { SecretKey key2 = skf.translateKey(key); @@ -99,21 +106,31 @@ SecretKey bf_128Key = new SecretKeySpec(rawBytes, 0, 16, "Blowfish"); SecretKey cc20Key = new SecretKeySpec(rawBytes, 0, 32, "ChaCha20"); - // fixed key length - test("AES", aes_128Key, p, TestResult.PASS); - test("AES", aes_256Key, p, TestResult.PASS); - test("AES", cc20Key, p, TestResult.FAIL); - - test("ChaCha20", aes_128Key, p, TestResult.FAIL); - test("ChaCha20", aes_256Key, p, TestResult.FAIL); - test("ChaCha20", cc20Key, p, TestResult.PASS); - - // variable key length - // Different PKCS11 impls may have different ranges - // of supported key sizes for variable-key-length - // algorithms. - test("Blowfish", aes_128Key, p, TestResult.FAIL); - test("Blowfish", cc20Key, p, TestResult.FAIL); - test("Blowfish", bf_128Key, p, TestResult.PASS); + List skippedList = new ArrayList<>(); + try { + // fixed key length + test("AES", aes_128Key, p, TestResult.PASS); + test("AES", aes_256Key, p, TestResult.PASS); + test("AES", cc20Key, p, TestResult.FAIL); + + test("ChaCha20", aes_128Key, p, TestResult.FAIL); + test("ChaCha20", aes_256Key, p, TestResult.FAIL); + test("ChaCha20", cc20Key, p, TestResult.PASS); + + // variable key length + // Different PKCS11 impls may have different ranges + // of supported key sizes for variable-key-length + // algorithms. + test("Blowfish", aes_128Key, p, TestResult.FAIL); + test("Blowfish", cc20Key, p, TestResult.FAIL); + test("Blowfish", bf_128Key, p, TestResult.PASS); + } catch (SkippedException skippedException){ + skippedException.printStackTrace(); + skippedList.add(skippedException.getMessage()); + } + + if (!skippedList.isEmpty()) { + throw new SkippedException("One or more tests skipped " + skippedList); + } } } diff -Nru openjdk-17-17.0.17+10/test/jdk/sun/security/pkcs11/SecureRandom/Basic.java openjdk-17-17.0.18+8/test/jdk/sun/security/pkcs11/SecureRandom/Basic.java --- openjdk-17-17.0.17+10/test/jdk/sun/security/pkcs11/SecureRandom/Basic.java 2025-10-13 07:48:04.000000000 +0000 +++ openjdk-17-17.0.18+8/test/jdk/sun/security/pkcs11/SecureRandom/Basic.java 2026-01-15 15:23:06.000000000 +0000 @@ -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 @@ -33,6 +33,8 @@ * @run main/othervm -Djava.security.manager=allow Basic sm */ +import jtreg.SkippedException; + import java.security.NoSuchAlgorithmException; import java.security.Provider; import java.security.SecureRandom; @@ -45,9 +47,8 @@ try { random = SecureRandom.getInstance("PKCS11"); } catch (NoSuchAlgorithmException e) { - System.out.println("Provider " + p + " does not support SecureRandom, skipping"); e.printStackTrace(); - return; + throw new SkippedException("Provider " + p + " does not support SecureRandom, skipping", e); } byte[] b = new byte[32]; random.nextBytes(b); diff -Nru openjdk-17-17.0.17+10/test/jdk/sun/security/pkcs11/SecureRandom/TestDeserialization.java openjdk-17-17.0.18+8/test/jdk/sun/security/pkcs11/SecureRandom/TestDeserialization.java --- openjdk-17-17.0.17+10/test/jdk/sun/security/pkcs11/SecureRandom/TestDeserialization.java 2025-10-13 07:48:04.000000000 +0000 +++ openjdk-17-17.0.18+8/test/jdk/sun/security/pkcs11/SecureRandom/TestDeserialization.java 2026-01-15 15:23:06.000000000 +0000 @@ -1,5 +1,5 @@ /* - * Copyright (c) 2010, 2018, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2010, 2025, Oracle and/or its affiliates. All rights reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * * This code is free software; you can redistribute it and/or modify it @@ -29,6 +29,8 @@ * @modules jdk.crypto.cryptoki */ +import jtreg.SkippedException; + import java.io.ByteArrayInputStream; import java.io.ByteArrayOutputStream; import java.io.ObjectInputStream; @@ -43,18 +45,16 @@ public void main(Provider p) throws Exception { // Skip this test for providers not found by java.security.Security if (Security.getProvider(p.getName()) != p) { - System.out.println("Skip test for provider " + p.getName()); - return; + throw new SkippedException("Skip test for provider " + p.getName()); } SecureRandom r; try { r = SecureRandom.getInstance("PKCS11", p); System.out.println("SecureRandom instance " + r); } catch (NoSuchAlgorithmException e) { - System.out.println("Provider " + p + - " does not support SecureRandom, skipping"); e.printStackTrace(); - return; + throw new SkippedException("Provider " + p + + " does not support SecureRandom, skipping"); } r.setSeed(System.currentTimeMillis()); byte[] buf = new byte[16]; diff -Nru openjdk-17-17.0.17+10/test/jdk/sun/security/pkcs11/Serialize/SerializeProvider.java openjdk-17-17.0.18+8/test/jdk/sun/security/pkcs11/Serialize/SerializeProvider.java --- openjdk-17-17.0.17+10/test/jdk/sun/security/pkcs11/Serialize/SerializeProvider.java 2025-10-13 07:48:04.000000000 +0000 +++ openjdk-17-17.0.18+8/test/jdk/sun/security/pkcs11/Serialize/SerializeProvider.java 2026-01-15 15:23:06.000000000 +0000 @@ -1,5 +1,5 @@ /* - * Copyright (c) 2003, 2018, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2003, 2025, Oracle and/or its affiliates. All rights reserved. * 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,9 +41,9 @@ public class SerializeProvider extends PKCS11Test { public void main(Provider p) throws Exception { + if (Security.getProvider(p.getName()) != p) { - System.out.println("Provider not installed in Security, skipping"); - return; + Security.addProvider(p); } ByteArrayOutputStream out = new ByteArrayOutputStream(); @@ -57,7 +57,7 @@ InputStream in = new ByteArrayInputStream(data); ObjectInputStream oin = new ObjectInputStream(in); - Provider p2 = (Provider)oin.readObject(); + Provider p2 = (Provider) oin.readObject(); System.out.println("Reconstituted: " + p2); diff -Nru openjdk-17-17.0.17+10/test/jdk/sun/security/pkcs11/tls/tls12/FipsModeTLS12.java openjdk-17-17.0.18+8/test/jdk/sun/security/pkcs11/tls/tls12/FipsModeTLS12.java --- openjdk-17-17.0.17+10/test/jdk/sun/security/pkcs11/tls/tls12/FipsModeTLS12.java 2025-10-13 07:48:04.000000000 +0000 +++ openjdk-17-17.0.18+8/test/jdk/sun/security/pkcs11/tls/tls12/FipsModeTLS12.java 2026-01-15 15:23:06.000000000 +0000 @@ -1,5 +1,6 @@ /* * Copyright (c) 2019, Red Hat, Inc. + * Copyright (c) 2024, Oracle and/or its affiliates. All rights reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * * This code is free software; you can redistribute it and/or modify it @@ -63,6 +64,7 @@ import javax.net.ssl.SSLSession; import javax.net.ssl.TrustManagerFactory; +import jdk.test.lib.security.SecurityUtils; import sun.security.internal.spec.TlsMasterSecretParameterSpec; import sun.security.internal.spec.TlsPrfParameterSpec; import sun.security.internal.spec.TlsRsaPremasterSecretParameterSpec; @@ -80,6 +82,9 @@ private static PublicKey publicKey; public static void main(String[] args) throws Exception { + // Re-enable TLS_RSA_* since test depends on it. + SecurityUtils.removeFromDisabledTlsAlgs("TLS_RSA_*"); + try { initialize(); } catch (Exception e) { diff -Nru openjdk-17-17.0.17+10/test/jdk/sun/security/ssl/ClientHandshaker/LengthCheckTest.java openjdk-17-17.0.18+8/test/jdk/sun/security/ssl/ClientHandshaker/LengthCheckTest.java --- openjdk-17-17.0.17+10/test/jdk/sun/security/ssl/ClientHandshaker/LengthCheckTest.java 2025-10-13 07:48:04.000000000 +0000 +++ openjdk-17-17.0.18+8/test/jdk/sun/security/ssl/ClientHandshaker/LengthCheckTest.java 2026-01-15 15:23:06.000000000 +0000 @@ -1,5 +1,5 @@ /* - * Copyright (c) 2015, 2023, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2015, 2024, Oracle and/or its affiliates. All rights reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * * This code is free software; you can redistribute it and/or modify it @@ -270,8 +270,8 @@ * Main entry point for this test. */ public static void main(String args[]) throws Exception { - // Re-enable TLSv1 since test depends on it. - SecurityUtils.removeFromDisabledTlsAlgs("TLSv1"); + // Re-enable TLSv1 and TLS_RSA_* since test depends on it. + SecurityUtils.removeFromDisabledTlsAlgs("TLSv1", "TLS_RSA_*"); List ccsTests = new ArrayList<>(); diff -Nru openjdk-17-17.0.17+10/test/jdk/sun/security/ssl/EngineArgs/DebugReportsOneExtraByte.java openjdk-17-17.0.18+8/test/jdk/sun/security/ssl/EngineArgs/DebugReportsOneExtraByte.java --- openjdk-17-17.0.17+10/test/jdk/sun/security/ssl/EngineArgs/DebugReportsOneExtraByte.java 2025-10-13 07:48:04.000000000 +0000 +++ openjdk-17-17.0.18+8/test/jdk/sun/security/ssl/EngineArgs/DebugReportsOneExtraByte.java 2026-01-15 15:23:06.000000000 +0000 @@ -1,5 +1,5 @@ /* - * Copyright (c) 2003, 2023, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2003, 2024, Oracle and/or its affiliates. All rights reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * * This code is free software; you can redistribute it and/or modify it @@ -100,8 +100,8 @@ System.out.println("Test Passed."); } else { - // Re-enable TLSv1 since test depends on it - SecurityUtils.removeFromDisabledTlsAlgs("TLSv1"); + // Re-enable TLSv1 and TLS_RSA_* since test depends on it + SecurityUtils.removeFromDisabledTlsAlgs("TLSv1", "TLS_RSA_*"); DebugReportsOneExtraByte test = new DebugReportsOneExtraByte(); test.runTest(); diff -Nru openjdk-17-17.0.17+10/test/jdk/sun/security/ssl/SignatureScheme/DisableSHA1inHandshakeSignatureDTLS12.java openjdk-17-17.0.18+8/test/jdk/sun/security/ssl/SignatureScheme/DisableSHA1inHandshakeSignatureDTLS12.java --- openjdk-17-17.0.17+10/test/jdk/sun/security/ssl/SignatureScheme/DisableSHA1inHandshakeSignatureDTLS12.java 1970-01-01 00:00:00.000000000 +0000 +++ openjdk-17-17.0.18+8/test/jdk/sun/security/ssl/SignatureScheme/DisableSHA1inHandshakeSignatureDTLS12.java 2026-01-15 15:23:06.000000000 +0000 @@ -0,0 +1,54 @@ +/* + * 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 8340321 + * @summary Disable SHA-1 in TLS/DTLS 1.2 signatures. + * This test only covers DTLS 1.2. + * @library /javax/net/ssl/templates + * /test/lib + * @run main/othervm DisableSHA1inHandshakeSignatureDTLS12 + */ + +public class DisableSHA1inHandshakeSignatureDTLS12 extends + DisableSHA1inHandshakeSignatureTLS12 { + + protected DisableSHA1inHandshakeSignatureDTLS12() throws Exception { + super(); + } + + public static void main(String[] args) throws Exception { + new DisableSHA1inHandshakeSignatureDTLS12().run(); + } + + @Override + protected String getProtocol() { + return "DTLSv1.2"; + } + + // No CertificateRequest in DTLS server flight. + @Override + protected void checkCertificateRequest() { + } +} diff -Nru openjdk-17-17.0.17+10/test/jdk/sun/security/ssl/SignatureScheme/DisableSHA1inHandshakeSignatureTLS12.java openjdk-17-17.0.18+8/test/jdk/sun/security/ssl/SignatureScheme/DisableSHA1inHandshakeSignatureTLS12.java --- openjdk-17-17.0.17+10/test/jdk/sun/security/ssl/SignatureScheme/DisableSHA1inHandshakeSignatureTLS12.java 1970-01-01 00:00:00.000000000 +0000 +++ openjdk-17-17.0.18+8/test/jdk/sun/security/ssl/SignatureScheme/DisableSHA1inHandshakeSignatureTLS12.java 2026-01-15 15:23:06.000000000 +0000 @@ -0,0 +1,120 @@ +/* + * 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 8340321 + * @summary Disable SHA-1 in TLS/DTLS 1.2 signatures. + * This test only covers TLS 1.2. + * @library /javax/net/ssl/templates + * /test/lib + * @run main/othervm DisableSHA1inHandshakeSignatureTLS12 + */ + +import static jdk.test.lib.Asserts.assertFalse; +import static jdk.test.lib.Asserts.assertTrue; + +import java.util.List; + +public class DisableSHA1inHandshakeSignatureTLS12 extends + AbstractCheckSignatureSchemes { + + protected DisableSHA1inHandshakeSignatureTLS12() throws Exception { + super(); + } + + public static void main(String[] args) throws Exception { + new DisableSHA1inHandshakeSignatureTLS12().run(); + } + + @Override + protected String getProtocol() { + return "TLSv1.2"; + } + + // Run things in TLS handshake order. + protected void run() throws Exception { + + // Produce client_hello + clientEngine.wrap(clientOut, cTOs); + cTOs.flip(); + + checkClientHello(); + + // Consume client_hello. + serverEngine.unwrap(cTOs, serverIn); + runDelegatedTasks(serverEngine); + + // Produce server_hello. + serverEngine.wrap(serverOut, sTOc); + sTOc.flip(); + + checkCertificateRequest(); + } + + // Returns SHA-1 signature schemes supported for TLSv1.2 handshake + protected List getDisabledSignatureSchemes() { + return List.of( + "ecdsa_sha1", + "rsa_pkcs1_sha1", + "dsa_sha1" + ); + } + + protected void checkClientHello() throws Exception { + // Get signature_algorithms extension signature schemes. + List sigAlgsSS = getSigSchemesCliHello( + extractHandshakeMsg(cTOs, TLS_HS_CLI_HELLO), + SIG_ALGS_EXT); + + // Should not be present in signature_algorithms extension. + getDisabledSignatureSchemes().forEach(ss -> + assertFalse(sigAlgsSS.contains(ss), + "Signature Scheme " + ss + + " present in ClientHello's signature_algorithms extension")); + + // Get signature_algorithms_cert extension signature schemes. + List sigAlgsCertSS = getSigSchemesCliHello( + extractHandshakeMsg(cTOs, TLS_HS_CLI_HELLO), + SIG_ALGS_CERT_EXT); + + // Should be present in signature_algorithms_cert extension. + getDisabledSignatureSchemes().forEach(ss -> + assertTrue(sigAlgsCertSS.contains(ss), + "Signature Scheme " + ss + + " isn't present in ClientHello's" + + " signature_algorithms extension")); + } + + protected void checkCertificateRequest() throws Exception { + // Get CertificateRequest message signature schemes. + List sigAlgsCertSS = getSigSchemesCertReq( + extractHandshakeMsg(sTOc, TLS_HS_CERT_REQ)); + + // Should not be present in CertificateRequest message. + getDisabledSignatureSchemes().forEach(ss -> + assertFalse(sigAlgsCertSS.contains(ss), + "Signature Scheme " + ss + + " present in CertificateRequest")); + } +} diff -Nru openjdk-17-17.0.17+10/test/jdk/sun/security/ssl/SignatureScheme/DisableSHA1inHandshakeSignatureTLS13.java openjdk-17-17.0.18+8/test/jdk/sun/security/ssl/SignatureScheme/DisableSHA1inHandshakeSignatureTLS13.java --- openjdk-17-17.0.17+10/test/jdk/sun/security/ssl/SignatureScheme/DisableSHA1inHandshakeSignatureTLS13.java 1970-01-01 00:00:00.000000000 +0000 +++ openjdk-17-17.0.18+8/test/jdk/sun/security/ssl/SignatureScheme/DisableSHA1inHandshakeSignatureTLS13.java 2026-01-15 15:23:06.000000000 +0000 @@ -0,0 +1,70 @@ +/* + * 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 8340321 + * @summary Disable SHA-1 in TLS/DTLS 1.2 signatures. + * This test only covers TLS 1.3. + * @library /javax/net/ssl/templates + * /test/lib + * @run main/othervm DisableSHA1inHandshakeSignatureTLS13 + */ + +import java.security.Security; +import java.util.List; + +public class DisableSHA1inHandshakeSignatureTLS13 extends + DisableSHA1inHandshakeSignatureTLS12 { + + protected DisableSHA1inHandshakeSignatureTLS13() throws Exception { + super(); + } + + public static void main(String[] args) throws Exception { + // SHA-1 algorithm MUST NOT be used in any TLSv1.3 handshake signatures. + // This is regardless of jdk.tls.disabledAlgorithms configuration. + Security.setProperty("jdk.tls.disabledAlgorithms", ""); + new DisableSHA1inHandshakeSignatureTLS13().run(); + } + + @Override + protected String getProtocol() { + return "TLSv1.3"; + } + + // Returns SHA-1 signature schemes NOT supported for TLSv1.3 handshake + // signatures, but supported for TLSv1.3 certificate signatures. + @Override + protected List getDisabledSignatureSchemes() { + return List.of("ecdsa_sha1", "rsa_pkcs1_sha1"); + } + + // TLSv1.3 sends CertificateRequest signature schemes in + // signature_algorithms and signature_algorithms_cert extensions. Same as + // ClientHello, but they are encrypted. So we skip CertificateRequest + // signature schemes verification for TLSv1.3. + @Override + protected void checkCertificateRequest() { + } +} diff -Nru openjdk-17-17.0.17+10/test/jdk/sun/security/ssl/SignatureScheme/SigAlgosExtTestWithTLS12.java openjdk-17-17.0.18+8/test/jdk/sun/security/ssl/SignatureScheme/SigAlgosExtTestWithTLS12.java --- openjdk-17-17.0.17+10/test/jdk/sun/security/ssl/SignatureScheme/SigAlgosExtTestWithTLS12.java 2025-10-13 07:48:04.000000000 +0000 +++ openjdk-17-17.0.18+8/test/jdk/sun/security/ssl/SignatureScheme/SigAlgosExtTestWithTLS12.java 2026-01-15 15:23:06.000000000 +0000 @@ -1,5 +1,5 @@ /* - * Copyright (C) 2021 THL A29 Limited, a Tencent company. All rights reserved. + * Copyright (C) 2021, Tencent. All rights reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * * This code is free software; you can redistribute it and/or modify it diff -Nru openjdk-17-17.0.17+10/test/jdk/sun/security/ssl/SignatureScheme/SigAlgosExtTestWithTLS13.java openjdk-17-17.0.18+8/test/jdk/sun/security/ssl/SignatureScheme/SigAlgosExtTestWithTLS13.java --- openjdk-17-17.0.17+10/test/jdk/sun/security/ssl/SignatureScheme/SigAlgosExtTestWithTLS13.java 2025-10-13 07:48:04.000000000 +0000 +++ openjdk-17-17.0.18+8/test/jdk/sun/security/ssl/SignatureScheme/SigAlgosExtTestWithTLS13.java 2026-01-15 15:23:06.000000000 +0000 @@ -1,5 +1,5 @@ /* - * Copyright (C) 2021 THL A29 Limited, a Tencent company. All rights reserved. + * Copyright (C) 2021, Tencent. All rights reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * * This code is free software; you can redistribute it and/or modify it diff -Nru openjdk-17-17.0.17+10/test/jdk/sun/security/tools/jarsigner/EC.java openjdk-17-17.0.18+8/test/jdk/sun/security/tools/jarsigner/EC.java --- openjdk-17-17.0.17+10/test/jdk/sun/security/tools/jarsigner/EC.java 2025-10-13 07:48:04.000000000 +0000 +++ openjdk-17-17.0.18+8/test/jdk/sun/security/tools/jarsigner/EC.java 2026-01-15 15:23:06.000000000 +0000 @@ -1,5 +1,5 @@ /* - * Copyright (c) 2009, 2020, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2009, 2025, Oracle and/or its affiliates. All rights reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * * This code is free software; you can redistribute it and/or modify it @@ -26,6 +26,7 @@ * @bug 6870812 * @summary enhance security tools to use ECC algorithm * @library /test/lib + * @run main/timeout=300 EC */ import jdk.test.lib.SecurityTools; diff -Nru openjdk-17-17.0.17+10/test/jdk/sun/security/tools/jarsigner/VerifyJarEntryName.java openjdk-17-17.0.18+8/test/jdk/sun/security/tools/jarsigner/VerifyJarEntryName.java --- openjdk-17-17.0.17+10/test/jdk/sun/security/tools/jarsigner/VerifyJarEntryName.java 1970-01-01 00:00:00.000000000 +0000 +++ openjdk-17-17.0.18+8/test/jdk/sun/security/tools/jarsigner/VerifyJarEntryName.java 2026-01-15 15:23:06.000000000 +0000 @@ -0,0 +1,142 @@ +/* + * 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 8339280 + * @summary Test that jarsigner -verify emits a warning when the filename of + * an entry in the LOC is changed + * @library /test/lib + * @run junit VerifyJarEntryName + */ + +import org.junit.jupiter.api.BeforeAll; +import org.junit.jupiter.api.BeforeEach; +import org.junit.jupiter.api.Test; + +import java.io.FileOutputStream; +import java.nio.charset.StandardCharsets; +import java.nio.file.Files; +import java.nio.file.Path; +import java.util.Arrays; +import java.util.jar.JarFile; +import java.util.zip.ZipEntry; +import java.util.zip.ZipOutputStream; + +import jdk.test.lib.SecurityTools; +import static org.junit.jupiter.api.Assertions.fail; + +public class VerifyJarEntryName { + + private static final Path ORIGINAL_JAR = Path.of("test.jar"); + private static final Path MODIFIED_JAR = Path.of("modified_test.jar"); + + @BeforeAll + static void setup() throws Exception { + try (FileOutputStream fos = new FileOutputStream(ORIGINAL_JAR.toFile()); + ZipOutputStream zos = new ZipOutputStream(fos)) { + zos.putNextEntry(new ZipEntry(JarFile.MANIFEST_NAME)); + zos.write("Manifest-Version: 1.0\nCreated-By: Test\n". + getBytes(StandardCharsets.UTF_8)); + zos.closeEntry(); + + // Add hello.txt file + ZipEntry textEntry = new ZipEntry("hello.txt"); + zos.putNextEntry(textEntry); + zos.write("hello".getBytes(StandardCharsets.UTF_8)); + zos.closeEntry(); + } + + SecurityTools.keytool("-genkeypair -keystore ks -storepass changeit " + + "-alias mykey -keyalg rsa -dname CN=me "); + + SecurityTools.jarsigner("-keystore ks -storepass changeit " + + ORIGINAL_JAR + " mykey") + .shouldHaveExitValue(0); + } + + @BeforeEach + void cleanup() throws Exception { + Files.deleteIfExists(MODIFIED_JAR); + } + + /* + * Modify a single byte in "MANIFEST.MF" filename in LOC, and + * validate that jarsigner -verify emits a warning message. + */ + @Test + void verifyManifestEntryName() throws Exception { + modifyJarEntryName(ORIGINAL_JAR, MODIFIED_JAR, "META-INF/MANIFEST.MF"); + SecurityTools.jarsigner("-verify -verbose " + MODIFIED_JAR) + .shouldContain("This JAR file contains internal " + + "inconsistencies that may result in different " + + "contents when reading via JarFile and JarInputStream:") + .shouldContain("- Manifest is missing when " + + "reading via JarInputStream") + .shouldHaveExitValue(0); + } + + /* + * Modify a single byte in signature filename in LOC, and + * validate that jarsigner -verify emits a warning message. + */ + @Test + void verifySignatureEntryName() throws Exception { + modifyJarEntryName(ORIGINAL_JAR, MODIFIED_JAR, "META-INF/MYKEY.SF"); + SecurityTools.jarsigner("-verify -verbose " + MODIFIED_JAR) + .shouldContain("This JAR file contains internal " + + "inconsistencies that may result in different " + + "contents when reading via JarFile and JarInputStream:") + .shouldContain("- Entry XETA-INF/MYKEY.SF is present when reading " + + "via JarInputStream but missing when reading via JarFile") + .shouldHaveExitValue(0); + } + + /* + * Validate that jarsigner -verify on a valid JAR works without + * emitting warnings about internal inconsistencies. + */ + @Test + void verifyOriginalJar() throws Exception { + SecurityTools.jarsigner("-verify -verbose " + ORIGINAL_JAR) + .shouldNotContain("This JAR file contains internal " + + "inconsistencies that may result in different contents when " + + "reading via JarFile and JarInputStream:") + .shouldHaveExitValue(0); + } + + private void modifyJarEntryName(Path origJar, Path modifiedJar, + String entryName) throws Exception { + byte[] jarBytes = Files.readAllBytes(origJar); + byte[] entryNameBytes = entryName.getBytes(StandardCharsets.UTF_8); + int pos = 0; + try { + while (!Arrays.equals(jarBytes, pos, pos + entryNameBytes.length, + entryNameBytes, 0, entryNameBytes.length)) pos++; + } catch (ArrayIndexOutOfBoundsException ignore) { + fail(entryName + " is not present in the JAR"); + } + jarBytes[pos] = 'X'; + Files.write(modifiedJar, jarBytes); + } +} diff -Nru openjdk-17-17.0.17+10/test/jdk/sun/security/util/Resources/TEST.properties openjdk-17-17.0.18+8/test/jdk/sun/security/util/Resources/TEST.properties --- openjdk-17-17.0.17+10/test/jdk/sun/security/util/Resources/TEST.properties 2025-10-13 07:48:04.000000000 +0000 +++ openjdk-17-17.0.18+8/test/jdk/sun/security/util/Resources/TEST.properties 1970-01-01 00:00:00.000000000 +0000 @@ -1,2 +0,0 @@ -# disabled till JDK-8219408 is fixed -allowSmartActionArgs=false diff -Nru openjdk-17-17.0.17+10/test/jdk/sun/security/x509/URICertStore/AIACertTimeout.java openjdk-17-17.0.18+8/test/jdk/sun/security/x509/URICertStore/AIACertTimeout.java --- openjdk-17-17.0.17+10/test/jdk/sun/security/x509/URICertStore/AIACertTimeout.java 2025-10-13 07:48:04.000000000 +0000 +++ openjdk-17-17.0.18+8/test/jdk/sun/security/x509/URICertStore/AIACertTimeout.java 2026-01-15 15:23:06.000000000 +0000 @@ -47,6 +47,7 @@ import java.io.*; import java.math.BigInteger; import java.net.InetSocketAddress; +import java.security.Security; import java.security.cert.*; import java.security.KeyPair; import java.security.KeyPairGenerator; @@ -69,6 +70,7 @@ private static X509Certificate eeCert; public static void main(String[] args) throws Exception { + Security.setProperty("com.sun.security.allowedAIALocations", "any"); int servTimeoutMsec = (args != null && args.length >= 1) ? Integer.parseInt(args[0]) : -1; boolean expectedPass = args != null && args.length >= 2 && diff -Nru openjdk-17-17.0.17+10/test/jdk/sun/security/x509/URICertStore/ExtensionsWithLDAP.java openjdk-17-17.0.18+8/test/jdk/sun/security/x509/URICertStore/ExtensionsWithLDAP.java --- openjdk-17-17.0.17+10/test/jdk/sun/security/x509/URICertStore/ExtensionsWithLDAP.java 2025-10-13 07:48:04.000000000 +0000 +++ openjdk-17-17.0.18+8/test/jdk/sun/security/x509/URICertStore/ExtensionsWithLDAP.java 2026-01-15 15:23:06.000000000 +0000 @@ -1,5 +1,5 @@ /* - * Copyright (c) 2015, 2021, 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 @@ -40,6 +40,7 @@ import java.io.IOException; import java.net.InetSocketAddress; import java.net.Socket; +import java.security.Security; import java.security.cert.CertPath; import java.security.cert.CertPathValidator; import java.security.cert.CertPathValidatorException; @@ -49,7 +50,6 @@ import java.security.cert.TrustAnchor; import java.security.cert.X509Certificate; import java.util.ArrayList; -import java.util.Arrays; import java.util.HashSet; import java.util.List; import java.util.Set; @@ -69,25 +69,27 @@ * Not After : Jan 17 18:03:59 2043 GMT * Subject: CN=Root */ - private static final String CA_CERT = "" - + "-----BEGIN CERTIFICATE-----\n" - + "MIIC8TCCAdmgAwIBAgIJAJsSNtj5wdqqMA0GCSqGSIb3DQEBDQUAMA8xDTALBgNV\n" - + "BAMMBFJvb3QwHhcNMTUwOTAxMTgwMzU5WhcNNDMwMTE3MTgwMzU5WjAPMQ0wCwYD\n" - + "VQQDDARSb290MIIBIjANBgkqhkiG9w0BAQEFAAOCAQ8AMIIBCgKCAQEAvj892vPm\n" - + "bB++x9QqqyBveP+ZqQ2B1stV7vh5JmDnOTevkZUOcemp3SXu/esNLSbpL+fARYXH\n" - + "V5ubnrfip6RbvcxPfVIIDJrRTLIIsU6W7M6/LJLbLkEVGy4ZV4IHkOw9W2O92rcv\n" - + "BkoqhzZnOTGR6uT3rRcKx4RevEKBKhZO+OPPf//lnckOybmYL7t7yQrajzHro76b\n" - + "QTXYjAUq/DKhglXfC7vF/JzlAvG2IunGmIfjGcnuDo/9X3Bxef/q5TxCS35fvb7t\n" - + "svC+g2QhTcBkQh4uNW2jSjlTIVp1uErCfP5aCjLaez5mqmb1hxPIlcvsNR23HwU6\n" - + "bQO7z7NBo9Do6QIDAQABo1AwTjAdBgNVHQ4EFgQUmLZNOBBkqdYoElyxklPYHmAb\n" - + "QXIwHwYDVR0jBBgwFoAUmLZNOBBkqdYoElyxklPYHmAbQXIwDAYDVR0TBAUwAwEB\n" - + "/zANBgkqhkiG9w0BAQ0FAAOCAQEAYV4fOhDi5q7+XNXCxO8Eil2frR9jqdP4LaQp\n" - + "3L0evW0gvPX68s2WmkPWzIu4TJcpdGFQqxyQFSXuKBXjthyiln77QItGTHWeafES\n" - + "q5ESrKdSaJZq1bTIrrReCIP74f+fY/F4Tnb3dCqzaljXfzpdbeRsIW6gF71xcOUQ\n" - + "nnPEjGVPLUegN+Wn/jQpeLxxIB7FmNXncdRUfMfZ43xVSKuMCy1UUYqJqTa/pXZj\n" - + "jCMeRPThRjRqHlJ69jStfWUQATbLyj9KN09rUaJxzmUSt61UqJi7sjcGySaCjAJc\n" - + "IcCdVmX/DmRLsdv8W36O3MgrvpT1zR3kaAlv2d8HppnBqcL3xg==\n" - + "-----END CERTIFICATE-----"; + private static final String CA_CERT = + """ + -----BEGIN CERTIFICATE----- + MIIC8TCCAdmgAwIBAgIJAJsSNtj5wdqqMA0GCSqGSIb3DQEBDQUAMA8xDTALBgNV + BAMMBFJvb3QwHhcNMTUwOTAxMTgwMzU5WhcNNDMwMTE3MTgwMzU5WjAPMQ0wCwYD + VQQDDARSb290MIIBIjANBgkqhkiG9w0BAQEFAAOCAQ8AMIIBCgKCAQEAvj892vPm + bB++x9QqqyBveP+ZqQ2B1stV7vh5JmDnOTevkZUOcemp3SXu/esNLSbpL+fARYXH + V5ubnrfip6RbvcxPfVIIDJrRTLIIsU6W7M6/LJLbLkEVGy4ZV4IHkOw9W2O92rcv + BkoqhzZnOTGR6uT3rRcKx4RevEKBKhZO+OPPf//lnckOybmYL7t7yQrajzHro76b + QTXYjAUq/DKhglXfC7vF/JzlAvG2IunGmIfjGcnuDo/9X3Bxef/q5TxCS35fvb7t + svC+g2QhTcBkQh4uNW2jSjlTIVp1uErCfP5aCjLaez5mqmb1hxPIlcvsNR23HwU6 + bQO7z7NBo9Do6QIDAQABo1AwTjAdBgNVHQ4EFgQUmLZNOBBkqdYoElyxklPYHmAb + QXIwHwYDVR0jBBgwFoAUmLZNOBBkqdYoElyxklPYHmAbQXIwDAYDVR0TBAUwAwEB + /zANBgkqhkiG9w0BAQ0FAAOCAQEAYV4fOhDi5q7+XNXCxO8Eil2frR9jqdP4LaQp + 3L0evW0gvPX68s2WmkPWzIu4TJcpdGFQqxyQFSXuKBXjthyiln77QItGTHWeafES + q5ESrKdSaJZq1bTIrrReCIP74f+fY/F4Tnb3dCqzaljXfzpdbeRsIW6gF71xcOUQ + nnPEjGVPLUegN+Wn/jQpeLxxIB7FmNXncdRUfMfZ43xVSKuMCy1UUYqJqTa/pXZj + jCMeRPThRjRqHlJ69jStfWUQATbLyj9KN09rUaJxzmUSt61UqJi7sjcGySaCjAJc + IcCdVmX/DmRLsdv8W36O3MgrvpT1zR3kaAlv2d8HppnBqcL3xg== + -----END CERTIFICATE----- + """; /* * Certificate: @@ -108,39 +110,41 @@ * Authority Information Access: * CA Issuers - URI:ldap://ldap.host.for.aia/dc=Root?cACertificate */ - private static final String EE_CERT = "" - + "-----BEGIN CERTIFICATE-----\n" - + "MIIDHTCCAgWgAwIBAgIBBzANBgkqhkiG9w0BAQ0FADAPMQ0wCwYDVQQDDARSb290\n" - + "MB4XDTE1MDkwMTE4MDM1OVoXDTQzMDExNzE4MDM1OVowDTELMAkGA1UEAwwCRUUw\n" - + "ggEiMA0GCSqGSIb3DQEBAQUAA4IBDwAwggEKAoIBAQCpyz97liuWPDYcLH9TX8Bi\n" - + "T78olCmAfmevvch6ncXUVuCzbdaKuKXwn4EVbDszsVJLoK5zdtP+X3iDhutj+IgK\n" - + "mLhuczF3M9VIcWr+JJUyTH4+3h/RT8cjCDZOmk9iXkb5ifruVsLqzb9g+Vp140Oz\n" - + "7leikne7KmclHvTfvFd0WDI7Gb9vo4f5rT717BXJ/n+M6pNk8DLpLiEu6eziYvXR\n" - + "v5x+t5Go3x0eCXdaxEQUf2j876Wfr2qHRJK7lDfFe1DDsMg/KpKGiILYZ+g2qtVM\n" - + "ZSxtp5BZEtfB5qV/IE5kWO+mCIAGpXSZIdbERR6pZUq8GLEe1T9e+sO6H24w2F19\n" - + "AgMBAAGjgYUwgYIwNAYDVR0fBC0wKzApoCegJYYjbGRhcDovL2xkYXAuaG9zdC5m\n" - + "b3IuY3JsZHAvbWFpbi5jcmwwSgYIKwYBBQUHAQEEPjA8MDoGCCsGAQUFBzAChi5s\n" - + "ZGFwOi8vbGRhcC5ob3N0LmZvci5haWEvZGM9Um9vdD9jQUNlcnRpZmljYXRlMA0G\n" - + "CSqGSIb3DQEBDQUAA4IBAQBWDfZHpuUx0yn5d3+BuztFqoks1MkGdk+USlH0TB1/\n" - + "gWWBd+4S4PCKlpSur0gj2rMW4fP5HQfNlHci8JV8/bG4KuKRAXW56dg1818Hl3pc\n" - + "iIrUSRn8uUjH3p9qb+Rb/u3mmVQRyJjN2t/zceNsO8/+Dd808OB9aEwGs8lMT0nn\n" - + "ZYaaAqYz1GIY/Ecyx1vfEZEQ1ljo6i/r70C3igbypBUShxSiGsleiVTLOGNA+MN1\n" - + "/a/Qh0bkaQyTGqK3bwvzzMeQVqWu2EWTBD/PmND5ExkpRICdv8LBVXfLnpoBr4lL\n" - + "hnxn9+e0Ah+t8dS5EKfn44w5bI5PCu2bqxs6RCTxNjcY\n" - + "-----END CERTIFICATE-----"; + private static final String EE_CERT = + """ + -----BEGIN CERTIFICATE----- + MIIDHTCCAgWgAwIBAgIBBzANBgkqhkiG9w0BAQ0FADAPMQ0wCwYDVQQDDARSb290 + MB4XDTE1MDkwMTE4MDM1OVoXDTQzMDExNzE4MDM1OVowDTELMAkGA1UEAwwCRUUw + ggEiMA0GCSqGSIb3DQEBAQUAA4IBDwAwggEKAoIBAQCpyz97liuWPDYcLH9TX8Bi + T78olCmAfmevvch6ncXUVuCzbdaKuKXwn4EVbDszsVJLoK5zdtP+X3iDhutj+IgK + mLhuczF3M9VIcWr+JJUyTH4+3h/RT8cjCDZOmk9iXkb5ifruVsLqzb9g+Vp140Oz + 7leikne7KmclHvTfvFd0WDI7Gb9vo4f5rT717BXJ/n+M6pNk8DLpLiEu6eziYvXR + v5x+t5Go3x0eCXdaxEQUf2j876Wfr2qHRJK7lDfFe1DDsMg/KpKGiILYZ+g2qtVM + ZSxtp5BZEtfB5qV/IE5kWO+mCIAGpXSZIdbERR6pZUq8GLEe1T9e+sO6H24w2F19 + AgMBAAGjgYUwgYIwNAYDVR0fBC0wKzApoCegJYYjbGRhcDovL2xkYXAuaG9zdC5m + b3IuY3JsZHAvbWFpbi5jcmwwSgYIKwYBBQUHAQEEPjA8MDoGCCsGAQUFBzAChi5s + ZGFwOi8vbGRhcC5ob3N0LmZvci5haWEvZGM9Um9vdD9jQUNlcnRpZmljYXRlMA0G + CSqGSIb3DQEBDQUAA4IBAQBWDfZHpuUx0yn5d3+BuztFqoks1MkGdk+USlH0TB1/ + gWWBd+4S4PCKlpSur0gj2rMW4fP5HQfNlHci8JV8/bG4KuKRAXW56dg1818Hl3pc + iIrUSRn8uUjH3p9qb+Rb/u3mmVQRyJjN2t/zceNsO8/+Dd808OB9aEwGs8lMT0nn + ZYaaAqYz1GIY/Ecyx1vfEZEQ1ljo6i/r70C3igbypBUShxSiGsleiVTLOGNA+MN1 + /a/Qh0bkaQyTGqK3bwvzzMeQVqWu2EWTBD/PmND5ExkpRICdv8LBVXfLnpoBr4lL + hnxn9+e0Ah+t8dS5EKfn44w5bI5PCu2bqxs6RCTxNjcY + -----END CERTIFICATE-----"""; public static void main(String[] args) throws Exception { String extension = args[0]; String targetHost = args[1]; - + Security.setProperty("com.sun.security.allowedAIALocations", + "ldap://" + targetHost + "/dc=Root"); X509Certificate trustedCert = loadCertificate(CA_CERT); X509Certificate eeCert = loadCertificate(EE_CERT); Set trustedCertsSet = new HashSet<>(); trustedCertsSet.add(new TrustAnchor(trustedCert, null)); - CertPath cp = (CertPath) CertificateFactory.getInstance("X509") - .generateCertPath(Arrays.asList(eeCert)); + CertPath cp = CertificateFactory.getInstance("X509") + .generateCertPath(List.of(eeCert)); // CertPath validator should try to parse CRLDP and AIA extensions, // and load CRLs/certs which they point to. diff -Nru openjdk-17-17.0.17+10/test/jdk/sun/security/x509/X509CertImpl/V3Certificate.java openjdk-17-17.0.18+8/test/jdk/sun/security/x509/X509CertImpl/V3Certificate.java --- openjdk-17-17.0.17+10/test/jdk/sun/security/x509/X509CertImpl/V3Certificate.java 2025-10-13 07:48:04.000000000 +0000 +++ openjdk-17-17.0.18+8/test/jdk/sun/security/x509/X509CertImpl/V3Certificate.java 2026-01-15 15:23:06.000000000 +0000 @@ -1,5 +1,5 @@ /* - * Copyright (c) 2015, 2020, 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 @@ -23,7 +23,7 @@ /* * @test - * @bug 8049237 8242151 + * @bug 8049237 8242151 8347841 * @modules java.base/sun.security.x509 * java.base/sun.security.util * jdk.crypto.ec @@ -113,7 +113,7 @@ // Validity interval Date firstDate = new Date(); - Calendar cal = Calendar.getInstance(TimeZone.getTimeZone("PST")); + Calendar cal = Calendar.getInstance(TimeZone.getTimeZone("America/Los_Angeles")); cal.set(2014, 03, 10, 12, 30, 30); Date lastDate = cal.getTime(); CertificateValidity interval = new CertificateValidity(firstDate, diff -Nru openjdk-17-17.0.17+10/test/jdk/sun/tools/jcmd/JcmdBase.java openjdk-17-17.0.18+8/test/jdk/sun/tools/jcmd/JcmdBase.java --- openjdk-17-17.0.17+10/test/jdk/sun/tools/jcmd/JcmdBase.java 2025-10-13 07:48:04.000000000 +0000 +++ openjdk-17-17.0.18+8/test/jdk/sun/tools/jcmd/JcmdBase.java 2026-01-15 15:23:06.000000000 +0000 @@ -1,5 +1,5 @@ /* - * Copyright (c) 2013, 2020, 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 @@ -102,6 +102,8 @@ launcher.addVMArg(vmArg); } } + // Some command output may be lengthy, disable streaming output to avoid deadlocks + launcher.addVMArg("-Djdk.attach.allowStreamingOutput=false"); if (requestToCurrentProcess) { launcher.addToolArg(Long.toString(ProcessTools.getProcessId())); } diff -Nru openjdk-17-17.0.17+10/test/jdk/sun/tools/jcmd/TestProcessHelper.java openjdk-17-17.0.18+8/test/jdk/sun/tools/jcmd/TestProcessHelper.java --- openjdk-17-17.0.17+10/test/jdk/sun/tools/jcmd/TestProcessHelper.java 2025-10-13 07:48:04.000000000 +0000 +++ openjdk-17-17.0.18+8/test/jdk/sun/tools/jcmd/TestProcessHelper.java 2026-01-15 15:23:06.000000000 +0000 @@ -1,5 +1,5 @@ /* - * Copyright (c) 2019, Oracle and/or its affiliates. All rights reserved. + * 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 @@ -41,10 +41,10 @@ import java.util.stream.Collectors; import java.util.stream.Stream; -import jdk.internal.module.ModuleInfoWriter; import jdk.test.lib.JDKToolFinder; import jdk.test.lib.process.ProcessTools; import jdk.test.lib.util.JarUtils; +import jdk.test.lib.util.ModuleInfoWriter; /* * @test @@ -54,10 +54,14 @@ * * @requires vm.flagless * @requires os.family == "linux" - * @library /test/lib * @modules jdk.jcmd/sun.tools.common:+open + * java.base/jdk.internal.org.objectweb.asm + * java.base/jdk.internal.org.objectweb.asm.commons * java.base/jdk.internal.module + * @library /test/lib * @build test.TestProcess + * jdk.test.lib.util.JarUtils + * jdk.test.lib.util.ModuleInfoWriter * @run main/othervm TestProcessHelper */ public class TestProcessHelper { diff -Nru openjdk-17-17.0.17+10/test/jdk/sun/util/calendar/zi/TestZoneInfo310.java openjdk-17-17.0.18+8/test/jdk/sun/util/calendar/zi/TestZoneInfo310.java --- openjdk-17-17.0.17+10/test/jdk/sun/util/calendar/zi/TestZoneInfo310.java 2025-10-13 07:48:04.000000000 +0000 +++ openjdk-17-17.0.18+8/test/jdk/sun/util/calendar/zi/TestZoneInfo310.java 2026-01-15 15:23:06.000000000 +0000 @@ -1,5 +1,5 @@ /* - * Copyright (c) 2012, 2019, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2012, 2024, Oracle and/or its affiliates. All rights reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * * This code is free software; you can redistribute it and/or modify it @@ -23,7 +23,7 @@ /* * @test - * @bug 8007572 8008161 8157792 8212970 8224560 + * @bug 8007572 8008161 8157792 8212970 8224560 8324065 * @summary Test whether the TimeZone generated from JSR310 tzdb is the same * as the one from the tz data from javazic * @modules java.base/sun.util.calendar:+open @@ -173,9 +173,9 @@ ZoneInfoOld zi = toZoneInfoOld(TimeZone.getTimeZone(zid)); ZoneInfoOld ziOLD = (ZoneInfoOld)ZoneInfoOld.getTimeZone(zid); /* - * Temporary ignoring the failing TimeZones which are having zone - * rules defined till year 2037 and/or above and have negative DST - * save time in IANA tzdata. This bug is tracked via JDK-8223388. + * Ignoring the failing TimeZones which have negative DST + * save time in IANA tzdata, as javazic/ZoneInfoOld cannot + * handle the negative DST. * * These are the zones/rules that employ negative DST in vanguard * format (as of 2019a), Palestine added in 2022d: @@ -185,11 +185,6 @@ * - Rule "Namibia" * - Rule "Palestine" * - Zone "Europe/Prague" - * - * Tehran/Iran rule has rules beyond 2037, in which javazic assumes - * to be the last year. Thus javazic's rule is based on year 2037 - * (Mar 20th/Sep 20th are the cutover dates), while the real rule - * has year 2087 where Mar 21st/Sep 21st are the cutover dates. */ if (zid.equals("Africa/Casablanca") || // uses "Morocco" rule zid.equals("Africa/El_Aaiun") || // uses "Morocco" rule @@ -198,10 +193,8 @@ zid.equals("Europe/Bratislava") || // link to "Europe/Prague" zid.equals("Europe/Dublin") || // uses "Eire" rule zid.equals("Europe/Prague") || - zid.equals("Asia/Tehran") || // last rule mismatch zid.equals("Asia/Gaza") || // uses "Palestine" rule - zid.equals("Asia/Hebron") || // uses "Palestine" rule - zid.equals("Iran")) { // last rule mismatch + zid.equals("Asia/Hebron")) { // uses "Palestine" rule continue; } if (! zi.equalsTo(ziOLD)) { diff -Nru openjdk-17-17.0.17+10/test/jdk/sun/util/calendar/zi/ZoneInfoOld.java openjdk-17-17.0.18+8/test/jdk/sun/util/calendar/zi/ZoneInfoOld.java --- openjdk-17-17.0.17+10/test/jdk/sun/util/calendar/zi/ZoneInfoOld.java 2025-10-13 07:48:04.000000000 +0000 +++ openjdk-17-17.0.18+8/test/jdk/sun/util/calendar/zi/ZoneInfoOld.java 2026-01-15 15:23:06.000000000 +0000 @@ -1,5 +1,5 @@ /* - * Copyright (c) 2000, 2018, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2000, 2024, Oracle and/or its affiliates. All rights reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * * This code is free software; you can redistribute it and/or modify it @@ -51,14 +51,14 @@ * for the {@link #getOffset(int,int,int,int,int,int) getOffset} * method that takes Gregorian calendar date fields. *

- * This table covers transitions from 1900 until 2037 (as of version - * 1.4), Before 1900, it assumes that there was no daylight saving + * This table covers transitions from 1900 until 2100 (as of version + * 23), Before 1900, it assumes that there was no daylight saving * time and the getOffset methods always return the * {@link #getRawOffset} value. No Local Mean Time is supported. If a * specified date is beyond the transition table and this time zone is - * supposed to observe daylight saving time in 2037, it delegates + * supposed to observe daylight saving time in 2100, it delegates * operations to a {@link java.util.SimpleTimeZone SimpleTimeZone} - * object created using the daylight saving time schedule as of 2037. + * object created using the daylight saving time schedule as of 2100. *

* The date items, transitions, GMT offset(s), etc. are read from a database * file. See {@link ZoneInfoFile} for details. diff -Nru openjdk-17-17.0.17+10/test/jdk/sun/util/calendar/zi/Zoneinfo.java openjdk-17-17.0.18+8/test/jdk/sun/util/calendar/zi/Zoneinfo.java --- openjdk-17-17.0.17+10/test/jdk/sun/util/calendar/zi/Zoneinfo.java 2025-10-13 07:48:04.000000000 +0000 +++ openjdk-17-17.0.18+8/test/jdk/sun/util/calendar/zi/Zoneinfo.java 2026-01-15 15:23:06.000000000 +0000 @@ -1,5 +1,5 @@ /* - * Copyright (c) 2000, 2018, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2000, 2024, Oracle and/or its affiliates. All rights reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * * This code is free software; you can redistribute it and/or modify it @@ -37,7 +37,7 @@ class Zoneinfo { private static final int minYear = 1900; - private static final int maxYear = 2037; + private static final int maxYear = 2100; private static final long minTime = Time.getLocalTime(minYear, Month.JANUARY, 1, 0); private static int startYear = minYear; private static int endYear = maxYear; diff -Nru openjdk-17-17.0.17+10/test/jdk/sun/util/logging/SourceClassName.java openjdk-17-17.0.18+8/test/jdk/sun/util/logging/SourceClassName.java --- openjdk-17-17.0.17+10/test/jdk/sun/util/logging/SourceClassName.java 2025-10-13 07:48:04.000000000 +0000 +++ openjdk-17-17.0.18+8/test/jdk/sun/util/logging/SourceClassName.java 2026-01-15 15:23:06.000000000 +0000 @@ -1,5 +1,5 @@ /* - * Copyright (c) 2010, 2016, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2010, 2025, Oracle and/or its affiliates. All rights reserved. * 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,17 +33,21 @@ * @run main/othervm SourceClassName */ +import java.util.Locale; import java.util.logging.*; import java.io.*; import sun.util.logging.PlatformLogger; public class SourceClassName { public static void main(String[] args) throws Exception { + Locale savedLocale = Locale.getDefault(); + Locale.setDefault(Locale.US); File dir = new File(System.getProperty("user.dir", ".")); File log = new File(dir, "testlog.txt"); PrintStream logps = new PrintStream(log); writeLogRecords(logps); checkLogRecords(log); + Locale.setDefault(savedLocale); } private static void writeLogRecords(PrintStream logps) throws Exception { diff -Nru openjdk-17-17.0.17+10/test/jdk/sun/util/resources/TimeZone/Bug4640234.java openjdk-17-17.0.18+8/test/jdk/sun/util/resources/TimeZone/Bug4640234.java --- openjdk-17-17.0.17+10/test/jdk/sun/util/resources/TimeZone/Bug4640234.java 2025-10-13 07:48:04.000000000 +0000 +++ openjdk-17-17.0.18+8/test/jdk/sun/util/resources/TimeZone/Bug4640234.java 2026-01-15 15:23:06.000000000 +0000 @@ -1,5 +1,5 @@ /* - * Copyright (c) 2007, 2015, 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 @@ -23,7 +23,7 @@ /** * @test - * @bug 4640234 4946057 4938151 4873691 5023181 + * @bug 4640234 4946057 4938151 4873691 5023181 8347841 * @summary Verifies the translation of time zone names, this test will catch * presence of country name for english and selected locales for all * ISO country codes. @@ -42,6 +42,8 @@ import java.text.MessageFormat; import java.text.SimpleDateFormat; +import java.time.ZoneId; +import java.util.Arrays; import java.util.Date; import java.util.Locale; import java.util.Enumeration; @@ -49,6 +51,7 @@ import java.util.Map; import java.util.ResourceBundle; import java.util.TimeZone; +import java.util.function.Predicate; import sun.util.resources.LocaleData; @@ -82,7 +85,9 @@ StringBuffer errors = new StringBuffer(""); StringBuffer warnings = new StringBuffer(""); - String[] timezones = TimeZone.getAvailableIDs(); + String[] timezones = Arrays.stream(TimeZone.getAvailableIDs()) + .filter(Predicate.not(ZoneId.SHORT_IDS::containsKey)) + .toArray(String[]::new); String[] countries = locEn.getISOCountries(); String[] languages = locEn.getISOLanguages(); diff -Nru openjdk-17-17.0.17+10/test/jdk/sun/util/resources/cldr/Bug8134384.java openjdk-17-17.0.18+8/test/jdk/sun/util/resources/cldr/Bug8134384.java --- openjdk-17-17.0.17+10/test/jdk/sun/util/resources/cldr/Bug8134384.java 2025-10-13 07:48:04.000000000 +0000 +++ openjdk-17-17.0.18+8/test/jdk/sun/util/resources/cldr/Bug8134384.java 2026-01-15 15:23:06.000000000 +0000 @@ -1,5 +1,5 @@ /* - * Copyright (c) 2015, 2020, 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 @@ -23,7 +23,7 @@ /* * @test - * @bug 8134384 8234347 8236548 + * @bug 8134384 8234347 8236548 8347841 * @summary Tests CLDR TimeZoneNames has English names for all tzids * @run main/othervm -Djava.locale.providers=CLDR Bug8134384 */ @@ -38,6 +38,9 @@ try { for (String tz : TimeZone.getAvailableIDs() ) { + if (ZoneId.SHORT_IDS.containsKey(tz)) { + continue; + } TimeZone.setDefault(TimeZone.getTimeZone(tz)); // Summer solstice String date1 = Date.from(Instant.parse("2015-06-21T00:00:00.00Z")).toString(); diff -Nru openjdk-17-17.0.17+10/test/jdk/sun/util/resources/cldr/Bug8202764.java openjdk-17-17.0.18+8/test/jdk/sun/util/resources/cldr/Bug8202764.java --- openjdk-17-17.0.17+10/test/jdk/sun/util/resources/cldr/Bug8202764.java 2025-10-13 07:48:04.000000000 +0000 +++ openjdk-17-17.0.18+8/test/jdk/sun/util/resources/cldr/Bug8202764.java 2026-01-15 15:23:06.000000000 +0000 @@ -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 @@ -23,7 +23,7 @@ /* * @test - * @bug 8202764 + * @bug 8202764 8347841 * @modules jdk.localedata * @summary Checks time zone names are consistent with aliased ids, * between DateFormatSymbols.getZoneStrings() and getDisplayName() @@ -49,6 +49,7 @@ public void testAliasedTZs() { Set zoneIds = ZoneId.getAvailableZoneIds(); Arrays.stream(DateFormatSymbols.getInstance(Locale.US).getZoneStrings()) + .filter(zone -> !ZoneId.SHORT_IDS.containsKey(zone[0])) .forEach(zone -> { System.out.println(zone[0]); TimeZone tz = TimeZone.getTimeZone(zone[0]); diff -Nru openjdk-17-17.0.17+10/test/jdk/tools/jlink/JLinkNegativeTest.java openjdk-17-17.0.18+8/test/jdk/tools/jlink/JLinkNegativeTest.java --- openjdk-17-17.0.17+10/test/jdk/tools/jlink/JLinkNegativeTest.java 2025-10-13 07:48:04.000000000 +0000 +++ openjdk-17-17.0.18+8/test/jdk/tools/jlink/JLinkNegativeTest.java 2026-01-15 15:23:06.000000000 +0000 @@ -1,5 +1,5 @@ /* - * Copyright (c) 2015, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2015, 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 @@ -28,15 +28,17 @@ * @bug 8174718 * @bug 8189671 * @author Andrei Eremeev - * @library ../lib - * @modules java.base/jdk.internal.jimage + * @modules java.base/jdk.internal.org.objectweb.asm + * java.base/jdk.internal.org.objectweb.asm.commons + * java.base/jdk.internal.jimage * java.base/jdk.internal.module * jdk.jdeps/com.sun.tools.classfile * jdk.jlink/jdk.tools.jlink.internal * jdk.jlink/jdk.tools.jmod * jdk.jlink/jdk.tools.jimage * jdk.compiler - * @build tests.* + * @library /test/lib ../lib + * @build tests.* jdk.test.lib.util.ModuleInfoWriter * @run testng JLinkNegativeTest */ @@ -48,17 +50,15 @@ import java.nio.file.FileVisitResult; import java.nio.file.Files; import java.nio.file.Path; -import java.nio.file.Paths; import java.nio.file.SimpleFileVisitor; import java.nio.file.attribute.BasicFileAttributes; import java.util.Arrays; -import java.util.Collections; import java.util.List; import java.util.Set; import java.util.jar.JarEntry; import java.util.jar.JarOutputStream; -import jdk.internal.module.ModuleInfoWriter; +import jdk.test.lib.util.ModuleInfoWriter; import org.testng.SkipException; import org.testng.annotations.BeforeClass; import org.testng.annotations.Test; diff -Nru openjdk-17-17.0.17+10/test/jdk/tools/jpackage/TEST.properties openjdk-17-17.0.18+8/test/jdk/tools/jpackage/TEST.properties --- openjdk-17-17.0.17+10/test/jdk/tools/jpackage/TEST.properties 2025-10-13 07:48:04.000000000 +0000 +++ openjdk-17-17.0.18+8/test/jdk/tools/jpackage/TEST.properties 2026-01-15 15:23:06.000000000 +0000 @@ -10,3 +10,6 @@ # } # but conditionals are not supported by jtreg configuration files. exclusiveAccess.dirs=share windows + +modules=jdk.jpackage/jdk.jpackage.internal:+open \ + java.base/jdk.internal.util diff -Nru openjdk-17-17.0.17+10/test/jdk/tools/jpackage/apps/UseShutdownHook.java openjdk-17-17.0.18+8/test/jdk/tools/jpackage/apps/UseShutdownHook.java --- openjdk-17-17.0.17+10/test/jdk/tools/jpackage/apps/UseShutdownHook.java 1970-01-01 00:00:00.000000000 +0000 +++ openjdk-17-17.0.18+8/test/jdk/tools/jpackage/apps/UseShutdownHook.java 2026-01-15 15:23:06.000000000 +0000 @@ -0,0 +1,88 @@ +/* + * 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. + */ + +import java.io.IOException; +import java.io.UncheckedIOException; +import java.nio.file.Files; +import java.nio.file.Path; +import java.nio.file.StandardOpenOption; +import java.text.SimpleDateFormat; +import java.util.Date; +import java.util.List; + +public class UseShutdownHook { + + public static void main(String[] args) throws InterruptedException { + trace("Started"); + + var outputFile = Path.of(args[0]); + trace(String.format("Write output in [%s] file", outputFile)); + + var shutdownTimeoutSeconds = Integer.parseInt(args[1]); + trace(String.format("Automatically shutdown the app in %ss", shutdownTimeoutSeconds)); + + Runtime.getRuntime().addShutdownHook(new Thread() { + @Override + public void run() { + output(outputFile, "shutdown hook executed"); + } + }); + + var startTime = System.currentTimeMillis(); + var lock = new Object(); + do { + synchronized (lock) { + lock.wait(shutdownTimeoutSeconds * 1000); + } + } while ((System.currentTimeMillis() - startTime) < (shutdownTimeoutSeconds * 1000)); + + output(outputFile, "exit"); + } + + private static void output(Path outputFilePath, String msg) { + + trace(String.format("Writing [%s] into [%s]", msg, outputFilePath)); + + try { + Files.createDirectories(outputFilePath.getParent()); + Files.writeString(outputFilePath, msg, StandardOpenOption.APPEND, StandardOpenOption.CREATE); + } catch (IOException ex) { + throw new UncheckedIOException(ex); + } + } + + private static void trace(String msg) { + Date time = new Date(System.currentTimeMillis()); + msg = String.format("UseShutdownHook [%s]: %s", SDF.format(time), msg); + System.out.println(msg); + try { + Files.write(traceFile, List.of(msg), StandardOpenOption.APPEND, StandardOpenOption.CREATE); + } catch (IOException ex) { + throw new UncheckedIOException(ex); + } + } + + private static final SimpleDateFormat SDF = new SimpleDateFormat("HH:mm:ss.SSS"); + + private static final Path traceFile = Path.of(System.getProperty("jpackage.test.trace-file")); +} diff -Nru openjdk-17-17.0.17+10/test/jdk/tools/jpackage/helpers/jdk/jpackage/test/CfgFile.java openjdk-17-17.0.18+8/test/jdk/tools/jpackage/helpers/jdk/jpackage/test/CfgFile.java --- openjdk-17-17.0.17+10/test/jdk/tools/jpackage/helpers/jdk/jpackage/test/CfgFile.java 2025-10-13 07:48:04.000000000 +0000 +++ openjdk-17-17.0.18+8/test/jdk/tools/jpackage/helpers/jdk/jpackage/test/CfgFile.java 2026-01-15 15:23:06.000000000 +0000 @@ -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 @@ -25,53 +25,115 @@ import java.io.IOException; import java.nio.file.Files; import java.nio.file.Path; +import java.util.ArrayList; import java.util.Collections; -import java.util.HashMap; +import java.util.List; import java.util.Map; import java.util.Objects; import java.util.Optional; import java.util.regex.Matcher; import java.util.regex.Pattern; +import java.util.stream.Stream; public final class CfgFile { - public String getValue(String section, String key) { - Objects.requireNonNull(section); - Objects.requireNonNull(key); - - Map entries = data.get(section); - TKit.assertTrue(entries != null, String.format( - "Check section [%s] is found in [%s] cfg file", section, id)); + public String getValue(String sectionName, String key) { + var section = getSection(sectionName); + TKit.assertTrue(section != null, String.format( + "Check section [%s] is found in [%s] cfg file", sectionName, id)); - String value = entries.get(key); + String value = section.getValue(key); TKit.assertNotNull(value, String.format( "Check key [%s] is found in [%s] section of [%s] cfg file", key, - section, id)); + sectionName, id)); return value; } - private CfgFile(Map> data, String id) { + public String getValueUnchecked(String sectionName, String key) { + var section = getSection(sectionName); + if (section != null) { + return section.getValue(key); + } else { + return null; + } + } + + public CfgFile addValue(String sectionName, String key, String value) { + var section = getSection(sectionName); + if (section == null) { + section = new Section(sectionName, new ArrayList<>()); + data.add(section); + } + section.data.add(Map.entry(key, value)); + return this; + } + + public CfgFile add(CfgFile other) { + return combine(this, other); + } + + public CfgFile() { + this(new ArrayList<>(), "*"); + } + + public static CfgFile combine(CfgFile base, CfgFile mods) { + var cfgFile = new CfgFile(new ArrayList<>(), "*"); + for (var src : List.of(base, mods)) { + for (var section : src.data) { + for (var kvp : section.data) { + cfgFile.addValue(section.name, kvp.getKey(), kvp.getValue()); + } + } + } + return cfgFile; + } + + private CfgFile(List

data, String id) { this.data = data; this.id = id; } - public static CfgFile readFromFile(Path path) throws IOException { + public CfgFile save(Path path) { + var lines = data.stream().flatMap(section -> { + return Stream.concat( + Stream.of(String.format("[%s]", section.name)), + section.data.stream().map(kvp -> { + return String.format("%s=%s", kvp.getKey(), kvp.getValue()); + })); + }); + TKit.createTextFile(path, lines); + return this; + } + + private Section getSection(String name) { + Objects.requireNonNull(name); + for (int i = data.size()-1; i >=0; i--) { + var section = data.get(i); + if (name.equals(section.name)) { + return section; + } + } + return null; + } + + public static CfgFile load(Path path) throws IOException { TKit.trace(String.format("Read [%s] jpackage cfg file", path)); final Pattern sectionBeginRegex = Pattern.compile( "\\s*\\[([^]]*)\\]\\s*"); final Pattern keyRegex = Pattern.compile( "\\s*([^=]*)=(.*)" ); - Map> result = new HashMap<>(); + List
sections = new ArrayList<>(); String currentSectionName = null; - Map currentSection = new HashMap<>(); + List> currentSection = new ArrayList<>(); for (String line : Files.readAllLines(path)) { Matcher matcher = sectionBeginRegex.matcher(line); if (matcher.find()) { if (currentSectionName != null) { - result.put(currentSectionName, Collections.unmodifiableMap( - new HashMap<>(currentSection))); + sections.add(new Section(currentSectionName, + Collections.unmodifiableList(new ArrayList<>( + currentSection)))); } currentSectionName = matcher.group(1); currentSection.clear(); @@ -80,19 +142,32 @@ matcher = keyRegex.matcher(line); if (matcher.find()) { - currentSection.put(matcher.group(1), matcher.group(2)); - continue; + currentSection.add(Map.entry(matcher.group(1), matcher.group(2))); } } if (!currentSection.isEmpty()) { - result.put(Optional.ofNullable(currentSectionName).orElse(""), - Collections.unmodifiableMap(currentSection)); + sections.add(new Section( + Optional.ofNullable(currentSectionName).orElse(""), + Collections.unmodifiableList(currentSection))); } - return new CfgFile(Collections.unmodifiableMap(result), path.toString()); + return new CfgFile(sections, path.toString()); + } + + private static record Section(String name, List> data) { + String getValue(String key) { + Objects.requireNonNull(key); + for (int i = data.size()-1; i >= 0; i--) { + var kvp = data.get(i); + if (key.equals(kvp.getKey())) { + return kvp.getValue(); + } + } + return null; + } } - private final Map> data; + private final List
data; private final String id; } diff -Nru openjdk-17-17.0.17+10/test/jdk/tools/jpackage/helpers/jdk/jpackage/test/Comm.java openjdk-17-17.0.18+8/test/jdk/tools/jpackage/helpers/jdk/jpackage/test/Comm.java --- openjdk-17-17.0.17+10/test/jdk/tools/jpackage/helpers/jdk/jpackage/test/Comm.java 1970-01-01 00:00:00.000000000 +0000 +++ openjdk-17-17.0.18+8/test/jdk/tools/jpackage/helpers/jdk/jpackage/test/Comm.java 2026-01-15 15:23:06.000000000 +0000 @@ -0,0 +1,39 @@ +/* + * Copyright (c) 2024, Oracle and/or its affiliates. All rights reserved. + * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. + * + * This code is free software; you can redistribute it and/or modify it + * under the terms of the GNU General Public License version 2 only, as + * published by the Free Software Foundation. + * + * This code is distributed in the hope that it will be useful, but WITHOUT + * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or + * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License + * version 2 for more details (a copy is included in the LICENSE file that + * accompanied this code). + * + * You should have received a copy of the GNU General Public License version + * 2 along with this work; if not, write to the Free Software Foundation, + * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. + * + * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA + * or visit www.oracle.com if you need additional information or have any + * questions. + */ +package jdk.jpackage.test; + +import java.util.HashSet; +import java.util.Set; + +record Comm(Set common, Set unique1, Set unique2) { + + static Comm compare(Set a, Set b) { + Set common = new HashSet<>(a); + common.retainAll(b); + Set unique1 = new HashSet<>(a); + unique1.removeAll(common); + Set unique2 = new HashSet<>(b); + unique2.removeAll(common); + return new Comm(common, unique1, unique2); + } +} diff -Nru openjdk-17-17.0.17+10/test/jdk/tools/jpackage/helpers/jdk/jpackage/test/Executor.java openjdk-17-17.0.18+8/test/jdk/tools/jpackage/helpers/jdk/jpackage/test/Executor.java --- openjdk-17-17.0.17+10/test/jdk/tools/jpackage/helpers/jdk/jpackage/test/Executor.java 2025-10-13 07:48:04.000000000 +0000 +++ openjdk-17-17.0.18+8/test/jdk/tools/jpackage/helpers/jdk/jpackage/test/Executor.java 2026-01-15 15:23:06.000000000 +0000 @@ -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 @@ -36,7 +36,9 @@ import java.util.HashSet; import java.util.List; import java.util.Objects; +import java.util.Optional; import java.util.Set; +import java.util.function.Supplier; import java.util.regex.Pattern; import java.util.spi.ToolProvider; import java.util.stream.Collectors; @@ -52,7 +54,7 @@ public Executor() { saveOutputType = new HashSet<>(Set.of(SaveOutputType.NONE)); - removePath = false; + winEnglishOutput = false; } public Executor setExecutable(String v) { @@ -75,6 +77,10 @@ return setToolProvider(v.asToolProvider()); } + public Optional getExecutable() { + return Optional.ofNullable(executable); + } + public Executor setDirectory(Path v) { directory = v; return this; @@ -84,8 +90,17 @@ return setExecutable(v.getPath()); } - public Executor setRemovePath(boolean value) { - removePath = value; + public Executor removeEnvVar(String envVarName) { + removeEnvVars.add(Objects.requireNonNull(envVarName)); + return this; + } + + public Executor setWinRunWithEnglishOutput(boolean value) { + if (!TKit.isWindows()) { + throw new UnsupportedOperationException( + "setWinRunWithEnglishOutput is only valid on Windows platform"); + } + winEnglishOutput = value; return this; } @@ -163,10 +178,10 @@ return this; } - public class Result { + public record Result(int exitCode, List output, Supplier cmdline) { - Result(int exitCode) { - this.exitCode = exitCode; + public Result { + Objects.requireNonNull(cmdline); } public String getFirstLineOfOutput() { @@ -177,14 +192,10 @@ return output; } - public String getPrintableCommandLine() { - return Executor.this.getPrintableCommandLine(); - } - public Result assertExitCodeIs(int expectedExitCode) { TKit.assertEquals(expectedExitCode, exitCode, String.format( "Check command %s exited with %d code", - getPrintableCommandLine(), expectedExitCode)); + cmdline.get(), expectedExitCode)); return this; } @@ -195,9 +206,6 @@ public int getExitCode() { return exitCode; } - - final int exitCode; - private List output; } public Result executeWithoutExitCodeCheck() { @@ -206,6 +214,11 @@ "Can't change directory when using tool provider"); } + if (toolProvider != null && winEnglishOutput) { + throw new IllegalArgumentException( + "Can't change locale when using tool provider"); + } + return ThrowingSupplier.toSupplier(() -> { if (toolProvider != null) { return runToolProvider(); @@ -235,18 +248,49 @@ return saveOutput().execute().getOutput(); } + private static class BadResultException extends RuntimeException { + BadResultException(Result v) { + value = v; + } + + Result getValue() { + return value; + } + + private final Result value; + } + /* * Repeates command "max" times and waits for "wait" seconds between each * execution until command returns expected error code. */ public Result executeAndRepeatUntilExitCode(int expectedCode, int max, int wait) { - Result result; + try { + return tryRunMultipleTimes(() -> { + Result result = executeWithoutExitCodeCheck(); + if (result.getExitCode() != expectedCode) { + throw new BadResultException(result); + } + return result; + }, max, wait).assertExitCodeIs(expectedCode); + } catch (BadResultException ex) { + return ex.getValue().assertExitCodeIs(expectedCode); + } + } + + /* + * Repeates a "task" "max" times and waits for "wait" seconds between each + * execution until the "task" returns without throwing an exception. + */ + public static T tryRunMultipleTimes(Supplier task, int max, int wait) { + RuntimeException lastException = null; int count = 0; do { - result = executeWithoutExitCodeCheck(); - if (result.getExitCode() == expectedCode) { - return result; + try { + return task.get(); + } catch (RuntimeException ex) { + lastException = ex; } try { @@ -258,7 +302,14 @@ count++; } while (count < max); - return result.assertExitCodeIs(expectedCode); + throw lastException; + } + + public static void tryRunMultipleTimes(Runnable task, int max, int wait) { + tryRunMultipleTimes(() -> { + task.run(); + return null; + }, max, wait); } public List executeWithoutExitCodeCheckAndGetOutput() { @@ -285,8 +336,17 @@ return executable.toAbsolutePath(); } + private List prefixCommandLineArgs() { + if (winEnglishOutput) { + return List.of("cmd.exe", "/c", "chcp", "437", ">nul", "2>&1", "&&"); + } else { + return List.of(); + } + } + private Result runExecutable() throws IOException, InterruptedException { List command = new ArrayList<>(); + command.addAll(prefixCommandLineArgs()); command.add(executablePath().toString()); command.addAll(args); ProcessBuilder builder = new ProcessBuilder(command); @@ -309,10 +369,12 @@ builder.directory(directory.toFile()); sb.append(String.format("; in directory [%s]", directory)); } - if (removePath) { - // run this with cleared Path in Environment - TKit.trace("Clearing PATH in environment"); - builder.environment().remove("PATH"); + if (!removeEnvVars.isEmpty()) { + final var envComm = Comm.compare(builder.environment().keySet(), removeEnvVars); + builder.environment().keySet().removeAll(envComm.common()); + envComm.common().forEach(envVar -> { + TKit.trace(String.format("Clearing %s in environment", envVar)); + }); } trace("Execute " + sb.toString() + "..."); @@ -343,28 +405,34 @@ } } - Result reply = new Result(process.waitFor()); - trace("Done. Exit code: " + reply.exitCode); + final int exitCode = process.waitFor(); + trace("Done. Exit code: " + exitCode); + final List output; if (outputLines != null) { - reply.output = Collections.unmodifiableList(outputLines); + output = Collections.unmodifiableList(outputLines); + } else { + output = null; } - return reply; + return createResult(exitCode, output); } - private Result runToolProvider(PrintStream out, PrintStream err) { + private int runToolProvider(PrintStream out, PrintStream err) { trace("Execute " + getPrintableCommandLine() + "..."); - Result reply = new Result(toolProvider.run(out, err, args.toArray( - String[]::new))); - trace("Done. Exit code: " + reply.exitCode); - return reply; + final int exitCode = toolProvider.run(out, err, args.toArray( + String[]::new)); + trace("Done. Exit code: " + exitCode); + return exitCode; } + private Result createResult(int exitCode, List output) { + return new Result(exitCode, output, this::getPrintableCommandLine); + } private Result runToolProvider() throws IOException { if (!withSavedOutput()) { if (saveOutputType.contains(SaveOutputType.DUMP)) { - return runToolProvider(System.out, System.err); + return createResult(runToolProvider(System.out, System.err), null); } PrintStream nullPrintStream = new PrintStream(new OutputStream() { @@ -373,36 +441,40 @@ // Nop } }); - return runToolProvider(nullPrintStream, nullPrintStream); + return createResult(runToolProvider(nullPrintStream, nullPrintStream), null); } try (ByteArrayOutputStream buf = new ByteArrayOutputStream(); PrintStream ps = new PrintStream(buf)) { - Result reply = runToolProvider(ps, ps); + final var exitCode = runToolProvider(ps, ps); ps.flush(); + final List output; try (BufferedReader bufReader = new BufferedReader(new StringReader( buf.toString()))) { if (saveOutputType.contains(SaveOutputType.FIRST_LINE)) { String firstLine = bufReader.lines().findFirst().orElse(null); if (firstLine != null) { - reply.output = List.of(firstLine); + output = List.of(firstLine); + } else { + output = null; } } else if (saveOutputType.contains(SaveOutputType.FULL)) { - reply.output = bufReader.lines().collect( - Collectors.toUnmodifiableList()); + output = bufReader.lines().collect(Collectors.toUnmodifiableList()); + } else { + output = null; } if (saveOutputType.contains(SaveOutputType.DUMP)) { Stream lines; if (saveOutputType.contains(SaveOutputType.FULL)) { - lines = reply.output.stream(); + lines = output.stream(); } else { lines = bufReader.lines(); } lines.forEach(System.out::println); } } - return reply; + return createResult(exitCode, output); } } @@ -418,15 +490,17 @@ exec = executablePath().toString(); } - return String.format(format, printCommandLine(exec, args), - args.size() + 1); + var cmdline = Stream.of(prefixCommandLineArgs(), List.of(exec), args).flatMap( + List::stream).toList(); + + return String.format(format, printCommandLine(cmdline), cmdline.size()); } - private static String printCommandLine(String executable, List args) { + private static String printCommandLine(List cmdline) { // Want command line printed in a way it can be easily copy/pasted - // to be executed manally + // to be executed manually Pattern regex = Pattern.compile("\\s"); - return Stream.concat(Stream.of(executable), args.stream()).map( + return cmdline.stream().map( v -> (v.isEmpty() || regex.matcher(v).find()) ? "\"" + v + "\"" : v).collect( Collectors.joining(" ")); } @@ -439,7 +513,8 @@ private Path executable; private Set saveOutputType; private Path directory; - private boolean removePath; + private Set removeEnvVars = new HashSet<>(); + private boolean winEnglishOutput; private String winTmpDir = null; private static enum SaveOutputType { diff -Nru openjdk-17-17.0.17+10/test/jdk/tools/jpackage/helpers/jdk/jpackage/test/Functional.java openjdk-17-17.0.18+8/test/jdk/tools/jpackage/helpers/jdk/jpackage/test/Functional.java --- openjdk-17-17.0.17+10/test/jdk/tools/jpackage/helpers/jdk/jpackage/test/Functional.java 2025-10-13 07:48:04.000000000 +0000 +++ openjdk-17-17.0.18+8/test/jdk/tools/jpackage/helpers/jdk/jpackage/test/Functional.java 2026-01-15 15:23:06.000000000 +0000 @@ -1,5 +1,5 @@ /* - * Copyright (c) 2019, 2021, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2019, 2024, Oracle and/or its affiliates. All rights reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * * This code is free software; you can redistribute it and/or modify it @@ -149,13 +149,18 @@ } @SuppressWarnings("unchecked") - public static void rethrowUnchecked(Throwable throwable) throws ExceptionBox { - if (throwable instanceof RuntimeException) { - throw (RuntimeException)throwable; + public static RuntimeException rethrowUnchecked(Throwable throwable) throws + ExceptionBox { + if (throwable instanceof RuntimeException err) { + throw err; } - if (throwable instanceof InvocationTargetException) { - throw new ExceptionBox(throwable.getCause()); + if (throwable instanceof Error err) { + throw err; + } + + if (throwable instanceof InvocationTargetException err) { + throw rethrowUnchecked(err.getCause()); } throw new ExceptionBox(throwable); diff -Nru openjdk-17-17.0.17+10/test/jdk/tools/jpackage/helpers/jdk/jpackage/test/HelloApp.java openjdk-17-17.0.18+8/test/jdk/tools/jpackage/helpers/jdk/jpackage/test/HelloApp.java --- openjdk-17-17.0.17+10/test/jdk/tools/jpackage/helpers/jdk/jpackage/test/HelloApp.java 2025-10-13 07:48:04.000000000 +0000 +++ openjdk-17-17.0.18+8/test/jdk/tools/jpackage/helpers/jdk/jpackage/test/HelloApp.java 2026-01-15 15:23:06.000000000 +0000 @@ -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 @@ -22,7 +22,6 @@ */ package jdk.jpackage.test; -import java.io.File; import java.io.IOException; import java.nio.file.Files; import java.nio.file.Path; @@ -57,15 +56,10 @@ private JarBuilder prepareSources(Path srcDir) throws IOException { final String srcClassName = appDesc.srcClassName(); - - final String qualifiedClassName = appDesc.className(); - - final String className = qualifiedClassName.substring( - qualifiedClassName.lastIndexOf('.') + 1); + final String className = appDesc.shortClassName(); final String packageName = appDesc.packageName(); - final Path srcFile = srcDir.resolve(Path.of(String.join( - File.separator, qualifiedClassName.split("\\.")) + ".java")); + final Path srcFile = srcDir.resolve(appDesc.classNameAsPath(".java")); Files.createDirectories(srcFile.getParent()); JarBuilder jarBuilder = createJarBuilder().addSourceFile(srcFile); @@ -317,20 +311,23 @@ public static void executeLauncherAndVerifyOutput(JPackageCommand cmd, String... args) { - AppOutputVerifier av = getVerifier(cmd, args); + AppOutputVerifier av = assertMainLauncher(cmd, args); if (av != null) { - // when running app launchers, clear users environment - av.executeAndVerifyOutput(true, args); + av.executeAndVerifyOutput(args); } } public static Executor.Result executeLauncher(JPackageCommand cmd, String... args) { - AppOutputVerifier av = getVerifier(cmd, args); - return av.executeOnly(true, args); + AppOutputVerifier av = assertMainLauncher(cmd, args); + if (av != null) { + return av.saveOutput(true).execute(args); + } else { + return null; + } } - private static AppOutputVerifier getVerifier(JPackageCommand cmd, + public static AppOutputVerifier assertMainLauncher(JPackageCommand cmd, String... args) { final Path launcherPath = cmd.appLauncherPath(); if (!cmd.canRunLauncher(String.format("Not running [%s] launcher", @@ -348,7 +345,7 @@ } - public final static class AppOutputVerifier { + public static final class AppOutputVerifier { AppOutputVerifier(Path helloAppLauncher) { this.launcherPath = helloAppLauncher; this.outputFilePath = TKit.workDir().resolve(OUTPUT_FILENAME); @@ -356,6 +353,16 @@ this.defaultLauncherArgs = new ArrayList<>(); } + public AppOutputVerifier saveOutput(boolean v) { + saveOutput = v; + return this; + } + + public AppOutputVerifier expectedExitCode(int v) { + expectedExitCode = v; + return this; + } + public AppOutputVerifier addDefaultArguments(String... v) { return addDefaultArguments(List.of(v)); } @@ -372,6 +379,8 @@ outputFilePath = Path.of(value); } else if ("jpackage.test.exitCode".equals(name)) { expectedExitCode = Integer.parseInt(value); + } else if ("jpackage.test.noexit".equals(name)) { + launcherNoExit = Boolean.parseBoolean(value); } return this; } @@ -415,36 +424,16 @@ } public void executeAndVerifyOutput(String... args) { - executeAndVerifyOutput(false, args); - } - - public void executeAndVerifyOutput(boolean removePath, - List launcherArgs, List appArgs) { - final int attempts = 3; - final int waitBetweenAttemptsSeconds = 5; - getExecutor(launcherArgs.toArray(new String[0])).dumpOutput().setRemovePath( - removePath).executeAndRepeatUntilExitCode(expectedExitCode, - attempts, waitBetweenAttemptsSeconds); - verifyOutputFile(outputFilePath, appArgs, params); + execute(args); + verifyOutput(args); } - public void executeAndVerifyOutput(boolean removePath, String... args) { - final List launcherArgs = List.of(args); - final List appArgs; - if (launcherArgs.isEmpty()) { - appArgs = defaultLauncherArgs; + public Executor.Result execute(String... args) { + if (launcherNoExit) { + return getExecutor(args).executeWithoutExitCodeCheck(); } else { - appArgs = launcherArgs; + return HelloApp.execute(expectedExitCode, getExecutor(args)); } - - executeAndVerifyOutput(removePath, launcherArgs, appArgs); - } - - public Executor.Result executeOnly(boolean removePath, String...args) { - return getExecutor(args) - .saveOutput() - .setRemovePath(removePath) - .executeWithoutExitCodeCheck(); } private Executor getExecutor(String...args) { @@ -462,12 +451,18 @@ } final List launcherArgs = List.of(args); - return new Executor() + final var executor = new Executor() .setDirectory(outputFile.getParent()) + .saveOutput(saveOutput) + .dumpOutput() .setExecutable(executablePath) - .addArguments(launcherArgs); + .addArguments(List.of(args)); + + return configureEnvironment(executor); } + private boolean launcherNoExit; + private boolean saveOutput; private final Path launcherPath; private Path outputFilePath; private int expectedExitCode; @@ -479,13 +474,39 @@ return new AppOutputVerifier(helloAppLauncher); } - final static String OUTPUT_FILENAME = "appOutput.txt"; + public static Executor.Result configureAndExecute(int expectedExitCode, Executor executor) { + return execute(expectedExitCode, configureEnvironment(executor)); + } + + private static Executor.Result execute(int expectedExitCode, Executor executor) { + if (TKit.isLinux()) { + final int attempts = 3; + final int waitBetweenAttemptsSeconds = 5; + return executor.executeAndRepeatUntilExitCode(expectedExitCode, attempts, + waitBetweenAttemptsSeconds); + } else { + return executor.execute(expectedExitCode); + } + } + + private static Executor configureEnvironment(Executor executor) { + if (CLEAR_JAVA_ENV_VARS) { + executor.removeEnvVar("JAVA_TOOL_OPTIONS"); + executor.removeEnvVar("_JAVA_OPTIONS"); + } + return executor; + } + + static final String OUTPUT_FILENAME = "appOutput.txt"; private final JavaAppDesc appDesc; private static final Path HELLO_JAVA = TKit.TEST_SRC_ROOT.resolve( "apps/Hello.java"); - private final static String CLASS_NAME = HELLO_JAVA.getFileName().toString().split( + private static final String CLASS_NAME = HELLO_JAVA.getFileName().toString().split( "\\.", 2)[0]; + + private static final boolean CLEAR_JAVA_ENV_VARS = Optional.ofNullable( + TKit.getConfigProperty("clear-app-launcher-java-env-vars")).map(Boolean::parseBoolean).orElse(false); } diff -Nru openjdk-17-17.0.17+10/test/jdk/tools/jpackage/helpers/jdk/jpackage/test/JPackageCommand.java openjdk-17-17.0.18+8/test/jdk/tools/jpackage/helpers/jdk/jpackage/test/JPackageCommand.java --- openjdk-17-17.0.17+10/test/jdk/tools/jpackage/helpers/jdk/jpackage/test/JPackageCommand.java 2025-10-13 07:48:04.000000000 +0000 +++ openjdk-17-17.0.18+8/test/jdk/tools/jpackage/helpers/jdk/jpackage/test/JPackageCommand.java 2026-01-15 15:23:06.000000000 +0000 @@ -57,7 +57,7 @@ * anything. The simplest is to compile test application and pack in a jar for * use on jpackage command line. */ -public final class JPackageCommand extends CommandArguments { +public class JPackageCommand extends CommandArguments { public JPackageCommand() { prerequisiteActions = new Actions(); @@ -570,8 +570,18 @@ } public boolean isFakeRuntime(String msg) { - Path runtimeDir = appRuntimeDirectory(); + if (isFakeRuntime()) { + // Fake runtime + Path runtimeDir = appRuntimeDirectory(); + TKit.trace(String.format( + "%s because application runtime directory [%s] is incomplete", + msg, runtimeDir)); + return true; + } + return false; + } + private boolean isFakeRuntime() { final Collection criticalRuntimeFiles; if (TKit.isWindows()) { criticalRuntimeFiles = WindowsHelper.CRITICAL_RUNTIME_FILES; @@ -583,16 +593,9 @@ throw TKit.throwUnknownPlatformError(); } - if (!criticalRuntimeFiles.stream().anyMatch(v -> { - return runtimeDir.resolve(v).toFile().exists(); - })) { - // Fake runtime - TKit.trace(String.format( - "%s because application runtime directory [%s] is incomplete", - msg, runtimeDir)); - return true; - } - return false; + Path runtimeDir = appRuntimeDirectory(); + return !criticalRuntimeFiles.stream().map(runtimeDir::resolve).allMatch( + Files::exists); } public boolean canRunLauncher(String msg) { @@ -657,6 +660,13 @@ return this; } + public JPackageCommand ignoreFakeRuntime() { + if (isFakeRuntime()) { + ignoreDefaultRuntime(true); + } + return this; + } + public JPackageCommand ignoreDefaultVerbose(boolean v) { verifyMutable(); ignoreDefaultVerbose = v; @@ -733,7 +743,7 @@ .createExecutor() .execute(expectedExitCode); - if (result.exitCode == 0) { + if (result.exitCode() == 0) { executeVerifyActions(); } @@ -876,7 +886,7 @@ if (isRuntime()) { return null; } - return ThrowingFunction.toFunction(CfgFile::readFromFile).apply( + return ThrowingFunction.toFunction(CfgFile::load).apply( appLauncherCfgPath(launcherName)); } diff -Nru openjdk-17-17.0.17+10/test/jdk/tools/jpackage/helpers/jdk/jpackage/test/JavaAppDesc.java openjdk-17-17.0.18+8/test/jdk/tools/jpackage/helpers/jdk/jpackage/test/JavaAppDesc.java --- openjdk-17-17.0.17+10/test/jdk/tools/jpackage/helpers/jdk/jpackage/test/JavaAppDesc.java 2025-10-13 07:48:04.000000000 +0000 +++ openjdk-17-17.0.18+8/test/jdk/tools/jpackage/helpers/jdk/jpackage/test/JavaAppDesc.java 2026-01-15 15:23:06.000000000 +0000 @@ -22,8 +22,9 @@ */ package jdk.jpackage.test; -import java.io.File; import java.nio.file.Path; +import java.util.Objects; +import java.util.stream.Stream; public final class JavaAppDesc { @@ -73,9 +74,18 @@ return qualifiedClassName; } + public String shortClassName() { + return qualifiedClassName.substring(qualifiedClassName.lastIndexOf('.') + 1); + } + + Path classNameAsPath(String extension) { + final String[] pathComponents = qualifiedClassName.split("\\."); + pathComponents[pathComponents.length - 1] = shortClassName() + extension; + return Stream.of(pathComponents).map(Path::of).reduce(Path::resolve).get(); + } + public Path classFilePath() { - return Path.of(qualifiedClassName.replace(".", File.separator) - + ".class"); + return classNameAsPath(".class"); } public String moduleName() { @@ -125,6 +135,48 @@ } @Override + public int hashCode() { + int hash = 5; + hash = 79 * hash + Objects.hashCode(this.srcJavaPath); + hash = 79 * hash + Objects.hashCode(this.qualifiedClassName); + hash = 79 * hash + Objects.hashCode(this.moduleName); + hash = 79 * hash + Objects.hashCode(this.bundleFileName); + hash = 79 * hash + Objects.hashCode(this.moduleVersion); + hash = 79 * hash + (this.withMainClass ? 1 : 0); + return hash; + } + + @Override + public boolean equals(Object obj) { + if (this == obj) { + return true; + } + if (obj == null) { + return false; + } + if (getClass() != obj.getClass()) { + return false; + } + final JavaAppDesc other = (JavaAppDesc) obj; + if (this.withMainClass != other.withMainClass) { + return false; + } + if (!Objects.equals(this.qualifiedClassName, other.qualifiedClassName)) { + return false; + } + if (!Objects.equals(this.moduleName, other.moduleName)) { + return false; + } + if (!Objects.equals(this.bundleFileName, other.bundleFileName)) { + return false; + } + if (!Objects.equals(this.moduleVersion, other.moduleVersion)) { + return false; + } + return Objects.equals(this.srcJavaPath, other.srcJavaPath); + } + + @Override public String toString() { StringBuilder sb = new StringBuilder(); if (srcJavaPath != null) { @@ -216,7 +268,9 @@ components[0].length() - 1); desc.setWithMainClass(true); } - desc.setClassName(components[0]); + if (!components[0].isEmpty()) { + desc.setClassName(components[0]); + } if (components.length == 2) { desc.setModuleVersion(components[1]); } diff -Nru openjdk-17-17.0.17+10/test/jdk/tools/jpackage/helpers/jdk/jpackage/test/LauncherIconVerifier.java openjdk-17-17.0.18+8/test/jdk/tools/jpackage/helpers/jdk/jpackage/test/LauncherIconVerifier.java --- openjdk-17-17.0.17+10/test/jdk/tools/jpackage/helpers/jdk/jpackage/test/LauncherIconVerifier.java 2025-10-13 07:48:04.000000000 +0000 +++ openjdk-17-17.0.18+8/test/jdk/tools/jpackage/helpers/jdk/jpackage/test/LauncherIconVerifier.java 2026-01-15 15:23:06.000000000 +0000 @@ -1,5 +1,5 @@ /* - * Copyright (c) 2019, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2019, 2022, Oracle and/or its affiliates. All rights reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * * This code is free software; you can redistribute it and/or modify it @@ -23,9 +23,14 @@ package jdk.jpackage.test; +import java.awt.image.BufferedImage; import java.io.IOException; +import java.lang.reflect.InvocationTargetException; +import java.lang.reflect.Method; import java.nio.file.Files; import java.nio.file.Path; +import java.util.Optional; +import javax.imageio.ImageIO; public final class LauncherIconVerifier { public LauncherIconVerifier() { @@ -60,7 +65,11 @@ Path iconPath = cmd.appLayout().destktopIntegrationDirectory().resolve( curLauncherName + TKit.ICON_SUFFIX); - if (expectedDefault) { + if (TKit.isWindows()) { + TKit.assertPathExists(iconPath, false); + WinIconVerifier.instance.verifyLauncherIcon(cmd, launcherName, + expectedIcon, expectedDefault); + } else if (expectedDefault) { TKit.assertPathExists(iconPath, true); } else if (expectedIcon == null) { TKit.assertPathExists(iconPath, false); @@ -73,6 +82,179 @@ } } + private static class WinIconVerifier { + + void verifyLauncherIcon(JPackageCommand cmd, String launcherName, + Path expectedIcon, boolean expectedDefault) { + TKit.withTempDirectory("icons", tmpDir -> { + Path launcher = cmd.appLauncherPath(launcherName); + Path iconWorkDir = tmpDir.resolve(launcher.getFileName()); + Path iconContainer = iconWorkDir.resolve("container.exe"); + Files.createDirectories(iconContainer.getParent()); + Files.copy(getDefaultAppLauncher(expectedIcon == null + && !expectedDefault), iconContainer); + if (expectedIcon != null) { + Executor.tryRunMultipleTimes(() -> { + setIcon(expectedIcon, iconContainer); + }, 3, 5); + } + + Path extractedExpectedIcon = extractIconFromExecutable( + iconWorkDir, iconContainer, "expected"); + Path extractedActualIcon = extractIconFromExecutable(iconWorkDir, + launcher, "actual"); + + TKit.trace(String.format( + "Check icon file [%s] of %s launcher is a copy of source icon file [%s]", + extractedActualIcon, + Optional.ofNullable(launcherName).orElse("main"), + extractedExpectedIcon)); + + if (Files.mismatch(extractedExpectedIcon, extractedActualIcon) + != -1) { + // On Windows11 .NET API extracting icons from executables + // produce slightly different output for the same icon. + // To workaround it, compare pixels of images and if the + // number of off pixels is below a threshold, assume + // equality. + BufferedImage expectedImg = ImageIO.read( + extractedExpectedIcon.toFile()); + BufferedImage actualImg = ImageIO.read( + extractedActualIcon.toFile()); + + int w = expectedImg.getWidth(); + int h = expectedImg.getHeight(); + + TKit.assertEquals(w, actualImg.getWidth(), + "Check expected and actual icons have the same width"); + TKit.assertEquals(h, actualImg.getHeight(), + "Check expected and actual icons have the same height"); + + int diffPixelCount = 0; + + for (int i = 0; i != w; ++i) { + for (int j = 0; j != h; ++j) { + int expectedRGB = expectedImg.getRGB(i, j); + int actualRGB = actualImg.getRGB(i, j); + + if (expectedRGB != actualRGB) { + TKit.trace(String.format( + "Images mismatch at [%d, %d] pixel", i, + j)); + diffPixelCount++; + } + } + } + + double threshold = 0.1; + TKit.assertTrue(((double) diffPixelCount) / (w * h) + < threshold, + String.format( + "Check the number of mismatched pixels [%d] of [%d] is < [%f] threshold", + diffPixelCount, (w * h), threshold)); + } + }); + } + + private WinIconVerifier() { + try { + executableRebranderClass = Class.forName( + "jdk.jpackage.internal.ExecutableRebrander"); + + lockResource = executableRebranderClass.getDeclaredMethod( + "lockResource", String.class); + // Note: this reflection call requires + // --add-opens jdk.jpackage/jdk.jpackage.internal=ALL-UNNAMED + lockResource.setAccessible(true); + + unlockResource = executableRebranderClass.getDeclaredMethod( + "unlockResource", long.class); + unlockResource.setAccessible(true); + + iconSwap = executableRebranderClass.getDeclaredMethod("iconSwap", + long.class, String.class); + iconSwap.setAccessible(true); + } catch (ClassNotFoundException | NoSuchMethodException + | SecurityException ex) { + throw Functional.rethrowUnchecked(ex); + } + } + + private Path extractIconFromExecutable(Path outputDir, Path executable, + String label) { + Path extractedIcon = outputDir.resolve(label + ".bmp"); + String script = String.join(";", + "[System.Reflection.Assembly]::LoadWithPartialName('System.Drawing')", + String.format( + "[System.Drawing.Icon]::ExtractAssociatedIcon('%s').ToBitmap().Save('%s', [System.Drawing.Imaging.ImageFormat]::Bmp)", + executable.toAbsolutePath().normalize(), + extractedIcon.toAbsolutePath().normalize())); + + Executor.of("powershell", "-NoLogo", "-NoProfile", "-Command", + script).execute(); + + return extractedIcon; + } + + private Path getDefaultAppLauncher(boolean noIcon) { + // Create app image with the sole purpose to get the default app launcher + Path defaultAppOutputDir = TKit.workDir().resolve(String.format( + "out-%d", ProcessHandle.current().pid())); + JPackageCommand cmd = JPackageCommand.helloAppImage().setFakeRuntime().setArgumentValue( + "--dest", defaultAppOutputDir); + + String launcherName; + if (noIcon) { + launcherName = "no-icon"; + new AdditionalLauncher(launcherName).setNoIcon().applyTo(cmd); + } else { + launcherName = null; + } + + if (!Files.isExecutable(cmd.appLauncherPath(launcherName))) { + cmd.execute(); + } + return cmd.appLauncherPath(launcherName); + } + + private void setIcon(Path iconPath, Path launcherPath) { + TKit.trace(String.format("Set icon of [%s] launcher to [%s] file", + launcherPath, iconPath)); + try { + launcherPath.toFile().setWritable(true, true); + try { + long lock = 0; + try { + lock = (Long) lockResource.invoke(null, new Object[]{ + launcherPath.toAbsolutePath().normalize().toString()}); + if (lock == 0) { + throw new RuntimeException(String.format( + "Failed to lock [%s] executable", + launcherPath)); + } + iconSwap.invoke(null, new Object[]{lock, + iconPath.toAbsolutePath().normalize().toString()}); + } finally { + if (lock != 0) { + unlockResource.invoke(null, new Object[]{lock}); + } + } + } catch (IllegalAccessException | InvocationTargetException ex) { + throw Functional.rethrowUnchecked(ex); + } + } finally { + launcherPath.toFile().setWritable(false, true); + } + } + + final static WinIconVerifier instance = new WinIconVerifier(); + + private final Class executableRebranderClass; + private final Method lockResource; + private final Method unlockResource; + private final Method iconSwap; + } + private String launcherName; private Path expectedIcon; private boolean expectedDefault; diff -Nru openjdk-17-17.0.17+10/test/jdk/tools/jpackage/helpers/jdk/jpackage/test/PackageTest.java openjdk-17-17.0.18+8/test/jdk/tools/jpackage/helpers/jdk/jpackage/test/PackageTest.java --- openjdk-17-17.0.17+10/test/jdk/tools/jpackage/helpers/jdk/jpackage/test/PackageTest.java 2025-10-13 07:48:04.000000000 +0000 +++ openjdk-17-17.0.18+8/test/jdk/tools/jpackage/helpers/jdk/jpackage/test/PackageTest.java 2026-01-15 15:23:06.000000000 +0000 @@ -24,10 +24,10 @@ import java.awt.Desktop; import java.awt.GraphicsEnvironment; -import java.io.File; import java.io.IOException; import java.nio.file.Files; import java.nio.file.Path; +import java.time.Duration; import java.util.ArrayList; import java.util.Collection; import java.util.Collections; @@ -271,7 +271,7 @@ TKit.trace(String.format("Use desktop to open [%s] file", testFile)); Desktop.getDesktop().open(testFile.toFile()); - TKit.waitForFileCreated(appOutput, 7); + TKit.waitForFileCreated(appOutput, Duration.ofSeconds(7), Duration.ofSeconds(3)); List expectedArgs = new ArrayList<>(List.of( faLauncherDefaultArgs)); @@ -709,7 +709,7 @@ private Set namedInitializers; private Map packageHandlers; - private final static File BUNDLE_OUTPUT_DIR; + private static final Path BUNDLE_OUTPUT_DIR; static { final String propertyName = "output"; @@ -717,9 +717,9 @@ if (val == null) { BUNDLE_OUTPUT_DIR = null; } else { - BUNDLE_OUTPUT_DIR = new File(val).getAbsoluteFile(); + BUNDLE_OUTPUT_DIR = Path.of(val).toAbsolutePath(); - if (!BUNDLE_OUTPUT_DIR.isDirectory()) { + if (!Files.isDirectory(BUNDLE_OUTPUT_DIR)) { throw new IllegalArgumentException(String.format("Invalid value of %s sytem property: [%s]. Should be existing directory", TKit.getConfigPropertyName(propertyName), BUNDLE_OUTPUT_DIR)); diff -Nru openjdk-17-17.0.17+10/test/jdk/tools/jpackage/helpers/jdk/jpackage/test/TKit.java openjdk-17-17.0.18+8/test/jdk/tools/jpackage/helpers/jdk/jpackage/test/TKit.java --- openjdk-17-17.0.17+10/test/jdk/tools/jpackage/helpers/jdk/jpackage/test/TKit.java 2025-10-13 07:48:04.000000000 +0000 +++ openjdk-17-17.0.18+8/test/jdk/tools/jpackage/helpers/jdk/jpackage/test/TKit.java 2026-01-15 15:23:06.000000000 +0000 @@ -22,7 +22,6 @@ */ package jdk.jpackage.test; -import java.io.File; import java.io.FileOutputStream; import java.io.IOException; import java.io.PrintStream; @@ -36,13 +35,16 @@ import static java.nio.file.StandardWatchEventKinds.ENTRY_MODIFY; import java.nio.file.WatchEvent; import java.nio.file.WatchKey; -import java.nio.file.WatchService; import java.text.SimpleDateFormat; +import java.time.Duration; +import java.time.Instant; import java.util.ArrayList; +import java.util.Arrays; import java.util.Collection; import java.util.Collections; import java.util.Comparator; import java.util.Date; +import java.util.HashSet; import java.util.Iterator; import java.util.List; import java.util.Map; @@ -55,13 +57,14 @@ import java.util.function.Predicate; import java.util.function.Supplier; import java.util.stream.Collectors; +import static java.util.stream.Collectors.toSet; import java.util.stream.Stream; import jdk.jpackage.test.Functional.ExceptionBox; import jdk.jpackage.test.Functional.ThrowingConsumer; import jdk.jpackage.test.Functional.ThrowingRunnable; import jdk.jpackage.test.Functional.ThrowingSupplier; -final public class TKit { +public final class TKit { private static final String OS = System.getProperty("os.name").toLowerCase(); @@ -82,7 +85,7 @@ return TEST_SRC_ROOT.resolve("../../../../src/jdk.jpackage").normalize().toAbsolutePath(); }).get(); - public final static String ICON_SUFFIX = Functional.identity(() -> { + public static final String ICON_SUFFIX = Functional.identity(() -> { if (isOSX()) { return ".icns"; } @@ -103,14 +106,21 @@ ThrowingRunnable.toRunnable(action).run(); } else { try (PrintStream logStream = openLogStream()) { - extraLogStream = logStream; - ThrowingRunnable.toRunnable(action).run(); - } finally { - extraLogStream = null; + withExtraLogStream(action, logStream); } } } + static void withExtraLogStream(ThrowingRunnable action, PrintStream logStream) { + var oldExtraLogStream = extraLogStream; + try { + extraLogStream = logStream; + ThrowingRunnable.toRunnable(action).run(); + } finally { + extraLogStream = oldExtraLogStream; + } + } + static void runTests(List tests) { if (currentTest != null) { throw new IllegalStateException( @@ -183,11 +193,7 @@ } public static boolean isLinuxAPT() { - if (!isLinux()) { - return false; - } - File aptFile = new File("/usr/bin/apt-get"); - return aptFile.exists(); + return isLinux() && Files.exists(Path.of("/usr/bin/apt-get")); } private static String addTimestamp(String msg) { @@ -237,6 +243,13 @@ trace("Done"); } + public static void traceFileContents(Path path, String label) throws IOException { + assertFileExists(path); + trace(String.format("Dump [%s] %s...", path, label)); + Files.readAllLines(path).forEach(TKit::trace); + trace("Done"); + } + public static void createPropertiesFile(Path propsFilename, Map.Entry... props) { createPropertiesFile(propsFilename, List.of(props)); @@ -264,6 +277,22 @@ throw new AssertionError(v); } + static void assertAssert(boolean expectedSuccess, Runnable runnable) { + try { + runnable.run(); + } catch (AssertionError err) { + if (expectedSuccess) { + assertUnexpected("Assertion failed"); + } else { + return; + } + } + + if (!expectedSuccess) { + assertUnexpected("Assertion passed"); + } + } + private final static String TEMP_FILE_PREFIX = null; private static Path createUniqueFileName(String defaultName) { @@ -500,49 +529,57 @@ return file; } - static void waitForFileCreated(Path fileToWaitFor, - long timeoutSeconds) throws IOException { + public static void waitForFileCreated(Path fileToWaitFor, + Duration timeout, Duration afterCreatedTimeout) throws IOException { + waitForFileCreated(fileToWaitFor, timeout); + // Wait after the file has been created to ensure it is fully written. + ThrowingConsumer.toConsumer(Thread::sleep).accept(afterCreatedTimeout.getSeconds()); + } + + private static void waitForFileCreated(Path fileToWaitFor, Duration timeout) throws IOException { trace(String.format("Wait for file [%s] to be available", fileToWaitFor.toAbsolutePath())); - WatchService ws = FileSystems.getDefault().newWatchService(); - - Path watchDirectory = fileToWaitFor.toAbsolutePath().getParent(); - watchDirectory.register(ws, ENTRY_CREATE, ENTRY_MODIFY); + try (var ws = FileSystems.getDefault().newWatchService()) { - long waitUntil = System.currentTimeMillis() + timeoutSeconds * 1000; - for (;;) { - long timeout = waitUntil - System.currentTimeMillis(); - assertTrue(timeout > 0, String.format( - "Check timeout value %d is positive", timeout)); + Path watchDirectory = fileToWaitFor.toAbsolutePath().getParent(); + watchDirectory.register(ws, ENTRY_CREATE, ENTRY_MODIFY); - WatchKey key = ThrowingSupplier.toSupplier(() -> ws.poll(timeout, - TimeUnit.MILLISECONDS)).get(); - if (key == null) { - if (fileToWaitFor.toFile().exists()) { - trace(String.format( - "File [%s] is available after poll timeout expired", - fileToWaitFor)); - return; + var waitUntil = Instant.now().plus(timeout); + for (;;) { + Instant n = Instant.now(); + Duration remainderTimeout = Duration.between(n, waitUntil); + assertTrue(!remainderTimeout.isNegative() && !remainderTimeout.isZero(), String.format( + "Check timeout value %dms is positive", remainderTimeout.toMillis())); + + WatchKey key = ThrowingSupplier.toSupplier(() -> { + return ws.poll(remainderTimeout.toMillis(), TimeUnit.MILLISECONDS); + }).get(); + if (key == null) { + if (Files.exists(fileToWaitFor)) { + trace(String.format( + "File [%s] is available after poll timeout expired", + fileToWaitFor)); + return; + } + assertUnexpected(String.format("Timeout %dms expired", remainderTimeout.toMillis())); } - assertUnexpected(String.format("Timeout expired", timeout)); - } - for (WatchEvent event : key.pollEvents()) { - if (event.kind() == StandardWatchEventKinds.OVERFLOW) { - continue; - } - Path contextPath = (Path) event.context(); - if (Files.isSameFile(watchDirectory.resolve(contextPath), - fileToWaitFor)) { - trace(String.format("File [%s] is available", fileToWaitFor)); - return; + for (WatchEvent event : key.pollEvents()) { + if (event.kind() == StandardWatchEventKinds.OVERFLOW) { + continue; + } + Path contextPath = (Path) event.context(); + if (Files.exists(fileToWaitFor) && Files.isSameFile(watchDirectory.resolve(contextPath), fileToWaitFor)) { + trace(String.format("File [%s] is available", fileToWaitFor)); + return; + } } - } - if (!key.reset()) { - assertUnexpected("Watch key invalidated"); + if (!key.reset()) { + assertUnexpected("Watch key invalidated"); + } } } } @@ -569,7 +606,7 @@ msg)); } - traceAssert(String.format("assertEquals(%d): %s", expected, msg)); + traceAssert(concatMessages(String.format("assertEquals(%d)", expected), msg)); } public static void assertNotEquals(long expected, long actual, String msg) { @@ -579,8 +616,8 @@ msg)); } - traceAssert(String.format("assertNotEquals(%d, %d): %s", expected, - actual, msg)); + traceAssert(concatMessages(String.format("assertNotEquals(%d, %d)", expected, + actual), msg)); } public static void assertEquals(String expected, String actual, String msg) { @@ -592,7 +629,7 @@ msg)); } - traceAssert(String.format("assertEquals(%s): %s", expected, msg)); + traceAssert(concatMessages(String.format("assertEquals(%s)", expected), msg)); } public static void assertNotEquals(String expected, String actual, String msg) { @@ -600,8 +637,8 @@ if ((actual != null && !actual.equals(expected)) || (expected != null && !expected.equals(actual))) { - traceAssert(String.format("assertNotEquals(%s, %s): %s", expected, - actual, msg)); + traceAssert(concatMessages(String.format("assertNotEquals(%s, %s)", expected, + actual), msg)); return; } @@ -615,7 +652,7 @@ value), msg)); } - traceAssert(String.format("assertNull(): %s", msg)); + traceAssert(concatMessages("assertNull()", msg)); } public static void assertNotNull(Object value, String msg) { @@ -624,7 +661,7 @@ error(concatMessages("Unexpected null value", msg)); } - traceAssert(String.format("assertNotNull(%s): %s", value, msg)); + traceAssert(concatMessages(String.format("assertNotNull(%s)", value), msg)); } public static void assertTrue(boolean actual, String msg) { @@ -644,7 +681,7 @@ error(concatMessages("Failed", msg)); } - traceAssert(String.format("assertTrue(): %s", msg)); + traceAssert(concatMessages("assertTrue()", msg)); } public static void assertFalse(boolean actual, String msg, Runnable onFail) { @@ -656,7 +693,7 @@ error(concatMessages("Failed", msg)); } - traceAssert(String.format("assertFalse(): %s", msg)); + traceAssert(concatMessages("assertFalse()", msg)); } public static void assertPathExists(Path path, boolean exists) { @@ -723,11 +760,80 @@ error(concatMessages("Unexpected", msg)); } + public static DirectoryContentVerifier assertDirectoryContent(Path dir) { + return new DirectoryContentVerifier(dir); + } + public static final class DirectoryContentVerifier { + public DirectoryContentVerifier(Path baseDir) { + this(baseDir, ThrowingSupplier.toSupplier(() -> { + try (var files = Files.list(baseDir)) { + return files.map(Path::getFileName).collect(toSet()); + } + }).get()); + } + public void match(Path ... expected) { + DirectoryContentVerifier.this.match(Set.of(expected)); + } + public void match(Set expected) { + currentTest.notifyAssert(); + var comm = Comm.compare(content, expected); + if (!comm.unique1().isEmpty() && !comm.unique2().isEmpty()) { + error(String.format( + "assertDirectoryContentEquals(%s): Some expected %s. Unexpected %s. Missing %s", + baseDir, format(comm.common()), format(comm.unique1()), format(comm.unique2()))); + } else if (!comm.unique1().isEmpty()) { + error(String.format( + "assertDirectoryContentEquals%s: Expected %s. Unexpected %s", + baseDir, format(comm.common()), format(comm.unique1()))); + } else if (!comm.unique2().isEmpty()) { + error(String.format( + "assertDirectoryContentEquals(%s): Some expected %s. Missing %s", + baseDir, format(comm.common()), format(comm.unique2()))); + } else { + traceAssert(String.format( + "assertDirectoryContentEquals(%s): Expected %s", + baseDir, format(expected))); + } + } + public void contains(Path ... expected) { + contains(Set.of(expected)); + } + public void contains(Set expected) { + currentTest.notifyAssert(); + var comm = Comm.compare(content, expected); + if (!comm.unique2().isEmpty()) { + error(String.format( + "assertDirectoryContentContains(%s): Some expected %s. Missing %s", + baseDir, format(comm.common()), format(comm.unique2()))); + } else { + traceAssert(String.format( + "assertDirectoryContentContains(%s): Expected %s", + baseDir, format(expected))); + } + } + public DirectoryContentVerifier removeAll(Path ... paths) { + Set newContent = new HashSet<>(content); + newContent.removeAll(List.of(paths)); + return new DirectoryContentVerifier(baseDir, newContent); + } + private DirectoryContentVerifier(Path baseDir, Set contents) { + this.baseDir = baseDir; + this.content = contents; + } + private static String format(Set paths) { + return Arrays.toString( + paths.stream().sorted().map(Path::toString).toArray( + String[]::new)); + } + private final Path baseDir; + private final Set content; + } + public static void assertStringListEquals(List expected, List actual, String msg) { currentTest.notifyAssert(); - traceAssert(String.format("assertStringListEquals(): %s", msg)); + traceAssert(concatMessages("assertStringListEquals()", msg)); String idxFieldFormat = Functional.identity(() -> { int listSize = expected.size(); @@ -757,7 +863,7 @@ expectedStr)); }); - if (expected.size() < actual.size()) { + if (actual.size() > expected.size()) { // Actual string list is longer than expected error(concatMessages(String.format( "Actual list is longer than expected by %d elements", @@ -767,12 +873,12 @@ if (actual.size() < expected.size()) { // Actual string list is shorter than expected error(concatMessages(String.format( - "Actual list is longer than expected by %d elements", + "Actual list is shorter than expected by %d elements", expected.size() - actual.size()), msg)); } } - public final static class TextStreamVerifier { + public static final class TextStreamVerifier { TextStreamVerifier(String value) { this.value = value; predicate(String::contains); @@ -835,7 +941,7 @@ private String label; private boolean negate; private Supplier createException; - final private String value; + private final String value; } public static TextStreamVerifier assertTextStream(String what) { diff -Nru openjdk-17-17.0.17+10/test/jdk/tools/jpackage/helpers/jdk/jpackage/test/WindowsHelper.java openjdk-17-17.0.18+8/test/jdk/tools/jpackage/helpers/jdk/jpackage/test/WindowsHelper.java --- openjdk-17-17.0.17+10/test/jdk/tools/jpackage/helpers/jdk/jpackage/test/WindowsHelper.java 2025-10-13 07:48:04.000000000 +0000 +++ openjdk-17-17.0.18+8/test/jdk/tools/jpackage/helpers/jdk/jpackage/test/WindowsHelper.java 2026-01-15 15:23:06.000000000 +0000 @@ -28,9 +28,12 @@ import java.util.HashMap; import java.util.List; import java.util.Map; +import java.util.Objects; import java.util.Optional; import java.util.Set; import java.util.function.BiConsumer; +import java.util.regex.Matcher; +import java.util.regex.Pattern; import java.util.stream.Collectors; import java.util.stream.Stream; import jdk.jpackage.test.Functional.ThrowingRunnable; @@ -61,28 +64,12 @@ return Path.of(cmd.getArgumentValue("--install-dir", cmd::name)); } - // Tests have problems on windows where path in the temp dir are too long - // for the wix tools. We can't use a tempDir outside the TKit's WorkDir, so - // we minimize both the tempRoot directory name (above) and the tempDir name - // (below) to the extension part (which is necessary to differenciate between - // the multiple PackageTypes that will be run for one JPackageCommand). - // It might be beter if the whole work dir name was shortened from: - // jtreg_open_test_jdk_tools_jpackage_share_jdk_jpackage_tests_BasicTest_java. - public static Path getTempDirectory(JPackageCommand cmd, Path tempRoot) { - String ext = cmd.outputBundle().getFileName().toString(); - int i = ext.lastIndexOf("."); - if (i > 0 && i < (ext.length() - 1)) { - ext = ext.substring(i+1); - } - return tempRoot.resolve(ext); - } - private static void runMsiexecWithRetries(Executor misexec) { Executor.Result result = null; for (int attempt = 0; attempt < 8; ++attempt) { result = misexec.executeWithoutExitCodeCheck(); - if (result.exitCode == 1605) { + if (result.exitCode() == 1605) { // ERROR_UNKNOWN_PRODUCT, attempt to uninstall not installed // package return; @@ -91,7 +78,7 @@ // The given Executor may either be of an msiexec command or an // unpack.bat script containing the msiexec command. In the later // case, when misexec returns 1618, the unpack.bat may return 1603 - if ((result.exitCode == 1618) || (result.exitCode == 1603)) { + if ((result.exitCode() == 1618) || (result.exitCode() == 1603)) { // Another installation is already in progress. // Wait a little and try again. Long timeout = 1000L * (attempt + 3); // from 3 to 10 seconds @@ -181,6 +168,90 @@ .executeAndGetOutput().stream().collect(Collectors.joining("\n")); } + public static void killProcess(long pid) { + Executor.of("taskkill", "/F", "/PID", Long.toString(pid)).dumpOutput(true).execute(); + } + + public static void killAppLauncherProcess(JPackageCommand cmd, + String launcherName, int expectedCount) { + var pids = findAppLauncherPIDs(cmd, launcherName); + try { + TKit.assertEquals(expectedCount, pids.length, String.format( + "Check [%d] %s app launcher processes found running", + expectedCount, Optional.ofNullable(launcherName).map( + str -> "[" + str + "]").orElse("
"))); + } finally { + if (pids.length != 0) { + killProcess(pids[0]); + } + } + } + + private static long[] findAppLauncherPIDs(JPackageCommand cmd, String launcherName) { + // Get the list of PIDs and PPIDs of app launcher processes. + // wmic process where (name = "foo.exe") get ProcessID,ParentProcessID + List output = Executor.of("wmic", "process", "where", "(name", + "=", + "\"" + cmd.appLauncherPath(launcherName).getFileName().toString() + "\"", + ")", "get", "ProcessID,ParentProcessID").dumpOutput(true). + saveOutput().executeAndGetOutput(); + + if ("No Instance(s) Available.".equals(output.get(0).trim())) { + return new long[0]; + } + + String[] headers = Stream.of(output.get(0).split("\\s+", 2)).map( + String::trim).map(String::toLowerCase).toArray(String[]::new); + Pattern pattern; + if (headers[0].equals("parentprocessid") && headers[1].equals( + "processid")) { + pattern = Pattern.compile("^(?\\d+)\\s+(?\\d+)\\s+$"); + } else if (headers[1].equals("parentprocessid") && headers[0].equals( + "processid")) { + pattern = Pattern.compile("^(?\\d+)\\s+(?\\d+)\\s+$"); + } else { + throw new RuntimeException( + "Unrecognizable output of \'wmic process\' command"); + } + + List processes = output.stream().skip(1).map(line -> { + Matcher m = pattern.matcher(line); + long[] pids = null; + if (m.matches()) { + pids = new long[]{Long.parseLong(m.group("pid")), Long. + parseLong(m.group("ppid"))}; + } + return pids; + }).filter(Objects::nonNull).toList(); + + switch (processes.size()) { + case 2 -> { + final long parentPID; + final long childPID; + if (processes.get(0)[0] == processes.get(1)[1]) { + parentPID = processes.get(0)[0]; + childPID = processes.get(1)[0]; + } else if (processes.get(1)[0] == processes.get(0)[1]) { + parentPID = processes.get(1)[0]; + childPID = processes.get(0)[0]; + } else { + TKit.assertUnexpected("App launcher processes unrelated"); + return null; // Unreachable + } + return new long[]{parentPID, childPID}; + } + case 1 -> { + return new long[]{processes.get(0)[0]}; + } + default -> { + TKit.assertUnexpected(String.format( + "Unexpected number of running processes [%d]", + processes.size())); + return null; // Unreachable + } + } + } + private static boolean isUserLocalInstall(JPackageCommand cmd) { return cmd.hasArgument("--win-per-user-install"); } @@ -353,7 +424,7 @@ var status = Executor.of("reg", "query", keyPath, "/v", valueName) .saveOutput() .executeWithoutExitCodeCheck(); - if (status.exitCode == 1) { + if (status.exitCode() == 1) { // Should be the case of no such registry value or key String lookupString = "ERROR: The system was unable to find the specified registry key or value."; TKit.assertTextStream(lookupString) @@ -394,15 +465,15 @@ "bin\\server\\jvm.dll")); // jtreg resets %ProgramFiles% environment variable by some reason. - private final static Path PROGRAM_FILES = Path.of(Optional.ofNullable( + private static final Path PROGRAM_FILES = Path.of(Optional.ofNullable( System.getenv("ProgramFiles")).orElse("C:\\Program Files")); - private final static Path USER_LOCAL = Path.of(System.getProperty( + private static final Path USER_LOCAL = Path.of(System.getProperty( "user.home"), "AppData", "Local"); - private final static String SYSTEM_SHELL_FOLDERS_REGKEY = "HKLM\\Software\\Microsoft\\Windows\\CurrentVersion\\Explorer\\Shell Folders"; - private final static String USER_SHELL_FOLDERS_REGKEY = "HKCU\\Software\\Microsoft\\Windows\\CurrentVersion\\Explorer\\Shell Folders"; + private static final String SYSTEM_SHELL_FOLDERS_REGKEY = "HKLM\\Software\\Microsoft\\Windows\\CurrentVersion\\Explorer\\Shell Folders"; + private static final String USER_SHELL_FOLDERS_REGKEY = "HKCU\\Software\\Microsoft\\Windows\\CurrentVersion\\Explorer\\Shell Folders"; private static final Map REGISTRY_VALUES = new HashMap<>(); } diff -Nru openjdk-17-17.0.17+10/test/jdk/tools/jpackage/helpers-test/jdk/jpackage/test/JavaAppDescTest.java openjdk-17-17.0.18+8/test/jdk/tools/jpackage/helpers-test/jdk/jpackage/test/JavaAppDescTest.java --- openjdk-17-17.0.17+10/test/jdk/tools/jpackage/helpers-test/jdk/jpackage/test/JavaAppDescTest.java 1970-01-01 00:00:00.000000000 +0000 +++ openjdk-17-17.0.18+8/test/jdk/tools/jpackage/helpers-test/jdk/jpackage/test/JavaAppDescTest.java 2026-01-15 15:23:06.000000000 +0000 @@ -0,0 +1,98 @@ +/* + * Copyright (c) 2024, Oracle and/or its affiliates. All rights reserved. + * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. + * + * This code is free software; you can redistribute it and/or modify it + * under the terms of the GNU General Public License version 2 only, as + * published by the Free Software Foundation. + * + * This code is distributed in the hope that it will be useful, but WITHOUT + * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or + * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License + * version 2 for more details (a copy is included in the LICENSE file that + * accompanied this code). + * + * You should have received a copy of the GNU General Public License version + * 2 along with this work; if not, write to the Free Software Foundation, + * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. + * + * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA + * or visit www.oracle.com if you need additional information or have any + * questions. + */ +package jdk.jpackage.test; + +import java.nio.file.Path; +import java.util.List; +import java.util.function.UnaryOperator; +import jdk.jpackage.test.Annotations.Parameter; +import jdk.jpackage.test.Annotations.Test; +import jdk.jpackage.test.Annotations.Parameters; + +public class JavaAppDescTest { + + public JavaAppDescTest(JavaAppDesc expectedAppDesc, JavaAppDesc actualAppDesc) { + this.expectedAppDesc = expectedAppDesc; + this.actualAppDesc = actualAppDesc; + } + + @Test + public void test() { + TKit.assertEquals(expectedAppDesc.toString(), actualAppDesc.toString(), null); + TKit.assertTrue(expectedAppDesc.equals(actualAppDesc), null); + } + + @Test + @Parameter({"Foo", "Foo.class"}) + @Parameter({"com.bar.A", "com/bar/A.class"}) + @Parameter({"module/com.bar.A", "com/bar/A.class"}) + public static void testClassFilePath(String... args) { + var appDesc = args[0]; + var expectedClassFilePath = Path.of(args[1]); + TKit.assertEquals(expectedClassFilePath.toString(), JavaAppDesc.parse( + appDesc).classFilePath().toString(), null); + } + + @Parameters + public static List input() { + return List.of(new Object[][] { + createTestCase("", "hello.jar:Hello"), + createTestCase("foo.jar*", "foo.jar*hello.jar:Hello"), + createTestCase("Bye", "hello.jar:Bye"), + createTestCase("bye.jar:", "bye.jar:Hello"), + createTestCase("duke.jar:com.other/com.other.foo.bar.Buz!@3.7", appDesc -> { + return appDesc + .setBundleFileName("duke.jar") + .setModuleName("com.other") + .setClassName("com.other.foo.bar.Buz") + .setWithMainClass(true) + .setModuleVersion("3.7"); + }), + }); + } + + private static JavaAppDesc[] createTestCase(String inputAppDesc, String expectedAppDescStr) { + return createTestCase(inputAppDesc, appDesc -> { + return stripDefaultSrcJavaPath(JavaAppDesc.parse(expectedAppDescStr)); + }); + } + + private static JavaAppDesc stripDefaultSrcJavaPath(JavaAppDesc appDesc) { + var defaultAppDesc = HelloApp.createDefaltAppDesc(); + if (appDesc.srcJavaPath().equals(defaultAppDesc.srcJavaPath())) { + appDesc.setSrcJavaPath(null); + } + return appDesc; + } + + private static JavaAppDesc[] createTestCase(String appDesc, UnaryOperator config) { + var actualAppDesc = stripDefaultSrcJavaPath(JavaAppDesc.parse(appDesc)); + + var expectedAppDesc = config.apply(stripDefaultSrcJavaPath(HelloApp.createDefaltAppDesc())); + + return new JavaAppDesc[] {expectedAppDesc, actualAppDesc}; + } + + private final JavaAppDesc expectedAppDesc; + private final JavaAppDesc actualAppDesc; +} diff -Nru openjdk-17-17.0.17+10/test/jdk/tools/jpackage/helpers-test/jdk/jpackage/test/TKitTest.java openjdk-17-17.0.18+8/test/jdk/tools/jpackage/helpers-test/jdk/jpackage/test/TKitTest.java --- openjdk-17-17.0.17+10/test/jdk/tools/jpackage/helpers-test/jdk/jpackage/test/TKitTest.java 1970-01-01 00:00:00.000000000 +0000 +++ openjdk-17-17.0.18+8/test/jdk/tools/jpackage/helpers-test/jdk/jpackage/test/TKitTest.java 2026-01-15 15:23:06.000000000 +0000 @@ -0,0 +1,244 @@ +/* + * Copyright (c) 2024, Oracle and/or its affiliates. All rights reserved. + * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. + * + * This code is free software; you can redistribute it and/or modify it + * under the terms of the GNU General Public License version 2 only, as + * published by the Free Software Foundation. + * + * This code is distributed in the hope that it will be useful, but WITHOUT + * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or + * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License + * version 2 for more details (a copy is included in the LICENSE file that + * accompanied this code). + * + * You should have received a copy of the GNU General Public License version + * 2 along with this work; if not, write to the Free Software Foundation, + * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. + * + * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA + * or visit www.oracle.com if you need additional information or have any + * questions. + */ +package jdk.jpackage.test; + +import java.io.BufferedReader; +import java.io.ByteArrayInputStream; +import java.io.ByteArrayOutputStream; +import java.io.InputStreamReader; +import java.io.PrintStream; +import java.lang.reflect.Method; +import java.nio.charset.StandardCharsets; +import java.util.ArrayList; +import java.util.Arrays; +import java.util.Collection; +import java.util.List; +import java.util.Objects; +import java.util.stream.Stream; +import jdk.jpackage.test.Annotations.Parameters; +import jdk.jpackage.test.Annotations.Test; +import jdk.jpackage.test.Functional.ThrowingRunnable; +import static jdk.jpackage.test.Functional.ThrowingRunnable.toRunnable; +import static jdk.jpackage.test.Functional.ThrowingSupplier.toSupplier; + +public class TKitTest { + + @Parameters + public static Collection assertTestsData() { + List data = new ArrayList<>(); + + var assertFunc = MethodCallConfig.build("assertTrue", boolean.class, String.class); + data.addAll(List.of(assertFunc.args(true).pass().expectLog("assertTrue()").createForMessage("Catbird"))); + data.addAll(List.of(assertFunc.args(false).fail().expectLog("Failed").createForMessage("Catbird"))); + + assertFunc = MethodCallConfig.build("assertFalse", boolean.class, String.class); + data.addAll(List.of(assertFunc.args(false).pass().expectLog("assertFalse()").createForMessage("Stork"))); + data.addAll(List.of(assertFunc.args(true).fail().expectLog("Failed").createForMessage("Stork"))); + + assertFunc = MethodCallConfig.build("assertEquals", String.class, String.class, String.class); + data.addAll(List.of(assertFunc.args("a", "a").pass().expectLog("assertEquals(a)").createForMessage("Crow"))); + data.addAll(List.of(assertFunc.args("a", "b").fail().expectLog("Expected [a]. Actual [b]").createForMessage("Crow"))); + + assertFunc = MethodCallConfig.build("assertEquals", long.class, long.class, String.class); + data.addAll(List.of(assertFunc.args(7, 7).pass().expectLog("assertEquals(7)").createForMessage("Owl"))); + data.addAll(List.of(assertFunc.args(7, 10).fail().expectLog("Expected [7]. Actual [10]").createForMessage("Owl"))); + + assertFunc = MethodCallConfig.build("assertNotEquals", String.class, String.class, String.class); + data.addAll(List.of(assertFunc.args("a", "b").pass().expectLog("assertNotEquals(a, b)").createForMessage("Tit"))); + data.addAll(List.of(assertFunc.args("a", "a").fail().expectLog("Unexpected [a] value").createForMessage("Tit"))); + + assertFunc = MethodCallConfig.build("assertNotEquals", long.class, long.class, String.class); + data.addAll(List.of(assertFunc.args(7, 10).pass().expectLog("assertNotEquals(7, 10)").createForMessage("Duck"))); + data.addAll(List.of(assertFunc.args(7, 7).fail().expectLog("Unexpected [7] value").createForMessage("Duck"))); + + assertFunc = MethodCallConfig.build("assertNull", Object.class, String.class); + data.addAll(List.of(assertFunc.args((Object) null).pass().expectLog("assertNull()").createForMessage("Ibis"))); + data.addAll(List.of(assertFunc.args("v").fail().expectLog("Unexpected not null value [v]").createForMessage("Ibis"))); + + assertFunc = MethodCallConfig.build("assertNotNull", Object.class, String.class); + data.addAll(List.of(assertFunc.args("v").pass().expectLog("assertNotNull(v)").createForMessage("Pigeon"))); + data.addAll(List.of(assertFunc.args((Object) null).fail().expectLog("Unexpected null value").createForMessage("Pigeon"))); + + assertFunc = MethodCallConfig.build("assertStringListEquals", List.class, List.class, String.class); + data.addAll(List.of(assertFunc.args(List.of(), List.of()).pass().expectLog( + "assertStringListEquals()").createForMessage("Gull"))); + + data.addAll(List.of(assertFunc.args(List.of("a", "b"), List.of("a", "b")).pass().expectLog( + "assertStringListEquals()", + "assertStringListEquals(1, a)", + "assertStringListEquals(2, b)").createForMessage("Pelican"))); + + assertFunc.fail().withAutoExpectLogPrefix(false); + for (var msg : new String[] { "Raven", null }) { + data.addAll(List.of(assertFunc.args(List.of("a"), List.of("a", "b"), msg).expectLog( + concatMessages("TRACE: assertStringListEquals()", msg), + "TRACE: assertStringListEquals(1, a)", + concatMessages("ERROR: Actual list is longer than expected by 1 elements", msg) + ).create())); + + data.addAll(List.of(assertFunc.args(List.of("n", "m"), List.of("n"), msg).expectLog( + concatMessages("TRACE: assertStringListEquals()", msg), + "TRACE: assertStringListEquals(1, n)", + concatMessages("ERROR: Actual list is shorter than expected by 1 elements", msg) + ).create())); + + data.addAll(List.of(assertFunc.args(List.of("a", "b"), List.of("n", "m"), msg).expectLog( + concatMessages("TRACE: assertStringListEquals()", msg), + concatMessages("ERROR: (1) Expected [a]. Actual [n]", msg) + ).create())); + } + + return data.stream().map(v -> { + return new Object[]{v}; + }).toList(); + } + + public record MethodCallConfig(Method method, Object[] args, boolean expectFail, String[] expectLog) { + @Override + public String toString() { + return String.format("%s%s%s", method.getName(), Arrays.toString(args), expectFail ? "!" : ""); + } + + static Builder build(String name, Class ... parameterTypes) { + return new Builder(name, parameterTypes); + } + + private static class Builder { + Builder(Method method) { + Objects.requireNonNull(method); + this.method = method; + } + + Builder(String name, Class ... parameterTypes) { + method = toSupplier(() -> TKit.class.getMethod(name, parameterTypes)).get(); + } + + MethodCallConfig create() { + String[] effectiveExpectLog; + if (!withAutoExpectLogPrefix) { + effectiveExpectLog = expectLog; + } else { + var prefix = expectFail ? "ERROR: " : "TRACE: "; + effectiveExpectLog = Stream.of(expectLog).map(line -> { + return prefix + line; + }).toArray(String[]::new); + } + return new MethodCallConfig(method, args, expectFail, effectiveExpectLog); + } + + MethodCallConfig[] createForMessage(String msg) { + return Arrays.asList(msg, null).stream().map(curMsg -> { + var builder = new Builder(method); + builder.expectFail = expectFail; + builder.withAutoExpectLogPrefix = withAutoExpectLogPrefix; + builder.args = Stream.concat(Stream.of(args), Stream.of(curMsg)).toArray(); + builder.expectLog = Arrays.copyOf(expectLog, expectLog.length); + builder.expectLog[0] = concatMessages(builder.expectLog[0], curMsg); + return builder.create(); + }).toArray(MethodCallConfig[]::new); + } + + Builder fail() { + expectFail = true; + return this; + } + + Builder pass() { + expectFail = false; + return this; + } + + Builder args(Object ... v) { + args = v; + return this; + } + + Builder expectLog(String expectLogFirstStr, String ... extra) { + expectLog = Stream.concat(Stream.of(expectLogFirstStr), Stream.of(extra)).toArray(String[]::new); + return this; + } + + Builder withAutoExpectLogPrefix(boolean v) { + withAutoExpectLogPrefix = v; + return this; + } + + private final Method method; + private Object[] args = new Object[0]; + private boolean expectFail; + private String[] expectLog; + private boolean withAutoExpectLogPrefix = true; + } + } + + public TKitTest(MethodCallConfig methodCall) { + this.methodCall = methodCall; + } + + @Test + public void test() { + runAssertWithExpectedLogOutput(() -> { + methodCall.method.invoke(null, methodCall.args); + }, methodCall.expectFail, methodCall.expectLog); + } + + private static void runAssertWithExpectedLogOutput(ThrowingRunnable action, + boolean expectFail, String... expectLogStrings) { + runWithExpectedLogOutput(() -> { + TKit.assertAssert(!expectFail, toRunnable(action)); + }, expectLogStrings); + } + + private static void runWithExpectedLogOutput(ThrowingRunnable action, + String... expectLogStrings) { + final var buf = new ByteArrayOutputStream(); + try (PrintStream ps = new PrintStream(buf, true, StandardCharsets.UTF_8)) { + TKit.withExtraLogStream(action, ps); + } finally { + toRunnable(() -> { + var output = new BufferedReader(new InputStreamReader( + new ByteArrayInputStream(buf.toByteArray()), + StandardCharsets.UTF_8)).lines().map(line -> { + // Skip timestamp + return line.substring(LOG_MSG_TIMESTAMP_LENGTH); + }).toList(); + if (output.size() == 1 && expectLogStrings.length == 1) { + TKit.assertEquals(expectLogStrings[0], output.get(0), null); + } else { + TKit.assertStringListEquals(List.of(expectLogStrings), output, null); + } + }).run(); + } + } + + private static String concatMessages(String msg, String msg2) { + if (msg2 != null && !msg2.isBlank()) { + return msg + ": " + msg2; + } + return msg; + } + + private final MethodCallConfig methodCall; + + private static final int LOG_MSG_TIMESTAMP_LENGTH = "[HH:mm:ss.SSS] ".length(); +} diff -Nru openjdk-17-17.0.17+10/test/jdk/tools/jpackage/helpers-test/jdk/jpackage/test/TestSuite.java openjdk-17-17.0.18+8/test/jdk/tools/jpackage/helpers-test/jdk/jpackage/test/TestSuite.java --- openjdk-17-17.0.17+10/test/jdk/tools/jpackage/helpers-test/jdk/jpackage/test/TestSuite.java 1970-01-01 00:00:00.000000000 +0000 +++ openjdk-17-17.0.18+8/test/jdk/tools/jpackage/helpers-test/jdk/jpackage/test/TestSuite.java 2026-01-15 15:23:06.000000000 +0000 @@ -0,0 +1,63 @@ +/* + * Copyright (c) 2024, Oracle and/or its affiliates. All rights reserved. + * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. + * + * This code is free software; you can redistribute it and/or modify it + * under the terms of the GNU General Public License version 2 only, as + * published by the Free Software Foundation. + * + * This code is distributed in the hope that it will be useful, but WITHOUT + * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or + * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License + * version 2 for more details (a copy is included in the LICENSE file that + * accompanied this code). + * + * You should have received a copy of the GNU General Public License version + * 2 along with this work; if not, write to the Free Software Foundation, + * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. + * + * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA + * or visit www.oracle.com if you need additional information or have any + * questions. + */ +package jdk.jpackage.test; + +import java.nio.file.Files; +import java.nio.file.Path; +import java.util.ArrayList; +import java.util.List; + +/* + * @test + * @summary Unit tests for jpackage test library + * @library /test/jdk/tools/jpackage/helpers + * @library /test/jdk/tools/jpackage/helpers-test + * @build jdk.jpackage.test.* + * @run main/othervm/timeout=360 -Xmx512m jdk.jpackage.test.TestSuite + */ + +public final class TestSuite { + public static void main(String args[]) throws Throwable { + final var pkgName = TestSuite.class.getPackageName(); + final var javaSuffix = ".java"; + final var testSrcNameSuffix = "Test" + javaSuffix; + + final var unitTestDir = TKit.TEST_SRC_ROOT.resolve(Path.of("helpers-test", pkgName.split("\\."))); + + final List runTestArgs = new ArrayList<>(); + runTestArgs.addAll(List.of(args)); + + try (var javaSources = Files.list(unitTestDir)) { + runTestArgs.addAll(javaSources.filter(path -> { + return path.getFileName().toString().endsWith(testSrcNameSuffix); + }).map(path -> { + var filename = path.getFileName().toString(); + return String.join(".", pkgName, filename.substring(0, filename.length() - javaSuffix.length())); + }).map(testClassName -> { + return "--jpt-run=" + testClassName; + }).toList()); + } + + Main.main(runTestArgs.toArray(String[]::new)); + } +} diff -Nru openjdk-17-17.0.17+10/test/jdk/tools/jpackage/linux/AppAboutUrlTest.java openjdk-17-17.0.18+8/test/jdk/tools/jpackage/linux/AppAboutUrlTest.java --- openjdk-17-17.0.17+10/test/jdk/tools/jpackage/linux/AppAboutUrlTest.java 2025-10-13 07:48:04.000000000 +0000 +++ openjdk-17-17.0.18+8/test/jdk/tools/jpackage/linux/AppAboutUrlTest.java 2026-01-15 15:23:06.000000000 +0000 @@ -1,5 +1,5 @@ /* - * Copyright (c) 2021, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2021, 2024, Oracle and/or its affiliates. All rights reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * * This code is free software; you can redistribute it and/or modify it @@ -44,13 +44,12 @@ /* * @test * @summary jpackage with --about-url - * @library ../helpers + * @library /test/jdk/tools/jpackage/helpers * @key jpackagePlatformPackage * @build jdk.jpackage.test.* * @build AppAboutUrlTest * @requires (os.family == "linux") * @requires (jpackage.test.SQETest == null) - * @modules jdk.jpackage/jdk.jpackage.internal * @run main/othervm/timeout=360 -Xmx512m jdk.jpackage.test.Main * --jpt-run=AppAboutUrlTest */ @@ -58,13 +57,12 @@ /* * @test * @summary jpackage with --about-url - * @library ../helpers + * @library /test/jdk/tools/jpackage/helpers * @key jpackagePlatformPackage * @build jdk.jpackage.test.* * @build AppAboutUrlTest * @requires (os.family == "linux") * @requires (jpackage.test.SQETest != null) - * @modules jdk.jpackage/jdk.jpackage.internal * @run main/othervm/timeout=360 -Xmx512m jdk.jpackage.test.Main * --jpt-run=AppAboutUrlTest.test */ diff -Nru openjdk-17-17.0.17+10/test/jdk/tools/jpackage/linux/AppCategoryTest.java openjdk-17-17.0.18+8/test/jdk/tools/jpackage/linux/AppCategoryTest.java --- openjdk-17-17.0.17+10/test/jdk/tools/jpackage/linux/AppCategoryTest.java 2025-10-13 07:48:04.000000000 +0000 +++ openjdk-17-17.0.18+8/test/jdk/tools/jpackage/linux/AppCategoryTest.java 2026-01-15 15:23:06.000000000 +0000 @@ -1,5 +1,5 @@ /* - * Copyright (c) 2019, 2021, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2019, 2024, Oracle and/or its affiliates. All rights reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * * This code is free software; you can redistribute it and/or modify it @@ -43,12 +43,11 @@ /* * @test * @summary jpackage with --linux-app-category - * @library ../helpers + * @library /test/jdk/tools/jpackage/helpers * @key jpackagePlatformPackage * @build jdk.jpackage.test.* * @build AppCategoryTest * @requires (os.family == "linux") - * @modules jdk.jpackage/jdk.jpackage.internal * @run main/othervm/timeout=360 -Xmx512m jdk.jpackage.test.Main * --jpt-run=AppCategoryTest */ diff -Nru openjdk-17-17.0.17+10/test/jdk/tools/jpackage/linux/LicenseTypeTest.java openjdk-17-17.0.18+8/test/jdk/tools/jpackage/linux/LicenseTypeTest.java --- openjdk-17-17.0.17+10/test/jdk/tools/jpackage/linux/LicenseTypeTest.java 2025-10-13 07:48:04.000000000 +0000 +++ openjdk-17-17.0.18+8/test/jdk/tools/jpackage/linux/LicenseTypeTest.java 2026-01-15 15:23:06.000000000 +0000 @@ -1,5 +1,5 @@ /* - * Copyright (c) 2018, 2021, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2018, 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 @@ -38,12 +38,11 @@ /* * @test * @summary jpackage with --linux-rpm-license-type - * @library ../helpers + * @library /test/jdk/tools/jpackage/helpers * @key jpackagePlatformPackage * @build jdk.jpackage.test.* * @build LicenseTypeTest * @requires (os.family == "linux") - * @modules jdk.jpackage/jdk.jpackage.internal * @run main/othervm/timeout=360 -Xmx512m jdk.jpackage.test.Main * --jpt-run=LicenseTypeTest */ diff -Nru openjdk-17-17.0.17+10/test/jdk/tools/jpackage/linux/LinuxBundleNameTest.java openjdk-17-17.0.18+8/test/jdk/tools/jpackage/linux/LinuxBundleNameTest.java --- openjdk-17-17.0.17+10/test/jdk/tools/jpackage/linux/LinuxBundleNameTest.java 2025-10-13 07:48:04.000000000 +0000 +++ openjdk-17-17.0.18+8/test/jdk/tools/jpackage/linux/LinuxBundleNameTest.java 2026-01-15 15:23:06.000000000 +0000 @@ -1,5 +1,5 @@ /* - * Copyright (c) 2019, 2021, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2019, 2024, Oracle and/or its affiliates. All rights reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * * This code is free software; you can redistribute it and/or modify it @@ -43,12 +43,11 @@ /* * @test * @summary jpackage with --linux-package-name - * @library ../helpers + * @library /test/jdk/tools/jpackage/helpers * @key jpackagePlatformPackage * @build jdk.jpackage.test.* * @build LinuxBundleNameTest * @requires (os.family == "linux") - * @modules jdk.jpackage/jdk.jpackage.internal * @run main/othervm/timeout=360 -Xmx512m jdk.jpackage.test.Main * --jpt-run=LinuxBundleNameTest */ diff -Nru openjdk-17-17.0.17+10/test/jdk/tools/jpackage/linux/LinuxResourceTest.java openjdk-17-17.0.18+8/test/jdk/tools/jpackage/linux/LinuxResourceTest.java --- openjdk-17-17.0.17+10/test/jdk/tools/jpackage/linux/LinuxResourceTest.java 2025-10-13 07:48:04.000000000 +0000 +++ openjdk-17-17.0.18+8/test/jdk/tools/jpackage/linux/LinuxResourceTest.java 2026-01-15 15:23:06.000000000 +0000 @@ -1,5 +1,5 @@ /* - * Copyright (c) 2019, 2020, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2019, 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 @@ -33,10 +33,9 @@ /* * @test * @summary jpackage with --resource-dir - * @library ../helpers + * @library /test/jdk/tools/jpackage/helpers * @build jdk.jpackage.test.* * @requires (os.family == "linux") - * @modules jdk.jpackage/jdk.jpackage.internal * @compile LinuxResourceTest.java * @run main/othervm/timeout=360 -Xmx512m jdk.jpackage.test.Main * --jpt-run=LinuxResourceTest diff -Nru openjdk-17-17.0.17+10/test/jdk/tools/jpackage/linux/LinuxWeirdOutputDirTest.java openjdk-17-17.0.18+8/test/jdk/tools/jpackage/linux/LinuxWeirdOutputDirTest.java --- openjdk-17-17.0.17+10/test/jdk/tools/jpackage/linux/LinuxWeirdOutputDirTest.java 2025-10-13 07:48:04.000000000 +0000 +++ openjdk-17-17.0.18+8/test/jdk/tools/jpackage/linux/LinuxWeirdOutputDirTest.java 2026-01-15 15:23:06.000000000 +0000 @@ -1,5 +1,5 @@ /* - * Copyright (c) 2021, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2021, 2024, Oracle and/or its affiliates. All rights reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * * This code is free software; you can redistribute it and/or modify it @@ -30,9 +30,8 @@ * @summary jpackage with values of --dest parameter breaking jpackage launcher * @requires (os.family == "linux") * @bug 8268974 - * @library ../helpers + * @library /test/jdk/tools/jpackage/helpers * @build jdk.jpackage.test.* - * @modules jdk.jpackage/jdk.jpackage.internal * @compile LinuxWeirdOutputDirTest.java * @run main/othervm/timeout=540 -Xmx512m jdk.jpackage.test.Main * --jpt-run=LinuxWeirdOutputDirTest diff -Nru openjdk-17-17.0.17+10/test/jdk/tools/jpackage/linux/MaintainerTest.java openjdk-17-17.0.18+8/test/jdk/tools/jpackage/linux/MaintainerTest.java --- openjdk-17-17.0.17+10/test/jdk/tools/jpackage/linux/MaintainerTest.java 2025-10-13 07:48:04.000000000 +0000 +++ openjdk-17-17.0.18+8/test/jdk/tools/jpackage/linux/MaintainerTest.java 2026-01-15 15:23:06.000000000 +0000 @@ -1,5 +1,5 @@ /* - * Copyright (c) 2018, 2021, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2018, 2024, Oracle and/or its affiliates. All rights reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * * This code is free software; you can redistribute it and/or modify it @@ -39,12 +39,11 @@ /* * @test * @summary jpackage with --linux-deb-maintainer - * @library ../helpers + * @library /test/jdk/tools/jpackage/helpers * @key jpackagePlatformPackage * @build jdk.jpackage.test.* * @build MaintainerTest * @requires (os.family == "linux") - * @modules jdk.jpackage/jdk.jpackage.internal * @run main/othervm/timeout=360 -Xmx512m jdk.jpackage.test.Main * --jpt-run=MaintainerTest */ diff -Nru openjdk-17-17.0.17+10/test/jdk/tools/jpackage/linux/PackageDepsTest.java openjdk-17-17.0.18+8/test/jdk/tools/jpackage/linux/PackageDepsTest.java --- openjdk-17-17.0.17+10/test/jdk/tools/jpackage/linux/PackageDepsTest.java 2025-10-13 07:48:04.000000000 +0000 +++ openjdk-17-17.0.18+8/test/jdk/tools/jpackage/linux/PackageDepsTest.java 2026-01-15 15:23:06.000000000 +0000 @@ -1,5 +1,5 @@ /* - * Copyright (c) 2018, 2019, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2018, 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 @@ -46,11 +46,10 @@ /* * @test * @summary jpackage with --linux-package-deps - * @library ../helpers + * @library /test/jdk/tools/jpackage/helpers * @key jpackagePlatformPackage * @build jdk.jpackage.test.* * @requires (os.family == "linux") - * @modules jdk.jpackage/jdk.jpackage.internal * @compile PackageDepsTest.java * @run main/othervm/timeout=360 -Xmx512m jdk.jpackage.test.Main * --jpt-run=PackageDepsTest diff -Nru openjdk-17-17.0.17+10/test/jdk/tools/jpackage/linux/ReleaseTest.java openjdk-17-17.0.18+8/test/jdk/tools/jpackage/linux/ReleaseTest.java --- openjdk-17-17.0.17+10/test/jdk/tools/jpackage/linux/ReleaseTest.java 2025-10-13 07:48:04.000000000 +0000 +++ openjdk-17-17.0.18+8/test/jdk/tools/jpackage/linux/ReleaseTest.java 2026-01-15 15:23:06.000000000 +0000 @@ -1,5 +1,5 @@ /* - * Copyright (c) 2019, 2021, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2019, 2024, Oracle and/or its affiliates. All rights reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * * This code is free software; you can redistribute it and/or modify it @@ -42,12 +42,11 @@ /* * @test * @summary jpackage with --linux-app-release - * @library ../helpers + * @library /test/jdk/tools/jpackage/helpers * @key jpackagePlatformPackage * @build jdk.jpackage.test.* * @build ReleaseTest * @requires (os.family == "linux") - * @modules jdk.jpackage/jdk.jpackage.internal * @run main/othervm/timeout=360 -Xmx512m jdk.jpackage.test.Main * --jpt-run=ReleaseTest */ diff -Nru openjdk-17-17.0.17+10/test/jdk/tools/jpackage/linux/ShortcutHintTest.java openjdk-17-17.0.18+8/test/jdk/tools/jpackage/linux/ShortcutHintTest.java --- openjdk-17-17.0.17+10/test/jdk/tools/jpackage/linux/ShortcutHintTest.java 2025-10-13 07:48:04.000000000 +0000 +++ openjdk-17-17.0.18+8/test/jdk/tools/jpackage/linux/ShortcutHintTest.java 2026-01-15 15:23:06.000000000 +0000 @@ -1,5 +1,5 @@ /* - * Copyright (c) 2019, 2020, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2019, 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 @@ -53,12 +53,11 @@ /* * @test * @summary jpackage with --linux-shortcut - * @library ../helpers + * @library /test/jdk/tools/jpackage/helpers * @key jpackagePlatformPackage * @requires jpackage.test.SQETest == null * @build jdk.jpackage.test.* * @requires (os.family == "linux") - * @modules jdk.jpackage/jdk.jpackage.internal * @compile ShortcutHintTest.java * @run main/othervm/timeout=360 -Xmx512m jdk.jpackage.test.Main * --jpt-run=ShortcutHintTest @@ -67,12 +66,11 @@ /* * @test * @summary jpackage with --linux-shortcut - * @library ../helpers + * @library /test/jdk/tools/jpackage/helpers * @key jpackagePlatformPackage * @build jdk.jpackage.test.* * @requires (os.family == "linux") * @requires jpackage.test.SQETest != null - * @modules jdk.jpackage/jdk.jpackage.internal * @compile ShortcutHintTest.java * @run main/othervm/timeout=360 -Xmx512m jdk.jpackage.test.Main * --jpt-run=ShortcutHintTest.testBasic diff -Nru openjdk-17-17.0.17+10/test/jdk/tools/jpackage/linux/UsrTreeTest.java openjdk-17-17.0.18+8/test/jdk/tools/jpackage/linux/UsrTreeTest.java --- openjdk-17-17.0.17+10/test/jdk/tools/jpackage/linux/UsrTreeTest.java 1970-01-01 00:00:00.000000000 +0000 +++ openjdk-17-17.0.18+8/test/jdk/tools/jpackage/linux/UsrTreeTest.java 2026-01-15 15:23:06.000000000 +0000 @@ -0,0 +1,126 @@ +/* + * Copyright (c) 2020, 2024, Oracle and/or its affiliates. All rights reserved. + * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. + * + * This code is free software; you can redistribute it and/or modify it + * 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.nio.file.Path; +import java.util.List; +import java.util.function.Consumer; +import java.util.stream.Collectors; +import jdk.jpackage.test.TKit; +import jdk.jpackage.test.PackageTest; +import jdk.jpackage.test.PackageType; +import jdk.jpackage.test.LinuxHelper; +import jdk.jpackage.test.Annotations.Test; + + +/** + * Simple Linux specific packaging test. Resulting package should be installed + * in /usr directory tree. + */ + +/* + * @test + * @summary jpackage command run installing app in /usr directory tree + * @library /test/jdk/tools/jpackage/helpers + * @key jpackagePlatformPackage + * @requires jpackage.test.SQETest == null + * @requires (os.family == "linux") + * @build jdk.jpackage.test.* + * @compile UsrTreeTest.java + * @run main/othervm/timeout=720 -Xmx512m jdk.jpackage.test.Main + * --jpt-run=UsrTreeTest + */ +public class UsrTreeTest { + + @Test + public static void testUsr() { + test("/usr", true); + } + + @Test + public static void testUsrLocal() { + test("/usr/local", true); + } + + @Test + public static void testUsrCustom() { + test("/usr/foo", false); + } + + @Test + public static void testUsrCustom2() { + test("/usrbuz", false); + } + + private static void test(String installDir, boolean expectedImageSplit) { + new PackageTest() + .forTypes(PackageType.LINUX) + .configureHelloApp() + .addInitializer(cmd -> cmd.addArguments("--install-dir", installDir)) + .addBundleDesktopIntegrationVerifier(false) + .addBundleVerifier(cmd -> { + final String packageName = LinuxHelper.getPackageName(cmd); + final Path launcherPath = cmd.appLauncherPath(); + final Path launcherCfgPath = cmd.appLauncherCfgPath(null); + final Path commonPath = commonPath(launcherPath, launcherCfgPath); + + final boolean actualImageSplit = !commonPath.getFileName().equals( + Path.of(packageName)); + TKit.assertTrue(expectedImageSplit == actualImageSplit, + String.format( + "Check there is%spackage name [%s] in common path [%s] between [%s] and [%s]", + expectedImageSplit ? " no " : " ", packageName, + commonPath, launcherPath, launcherCfgPath)); + + List packageFiles = LinuxHelper.getPackageFiles(cmd).collect( + Collectors.toList()); + + Consumer packageFileVerifier = file -> { + TKit.assertTrue(packageFiles.stream().filter( + path -> path.equals(file)).findFirst().orElse( + null) != null, String.format( + "Check file [%s] is in [%s] package", file, + packageName)); + }; + + packageFileVerifier.accept(launcherPath); + packageFileVerifier.accept(launcherCfgPath); + }) + .run(); + } + + private static Path commonPath(Path a, Path b) { + if (a.equals(b)) { + return a; + } + + final int minCount = Math.min(a.getNameCount(), b.getNameCount()); + for (int i = minCount; i > 0; i--) { + Path sp = a.subpath(0, i); + if (sp.equals(b.subpath(0, i))) { + return a.getRoot().resolve(sp); + } + } + + return a.getRoot(); + } +} diff -Nru openjdk-17-17.0.17+10/test/jdk/tools/jpackage/linux/jdk/jpackage/tests/UsrTreeTest.java openjdk-17-17.0.18+8/test/jdk/tools/jpackage/linux/jdk/jpackage/tests/UsrTreeTest.java --- openjdk-17-17.0.17+10/test/jdk/tools/jpackage/linux/jdk/jpackage/tests/UsrTreeTest.java 2025-10-13 07:48:04.000000000 +0000 +++ openjdk-17-17.0.18+8/test/jdk/tools/jpackage/linux/jdk/jpackage/tests/UsrTreeTest.java 1970-01-01 00:00:00.000000000 +0000 @@ -1,127 +0,0 @@ -/* - * Copyright (c) 2020, Oracle and/or its affiliates. All rights reserved. - * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. - * - * This code is free software; you can redistribute it and/or modify it - * under the terms of the GNU General Public License version 2 only, as - * published by the Free Software Foundation. - * - * This code is distributed in the hope that it will be useful, but WITHOUT - * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or - * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License - * version 2 for more details (a copy is included in the LICENSE file that - * accompanied this code). - * - * You should have received a copy of the GNU General Public License version - * 2 along with this work; if not, write to the Free Software Foundation, - * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. - * - * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA - * or visit www.oracle.com if you need additional information or have any - * questions. - */ - -import java.nio.file.Path; -import java.util.List; -import java.util.function.Consumer; -import java.util.stream.Collectors; -import jdk.jpackage.test.TKit; -import jdk.jpackage.test.PackageTest; -import jdk.jpackage.test.PackageType; -import jdk.jpackage.test.LinuxHelper; -import jdk.jpackage.test.Annotations.Test; - - -/** - * Simple Linux specific packaging test. Resulting package should be installed - * in /usr directory tree. - */ - -/* - * @test - * @summary jpackage command run installing app in /usr directory tree - * @library ../../../../helpers - * @key jpackagePlatformPackage - * @requires jpackage.test.SQETest == null - * @requires (os.family == "linux") - * @build jdk.jpackage.test.* - * @modules jdk.jpackage/jdk.jpackage.internal - * @compile UsrTreeTest.java - * @run main/othervm/timeout=720 -Xmx512m jdk.jpackage.test.Main - * --jpt-run=UsrTreeTest - */ -public class UsrTreeTest { - - @Test - public static void testUsr() { - test("/usr", true); - } - - @Test - public static void testUsrLocal() { - test("/usr/local", true); - } - - @Test - public static void testUsrCustom() { - test("/usr/foo", false); - } - - @Test - public static void testUsrCustom2() { - test("/usrbuz", false); - } - - private static void test(String installDir, boolean expectedImageSplit) { - new PackageTest() - .forTypes(PackageType.LINUX) - .configureHelloApp() - .addInitializer(cmd -> cmd.addArguments("--install-dir", installDir)) - .addBundleDesktopIntegrationVerifier(false) - .addBundleVerifier(cmd -> { - final String packageName = LinuxHelper.getPackageName(cmd); - final Path launcherPath = cmd.appLauncherPath(); - final Path launcherCfgPath = cmd.appLauncherCfgPath(null); - final Path commonPath = commonPath(launcherPath, launcherCfgPath); - - final boolean actualImageSplit = !commonPath.getFileName().equals( - Path.of(packageName)); - TKit.assertTrue(expectedImageSplit == actualImageSplit, - String.format( - "Check there is%spackage name [%s] in common path [%s] between [%s] and [%s]", - expectedImageSplit ? " no " : " ", packageName, - commonPath, launcherPath, launcherCfgPath)); - - List packageFiles = LinuxHelper.getPackageFiles(cmd).collect( - Collectors.toList()); - - Consumer packageFileVerifier = file -> { - TKit.assertTrue(packageFiles.stream().filter( - path -> path.equals(file)).findFirst().orElse( - null) != null, String.format( - "Check file [%s] is in [%s] package", file, - packageName)); - }; - - packageFileVerifier.accept(launcherPath); - packageFileVerifier.accept(launcherCfgPath); - }) - .run(); - } - - private static Path commonPath(Path a, Path b) { - if (a.equals(b)) { - return a; - } - - final int minCount = Math.min(a.getNameCount(), b.getNameCount()); - for (int i = minCount; i > 0; i--) { - Path sp = a.subpath(0, i); - if (sp.equals(b.subpath(0, i))) { - return a.getRoot().resolve(sp); - } - } - - return a.getRoot(); - } -} diff -Nru openjdk-17-17.0.17+10/test/jdk/tools/jpackage/macosx/ArgumentsFilteringTest.java openjdk-17-17.0.18+8/test/jdk/tools/jpackage/macosx/ArgumentsFilteringTest.java --- openjdk-17-17.0.17+10/test/jdk/tools/jpackage/macosx/ArgumentsFilteringTest.java 2025-10-13 07:48:04.000000000 +0000 +++ openjdk-17-17.0.18+8/test/jdk/tools/jpackage/macosx/ArgumentsFilteringTest.java 2026-01-15 15:23:06.000000000 +0000 @@ -1,5 +1,5 @@ /* - * Copyright (c) 2020, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2020, 2024, Oracle and/or its affiliates. All rights reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * * This code is free software; you can redistribute it and/or modify it @@ -21,9 +21,6 @@ * questions. */ -import java.nio.file.Path; -import java.util.List; -import java.util.ArrayList; import jdk.jpackage.test.JPackageCommand; import jdk.jpackage.test.HelloApp; import jdk.jpackage.test.Annotations.Test; @@ -39,9 +36,8 @@ /* * @test * @summary jpackage with -psn - * @library ../helpers + * @library /test/jdk/tools/jpackage/helpers * @build jdk.jpackage.test.* - * @modules jdk.jpackage/jdk.jpackage.internal * @compile ArgumentsFilteringTest.java * @requires (os.family == "mac") * @run main/othervm/timeout=540 -Xmx512m jdk.jpackage.test.Main @@ -53,10 +49,11 @@ public void test1() { JPackageCommand cmd = JPackageCommand.helloAppImage(); cmd.executeAndAssertHelloAppImageCreated(); - Path launcherPath = cmd.appLauncherPath(); - HelloApp.assertApp(launcherPath) - .executeAndVerifyOutput(false, List.of("-psn_1_1"), - new ArrayList<>()); + var appVerifier = HelloApp.assertMainLauncher(cmd); + if (appVerifier != null) { + appVerifier.execute("-psn_1_1"); + appVerifier.verifyOutput(); + } } @Test @@ -64,9 +61,10 @@ JPackageCommand cmd = JPackageCommand.helloAppImage() .addArguments("--arguments", "-psn_2_2"); cmd.executeAndAssertHelloAppImageCreated(); - Path launcherPath = cmd.appLauncherPath(); - HelloApp.assertApp(launcherPath) - .executeAndVerifyOutput(false, List.of("-psn_1_1"), - List.of("-psn_2_2")); + var appVerifier = HelloApp.assertMainLauncher(cmd); + if (appVerifier != null) { + appVerifier.execute("-psn_1_1"); + appVerifier.verifyOutput("-psn_2_2"); + } } } diff -Nru openjdk-17-17.0.17+10/test/jdk/tools/jpackage/macosx/HostArchPkgTest.java openjdk-17-17.0.18+8/test/jdk/tools/jpackage/macosx/HostArchPkgTest.java --- openjdk-17-17.0.17+10/test/jdk/tools/jpackage/macosx/HostArchPkgTest.java 2025-10-13 07:48:04.000000000 +0000 +++ openjdk-17-17.0.18+8/test/jdk/tools/jpackage/macosx/HostArchPkgTest.java 2026-01-15 15:23:06.000000000 +0000 @@ -1,5 +1,5 @@ /* - * Copyright (c) 2021, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2021, 2024, Oracle and/or its affiliates. All rights reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * * This code is free software; you can redistribute it and/or modify it @@ -42,9 +42,8 @@ /* * @test * @summary jpackage test to validate "hostArchitectures" attribute - * @library ../helpers + * @library /test/jdk/tools/jpackage/helpers * @build jdk.jpackage.test.* - * @modules jdk.jpackage/jdk.jpackage.internal * @compile HostArchPkgTest.java * @requires (os.family == "mac") * @key jpackagePlatformPackage diff -Nru openjdk-17-17.0.17+10/test/jdk/tools/jpackage/macosx/MacAppStoreJlinkOptionsTest.java openjdk-17-17.0.18+8/test/jdk/tools/jpackage/macosx/MacAppStoreJlinkOptionsTest.java --- openjdk-17-17.0.17+10/test/jdk/tools/jpackage/macosx/MacAppStoreJlinkOptionsTest.java 2025-10-13 07:48:04.000000000 +0000 +++ openjdk-17-17.0.18+8/test/jdk/tools/jpackage/macosx/MacAppStoreJlinkOptionsTest.java 2026-01-15 15:23:06.000000000 +0000 @@ -1,5 +1,5 @@ /* - * Copyright (c) 2022, 2023, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2022, 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 @@ -33,11 +33,9 @@ /* * @test * @summary jpackage with --mac-app-store and --jlink-options - * @library ../helpers - * @library /test/lib + * @library /test/jdk/tools/jpackage/helpers * @build jdk.jpackage.test.* * @build MacAppStoreJLinkOptionsTest - * @modules jdk.jpackage/jdk.jpackage.internal * @requires (os.family == "mac") * @run main/othervm/timeout=540 -Xmx512m jdk.jpackage.test.Main * --jpt-run=MacAppStoreJLinkOptionsTest diff -Nru openjdk-17-17.0.17+10/test/jdk/tools/jpackage/macosx/MacAppStoreRuntimeTest.java openjdk-17-17.0.18+8/test/jdk/tools/jpackage/macosx/MacAppStoreRuntimeTest.java --- openjdk-17-17.0.17+10/test/jdk/tools/jpackage/macosx/MacAppStoreRuntimeTest.java 2025-10-13 07:48:04.000000000 +0000 +++ openjdk-17-17.0.18+8/test/jdk/tools/jpackage/macosx/MacAppStoreRuntimeTest.java 2026-01-15 15:23:06.000000000 +0000 @@ -1,5 +1,5 @@ /* - * Copyright (c) 2022, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2022, 2024, Oracle and/or its affiliates. All rights reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * * This code is free software; you can redistribute it and/or modify it @@ -43,11 +43,9 @@ /* * @test * @summary jpackage with --mac-app-store and --runtime-image - * @library ../helpers - * @library /test/lib + * @library /test/jdk/tools/jpackage/helpers * @build jdk.jpackage.test.* * @build MacAppStoreRuntimeTest - * @modules jdk.jpackage/jdk.jpackage.internal * @requires (os.family == "mac") * @run main/othervm -Xmx512m jdk.jpackage.test.Main * --jpt-run=MacAppStoreRuntimeTest diff -Nru openjdk-17-17.0.17+10/test/jdk/tools/jpackage/macosx/MacFileAssociationsTest.java openjdk-17-17.0.18+8/test/jdk/tools/jpackage/macosx/MacFileAssociationsTest.java --- openjdk-17-17.0.17+10/test/jdk/tools/jpackage/macosx/MacFileAssociationsTest.java 2025-10-13 07:48:04.000000000 +0000 +++ openjdk-17-17.0.18+8/test/jdk/tools/jpackage/macosx/MacFileAssociationsTest.java 2026-01-15 15:23:06.000000000 +0000 @@ -1,5 +1,5 @@ /* - * Copyright (c) 2020, 2021, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2020, 2024, Oracle and/or its affiliates. All rights reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * * This code is free software; you can redistribute it and/or modify it @@ -40,10 +40,9 @@ /* * @test * @summary jpackage with --file-associations and mac specific file association args - * @library ../helpers + * @library /test/jdk/tools/jpackage/helpers * @build jdk.jpackage.test.* * @build MacFileAssociationsTest - * @modules jdk.jpackage/jdk.jpackage.internal * @requires (os.family == "mac") * @run main/othervm -Xmx512m jdk.jpackage.test.Main * --jpt-run=MacFileAssociationsTest diff -Nru openjdk-17-17.0.17+10/test/jdk/tools/jpackage/macosx/MacPropertiesTest.java openjdk-17-17.0.18+8/test/jdk/tools/jpackage/macosx/MacPropertiesTest.java --- openjdk-17-17.0.17+10/test/jdk/tools/jpackage/macosx/MacPropertiesTest.java 2025-10-13 07:48:04.000000000 +0000 +++ openjdk-17-17.0.18+8/test/jdk/tools/jpackage/macosx/MacPropertiesTest.java 2026-01-15 15:23:06.000000000 +0000 @@ -1,5 +1,5 @@ /* - * Copyright (c) 2019, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2019, 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 @@ -35,10 +35,9 @@ /* * @test * @summary jpackage with --mac-package-name, --mac-package-identifier - * @library ../helpers + * @library /test/jdk/tools/jpackage/helpers * @build jdk.jpackage.test.* * @requires (os.family == "mac") - * @modules jdk.jpackage/jdk.jpackage.internal * @compile MacPropertiesTest.java * @run main/othervm/timeout=360 -Xmx512m jdk.jpackage.test.Main * --jpt-run=MacPropertiesTest diff -Nru openjdk-17-17.0.17+10/test/jdk/tools/jpackage/macosx/NameWithSpaceTest.java openjdk-17-17.0.18+8/test/jdk/tools/jpackage/macosx/NameWithSpaceTest.java --- openjdk-17-17.0.17+10/test/jdk/tools/jpackage/macosx/NameWithSpaceTest.java 2025-10-13 07:48:04.000000000 +0000 +++ openjdk-17-17.0.18+8/test/jdk/tools/jpackage/macosx/NameWithSpaceTest.java 2026-01-15 15:23:06.000000000 +0000 @@ -1,5 +1,5 @@ /* - * Copyright (c) 2018, 2019, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2018, 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 @@ -38,9 +38,8 @@ /* * @test * @summary jpackage test with name containing spaces - * @library ../helpers + * @library /test/jdk/tools/jpackage/helpers * @build jdk.jpackage.test.* - * @modules jdk.jpackage/jdk.jpackage.internal * @compile NameWithSpaceTest.java * @requires (os.family == "mac") * @key jpackagePlatformPackage diff -Nru openjdk-17-17.0.17+10/test/jdk/tools/jpackage/macosx/SigningAppImageTest.java openjdk-17-17.0.18+8/test/jdk/tools/jpackage/macosx/SigningAppImageTest.java --- openjdk-17-17.0.17+10/test/jdk/tools/jpackage/macosx/SigningAppImageTest.java 2025-10-13 07:48:04.000000000 +0000 +++ openjdk-17-17.0.18+8/test/jdk/tools/jpackage/macosx/SigningAppImageTest.java 2026-01-15 15:23:06.000000000 +0000 @@ -1,5 +1,5 @@ /* - * Copyright (c) 2019, 2022, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2019, 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 @@ -46,7 +46,7 @@ /* * @test * @summary jpackage with --type app-image --mac-sign - * @library ../helpers + * @library /test/jdk/tools/jpackage/helpers * @library /test/lib * @library base * @build SigningBase @@ -54,7 +54,6 @@ * @build jtreg.SkippedException * @build jdk.jpackage.test.* * @build SigningAppImageTest - * @modules jdk.jpackage/jdk.jpackage.internal * @requires (os.family == "mac") * @run main/othervm -Xmx512m jdk.jpackage.test.Main * --jpt-run=SigningAppImageTest diff -Nru openjdk-17-17.0.17+10/test/jdk/tools/jpackage/macosx/SigningPackageTest.java openjdk-17-17.0.18+8/test/jdk/tools/jpackage/macosx/SigningPackageTest.java --- openjdk-17-17.0.17+10/test/jdk/tools/jpackage/macosx/SigningPackageTest.java 2025-10-13 07:48:04.000000000 +0000 +++ openjdk-17-17.0.18+8/test/jdk/tools/jpackage/macosx/SigningPackageTest.java 2026-01-15 15:23:06.000000000 +0000 @@ -1,5 +1,5 @@ /* - * Copyright (c) 2019, 2021, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2019, 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 @@ -46,7 +46,7 @@ /* * @test * @summary jpackage with --type pkg,dmg --mac-sign - * @library ../helpers + * @library /test/jdk/tools/jpackage/helpers * @library /test/lib * @library base * @key jpackagePlatformPackage @@ -55,7 +55,6 @@ * @build jtreg.SkippedException * @build jdk.jpackage.test.* * @build SigningPackageTest - * @modules jdk.jpackage/jdk.jpackage.internal * @requires (os.family == "mac") * @run main/othervm/timeout=360 -Xmx512m jdk.jpackage.test.Main * --jpt-run=SigningPackageTest diff -Nru openjdk-17-17.0.17+10/test/jdk/tools/jpackage/resources/Win8365790Test.ps1 openjdk-17-17.0.18+8/test/jdk/tools/jpackage/resources/Win8365790Test.ps1 --- openjdk-17-17.0.17+10/test/jdk/tools/jpackage/resources/Win8365790Test.ps1 1970-01-01 00:00:00.000000000 +0000 +++ openjdk-17-17.0.18+8/test/jdk/tools/jpackage/resources/Win8365790Test.ps1 2026-01-15 15:23:06.000000000 +0000 @@ -0,0 +1,83 @@ +# +# 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. +# + +param ( + # Path to executable to start. + [Parameter(Mandatory=$true)] + [string]$Executable, + + # Timeout to wait after the executable has been started. + [Parameter(Mandatory=$true)] + [double]$TimeoutSeconds +) + +$type = @{ + TypeDefinition = @' +using System; +using System.Runtime.InteropServices; + +namespace Stuff { + + internal struct Details { + [DllImport("kernel32.dll", SetLastError = true)] + [return: MarshalAs(UnmanagedType.Bool)] + internal static extern bool GenerateConsoleCtrlEvent(uint dwCtrlEvent, uint dwProcessGroupId); + } + + public struct Facade { + public static void GenerateConsoleCtrlEvent() { + if (!Details.GenerateConsoleCtrlEvent(0, 0)) { + reportLastErrorAndExit("GenerateConsoleCtrlEvent"); + } + } + + internal static void reportLastErrorAndExit(String func) { + int errorCode = Marshal.GetLastWin32Error(); + Console.Error.WriteLine(func + " function failed with error code: " + errorCode); + Environment.Exit(100); + } + } +} +'@ +} +Add-Type @type + +Set-PSDebug -Trace 2 + +# Launch the target executable. +# `-NoNewWindow` parameter will attach the started process to the existing console. +$childProc = Start-Process -PassThru -NoNewWindow $Executable + +# Wait a bit to let the started process complete initialization. +Start-Sleep -Seconds $TimeoutSeconds + +# Call GenerateConsoleCtrlEvent to send a CTRL+C event to the launched executable. +# CTRL+C event will be sent to all processes attached to the console of the current process, +# i.e., it will be sent to this PowerShell process and to the started $Executable process because +# it was configured to attach to the existing console (the console of this PowerShell process). +[Stuff.Facade]::GenerateConsoleCtrlEvent() + +# Wait for child process termination +Wait-Process -InputObject $childProc + +Exit 0 diff -Nru openjdk-17-17.0.17+10/test/jdk/tools/jpackage/share/AddLauncherTest.java openjdk-17-17.0.18+8/test/jdk/tools/jpackage/share/AddLauncherTest.java --- openjdk-17-17.0.17+10/test/jdk/tools/jpackage/share/AddLauncherTest.java 2025-10-13 07:48:04.000000000 +0000 +++ openjdk-17-17.0.18+8/test/jdk/tools/jpackage/share/AddLauncherTest.java 2026-01-15 15:23:06.000000000 +0000 @@ -1,5 +1,5 @@ /* - * Copyright (c) 2018, 2021, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2018, 2024, Oracle and/or its affiliates. All rights reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * * This code is free software; you can redistribute it and/or modify it @@ -22,7 +22,6 @@ */ import java.nio.file.Path; -import java.io.File; import java.util.Map; import java.lang.invoke.MethodHandles; import jdk.jpackage.test.PackageTest; @@ -48,11 +47,12 @@ * @summary jpackage with --add-launcher * @key jpackagePlatformPackage * @requires (jpackage.test.SQETest != null) - * @library ../helpers + * @library /test/jdk/tools/jpackage/helpers * @build jdk.jpackage.test.* - * @modules jdk.jpackage/jdk.jpackage.internal * @compile AddLauncherTest.java - * @run main/othervm/timeout=360 -Xmx512m jdk.jpackage.test.Main + * @run main/othervm/timeout=360 -Xmx512m + * --add-opens jdk.jpackage/jdk.jpackage.internal=ALL-UNNAMED + * jdk.jpackage.test.Main * --jpt-run=AddLauncherTest.test */ @@ -61,11 +61,12 @@ * @summary jpackage with --add-launcher * @key jpackagePlatformPackage * @requires (jpackage.test.SQETest == null) - * @library ../helpers + * @library /test/jdk/tools/jpackage/helpers * @build jdk.jpackage.test.* - * @modules jdk.jpackage/jdk.jpackage.internal * @compile AddLauncherTest.java - * @run main/othervm/timeout=540 -Xmx512m jdk.jpackage.test.Main + * @run main/othervm/timeout=540 -Xmx512m + * --add-opens jdk.jpackage/jdk.jpackage.internal=ALL-UNNAMED + * jdk.jpackage.test.Main * --jpt-run=AddLauncherTest */ @@ -225,11 +226,11 @@ TKit.assertEquals(ExpectedCN, mainClass, String.format("Check value of app.mainclass=[%s]" + "in NonModularAppLauncher cfg file is as expected", ExpectedCN)); - TKit.assertTrue(classpath.startsWith("$APPDIR" + File.separator - + nonModularAppDesc.jarFileName()), + TKit.assertTrue(classpath.startsWith(Path.of("$APPDIR", + nonModularAppDesc.jarFileName()).toString()), "Check app.classpath value in ModularAppLauncher cfg file"); } - private final static Path GOLDEN_ICON = TKit.TEST_SRC_ROOT.resolve(Path.of( + private static final Path GOLDEN_ICON = TKit.TEST_SRC_ROOT.resolve(Path.of( "resources", "icon" + TKit.ICON_SUFFIX)); } diff -Nru openjdk-17-17.0.17+10/test/jdk/tools/jpackage/share/AppImagePackageTest.java openjdk-17-17.0.18+8/test/jdk/tools/jpackage/share/AppImagePackageTest.java --- openjdk-17-17.0.17+10/test/jdk/tools/jpackage/share/AppImagePackageTest.java 2025-10-13 07:48:04.000000000 +0000 +++ openjdk-17-17.0.18+8/test/jdk/tools/jpackage/share/AppImagePackageTest.java 2026-01-15 15:23:06.000000000 +0000 @@ -1,5 +1,5 @@ /* - * Copyright (c) 2018, 2021, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2018, 2024, Oracle and/or its affiliates. All rights reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * * This code is free software; you can redistribute it and/or modify it @@ -42,10 +42,9 @@ * @test * @summary jpackage with --app-image * @key jpackagePlatformPackage - * @library ../helpers + * @library /test/jdk/tools/jpackage/helpers * @requires (jpackage.test.SQETest == null) * @build jdk.jpackage.test.* - * @modules jdk.jpackage/jdk.jpackage.internal * @compile AppImagePackageTest.java * @run main/othervm/timeout=540 -Xmx512m jdk.jpackage.test.Main * --jpt-run=AppImagePackageTest diff -Nru openjdk-17-17.0.17+10/test/jdk/tools/jpackage/share/AppLauncherEnvTest.java openjdk-17-17.0.18+8/test/jdk/tools/jpackage/share/AppLauncherEnvTest.java --- openjdk-17-17.0.17+10/test/jdk/tools/jpackage/share/AppLauncherEnvTest.java 2025-10-13 07:48:04.000000000 +0000 +++ openjdk-17-17.0.18+8/test/jdk/tools/jpackage/share/AppLauncherEnvTest.java 2026-01-15 15:23:06.000000000 +0000 @@ -1,5 +1,5 @@ /* - * Copyright (c) 2021, 2023, 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 @@ -30,6 +30,7 @@ import jdk.jpackage.test.JPackageCommand; import jdk.jpackage.test.Annotations.Test; import jdk.jpackage.test.Executor; +import static jdk.jpackage.test.HelloApp.configureAndExecute; import jdk.jpackage.test.TKit; /** @@ -39,12 +40,9 @@ /* * @test * @summary Tests values of environment variables altered by jpackage launcher - * @library ../helpers - * @library /test/lib - * @build AppLauncherEnvTest + * @library /test/jdk/tools/jpackage/helpers * @build jdk.jpackage.test.* * @build AppLauncherEnvTest - * @modules jdk.jpackage/jdk.jpackage.internal * @run main/othervm -Xmx512m jdk.jpackage.test.Main * --jpt-run=AppLauncherEnvTest */ @@ -56,6 +54,7 @@ JPackageCommand cmd = JPackageCommand .helloAppImage(TEST_APP_JAVA + "*Hello") + .ignoreFakeRuntime() .addArguments("--java-options", "-D" + testAddDirProp + "=$APPDIR"); @@ -63,16 +62,12 @@ final String envVarName = envVarName(); - final int attempts = 3; - final int waitBetweenAttemptsSeconds = 5; - List output = new Executor() + List output = configureAndExecute(0, new Executor() .saveOutput() .setExecutable(cmd.appLauncherPath().toAbsolutePath()) .addArguments("--print-env-var=" + envVarName) .addArguments("--print-sys-prop=" + testAddDirProp) - .addArguments("--print-sys-prop=" + "java.library.path") - .executeAndRepeatUntilExitCode(0, attempts, - waitBetweenAttemptsSeconds).getOutput(); + .addArguments("--print-sys-prop=" + "java.library.path")).getOutput(); BiFunction getValue = (idx, name) -> { return output.get(idx).substring((name + "=").length()); diff -Nru openjdk-17-17.0.17+10/test/jdk/tools/jpackage/share/AppVersionTest.java openjdk-17-17.0.18+8/test/jdk/tools/jpackage/share/AppVersionTest.java --- openjdk-17-17.0.17+10/test/jdk/tools/jpackage/share/AppVersionTest.java 1970-01-01 00:00:00.000000000 +0000 +++ openjdk-17-17.0.18+8/test/jdk/tools/jpackage/share/AppVersionTest.java 2026-01-15 15:23:06.000000000 +0000 @@ -0,0 +1,130 @@ +/* + * Copyright (c) 2019, 2024, Oracle and/or its affiliates. All rights reserved. + * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. + * + * This code is free software; you can redistribute it and/or modify it + * under the terms of the GNU General Public License version 2 only, as + * published by the Free Software Foundation. + * + * This code is distributed in the hope that it will be useful, but WITHOUT + * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or + * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License + * version 2 for more details (a copy is included in the LICENSE file that + * accompanied this code). + * + * You should have received a copy of the GNU General Public License version + * 2 along with this work; if not, write to the Free Software Foundation, + * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. + * + * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA + * or visit www.oracle.com if you need additional information or have any + * questions. + */ + + +import java.io.IOException; +import java.util.Collection; +import java.util.ArrayList; +import java.util.List; +import javax.xml.xpath.XPathConstants; +import javax.xml.xpath.XPathExpressionException; +import javax.xml.xpath.XPathFactory; +import jdk.jpackage.internal.AppImageFile; +import jdk.jpackage.test.Annotations.Parameters; +import jdk.jpackage.test.Annotations.Test; +import jdk.jpackage.test.JPackageCommand; +import jdk.jpackage.test.PackageTest; +import jdk.jpackage.test.TKit; +import jdk.jpackage.internal.AppImageFile; +import org.w3c.dom.Document; + +/* + * @test + * @summary jpackage application version testing + * @library /test/jdk/tools/jpackage/helpers + * @build jdk.jpackage.test.* + * @compile AppVersionTest.java + * @run main/othervm/timeout=360 -Xmx512m jdk.jpackage.test.Main + * --jpt-run=AppVersionTest + */ + +public final class AppVersionTest { + + @Parameters + public static Collection input() { + List data = new ArrayList<>(); + + data.addAll(List.of(new Object[][]{ + // Default jpackage version + {"1.0", "Hello", null}, + {"1.0", "com.other/com.other.Hello", null}, + // Version should be picked from --app-version + {"3.1", "Hello", new String[]{"--app-version", "3.1"}}, + {"3.2", "com.other/com.other.Hello", new String[]{"--app-version", + "3.2"}}, + // Version should be picked from the last --app-version + {"3.3", "Hello", new String[]{"--app-version", "4", "--app-version", + "3.3"}}, + {"7.8", "com.other/com.other.Hello", new String[]{"--app-version", + "4", "--app-version", "7.8"}}, + // Pick version from jar + {"3.10.17", "com.other/com.other.Hello@3.10.17", null}, + // Ignore version in jar if --app-version given + {"7.5.81", "com.other/com.other.Hello@3.10.17", new String[]{ + "--app-version", "7.5.81"}} + })); + + // These are invalid version strings. + // Don't need to test all invalid input as this is handled in + // PlatformVersionTest unit test + if (TKit.isWindows()) { + data.addAll(List.of(new Object[][]{ + {null, "Hello", new String[]{"--app-version", "256"}} + })); + } else if (TKit.isOSX()) { + data.addAll(List.of(new Object[][]{ + {null, "Hello", new String[]{"--app-version", "0.2"}} + })); + } + + return data; + } + + public AppVersionTest(String expectedVersion, String javaAppDesc, + String[] jpackageArgs) { + this.expectedVersion = expectedVersion; + this.javaAppDesc = javaAppDesc; + this.jpackageArgs = jpackageArgs; + } + + @Test + public void test() throws XPathExpressionException, IOException { + if (expectedVersion == null) { + new PackageTest() + .setExpectedExitCode(1) + .configureHelloApp(javaAppDesc) + .addInitializer(cmd -> { + cmd.addArguments(jpackageArgs); + }) + .run(); + return; + } + + JPackageCommand cmd = JPackageCommand.helloAppImage(javaAppDesc); + if (jpackageArgs != null) { + cmd.addArguments(jpackageArgs); + } + cmd.executeAndAssertHelloAppImageCreated(); + + Document xml = AppImageFile.readXml(cmd.outputBundle()); + String actualVersion = XPathFactory.newInstance().newXPath().evaluate( + "/jpackage-state/app-version/text()", xml, XPathConstants.STRING).toString(); + + TKit.assertEquals(expectedVersion, actualVersion, + "Check application version"); + } + + private final String expectedVersion; + private final String javaAppDesc; + private final String[] jpackageArgs; +} diff -Nru openjdk-17-17.0.17+10/test/jdk/tools/jpackage/share/ArgumentsTest.java openjdk-17-17.0.18+8/test/jdk/tools/jpackage/share/ArgumentsTest.java --- openjdk-17-17.0.17+10/test/jdk/tools/jpackage/share/ArgumentsTest.java 2025-10-13 07:48:04.000000000 +0000 +++ openjdk-17-17.0.18+8/test/jdk/tools/jpackage/share/ArgumentsTest.java 2026-01-15 15:23:06.000000000 +0000 @@ -1,5 +1,5 @@ /* - * Copyright (c) 2018, 2022, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2018, 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 @@ -24,7 +24,6 @@ import java.nio.file.Path; import java.util.List; import jdk.jpackage.test.HelloApp; -import jdk.jpackage.test.Functional.ThrowingConsumer; import jdk.jpackage.test.JPackageCommand; import jdk.jpackage.test.Annotations.BeforeEach; import jdk.jpackage.test.Annotations.Test; @@ -47,9 +46,8 @@ /* * @test * @summary jpackage create image with --arguments test - * @library ../helpers + * @library /test/jdk/tools/jpackage/helpers * @build jdk.jpackage.test.* - * @modules jdk.jpackage/jdk.jpackage.internal * @compile ArgumentsTest.java * @run main/othervm/timeout=360 -Xmx512m jdk.jpackage.test.Main * --jpt-run=ArgumentsTest @@ -65,27 +63,19 @@ @Parameter("Goodbye") @Parameter("com.hello/com.hello.Hello") public static void testApp(String javaAppDesc) { - testIt(javaAppDesc, null); - } - - private static void testIt(String javaAppDesc, - ThrowingConsumer initializer) { - JPackageCommand cmd = JPackageCommand.helloAppImage(javaAppDesc).addArguments( "--arguments", JPackageCommand.escapeAndJoin(TRICKY_ARGUMENTS)); - if (initializer != null) { - ThrowingConsumer.toConsumer(initializer).accept(cmd); - } cmd.executeAndAssertImageCreated(); - Path launcherPath = cmd.appLauncherPath(); - if (!cmd.isFakeRuntime(String.format( - "Not running [%s] launcher", launcherPath))) { - HelloApp.assertApp(launcherPath) - .addDefaultArguments(TRICKY_ARGUMENTS) - .executeAndVerifyOutput(); + if (!cmd.canRunLauncher("Not running the test")) { + return; } + + Path launcherPath = cmd.appLauncherPath(); + HelloApp.assertApp(launcherPath) + .addDefaultArguments(TRICKY_ARGUMENTS) + .executeAndVerifyOutput(); } private final static List TRICKY_ARGUMENTS = List.of( diff -Nru openjdk-17-17.0.17+10/test/jdk/tools/jpackage/share/BasicTest.java openjdk-17-17.0.18+8/test/jdk/tools/jpackage/share/BasicTest.java --- openjdk-17-17.0.17+10/test/jdk/tools/jpackage/share/BasicTest.java 1970-01-01 00:00:00.000000000 +0000 +++ openjdk-17-17.0.18+8/test/jdk/tools/jpackage/share/BasicTest.java 2026-01-15 15:23:06.000000000 +0000 @@ -0,0 +1,363 @@ +/* + * Copyright (c) 2019, 2024, Oracle and/or its affiliates. All rights reserved. + * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. + * + * This code is free software; you can redistribute it and/or modify it + * under the terms of the GNU General Public License version 2 only, as + * published by the Free Software Foundation. + * + * This code is distributed in the hope that it will be useful, but WITHOUT + * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or + * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License + * version 2 for more details (a copy is included in the LICENSE file that + * accompanied this code). + * + * You should have received a copy of the GNU General Public License version + * 2 along with this work; if not, write to the Free Software Foundation, + * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. + * + * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA + * or visit www.oracle.com if you need additional information or have any + * questions. + */ + + +import java.io.IOException; +import java.nio.file.Files; +import java.nio.file.Path; +import java.util.List; +import java.util.ArrayList; +import java.util.function.Function; +import java.util.function.Predicate; +import java.util.regex.Pattern; +import java.util.stream.Stream; +import jdk.jpackage.test.TKit; +import jdk.jpackage.test.JPackageCommand; +import jdk.jpackage.test.JavaAppDesc; +import jdk.jpackage.test.PackageTest; +import jdk.jpackage.test.HelloApp; +import jdk.jpackage.test.Executor; +import jdk.jpackage.test.JavaTool; +import jdk.jpackage.test.Annotations.Test; +import jdk.jpackage.test.Annotations.Parameter; + +/* + * @test + * @summary jpackage basic testing + * @library /test/jdk/tools/jpackage/helpers + * @build jdk.jpackage.test.* + * @compile BasicTest.java + * @run main/othervm/timeout=720 -Xmx512m jdk.jpackage.test.Main + * --jpt-run=BasicTest + */ + +public final class BasicTest { + @Test + public void testNoArgs() { + List output = + getJPackageToolProvider().executeAndGetOutput(); + TKit.assertStringListEquals(List.of("Usage: jpackage ", + "Use jpackage --help (or -h) for a list of possible options"), + output, "Check jpackage output"); + } + + @Test + public void testJpackageProps() { + String appVersion = "3.0"; + JPackageCommand cmd = JPackageCommand.helloAppImage( + JavaAppDesc.parse("Hello")) + // Disable default logic adding `--verbose` option + // to jpackage command line. + .ignoreDefaultVerbose(true) + .saveConsoleOutput(true) + .addArguments("--app-version", appVersion, "--arguments", + "jpackage.app-version jpackage.app-path") + .ignoreFakeRuntime(); + + cmd.executeAndAssertImageCreated(); + Path launcherPath = cmd.appLauncherPath(); + + List output = HelloApp.executeLauncher(cmd).getOutput(); + + TKit.assertTextStream("jpackage.app-version=" + appVersion).apply(output.stream()); + TKit.assertTextStream("jpackage.app-path=").apply(output.stream()); + } + + @Test + public void testVersion() { + List output = + getJPackageToolProvider() + .addArgument("--version") + .executeAndGetOutput(); + TKit.assertStringListEquals(List.of(System.getProperty("java.version")), + output, "Check jpackage output"); + } + + @Test + public void testHelp() { + List hOutput = getJPackageToolProvider() + .addArgument("-h").executeAndGetOutput(); + List helpOutput = getJPackageToolProvider() + .addArgument("--help").executeAndGetOutput(); + + TKit.assertStringListEquals(hOutput, helpOutput, + "Check -h and --help parameters produce the same output"); + + final String windowsPrefix = "--win-"; + final String linuxPrefix = "--linux-"; + final String osxPrefix = "--mac-"; + + final String expectedPrefix; + final List unexpectedPrefixes; + + if (TKit.isWindows()) { + expectedPrefix = windowsPrefix; + unexpectedPrefixes = List.of(osxPrefix, linuxPrefix); + } else if (TKit.isLinux()) { + expectedPrefix = linuxPrefix; + unexpectedPrefixes = List.of(windowsPrefix, osxPrefix); + } else if (TKit.isOSX()) { + expectedPrefix = osxPrefix; + unexpectedPrefixes = List.of(linuxPrefix, windowsPrefix); + } else { + throw TKit.throwUnknownPlatformError(); + } + + Function> createPattern = (prefix) -> { + return Pattern.compile("^ " + prefix).asPredicate(); + }; + + Function, Long> countStrings = (prefixes) -> { + return hOutput.stream().filter( + prefixes.stream().map(createPattern).reduce(x -> false, + Predicate::or)).peek(TKit::trace).count(); + }; + + TKit.trace("Check parameters in help text"); + TKit.assertNotEquals(0, countStrings.apply(List.of(expectedPrefix)), + "Check help text contains platform specific parameters"); + TKit.assertEquals(0, countStrings.apply(unexpectedPrefixes), + "Check help text doesn't contain unexpected parameters"); + } + + @Test + @SuppressWarnings("unchecked") + public void testVerbose() { + JPackageCommand cmd = JPackageCommand.helloAppImage() + // Disable default logic adding `--verbose` option + // to jpackage command line. + .ignoreDefaultVerbose(true) + .saveConsoleOutput(true) + .setFakeRuntime().executePrerequisiteActions(); + + List expectedVerboseOutputStrings = new ArrayList<>(); + expectedVerboseOutputStrings.add("Creating app package:"); + if (TKit.isWindows()) { + expectedVerboseOutputStrings.add( + "Succeeded in building Windows Application Image package"); + } else if (TKit.isLinux()) { + expectedVerboseOutputStrings.add( + "Succeeded in building Linux Application Image package"); + } else if (TKit.isOSX()) { + expectedVerboseOutputStrings.add("Preparing Info.plist:"); + expectedVerboseOutputStrings.add( + "Succeeded in building Mac Application Image package"); + } else { + TKit.throwUnknownPlatformError(); + } + + TKit.deleteDirectoryContentsRecursive(cmd.outputDir()); + List nonVerboseOutput = cmd.execute().getOutput(); + List[] verboseOutput = (List[])new List[1]; + + // Directory clean up is not 100% reliable on Windows because of + // antivirus software that can lock .exe files. Setup + // different output directory instead of cleaning the default one for + // verbose jpackage run. + TKit.withTempDirectory("verbose-output", tempDir -> { + cmd.setArgumentValue("--dest", tempDir); + cmd.addArgument("--verbose"); + verboseOutput[0] = cmd.execute().getOutput(); + }); + + TKit.assertTrue(nonVerboseOutput.size() < verboseOutput[0].size(), + "Check verbose output is longer than regular"); + + expectedVerboseOutputStrings.forEach(str -> { + TKit.assertTextStream(str).label("regular output") + .predicate(String::contains).negate() + .apply(nonVerboseOutput.stream()); + }); + + expectedVerboseOutputStrings.forEach(str -> { + TKit.assertTextStream(str).label("verbose output") + .apply(verboseOutput[0].stream()); + }); + } + + @Test + public void testNoName() { + final String mainClassName = "Greetings"; + + JPackageCommand cmd = JPackageCommand.helloAppImage(mainClassName) + .removeArgumentWithValue("--name"); + + Path expectedImageDir = cmd.outputDir().resolve(mainClassName); + if (TKit.isOSX()) { + expectedImageDir = expectedImageDir.getParent().resolve( + expectedImageDir.getFileName().toString() + ".app"); + } + + cmd.executeAndAssertHelloAppImageCreated(); + TKit.assertEquals(expectedImageDir.toAbsolutePath().normalize().toString(), + cmd.outputBundle().toAbsolutePath().normalize().toString(), + String.format( + "Check [%s] directory is filled with application image data", + expectedImageDir)); + } + + @Test + // Regular app + @Parameter("Hello") + // Modular app in .jar file + @Parameter("com.other/com.other.Hello") + // Modular app in .jmod file + @Parameter("hello.jmod:com.other/com.other.Hello") + // Modular app in exploded .jmod file + @Parameter("hello.ejmod:com.other/com.other.Hello") + public void testApp(String javaAppDesc) { + JavaAppDesc appDesc = JavaAppDesc.parse(javaAppDesc); + JPackageCommand cmd = JPackageCommand.helloAppImage(appDesc); + if (appDesc.jmodFileName() != null) { + // .jmod files are not supported at run-time. They should be + // bundled in Java run-time with jlink command, so disable + // use of external Java run-time if any configured. + cmd.ignoreDefaultRuntime(true); + } + cmd.executeAndAssertHelloAppImageCreated(); + } + + @Test + public void testWhitespaceInPaths() { + JPackageCommand.helloAppImage("a/b c.jar:Hello") + .setArgumentValue("--input", TKit.workDir().resolve("The quick brown fox")) + .setArgumentValue("--dest", TKit.workDir().resolve("jumps over the lazy dog")) + .executeAndAssertHelloAppImageCreated(); + } + + @Test + @Parameter("ALL-MODULE-PATH") + @Parameter("ALL-DEFAULT") + @Parameter("java.desktop") + @Parameter("java.desktop,jdk.jartool") + @Parameter({ "java.desktop", "jdk.jartool" }) + public void testAddModules(String... addModulesArg) { + JPackageCommand cmd = JPackageCommand + .helloAppImage("goodbye.jar:com.other/com.other.Hello") + .ignoreDefaultRuntime(true); // because of --add-modules + Stream.of(addModulesArg).map(v -> Stream.of("--add-modules", v)).flatMap( + s -> s).forEachOrdered(cmd::addArgument); + cmd.executeAndAssertHelloAppImageCreated(); + } + + public static enum TestTempType { + TEMPDIR_EMPTY, + TEMPDIR_NOT_EMPTY, + TEMPDIR_NOT_EXIST, + } + + /** + * Test --temp option. Doesn't make much sense for app image as temporary + * directory is used only on Windows. Test it in packaging mode. + */ + @Test + @Parameter("TEMPDIR_EMPTY") + @Parameter("TEMPDIR_NOT_EMPTY") + @Parameter("TEMPDIR_NOT_EXIST") + public void testTemp(TestTempType type) throws IOException { + final Path tempRoot = TKit.createTempDirectory("tmp"); + + var pkgTest = new PackageTest() + .configureHelloApp() + // Force save of package bundle in test work directory. + .addInitializer(JPackageCommand::setDefaultInputOutput) + .addInitializer(cmd -> { + Path tempDir = tempRoot.resolve(cmd.packageType().name()); + switch (type) { + case TEMPDIR_EMPTY -> Files.createDirectories(tempDir); + case TEMPDIR_NOT_EXIST -> Files.createDirectories(tempDir.getParent()); + case TEMPDIR_NOT_EMPTY -> { + Files.createDirectories(tempDir); + TKit.createTextFile(tempDir.resolve("foo.txt"), List.of( + "Hello Duke!")); + } + } + cmd.addArguments("--temp", tempDir); + } + ); + + if (TestTempType.TEMPDIR_NOT_EMPTY.equals(type)) { + pkgTest.setExpectedExitCode(1).addBundleVerifier(cmd -> { + // Check jpackage didn't use the supplied directory. + Path tempDir = Path.of(cmd.getArgumentValue("--temp")); + TKit.assertDirectoryContent(tempDir).match(Path.of("foo.txt")); + TKit.assertStringListEquals(List.of("Hello Duke!"), + Files.readAllLines(tempDir.resolve("foo.txt")), + "Check the contents of the file in the supplied temporary directory"); + }); + } else { + pkgTest.addBundleVerifier(cmd -> { + // Check jpackage used the supplied directory. + Path tempDir = Path.of(cmd.getArgumentValue("--temp")); + TKit.assertDirectoryNotEmpty(tempDir); + }); + } + + pkgTest.run(PackageTest.Action.CREATE); + } + + @Test + public void testAtFile() throws IOException { + JPackageCommand cmd = JPackageCommand + .helloAppImage() + .setArgumentValue("--dest", TKit.createTempDirectory("output")); + + // Init options file with the list of options configured + // for JPackageCommand instance. + final Path optionsFile = TKit.createTempFile(Path.of("options")); + Files.write(optionsFile, + List.of(String.join(" ", cmd.getAllArguments()))); + + // Build app jar file. + cmd.executePrerequisiteActions(); + + // Instead of running jpackage command through configured + // JPackageCommand instance, run vanilla jpackage command with @ file. + getJPackageToolProvider() + .addArgument(String.format("@%s", optionsFile)) + .execute(); + + // Verify output of jpackage command. + cmd.assertImageCreated(); + HelloApp.executeLauncherAndVerifyOutput(cmd); + } + + @Test + @Parameter("1") + @Parameter("123") + public void testExitCode(int exitCode) { + JPackageCommand cmd = JPackageCommand + .helloAppImage() + .addArguments("--java-options", String.format( + "-Djpackage.test.exitCode=%d", exitCode)); + cmd.executeAndAssertHelloAppImageCreated(); + } + + private static Executor getJPackageToolProvider() { + return getToolProvider(JavaTool.JPACKAGE); + } + + private static Executor getToolProvider(JavaTool tool) { + return new Executor().dumpOutput().saveOutput().setToolProvider(tool); + } +} diff -Nru openjdk-17-17.0.17+10/test/jdk/tools/jpackage/share/CookedRuntimeTest.java openjdk-17-17.0.18+8/test/jdk/tools/jpackage/share/CookedRuntimeTest.java --- openjdk-17-17.0.17+10/test/jdk/tools/jpackage/share/CookedRuntimeTest.java 1970-01-01 00:00:00.000000000 +0000 +++ openjdk-17-17.0.18+8/test/jdk/tools/jpackage/share/CookedRuntimeTest.java 2026-01-15 15:23:06.000000000 +0000 @@ -0,0 +1,140 @@ +/* + * Copyright (c) 2020, 2024, Oracle and/or its affiliates. All rights reserved. + * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. + * + * This code is free software; you can redistribute it and/or modify it + * under the terms of the GNU General Public License version 2 only, as + * published by the Free Software Foundation. + * + * This code is distributed in the hope that it will be useful, but WITHOUT + * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or + * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License + * version 2 for more details (a copy is included in the LICENSE file that + * accompanied this code). + * + * You should have received a copy of the GNU General Public License version + * 2 along with this work; if not, write to the Free Software Foundation, + * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. + * + * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA + * or visit www.oracle.com if you need additional information or have any + * questions. + */ + + +import java.io.IOException; +import java.nio.file.Files; +import java.util.Collection; +import java.util.ArrayList; +import java.util.List; +import java.util.stream.Stream; +import java.nio.file.Path; +import jdk.jpackage.test.Annotations.Parameters; +import jdk.jpackage.test.Annotations.Test; +import jdk.jpackage.test.Executor; +import jdk.jpackage.test.JPackageCommand; +import jdk.jpackage.test.JavaAppDesc; +import jdk.jpackage.test.JavaTool; +import jdk.jpackage.test.TKit; + + +/* + * @test + * @summary test '--runtime-image' option of jpackage + * @library /test/jdk/tools/jpackage/helpers + * @build jdk.jpackage.test.* + * @compile CookedRuntimeTest.java + * @run main/othervm/timeout=360 -Xmx512m jdk.jpackage.test.Main + * --jpt-run=CookedRuntimeTest + */ + +public final class CookedRuntimeTest { + + public CookedRuntimeTest(String javaAppDesc, String jlinkOutputSubdir, + String runtimeSubdir) { + this.javaAppDesc = javaAppDesc; + this.jlinkOutputSubdir = Path.of(jlinkOutputSubdir); + this.runtimeSubdir = Path.of(runtimeSubdir); + } + + @Test + public void test() throws IOException { + JavaAppDesc appDesc = JavaAppDesc.parse(javaAppDesc); + + JPackageCommand cmd = JPackageCommand.helloAppImage(appDesc); + + final String moduleName = appDesc.moduleName(); + + if (moduleName != null) { + // Build module jar. + cmd.executePrerequisiteActions(); + } + + final Path workDir = TKit.createTempDirectory("runtime").resolve("data"); + final Path jlinkOutputDir = workDir.resolve(jlinkOutputSubdir); + Files.createDirectories(jlinkOutputDir.getParent()); + + // List of modules required for test app. + final var modules = new String[] { + "java.base", + "java.desktop" + }; + + Executor jlink = new Executor() + .setToolProvider(JavaTool.JLINK) + .dumpOutput() + .addArguments( + "--add-modules", String.join(",", modules), + "--output", jlinkOutputDir.toString(), + "--strip-debug", + "--no-header-files", + "--no-man-pages"); + + if (moduleName != null) { + jlink.addArguments("--add-modules", moduleName, "--module-path", + Path.of(cmd.getArgumentValue("--module-path")).resolve( + "hello.jar").toString()); + } + + jlink.execute(); + + TKit.trace("jlink output BEGIN"); + try (Stream paths = Files.walk(jlinkOutputDir)) { + paths.filter(Files::isRegularFile) + .map(jlinkOutputDir::relativize) + .map(Path::toString) + .forEach(TKit::trace); + } + TKit.trace("jlink output END"); + + cmd.setArgumentValue("--runtime-image", workDir.resolve(runtimeSubdir)); + cmd.executeAndAssertHelloAppImageCreated(); + } + + @Parameters + public static Collection data() { + final List javaAppDescs = List.of("Hello", + "com.foo/com.foo.main.Aloha"); + + final List paths = new ArrayList<>(); + paths.add(new String[] { "", "" }); + if (TKit.isOSX()) { + // On OSX jpackage should accept both runtime root and runtime home + // directories. + paths.add(new String[] { "Contents/Home", "" }); + } + + List data = new ArrayList<>(); + for (var javaAppDesc : javaAppDescs) { + for (var pathCfg : paths) { + data.add(new Object[] { javaAppDesc, pathCfg[0], pathCfg[1] }); + } + } + + return data; + } + + private final String javaAppDesc; + private final Path jlinkOutputSubdir; + private final Path runtimeSubdir; +} diff -Nru openjdk-17-17.0.17+10/test/jdk/tools/jpackage/share/DotInNameTest.java openjdk-17-17.0.18+8/test/jdk/tools/jpackage/share/DotInNameTest.java --- openjdk-17-17.0.17+10/test/jdk/tools/jpackage/share/DotInNameTest.java 1970-01-01 00:00:00.000000000 +0000 +++ openjdk-17-17.0.18+8/test/jdk/tools/jpackage/share/DotInNameTest.java 2026-01-15 15:23:06.000000000 +0000 @@ -0,0 +1,59 @@ +/* + * Copyright (c) 2021, 2024, Oracle and/or its affiliates. All rights reserved. + * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. + * + * This code is free software; you can redistribute it and/or modify it + * 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.jpackage.test.JPackageCommand; +import jdk.jpackage.test.HelloApp; +import jdk.jpackage.test.TKit; +import jdk.jpackage.test.Annotations.Parameters; +import jdk.jpackage.test.Annotations.Test; + + +/* + * @test + * @summary jpackage create image with --java-options test + * @library /test/jdk/tools/jpackage/helpers + * @build jdk.jpackage.test.* + * @compile DotInNameTest.java + * @run main/othervm/timeout=360 -Xmx512m jdk.jpackage.test.Main + * --jpt-run=DotInNameTest + * --jpt-before-run=jdk.jpackage.test.JPackageCommand.useToolProviderByDefault + */ + +public class DotInNameTest { + + @Test + public void test() { + JPackageCommand cmd = JPackageCommand.helloAppImage("Hello"); + + cmd.setArgumentValue("--name", + cmd.getArgumentValue("--name") + ".with.dot"); + // run the jpackage command + cmd.executeAndAssertImageCreated(); + + // run the launcher it generated + HelloApp.executeLauncherAndVerifyOutput(cmd); + + } + +} diff -Nru openjdk-17-17.0.17+10/test/jdk/tools/jpackage/share/EmptyFolderTest.java openjdk-17-17.0.18+8/test/jdk/tools/jpackage/share/EmptyFolderTest.java --- openjdk-17-17.0.17+10/test/jdk/tools/jpackage/share/EmptyFolderTest.java 2025-10-13 07:48:04.000000000 +0000 +++ openjdk-17-17.0.18+8/test/jdk/tools/jpackage/share/EmptyFolderTest.java 2026-01-15 15:23:06.000000000 +0000 @@ -37,12 +37,10 @@ /* * @test * @summary jpackage for package with input containing empty folders - * @library ../helpers - * @library /test/lib + * @library /test/jdk/tools/jpackage/helpers * @key jpackagePlatformPackage * @build jdk.jpackage.test.* * @build EmptyFolderTest - * @modules jdk.jpackage/jdk.jpackage.internal * @run main/othervm/timeout=720 -Xmx512m jdk.jpackage.test.Main * --jpt-run=EmptyFolderTest.testPackage */ @@ -50,11 +48,9 @@ /* * @test * @summary jpackage for app image with input containing empty folders - * @library ../helpers - * @library /test/lib + * @library /test/jdk/tools/jpackage/helpers * @build jdk.jpackage.test.* * @build EmptyFolderTest - * @modules jdk.jpackage/jdk.jpackage.internal * @run main/othervm -Xmx512m jdk.jpackage.test.Main * --jpt-run=EmptyFolderTest.testAppImage */ diff -Nru openjdk-17-17.0.17+10/test/jdk/tools/jpackage/share/ErrorTest.java openjdk-17-17.0.18+8/test/jdk/tools/jpackage/share/ErrorTest.java --- openjdk-17-17.0.17+10/test/jdk/tools/jpackage/share/ErrorTest.java 1970-01-01 00:00:00.000000000 +0000 +++ openjdk-17-17.0.18+8/test/jdk/tools/jpackage/share/ErrorTest.java 2026-01-15 15:23:06.000000000 +0000 @@ -0,0 +1,133 @@ +/* + * Copyright (c) 2020, 2024, Oracle and/or its affiliates. All rights reserved. + * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. + * + * This code is free software; you can redistribute it and/or modify it + * under the terms of the GNU General Public License version 2 only, as + * published by the Free Software Foundation. + * + * This code is distributed in the hope that it will be useful, but WITHOUT + * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or + * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License + * version 2 for more details (a copy is included in the LICENSE file that + * accompanied this code). + * + * You should have received a copy of the GNU General Public License version + * 2 along with this work; if not, write to the Free Software Foundation, + * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. + * + * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA + * or visit www.oracle.com if you need additional information or have any + * questions. + */ + + +import java.util.Collection; +import java.util.List; +import jdk.jpackage.test.Annotations.Parameters; +import jdk.jpackage.test.Annotations.Test; +import jdk.jpackage.test.JPackageCommand; +import jdk.jpackage.test.TKit; + +/* + * @test + * @summary Test jpackage output for erroneous input + * @library /test/jdk/tools/jpackage/helpers + * @build jdk.jpackage.test.* + * @compile ErrorTest.java + * @run main/othervm/timeout=360 -Xmx512m jdk.jpackage.test.Main + * --jpt-run=ErrorTest + * --jpt-before-run=jdk.jpackage.test.JPackageCommand.useExecutableByDefault + */ + +/* + * @test + * @summary Test jpackage output for erroneous input + * @library /test/jdk/tools/jpackage/helpers + * @build jdk.jpackage.test.* + * @compile ErrorTest.java + * @run main/othervm/timeout=360 -Xmx512m jdk.jpackage.test.Main + * --jpt-run=ErrorTest + * --jpt-before-run=jdk.jpackage.test.JPackageCommand.useToolProviderByDefault + */ + +public final class ErrorTest { + + private final String expectedError; + private final JPackageCommand cmd; + + @Parameters + public static Collection input() { + return List.of(new Object[][]{ + // non-existent arg + {"Hello", + new String[]{"--no-such-argument"}, + null, + "Invalid Option: [--no-such-argument]"}, + // no main jar + {"Hello", + null, + new String[]{"--main-jar"}, + "--main-jar or --module"}, + // no main-class + {"Hello", + null, + new String[]{"--main-class"}, + "main class was not specified"}, + // non-existent main jar + {"Hello", + new String[]{"--main-jar", "non-existent.jar"}, + null, + "main jar does not exist"}, + // non-existent runtime + {"Hello", + new String[]{"--runtime-image", "non-existent.runtime"}, + null, + "does not exist"}, + // non-existent resource-dir + {"Hello", + new String[]{"--resource-dir", "non-existent.dir"}, + null, + "does not exist"}, + // invalid type + {"Hello", + new String[]{"--type", "invalid-type"}, + null, + "Invalid or unsupported type: [invalid-type]"}, + // no --input + {"Hello", + null, + new String[]{"--input"}, + "Missing argument: --input"}, + // no --module-path + {"com.other/com.other.Hello", + null, + new String[]{"--module-path"}, + "Missing argument: --runtime-image or --module-path"}, + }); + } + + public ErrorTest(String javaAppDesc, String[] jpackageArgs, + String[] removeArgs, + String expectedError) { + this.expectedError = expectedError; + + cmd = JPackageCommand.helloAppImage(javaAppDesc) + .saveConsoleOutput(true).dumpOutput(true); + if (jpackageArgs != null) { + cmd.addArguments(jpackageArgs); + } if (removeArgs != null) { + for (String arg : removeArgs) { + cmd.removeArgumentWithValue(arg); + } + } + } + + @Test + public void test() { + List output = cmd.execute(1).getOutput(); + TKit.assertNotNull(output, "output is null"); + TKit.assertTextStream(expectedError).apply(output.stream()); + } + +} diff -Nru openjdk-17-17.0.17+10/test/jdk/tools/jpackage/share/FileAssociationsTest.java openjdk-17-17.0.18+8/test/jdk/tools/jpackage/share/FileAssociationsTest.java --- openjdk-17-17.0.17+10/test/jdk/tools/jpackage/share/FileAssociationsTest.java 2025-10-13 07:48:04.000000000 +0000 +++ openjdk-17-17.0.18+8/test/jdk/tools/jpackage/share/FileAssociationsTest.java 2026-01-15 15:23:06.000000000 +0000 @@ -1,5 +1,5 @@ /* - * Copyright (c) 2018, 2019, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2018, 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 @@ -57,11 +57,10 @@ /* * @test * @summary jpackage with --file-associations - * @library ../helpers + * @library /test/jdk/tools/jpackage/helpers * @key jpackagePlatformPackage * @requires jpackage.test.SQETest == null * @build jdk.jpackage.test.* - * @modules jdk.jpackage/jdk.jpackage.internal * @compile FileAssociationsTest.java * @run main/othervm/timeout=360 -Xmx512m jdk.jpackage.test.Main * --jpt-run=FileAssociationsTest @@ -70,11 +69,10 @@ /* * @test * @summary jpackage with --file-associations - * @library ../helpers + * @library /test/jdk/tools/jpackage/helpers * @key jpackagePlatformPackage * @requires jpackage.test.SQETest != null * @build jdk.jpackage.test.* - * @modules jdk.jpackage/jdk.jpackage.internal * @compile FileAssociationsTest.java * @run main/othervm/timeout=360 -Xmx512m jdk.jpackage.test.Main * --jpt-run=FileAssociationsTest.test diff -Nru openjdk-17-17.0.17+10/test/jdk/tools/jpackage/share/IconTest.java openjdk-17-17.0.18+8/test/jdk/tools/jpackage/share/IconTest.java --- openjdk-17-17.0.17+10/test/jdk/tools/jpackage/share/IconTest.java 2025-10-13 07:48:04.000000000 +0000 +++ openjdk-17-17.0.18+8/test/jdk/tools/jpackage/share/IconTest.java 2026-01-15 15:23:06.000000000 +0000 @@ -1,5 +1,5 @@ /* - * Copyright (c) 2018, 2020, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2018, 2024, Oracle and/or its affiliates. All rights reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * * This code is free software; you can redistribute it and/or modify it @@ -49,11 +49,12 @@ /* * @test * @summary jpackage create image and package with custom icons for the main and additional launcher - * @library ../helpers + * @library /test/jdk/tools/jpackage/helpers * @build jdk.jpackage.test.* - * @modules jdk.jpackage/jdk.jpackage.internal * @compile IconTest.java - * @run main/othervm/timeout=540 -Xmx512m jdk.jpackage.test.Main + * @run main/othervm/timeout=540 -Xmx512m + * --add-opens jdk.jpackage/jdk.jpackage.internal=ALL-UNNAMED + * jdk.jpackage.test.Main * --jpt-run=IconTest */ diff -Nru openjdk-17-17.0.17+10/test/jdk/tools/jpackage/share/InstallDirTest.java openjdk-17-17.0.18+8/test/jdk/tools/jpackage/share/InstallDirTest.java --- openjdk-17-17.0.17+10/test/jdk/tools/jpackage/share/InstallDirTest.java 2025-10-13 07:48:04.000000000 +0000 +++ openjdk-17-17.0.18+8/test/jdk/tools/jpackage/share/InstallDirTest.java 2026-01-15 15:23:06.000000000 +0000 @@ -1,5 +1,5 @@ /* - * Copyright (c) 2018, 2020, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2018, 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 @@ -54,11 +54,10 @@ /* * @test * @summary jpackage with --install-dir - * @library ../helpers + * @library /test/jdk/tools/jpackage/helpers * @key jpackagePlatformPackage * @build jdk.jpackage.test.* * @compile InstallDirTest.java - * @modules jdk.jpackage/jdk.jpackage.internal * @run main/othervm/timeout=540 -Xmx512m jdk.jpackage.test.Main * --jpt-run=InstallDirTest.testCommon */ @@ -66,11 +65,10 @@ /* * @test * @summary jpackage with --install-dir - * @library ../helpers + * @library /test/jdk/tools/jpackage/helpers * @key jpackagePlatformPackage * @build jdk.jpackage.test.* * @compile InstallDirTest.java - * @modules jdk.jpackage/jdk.jpackage.internal * @requires (os.family == "linux") * @requires (jpackage.test.SQETest == null) * @run main/othervm/timeout=360 -Xmx512m jdk.jpackage.test.Main diff -Nru openjdk-17-17.0.17+10/test/jdk/tools/jpackage/share/JLinkOptionsTest.java openjdk-17-17.0.18+8/test/jdk/tools/jpackage/share/JLinkOptionsTest.java --- openjdk-17-17.0.17+10/test/jdk/tools/jpackage/share/JLinkOptionsTest.java 1970-01-01 00:00:00.000000000 +0000 +++ openjdk-17-17.0.18+8/test/jdk/tools/jpackage/share/JLinkOptionsTest.java 2026-01-15 15:23:06.000000000 +0000 @@ -0,0 +1,142 @@ +/* + * Copyright (c) 2020, 2024, Oracle and/or its affiliates. All rights reserved. + * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. + * + * This code is free software; you can redistribute it and/or modify it + * under the terms of the GNU General Public License version 2 only, as + * published by the Free Software Foundation. + * + * This code is distributed in the hope that it will be useful, but WITHOUT + * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or + * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License + * version 2 for more details (a copy is included in the LICENSE file that + * accompanied this code). + * + * You should have received a copy of the GNU General Public License version + * 2 along with this work; if not, write to the Free Software Foundation, + * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. + * + * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA + * or visit www.oracle.com if you need additional information or have any + * questions. + */ + + +import java.util.Collection; +import java.util.List; +import jdk.jpackage.test.Annotations.Parameters; +import jdk.jpackage.test.Annotations.Test; +import jdk.jpackage.test.JPackageCommand; +import jdk.jpackage.test.TKit; + +/* + * @test + * @summary jpackage application version testing + * @library /test/jdk/tools/jpackage/helpers + * @build jdk.jpackage.test.* + * @compile JLinkOptionsTest.java + * @run main/othervm/timeout=360 -Xmx512m jdk.jpackage.test.Main + * --jpt-run=JLinkOptionsTest + */ + +public final class JLinkOptionsTest { + + @Parameters + public static Collection input() { + return List.of(new Object[][]{ + // default but with strip-native-commands removed + {"Hello", new String[]{ + "--jlink-options", + "--strip-debug --no-man-pages --no-header-files", + }, + // non modular should have everything + new String[]{"jdk.jartool", "jdk.unsupported"}, + null, + }, + // multiple jlink-options + {"com.other/com.other.Hello", new String[]{ + "--jlink-options", + "--strip-debug --no-man-pages --no-header-files", + "--jlink-options", + "--bind-services", + }, + // with bind-services should have some services + new String[]{"java.smartcardio", "jdk.crypto.ec"}, + null, + }, + // bind-services + {"Hello", new String[]{ + "--jlink-options", "--bind-services", + }, + // non modular should have everything + new String[]{"jdk.jartool", "jdk.unsupported"}, + null, + }, + + // jlink-options --bind-services + {"com.other/com.other.Hello", new String[]{ + "--jlink-options", "--bind-services", + }, + // with bind-services should have some services + new String[]{"java.smartcardio", "jdk.crypto.ec"}, + null, + }, + + // limit modules + {"com.other/com.other.Hello", new String[]{ + "--jlink-options", + "--limit-modules java.base,java.datatransfer,java.xml,java.prefs,java.desktop,com.other", + }, + // should have whatever it needs + new String[]{"java.base", "com.other"}, + // should not have whatever it doesn't need + new String[]{"jdk.jpackage"}, + }, + + // bind-services and limit-options + {"com.other/com.other.Hello", new String[]{ + "--jlink-options", + "--bind-services", + "--jlink-options", + "--limit-modules java.base,java.datatransfer,java.xml,java.prefs,java.desktop,com.other,java.smartcardio", + }, + // with bind-services should have some services + new String[]{"java.smartcardio"}, + // but not limited + new String[]{"jdk.crypto.ec"}, + }, + + }); + } + + public JLinkOptionsTest(String javaAppDesc, String[] jpackageArgs, String[] required, String[] prohibited) { + this.required = required; + this.prohibited = prohibited; + cmd = JPackageCommand + .helloAppImage(javaAppDesc) + .ignoreDefaultRuntime(true) + .addArguments(jpackageArgs); + } + + @Test + public void test() { + cmd.executeAndAssertHelloAppImageCreated(); + + List release = cmd.readRuntimeReleaseFile(); + List mods = List.of(release.get(1)); + if (required != null) { + for (String s : required) { + TKit.assertTextStream(s).label("mods").apply(mods.stream()); + } + } + if (prohibited != null) { + for (String s : prohibited) { + TKit.assertTextStream(s).label("mods").negate().apply(mods.stream()); + } + } + } + + private final String[] required; + private final String[] prohibited; + private final JPackageCommand cmd; +} diff -Nru openjdk-17-17.0.17+10/test/jdk/tools/jpackage/share/JavaOptionsEqualsTest.java openjdk-17-17.0.18+8/test/jdk/tools/jpackage/share/JavaOptionsEqualsTest.java --- openjdk-17-17.0.17+10/test/jdk/tools/jpackage/share/JavaOptionsEqualsTest.java 1970-01-01 00:00:00.000000000 +0000 +++ openjdk-17-17.0.18+8/test/jdk/tools/jpackage/share/JavaOptionsEqualsTest.java 2026-01-15 15:23:06.000000000 +0000 @@ -0,0 +1,93 @@ +/* + * Copyright (c) 2018, 2024, Oracle and/or its affiliates. All rights reserved. + * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. + * + * This code is free software; you can redistribute it and/or modify it + * under the terms of the GNU General Public License version 2 only, as + * published by the Free Software Foundation. + * + * This code is distributed in the hope that it will be useful, but WITHOUT + * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or + * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License + * version 2 for more details (a copy is included in the LICENSE file that + * accompanied this code). + * + * You should have received a copy of the GNU General Public License version + * 2 along with this work; if not, write to the Free Software Foundation, + * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. + * + * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA + * or visit www.oracle.com if you need additional information or have any + * questions. + */ + + +import java.util.Collection; +import java.util.List; +import jdk.jpackage.test.Annotations.Parameters; +import jdk.jpackage.test.Annotations.Test; +import jdk.jpackage.test.JPackageCommand; +import jdk.jpackage.test.HelloApp; +import jdk.jpackage.test.Executor; +import jdk.jpackage.test.TKit; + +/* + * @test + * @summary jpackage create image with --java-options test + * @library /test/jdk/tools/jpackage/helpers + * @build jdk.jpackage.test.* + * @compile JavaOptionsEqualsTest.java + * @run main/othervm/timeout=360 -Xmx512m jdk.jpackage.test.Main + * --jpt-run=JavaOptionsEqualsTest + * --jpt-before-run=jdk.jpackage.test.JPackageCommand.useExecutableByDefault + */ + +/* + * @test + * @summary jpackage create image with --java-options test + * @library /test/jdk/tools/jpackage/helpers + * @build jdk.jpackage.test.* + * @compile JavaOptionsEqualsTest.java + * @run main/othervm/timeout=360 -Xmx512m jdk.jpackage.test.Main + * --jpt-run=JavaOptionsEqualsTest + * --jpt-before-run=jdk.jpackage.test.JPackageCommand.useToolProviderByDefault + */ + +public class JavaOptionsEqualsTest { + + private final static String OPTION1 = + "--add-exports=java.base/sun.util=me.mymodule.foo,ALL-UNNAMED"; + private final static String OPTION2 = + "--add-exports=java.base/sun.security.util=other.mod.bar,ALL-UNNAMED"; + private final static String WARNING1 = + "WARNING: Unknown module: me.mymodule.foo"; + private final static String WARNING2 = + "WARNING: Unknown module: other.mod.bar"; + + private final JPackageCommand cmd; + + @Parameters + public static Collection input() { + return List.of(new Object[][]{ + {"Hello", new String[]{"--java-options", OPTION1, + "--java-options", OPTION2 }, + }, + }); + } + + public JavaOptionsEqualsTest(String javaAppDesc, String[] jpackageArgs) { + cmd = JPackageCommand.helloAppImage(javaAppDesc); + if (jpackageArgs != null) { + cmd.addArguments(jpackageArgs); + } + } + + @Test + public void test() { + cmd.executeAndAssertHelloAppImageCreated(); + List output = HelloApp.executeLauncher(cmd).getOutput(); + TKit.assertNotNull(output, "output is null"); + TKit.assertTextStream(WARNING1).apply(output.stream()); + TKit.assertTextStream(WARNING2).apply(output.stream()); + } +} diff -Nru openjdk-17-17.0.17+10/test/jdk/tools/jpackage/share/JavaOptionsTest.java openjdk-17-17.0.18+8/test/jdk/tools/jpackage/share/JavaOptionsTest.java --- openjdk-17-17.0.17+10/test/jdk/tools/jpackage/share/JavaOptionsTest.java 1970-01-01 00:00:00.000000000 +0000 +++ openjdk-17-17.0.18+8/test/jdk/tools/jpackage/share/JavaOptionsTest.java 2026-01-15 15:23:06.000000000 +0000 @@ -0,0 +1,99 @@ +/* + * Copyright (c) 2018, 2024, Oracle and/or its affiliates. All rights reserved. + * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. + * + * This code is free software; you can redistribute it and/or modify it + * under the terms of the GNU General Public License version 2 only, as + * published by the Free Software Foundation. + * + * This code is distributed in the hope that it will be useful, but WITHOUT + * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or + * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License + * version 2 for more details (a copy is included in the LICENSE file that + * accompanied this code). + * + * You should have received a copy of the GNU General Public License version + * 2 along with this work; if not, write to the Free Software Foundation, + * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. + * + * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA + * or visit www.oracle.com if you need additional information or have any + * questions. + */ + + +import java.util.Collection; +import java.util.List; +import java.util.ArrayList; +import jdk.jpackage.test.Annotations.Parameters; +import jdk.jpackage.test.Annotations.Test; +import jdk.jpackage.test.JPackageCommand; +import jdk.jpackage.test.HelloApp; +import jdk.jpackage.test.TKit; + +/* + * @test + * @summary jpackage create image with --java-options test + * @library /test/jdk/tools/jpackage/helpers + * @build jdk.jpackage.test.* + * @compile JavaOptionsTest.java + * @run main/othervm/timeout=360 -Xmx512m jdk.jpackage.test.Main + * --jpt-run=JavaOptionsTest + * --jpt-before-run=jdk.jpackage.test.JPackageCommand.useToolProviderByDefault + */ + +public class JavaOptionsTest { + private static final String PARAM1 = "Some Param 1"; + private static final String PARAM2 = "Some \"Param\" 2"; + private static final String PARAM3 = "Some \"Param\" with \" 3"; + private static final String ARG1 = "-Dparam1=" + "\'" + PARAM1 + "\'"; + private static final String ARG2 = "-Dparam2=" + "\'" + PARAM2 + "\'"; + private static final String ARG3 = "-Dparam3=" + "\'" + PARAM3 + "\'"; + private static final String EXPECT1 = "-Dparam1=" + PARAM1; + private static final String EXPECT2 = "-Dparam2=" + PARAM2; + private static final String EXPECT3 = "-Dparam3=" + PARAM3; + + + private final JPackageCommand cmd; + private final String[] expected; + + @Parameters + public static Collection input() { + List result = new ArrayList<>(); + for (var app : List.of("Hello", "com.other/com.other.Hello")) { + result.add(new Object[]{app, new String[]{"--java-options", ARG1}, + new String[]{EXPECT1},}); + result.add(new Object[]{app, new String[]{"--java-options", ARG2}, + new String[]{EXPECT2},}); + result.add(new Object[]{app, new String[]{"--java-options", ARG3}, + new String[]{EXPECT3},}); + result.add(new Object[]{app, new String[]{"--java-options", ARG1, + "--java-options", ARG2, "--java-options", ARG3}, new String[]{ + EXPECT1, EXPECT2, EXPECT3},}); + } + return List.of(result.toArray(Object[][]::new)); + } + + public JavaOptionsTest(String javaAppDesc, String[] jpackageArgs, + String[] expectedParams) { + cmd = JPackageCommand.helloAppImage(javaAppDesc); + if (jpackageArgs != null) { + cmd.addArguments(jpackageArgs); + } + expected = expectedParams; + } + + @Test + public void test() { + // 1.) run the jpackage command + cmd.executeAndAssertImageCreated(); + + // 2.) run the launcher it generated + List output = HelloApp.executeLauncher(cmd).getOutput(); + TKit.assertNotNull(output, "output is null"); + for (String expect : expected) { + TKit.assertTextStream(expect).apply(output.stream()); + } + } + +} diff -Nru openjdk-17-17.0.17+10/test/jdk/tools/jpackage/share/LicenseTest.java openjdk-17-17.0.18+8/test/jdk/tools/jpackage/share/LicenseTest.java --- openjdk-17-17.0.17+10/test/jdk/tools/jpackage/share/LicenseTest.java 2025-10-13 07:48:04.000000000 +0000 +++ openjdk-17-17.0.18+8/test/jdk/tools/jpackage/share/LicenseTest.java 2026-01-15 15:23:06.000000000 +0000 @@ -1,5 +1,5 @@ /* - * Copyright (c) 2018, 2020, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2018, 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 @@ -63,11 +63,10 @@ /* * @test * @summary jpackage with --license-file - * @library ../helpers + * @library /test/jdk/tools/jpackage/helpers * @key jpackagePlatformPackage * @build jdk.jpackage.test.* * @compile LicenseTest.java - * @modules jdk.jpackage/jdk.jpackage.internal * @run main/othervm/timeout=360 -Xmx512m jdk.jpackage.test.Main * --jpt-run=LicenseTest.testCommon */ @@ -75,13 +74,12 @@ /* * @test * @summary jpackage with --license-file - * @library ../helpers + * @library /test/jdk/tools/jpackage/helpers * @key jpackagePlatformPackage * @build jdk.jpackage.test.* * @compile LicenseTest.java * @requires (os.family == "linux") * @requires (jpackage.test.SQETest == null) - * @modules jdk.jpackage/jdk.jpackage.internal * @run main/othervm/timeout=1440 -Xmx512m jdk.jpackage.test.Main * --jpt-run=LicenseTest.testCustomDebianCopyright * --jpt-run=LicenseTest.testCustomDebianCopyrightSubst diff -Nru openjdk-17-17.0.17+10/test/jdk/tools/jpackage/share/MainClassTest.java openjdk-17-17.0.18+8/test/jdk/tools/jpackage/share/MainClassTest.java --- openjdk-17-17.0.17+10/test/jdk/tools/jpackage/share/MainClassTest.java 1970-01-01 00:00:00.000000000 +0000 +++ openjdk-17-17.0.18+8/test/jdk/tools/jpackage/share/MainClassTest.java 2026-01-15 15:23:06.000000000 +0000 @@ -0,0 +1,319 @@ +/* + * Copyright (c) 2019, 2024, Oracle and/or its affiliates. All rights reserved. + * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. + * + * This code is free software; you can redistribute it and/or modify it + * under the terms of the GNU General Public License version 2 only, as + * published by the Free Software Foundation. + * + * This code is distributed in the hope that it will be useful, but WITHOUT + * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or + * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License + * version 2 for more details (a copy is included in the LICENSE file that + * accompanied this code). + * + * You should have received a copy of the GNU General Public License version + * 2 along with this work; if not, write to the Free Software Foundation, + * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. + * + * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA + * or visit www.oracle.com if you need additional information or have any + * questions. + */ + + +import java.io.IOException; +import java.nio.file.Files; +import java.util.Collection; +import java.util.ArrayList; +import java.util.List; +import java.util.Set; +import java.util.jar.JarFile; +import java.util.Objects; +import java.util.stream.Collectors; +import java.util.stream.Stream; +import java.nio.file.Path; +import java.util.function.Predicate; +import java.util.jar.JarEntry; +import jdk.jpackage.test.JavaAppDesc; +import jdk.jpackage.test.JPackageCommand; +import jdk.jpackage.test.TKit; +import jdk.jpackage.test.Executor; +import jdk.jpackage.test.HelloApp; +import jdk.jpackage.test.JavaTool; +import jdk.jpackage.test.Annotations.Parameters; +import jdk.jpackage.test.Annotations.Test; +import jdk.jpackage.test.Functional.ThrowingConsumer; + + + +/* + * @test + * @summary test different settings of main class name for jpackage + * @library /test/jdk/tools/jpackage/helpers + * @build jdk.jpackage.test.* + * @compile MainClassTest.java + * @run main/othervm/timeout=720 -Xmx512m jdk.jpackage.test.Main + * --jpt-run=MainClassTest + */ + +public final class MainClassTest { + + static final class Script { + Script() { + appDesc = JavaAppDesc.parse("test.Hello"); + } + + Script modular(boolean v) { + appDesc.setModuleName(v ? "com.other" : null); + return this; + } + + Script withJLink(boolean v) { + withJLink = v; + return this; + } + + Script withMainClass(MainClassType v) { + mainClass = v; + return this; + } + + Script withJarMainClass(MainClassType v) { + appDesc.setWithMainClass(v != MainClassType.NotSet); + jarMainClass = v; + return this; + } + + Script expectedErrorMessage(String v) { + expectedErrorMessage = v; + return this; + } + + @Override + public String toString() { + return Stream.of( + format("modular", appDesc.moduleName() != null ? 'y' : 'n'), + format("main-class", mainClass), + format("jar-main-class", jarMainClass), + format("jlink", withJLink ? 'y' : 'n'), + format("error", expectedErrorMessage) + ).filter(Objects::nonNull).collect(Collectors.joining("; ")); + } + + private static String format(String key, Object value) { + if (value == null) { + return null; + } + return String.join("=", key, value.toString()); + } + + enum MainClassType { + NotSet("n"), + SetWrong("b"), + SetRight("y"); + + MainClassType(String label) { + this.label = label; + } + + @Override + public String toString() { + return label; + } + + private final String label; + }; + + private JavaAppDesc appDesc; + private boolean withJLink; + private MainClassType mainClass; + private MainClassType jarMainClass; + private String expectedErrorMessage; + } + + public MainClassTest(Script script) { + this.script = script; + + nonExistingMainClass = Stream.of( + script.appDesc.packageName(), "ThereIsNoSuchClass").filter( + Objects::nonNull).collect(Collectors.joining(".")); + + cmd = JPackageCommand + .helloAppImage(script.appDesc) + .ignoreDefaultRuntime(true); + if (!script.withJLink) { + cmd.addArguments("--runtime-image", Path.of(System.getProperty( + "java.home"))); + } + + final String moduleName = script.appDesc.moduleName(); + switch (script.mainClass) { + case NotSet: + if (moduleName != null) { + // Don't specify class name, only module name. + cmd.setArgumentValue("--module", moduleName); + } else { + cmd.removeArgumentWithValue("--main-class"); + } + break; + + case SetWrong: + if (moduleName != null) { + cmd.setArgumentValue("--module", + String.join("/", moduleName, nonExistingMainClass)); + } else { + cmd.setArgumentValue("--main-class", nonExistingMainClass); + } + } + } + + @Parameters + public static Collection scripts() { + final var withMainClass = Set.of(Script.MainClassType.SetWrong, + Script.MainClassType.SetRight); + + List scripts = new ArrayList<>(); + for (var withJLink : List.of(true, false)) { + for (var modular : List.of(true, false)) { + for (var mainClass : Script.MainClassType.values()) { + for (var jarMainClass : Script.MainClassType.values()) { + Script script = new Script() + .modular(modular) + .withJLink(withJLink) + .withMainClass(mainClass) + .withJarMainClass(jarMainClass); + + if (withMainClass.contains(jarMainClass) + || withMainClass.contains(mainClass)) { + } else if (modular) { + script.expectedErrorMessage( + "Error: Main application class is missing"); + } else { + script.expectedErrorMessage( + "A main class was not specified nor was one found in the jar"); + } + + scripts.add(new Script[]{script}); + } + } + } + } + return scripts; + } + + @Test + public void test() throws IOException { + if (script.jarMainClass == Script.MainClassType.SetWrong) { + initJarWithWrongMainClass(); + } + + if (script.expectedErrorMessage != null) { + // This is the case when main class is not found nor in jar + // file nor on command line. + List output = cmd + .saveConsoleOutput(true) + .execute(1) + .getOutput(); + TKit.assertTextStream(script.expectedErrorMessage).apply(output.stream()); + return; + } + + // Get here only if main class is specified. + boolean appShouldSucceed = false; + + // Should succeed if valid main class is set on the command line. + appShouldSucceed |= (script.mainClass == Script.MainClassType.SetRight); + + // Should succeed if main class is not set on the command line but set + // to valid value in the jar. + appShouldSucceed |= (script.mainClass == Script.MainClassType.NotSet && script.jarMainClass == Script.MainClassType.SetRight); + + if (appShouldSucceed) { + cmd.executeAndAssertHelloAppImageCreated(); + } else { + cmd.executeAndAssertImageCreated(); + var appVerifier = HelloApp.assertMainLauncher(cmd); + if (appVerifier != null) { + List output = appVerifier + .saveOutput(true) + .expectedExitCode(1) + .execute().getOutput(); + TKit.assertTextStream(String.format( + "Error: Could not find or load main class %s", + nonExistingMainClass)).apply(output.stream()); + } + } + } + + private void initJarWithWrongMainClass() throws IOException { + // Call JPackageCommand.executePrerequisiteActions() to build app's jar. + // executePrerequisiteActions() is called by JPackageCommand instance + // only once. + cmd.executePrerequisiteActions(); + + final Path jarFile; + if (script.appDesc.moduleName() != null) { + jarFile = Path.of(cmd.getArgumentValue("--module-path"), + script.appDesc.jarFileName()); + } else { + jarFile = cmd.inputDir().resolve(cmd.getArgumentValue("--main-jar")); + } + + // Create new jar file filtering out main class from the old jar file. + TKit.withTempDirectory("repack-jar", workDir -> { + // Extract app's class from the old jar. + explodeJar(jarFile, workDir, + jarEntry -> Path.of(jarEntry.getName()).equals( + script.appDesc.classFilePath())); + + // Create app's jar file with different main class. + var badAppDesc = JavaAppDesc + .parse(script.appDesc.toString()) + .setClassName(nonExistingMainClass); + HelloApp.createBundle(badAppDesc, jarFile.getParent()); + + // Extract new jar but skip app's class. + explodeJar(jarFile, workDir, + jarEntry -> !Path.of(jarEntry.getName()).equals( + badAppDesc.classFilePath())); + + // At this point we should have: + // 1. Manifest from the new jar referencing non-existing class + // as the main class. + // 2. Module descriptor referencing non-existing class as the main + // class in case of modular app. + // 3. App's class from the old jar. We need it to let jlink find some + // classes in the package declared in module descriptor + // in case of modular app. + + Files.delete(jarFile); + new Executor().setToolProvider(JavaTool.JAR) + .addArguments("-v", "-c", "-M", "-f", jarFile.toString()) + .addArguments("-C", workDir.toString(), ".") + .dumpOutput() + .execute(); + }); + } + + private static void explodeJar(Path jarFile, Path workDir, + Predicate filter) throws IOException { + try (var jar = new JarFile(jarFile.toFile())) { + jar.stream() + .filter(Predicate.not(JarEntry::isDirectory)) + .filter(filter) + .sequential().forEachOrdered(ThrowingConsumer.toConsumer( + jarEntry -> { + try (var in = jar.getInputStream(jarEntry)) { + Path fileName = workDir.resolve(jarEntry.getName()); + Files.createDirectories(fileName.getParent()); + Files.copy(in, fileName); + } + })); + } + } + + private final JPackageCommand cmd; + private final Script script; + private final String nonExistingMainClass; +} diff -Nru openjdk-17-17.0.17+10/test/jdk/tools/jpackage/share/ModulePathTest.java openjdk-17-17.0.18+8/test/jdk/tools/jpackage/share/ModulePathTest.java --- openjdk-17-17.0.17+10/test/jdk/tools/jpackage/share/ModulePathTest.java 1970-01-01 00:00:00.000000000 +0000 +++ openjdk-17-17.0.18+8/test/jdk/tools/jpackage/share/ModulePathTest.java 2026-01-15 15:23:06.000000000 +0000 @@ -0,0 +1,145 @@ +/* + * Copyright (c) 2019, 2024, Oracle and/or its affiliates. All rights reserved. + * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. + * + * This code is free software; you can redistribute it and/or modify it + * under the terms of the GNU General Public License version 2 only, as + * published by the Free Software Foundation. + * + * This code is distributed in the hope that it will be useful, but WITHOUT + * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or + * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License + * version 2 for more details (a copy is included in the LICENSE file that + * accompanied this code). + * + * You should have received a copy of the GNU General Public License version + * 2 along with this work; if not, write to the Free Software Foundation, + * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. + * + * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA + * or visit www.oracle.com if you need additional information or have any + * questions. + */ + + +import java.io.File; +import java.io.IOException; +import java.nio.file.Path; +import java.util.Collection; +import java.util.List; +import java.util.function.Function; +import java.util.stream.Collectors; +import java.util.stream.Stream; +import jdk.jpackage.test.TKit; +import jdk.jpackage.test.JavaAppDesc; +import jdk.jpackage.test.HelloApp; +import jdk.jpackage.test.JPackageCommand; +import jdk.jpackage.test.PackageType; +import jdk.jpackage.test.Annotations.Parameter; +import jdk.jpackage.test.Annotations.Parameters; +import jdk.jpackage.test.Annotations.Test; + + +/* + * @test + * @summary jpackage with --module-path testing + * @library /test/jdk/tools/jpackage/helpers + * @build jdk.jpackage.test.* + * @compile ModulePathTest.java + * @run main/othervm/timeout=360 -Xmx512m jdk.jpackage.test.Main + * --jpt-run=ModulePathTest + */ + +public final class ModulePathTest { + + @Parameters + public static Collection data() { + return List.of(new String[][]{ + {GOOD_PATH, EMPTY_DIR, NON_EXISTING_DIR}, + {EMPTY_DIR, NON_EXISTING_DIR, GOOD_PATH}, + {GOOD_PATH + "/a/b/c/d", GOOD_PATH}, + {String.join(File.pathSeparator, EMPTY_DIR, NON_EXISTING_DIR, + GOOD_PATH)}, + {String.join(File.pathSeparator, EMPTY_DIR, NON_EXISTING_DIR), + String.join(File.pathSeparator, EMPTY_DIR, NON_EXISTING_DIR, + GOOD_PATH)}, + {}, + {EMPTY_DIR} + }); + } + + public ModulePathTest(String... modulePathArgs) { + this.modulePathArgs = List.of(modulePathArgs); + } + + @Test + @Parameter("benvenuto.jar:com.jar.foo/com.jar.foo.Hello") + @Parameter("benvenuto.jmod:com.jmod.foo/com.jmod.foo.JModHello") + public void test(String javaAppDesc) throws IOException { + JavaAppDesc appDesc = JavaAppDesc.parse(javaAppDesc); + + Path goodModulePath = TKit.createTempDirectory("modules"); + + Path appBundle = HelloApp.createBundle(appDesc, goodModulePath); + + JPackageCommand cmd = new JPackageCommand() + .setArgumentValue("--dest", TKit.workDir().resolve("output")) + .setDefaultAppName() + .setPackageType(PackageType.IMAGE); + + if (TKit.isWindows()) { + cmd.addArguments("--win-console"); + } + + cmd.addArguments("--module", String.join("/", appDesc.moduleName(), + appDesc.className())); + + // Ignore runtime that can be set for all tests. Usually if default + // runtime is set, it is fake one to save time on running jlink and + // copying megabytes of data from Java home to application image. + // We need proper runtime for this test. + cmd.ignoreDefaultRuntime(true); + + Path emptyDir = TKit.createTempDirectory("empty-dir"); + Path nonExistingDir = TKit.withTempDirectory("non-existing-dir", x -> {}); + + Function substitute = str -> { + String v = str; + v = v.replace(GOOD_PATH, goodModulePath.toString()); + v = v.replace(EMPTY_DIR, emptyDir.toString()); + v = v.replace(NON_EXISTING_DIR, nonExistingDir.toString()); + return v; + }; + + boolean withGoodPath = modulePathArgs.stream().anyMatch( + s -> s.contains(GOOD_PATH)); + + cmd.addArguments(modulePathArgs.stream().map(arg -> Stream.of( + "--module-path", substitute.apply(arg))).flatMap(s -> s).collect( + Collectors.toList())); + + if (withGoodPath) { + cmd.executeAndAssertHelloAppImageCreated(); + } else { + final String expectedErrorMessage; + if (modulePathArgs.isEmpty()) { + expectedErrorMessage = "Error: Missing argument: --runtime-image or --module-path"; + } else { + expectedErrorMessage = String.format( + "Failed to find %s module in module path", appDesc.moduleName()); + } + + List output = cmd + .saveConsoleOutput(true) + .execute(1) + .getOutput(); + TKit.assertTextStream(expectedErrorMessage).apply(output.stream()); + } + } + + private final List modulePathArgs; + + private final static String GOOD_PATH = "@GoodPath@"; + private final static String EMPTY_DIR = "@EmptyDir@"; + private final static String NON_EXISTING_DIR = "@NonExistingDir@"; +} diff -Nru openjdk-17-17.0.17+10/test/jdk/tools/jpackage/share/ModulePathTest2.java openjdk-17-17.0.18+8/test/jdk/tools/jpackage/share/ModulePathTest2.java --- openjdk-17-17.0.17+10/test/jdk/tools/jpackage/share/ModulePathTest2.java 1970-01-01 00:00:00.000000000 +0000 +++ openjdk-17-17.0.18+8/test/jdk/tools/jpackage/share/ModulePathTest2.java 2026-01-15 15:23:06.000000000 +0000 @@ -0,0 +1,74 @@ +/* + * Copyright (c) 2019, 2024, Oracle and/or its affiliates. All rights reserved. + * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. + * + * This code is free software; you can redistribute it and/or modify it + * under the terms of the GNU General Public License version 2 only, as + * published by the Free Software Foundation. + * + * This code is distributed in the hope that it will be useful, but WITHOUT + * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or + * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License + * version 2 for more details (a copy is included in the LICENSE file that + * accompanied this code). + * + * You should have received a copy of the GNU General Public License version + * 2 along with this work; if not, write to the Free Software Foundation, + * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. + * + * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA + * or visit www.oracle.com if you need additional information or have any + * questions. + */ + + +import java.io.IOException; +import java.nio.file.Path; +import jdk.jpackage.test.HelloApp; +import jdk.jpackage.test.JavaAppDesc; +import jdk.jpackage.test.Annotations.Test; +import jdk.jpackage.test.Annotations.Parameter; +import jdk.jpackage.test.JPackageCommand; +import jdk.jpackage.test.TKit; + + +/* + * @test + * @summary jpackage with --module-path testing + * @library /test/jdk/tools/jpackage/helpers + * @build jdk.jpackage.test.* + * @compile ModulePathTest2.java + * @run main/othervm/timeout=360 -Xmx512m jdk.jpackage.test.Main + * --jpt-run=ModulePathTest2 + */ + +public final class ModulePathTest2 { + + /** + * Test case for JDK-8233265. + * Adding modules in .jmod files for non-modular app results in unexpected + * jpackage failure. + * @param mainAppDesc + */ + @Test + @Parameter("Hello!") + @Parameter("com.foo/com.foo.ModuleApp") + public void test8233265(String mainAppDesc) throws IOException { + JPackageCommand cmd = JPackageCommand.helloAppImage(mainAppDesc); + + // The test should make jpackage invoke jlink. + cmd.ignoreDefaultRuntime(true); + + Path modulePath = cmd.getArgumentValue("--module-path", () -> null, Path::of); + if (modulePath == null) { + modulePath = TKit.createTempDirectory("input-modules"); + cmd.addArguments("--module-path", modulePath); + } + + JavaAppDesc extraModule = JavaAppDesc.parse("x.jmod:com.x/com.x.Y"); + HelloApp.createBundle(extraModule, modulePath); + cmd.addArguments("--add-modules", extraModule.moduleName()); + + cmd.executeAndAssertHelloAppImageCreated(); + } +} diff -Nru openjdk-17-17.0.17+10/test/jdk/tools/jpackage/share/ModulePathTest3.java openjdk-17-17.0.18+8/test/jdk/tools/jpackage/share/ModulePathTest3.java --- openjdk-17-17.0.17+10/test/jdk/tools/jpackage/share/ModulePathTest3.java 1970-01-01 00:00:00.000000000 +0000 +++ openjdk-17-17.0.18+8/test/jdk/tools/jpackage/share/ModulePathTest3.java 2026-01-15 15:23:06.000000000 +0000 @@ -0,0 +1,138 @@ +/* + * Copyright (c) 2020, 2024, Oracle and/or its affiliates. All rights reserved. + * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. + * + * This code is free software; you can redistribute it and/or modify it + * under the terms of the GNU General Public License version 2 only, as + * published by the Free Software Foundation. + * + * This code is distributed in the hope that it will be useful, but WITHOUT + * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or + * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License + * version 2 for more details (a copy is included in the LICENSE file that + * accompanied this code). + * + * You should have received a copy of the GNU General Public License version + * 2 along with this work; if not, write to the Free Software Foundation, + * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. + * + * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA + * or visit www.oracle.com if you need additional information or have any + * questions. + */ + + +import java.io.IOException; +import java.nio.file.Files; +import java.nio.file.Path; +import java.util.ArrayList; +import java.util.Collection; +import java.util.List; +import javax.xml.xpath.XPathExpressionException; +import javax.xml.xpath.XPathConstants; +import javax.xml.xpath.XPathFactory; +import jdk.jpackage.internal.AppImageFile; +import jdk.jpackage.test.HelloApp; +import jdk.jpackage.test.JavaAppDesc; +import jdk.jpackage.test.Annotations.Test; +import jdk.jpackage.test.Annotations.Parameter; +import jdk.jpackage.test.Annotations.Parameters; +import jdk.jpackage.test.Executor; +import jdk.jpackage.test.JPackageCommand; +import jdk.jpackage.test.JavaTool; +import jdk.jpackage.test.PackageType; +import jdk.jpackage.test.TKit; +import org.w3c.dom.Document; + + +/* + * @test + * @summary jpackage for app's module linked in external runtime + * @library /test/jdk/tools/jpackage/helpers + * @build jdk.jpackage.test.* + * @compile ModulePathTest3.java + * @run main/othervm/timeout=360 -Xmx512m jdk.jpackage.test.Main + * --jpt-run=ModulePathTest3 + */ + +public final class ModulePathTest3 { + + public ModulePathTest3(String jlinkOutputSubdir, String runtimeSubdir) { + this.jlinkOutputSubdir = Path.of(jlinkOutputSubdir); + this.runtimeSubdir = Path.of(runtimeSubdir); + } + + /** + * Test case for JDK-8248254. + * App's module in runtime directory. + */ + @Test + public void test8248254() throws XPathExpressionException, IOException { + testIt("me.mymodule/me.mymodule.Main"); + } + + private void testIt(String mainAppDesc) throws XPathExpressionException, + IOException { + final JavaAppDesc appDesc = JavaAppDesc.parse(mainAppDesc); + final Path moduleOutputDir = TKit.createTempDirectory("modules"); + HelloApp.createBundle(appDesc, moduleOutputDir); + + final Path workDir = TKit.createTempDirectory("runtime").resolve("data"); + final Path jlinkOutputDir = workDir.resolve(jlinkOutputSubdir); + Files.createDirectories(jlinkOutputDir.getParent()); + + new Executor() + .setToolProvider(JavaTool.JLINK) + .dumpOutput() + .addArguments( + "--add-modules", appDesc.moduleName(), + "--output", jlinkOutputDir.toString(), + "--module-path", moduleOutputDir.resolve(appDesc.jarFileName()).toString(), + "--strip-debug", + "--no-header-files", + "--no-man-pages", + "--strip-native-commands") + .execute(); + + JPackageCommand cmd = new JPackageCommand() + .setDefaultAppName() + .setPackageType(PackageType.IMAGE) + .setDefaultInputOutput() + .removeArgumentWithValue("--input") + .addArguments("--module", appDesc.moduleName() + "/" + appDesc.className()) + .setArgumentValue("--runtime-image", workDir.resolve(runtimeSubdir)); + + cmd.executeAndAssertHelloAppImageCreated(); + + if (appDesc.moduleVersion() != null) { + Document xml = AppImageFile.readXml(cmd.outputBundle()); + String actualVersion = XPathFactory.newInstance().newXPath().evaluate( + "/jpackage-state/app-version/text()", xml, + XPathConstants.STRING).toString(); + + TKit.assertEquals(appDesc.moduleVersion(), actualVersion, + "Check application version"); + } + } + + @Parameters + public static Collection data() { + final List paths = new ArrayList<>(); + paths.add(new String[] { "", "" }); + if (TKit.isOSX()) { + // On OSX jpackage should accept both runtime root and runtime home + // directories. + paths.add(new String[] { "Contents/Home", "" }); + } + + List data = new ArrayList<>(); + for (var pathCfg : paths) { + data.add(new Object[] { pathCfg[0], pathCfg[1] }); + } + + return data; + } + + private final Path jlinkOutputSubdir; + private final Path runtimeSubdir; +} diff -Nru openjdk-17-17.0.17+10/test/jdk/tools/jpackage/share/MultiLauncherTwoPhaseTest.java openjdk-17-17.0.18+8/test/jdk/tools/jpackage/share/MultiLauncherTwoPhaseTest.java --- openjdk-17-17.0.17+10/test/jdk/tools/jpackage/share/MultiLauncherTwoPhaseTest.java 2025-10-13 07:48:04.000000000 +0000 +++ openjdk-17-17.0.18+8/test/jdk/tools/jpackage/share/MultiLauncherTwoPhaseTest.java 2026-01-15 15:23:06.000000000 +0000 @@ -1,5 +1,5 @@ /* - * Copyright (c) 2020, 2022, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2020, 2024, Oracle and/or its affiliates. All rights reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * * This code is free software; you can redistribute it and/or modify it @@ -43,13 +43,13 @@ /* * @test * @summary Multiple launchers in two phases - * @library ../helpers - * @library /test/lib + * @library /test/jdk/tools/jpackage/helpers * @key jpackagePlatformPackage * @build jdk.jpackage.test.* - * @modules jdk.jpackage/jdk.jpackage.internal * @compile MultiLauncherTwoPhaseTest.java - * @run main/othervm/timeout=360 -Xmx512m jdk.jpackage.test.Main + * @run main/othervm/timeout=360 -Xmx512m + * --add-opens jdk.jpackage/jdk.jpackage.internal=ALL-UNNAMED + * jdk.jpackage.test.Main * --jpt-run=MultiLauncherTwoPhaseTest */ diff -Nru openjdk-17-17.0.17+10/test/jdk/tools/jpackage/share/MultiNameTwoPhaseTest.java openjdk-17-17.0.18+8/test/jdk/tools/jpackage/share/MultiNameTwoPhaseTest.java --- openjdk-17-17.0.17+10/test/jdk/tools/jpackage/share/MultiNameTwoPhaseTest.java 2025-10-13 07:48:04.000000000 +0000 +++ openjdk-17-17.0.18+8/test/jdk/tools/jpackage/share/MultiNameTwoPhaseTest.java 2026-01-15 15:23:06.000000000 +0000 @@ -1,5 +1,5 @@ /* - * Copyright (c) 2020, 2022, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2020, 2024, Oracle and/or its affiliates. All rights reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * * This code is free software; you can redistribute it and/or modify it @@ -41,12 +41,10 @@ /* * @test * @summary Multiple names in two phases - * @library ../helpers - * @library /test/lib + * @library /test/jdk/tools/jpackage/helpers * @key jpackagePlatformPackage * @requires (jpackage.test.SQETest == null) * @build jdk.jpackage.test.* - * @modules jdk.jpackage/jdk.jpackage.internal * @compile MultiNameTwoPhaseTest.java * @run main/othervm/timeout=540 -Xmx512m jdk.jpackage.test.Main * --jpt-run=MultiNameTwoPhaseTest diff -Nru openjdk-17-17.0.17+10/test/jdk/tools/jpackage/share/MultipleJarAppTest.java openjdk-17-17.0.18+8/test/jdk/tools/jpackage/share/MultipleJarAppTest.java --- openjdk-17-17.0.17+10/test/jdk/tools/jpackage/share/MultipleJarAppTest.java 1970-01-01 00:00:00.000000000 +0000 +++ openjdk-17-17.0.18+8/test/jdk/tools/jpackage/share/MultipleJarAppTest.java 2026-01-15 15:23:06.000000000 +0000 @@ -0,0 +1,55 @@ +/* + * Copyright (c) 2019, 2024, Oracle and/or its affiliates. All rights reserved. + * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. + * + * This code is free software; you can redistribute it and/or modify it + * under the terms of the GNU General Public License version 2 only, as + * published by the Free Software Foundation. + * + * This code is distributed in the hope that it will be useful, but WITHOUT + * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or + * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License + * version 2 for more details (a copy is included in the LICENSE file that + * accompanied this code). + * + * You should have received a copy of the GNU General Public License version + * 2 along with this work; if not, write to the Free Software Foundation, + * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. + * + * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA + * or visit www.oracle.com if you need additional information or have any + * questions. + */ + + +import java.nio.file.Path; +import jdk.jpackage.test.Annotations.Test; +import jdk.jpackage.test.Annotations.Parameter; +import jdk.jpackage.test.HelloApp; +import jdk.jpackage.test.JavaAppDesc; +import jdk.jpackage.test.JPackageCommand; + +/* + * @test + * @summary jpackage application packed in multiple jars + * @library /test/jdk/tools/jpackage/helpers + * @build jdk.jpackage.test.* + * @compile MultipleJarAppTest.java + * @run main/othervm/timeout=360 -Xmx512m jdk.jpackage.test.Main + * --jpt-run=MultipleJarAppTest + */ + +public final class MultipleJarAppTest { + + @Test + @Parameter("B") + @Parameter("C") + public void test(String mainClass) { + JPackageCommand cmd = JPackageCommand.helloAppImage("a.jar:A"); + HelloApp.createBundle(JavaAppDesc.parse("b.jar:B"), cmd.inputDir()); + HelloApp.createBundle(JavaAppDesc.parse("c.jar:C"), cmd.inputDir()); + + cmd.setArgumentValue("--main-class", mainClass); + cmd.executeAndAssertHelloAppImageCreated(); + } +} diff -Nru openjdk-17-17.0.17+10/test/jdk/tools/jpackage/share/NoMPathRuntimeTest.java openjdk-17-17.0.18+8/test/jdk/tools/jpackage/share/NoMPathRuntimeTest.java --- openjdk-17-17.0.17+10/test/jdk/tools/jpackage/share/NoMPathRuntimeTest.java 1970-01-01 00:00:00.000000000 +0000 +++ openjdk-17-17.0.18+8/test/jdk/tools/jpackage/share/NoMPathRuntimeTest.java 2026-01-15 15:23:06.000000000 +0000 @@ -0,0 +1,134 @@ +/* + * Copyright (c) 2020, 2024, Oracle and/or its affiliates. All rights reserved. + * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. + * + * This code is free software; you can redistribute it and/or modify it + * under the terms of the GNU General Public License version 2 only, as + * published by the Free Software Foundation. + * + * This code is distributed in the hope that it will be useful, but WITHOUT + * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or + * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License + * version 2 for more details (a copy is included in the LICENSE file that + * accompanied this code). + * + * You should have received a copy of the GNU General Public License version + * 2 along with this work; if not, write to the Free Software Foundation, + * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. + * + * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA + * or visit www.oracle.com if you need additional information or have any + * questions. + */ + + +import java.io.IOException; +import java.nio.file.Files; +import java.util.Collection; +import java.util.ArrayList; +import java.util.List; +import java.util.stream.Stream; +import java.nio.file.Path; +import jdk.jpackage.test.Annotations.Parameters; +import jdk.jpackage.test.Annotations.Test; +import jdk.jpackage.test.Executor; +import jdk.jpackage.test.JPackageCommand; +import jdk.jpackage.test.JavaAppDesc; +import jdk.jpackage.test.JavaTool; +import jdk.jpackage.test.TKit; +import jdk.jpackage.test.HelloApp; + + +/* + * @test + * @summary test '--runtime-image' option of jpackage + * @library /test/jdk/tools/jpackage/helpers + * @build jdk.jpackage.test.* + * @compile NoMPathRuntimeTest.java + * @run main/othervm/timeout=360 -Xmx512m jdk.jpackage.test.Main + * --jpt-run=NoMPathRuntimeTest + */ + +public final class NoMPathRuntimeTest { + + public NoMPathRuntimeTest(String jlinkOutputSubdir, String runtimeSubdir) { + this.jlinkOutputSubdir = Path.of(jlinkOutputSubdir); + this.runtimeSubdir = Path.of(runtimeSubdir); + } + + @Test + public void test() throws IOException { + JavaAppDesc appDesc = JavaAppDesc.parse("com.foo/com.foo.main.Aloha"); + + JPackageCommand cmd = JPackageCommand.helloAppImage(appDesc); + + // Build module jar. + cmd.executePrerequisiteActions(); + + final Path workDir = TKit.createTempDirectory("runtime").resolve("data"); + final Path jlinkOutputDir = workDir.resolve(jlinkOutputSubdir); + Files.createDirectories(jlinkOutputDir.getParent()); + + // List of modules required for test app. + final var modules = new String[] { + "java.base", + "java.desktop" + }; + + Executor jlink = new Executor() + .setToolProvider(JavaTool.JLINK) + .dumpOutput() + .addArguments( + "--add-modules", String.join(",", modules), + "--output", jlinkOutputDir.toString(), + "--strip-debug", + "--no-header-files", + "--no-man-pages"); + + jlink.addArguments("--add-modules", appDesc.moduleName(), + "--module-path", Path.of(cmd.getArgumentValue("--module-path")) + .resolve("hello.jar").toString()); + + jlink.execute(); + + // non-modular jar in current dir caused error whe no module-path given + cmd.removeArgumentWithValue("--module-path"); + + cmd.setArgumentValue("--runtime-image", workDir.resolve(runtimeSubdir)); + Path junkJar = null; + try { + // create a non-modular jar in the current directory + junkJar = HelloApp.createBundle( + JavaAppDesc.parse("junk.jar:Hello"), Path.of(".")); + + cmd.executeAndAssertHelloAppImageCreated(); + } finally { + if (junkJar != null) { + TKit.deleteIfExists(junkJar); + } + } + + } + + @Parameters + public static Collection data() { + + final List paths = new ArrayList<>(); + paths.add(new String[] { "", "" }); + if (TKit.isOSX()) { + // On OSX jpackage should accept both runtime root and runtime home + // directories. + paths.add(new String[] { "Contents/Home", "" }); + } + + List data = new ArrayList<>(); + for (var pathCfg : paths) { + data.add(new Object[] { pathCfg[0], pathCfg[1] }); + } + + return data; + } + + private final Path jlinkOutputSubdir; + private final Path runtimeSubdir; +} diff -Nru openjdk-17-17.0.17+10/test/jdk/tools/jpackage/share/NonExistentTest.java openjdk-17-17.0.18+8/test/jdk/tools/jpackage/share/NonExistentTest.java --- openjdk-17-17.0.17+10/test/jdk/tools/jpackage/share/NonExistentTest.java 1970-01-01 00:00:00.000000000 +0000 +++ openjdk-17-17.0.18+8/test/jdk/tools/jpackage/share/NonExistentTest.java 2026-01-15 15:23:06.000000000 +0000 @@ -0,0 +1,91 @@ +/* + * Copyright (c) 2020, 2024, Oracle and/or its affiliates. All rights reserved. + * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. + * + * This code is free software; you can redistribute it and/or modify it + * under the terms of the GNU General Public License version 2 only, as + * published by the Free Software Foundation. + * + * This code is distributed in the hope that it will be useful, but WITHOUT + * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or + * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License + * version 2 for more details (a copy is included in the LICENSE file that + * accompanied this code). + * + * You should have received a copy of the GNU General Public License version + * 2 along with this work; if not, write to the Free Software Foundation, + * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. + * + * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA + * or visit www.oracle.com if you need additional information or have any + * questions. + */ + + +import java.util.Collection; +import java.util.List; +import jdk.jpackage.test.Annotations.Parameters; +import jdk.jpackage.test.Annotations.Test; +import jdk.jpackage.test.JPackageCommand; +import jdk.jpackage.test.TKit; + +/* + * @test + * @summary jpackage application version testing + * @library /test/jdk/tools/jpackage/helpers + * @build jdk.jpackage.test.* + * @compile NonExistentTest.java + * @run main/othervm/timeout=360 -Xmx512m jdk.jpackage.test.Main + * --jpt-run=NonExistentTest + */ + +public final class NonExistentTest { + + private final String expectedError; + private final JPackageCommand cmd; + + @Parameters + public static Collection input() { + return List.of(new Object[][]{ + // non-existent icon + {"Hello", + new String[]{"--icon", "non-existent"}, + "Error:"}, + {"com.other/com.other.Hello", + new String[]{"--icon", "non-existent"}, + "Error:"}, + // non-existent input + {"Hello", + new String[]{"--input", "non-existent"}, + "Exception:"}, + {"com.other/com.other.Hello", + new String[]{"--input", "non-existent"}, + "Exception:"}, + // non-existent resource-dir + {"Hello", + new String[]{"--resource-dir", "non-existent"}, + "Specified resource directory"}, + {"com.other/com.other.Hello", + new String[]{"--resource-dir", "non-existent"}, + "Specified resource directory"}, + }); + } + + public NonExistentTest(String javaAppDesc, String[] jpackageArgs, + String expectedError) { + this.expectedError = expectedError; + + cmd = JPackageCommand.helloAppImage(javaAppDesc) + .saveConsoleOutput(true).dumpOutput(true); + if (jpackageArgs != null) { + cmd.addArguments(jpackageArgs); + } + } + + @Test + public void test() { + List output = cmd.execute(1).getOutput(); + TKit.assertNotNull(output, "output is null"); + TKit.assertTextStream(expectedError).apply(output.stream()); + } +} diff -Nru openjdk-17-17.0.17+10/test/jdk/tools/jpackage/share/RuntimeImageTest.java openjdk-17-17.0.18+8/test/jdk/tools/jpackage/share/RuntimeImageTest.java --- openjdk-17-17.0.17+10/test/jdk/tools/jpackage/share/RuntimeImageTest.java 2025-10-13 07:48:04.000000000 +0000 +++ openjdk-17-17.0.18+8/test/jdk/tools/jpackage/share/RuntimeImageTest.java 2026-01-15 15:23:06.000000000 +0000 @@ -42,10 +42,9 @@ /* * @test * @summary jpackage with --runtime-image - * @library ../helpers + * @library /test/jdk/tools/jpackage/helpers * @key jpackagePlatformPackage * @build jdk.jpackage.test.* - * @modules jdk.incubator.jpackage/jdk.incubator.jpackage.internal * @compile RuntimeImageTest.java * @run main/othervm/timeout=1400 jdk.jpackage.test.Main * --jpt-run=RuntimeImageTest diff -Nru openjdk-17-17.0.17+10/test/jdk/tools/jpackage/share/RuntimePackageTest.java openjdk-17-17.0.18+8/test/jdk/tools/jpackage/share/RuntimePackageTest.java --- openjdk-17-17.0.17+10/test/jdk/tools/jpackage/share/RuntimePackageTest.java 2025-10-13 07:48:04.000000000 +0000 +++ openjdk-17-17.0.18+8/test/jdk/tools/jpackage/share/RuntimePackageTest.java 2026-01-15 15:23:06.000000000 +0000 @@ -25,7 +25,6 @@ import java.nio.file.Files; import java.nio.file.Path; import java.util.HashSet; -import java.util.Optional; import java.util.Set; import java.util.function.Predicate; import java.util.stream.Collectors; @@ -34,6 +33,8 @@ import jdk.jpackage.test.JPackageCommand; import jdk.jpackage.test.TKit; import jdk.jpackage.test.Annotations.Test; +import jdk.jpackage.test.Executor; +import jdk.jpackage.test.JavaTool; import jdk.jpackage.test.LinuxHelper; import static jdk.jpackage.test.TKit.assertTrue; import static jdk.jpackage.test.TKit.assertFalse; @@ -54,11 +55,10 @@ /* * @test * @summary jpackage with --runtime-image - * @library ../helpers + * @library /test/jdk/tools/jpackage/helpers * @key jpackagePlatformPackage * @build jdk.jpackage.test.* * @requires (jpackage.test.SQETest == null) - * @modules jdk.jpackage/jdk.jpackage.internal * @compile RuntimePackageTest.java * @run main/othervm/timeout=1400 -Xmx512m jdk.jpackage.test.Main * --jpt-run=RuntimePackageTest @@ -67,11 +67,10 @@ /* * @test * @summary jpackage with --runtime-image - * @library ../helpers + * @library /test/jdk/tools/jpackage/helpers * @key jpackagePlatformPackage * @build jdk.jpackage.test.* * @requires (jpackage.test.SQETest != null) - * @modules jdk.jpackage/jdk.jpackage.internal * @compile RuntimePackageTest.java * @run main/othervm/timeout=720 -Xmx512m jdk.jpackage.test.Main * --jpt-run=RuntimePackageTest.test @@ -101,9 +100,25 @@ return new PackageTest() .forTypes(types) .addInitializer(cmd -> { - cmd.addArguments("--runtime-image", Optional.ofNullable( - JPackageCommand.DEFAULT_RUNTIME_IMAGE).orElse(Path.of( - System.getProperty("java.home")))); + final Path runtimeImageDir; + if (JPackageCommand.DEFAULT_RUNTIME_IMAGE != null) { + runtimeImageDir = JPackageCommand.DEFAULT_RUNTIME_IMAGE; + } else { + runtimeImageDir = TKit.createTempDirectory("runtime").resolve("data"); + + new Executor() + .setToolProvider(JavaTool.JLINK) + .dumpOutput() + .addArguments( + "--output", runtimeImageDir.toString(), + "--compress=0", + "--add-modules", "ALL-MODULE-PATH", + "--strip-debug", + "--no-header-files", + "--no-man-pages") + .execute(); + } + cmd.addArguments("--runtime-image", runtimeImageDir); // Remove --input parameter from jpackage command line as we don't // create input directory in the test and jpackage fails // if --input references non existant directory. diff -Nru openjdk-17-17.0.17+10/test/jdk/tools/jpackage/share/SimplePackageTest.java openjdk-17-17.0.18+8/test/jdk/tools/jpackage/share/SimplePackageTest.java --- openjdk-17-17.0.17+10/test/jdk/tools/jpackage/share/SimplePackageTest.java 2025-10-13 07:48:04.000000000 +0000 +++ openjdk-17-17.0.18+8/test/jdk/tools/jpackage/share/SimplePackageTest.java 2026-01-15 15:23:06.000000000 +0000 @@ -1,5 +1,5 @@ /* - * Copyright (c) 2018, 2020, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2018, 2024, Oracle and/or its affiliates. All rights reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * * This code is free software; you can redistribute it and/or modify it @@ -40,10 +40,9 @@ /* * @test * @summary Simple jpackage command run - * @library ../helpers + * @library /test/jdk/tools/jpackage/helpers * @key jpackagePlatformPackage * @build jdk.jpackage.test.* - * @modules jdk.jpackage/jdk.jpackage.internal * @compile SimplePackageTest.java * @run main/othervm/timeout=360 -Xmx512m jdk.jpackage.test.Main * --jpt-run=SimplePackageTest diff -Nru openjdk-17-17.0.17+10/test/jdk/tools/jpackage/share/UnicodeArgsTest.java openjdk-17-17.0.18+8/test/jdk/tools/jpackage/share/UnicodeArgsTest.java --- openjdk-17-17.0.17+10/test/jdk/tools/jpackage/share/UnicodeArgsTest.java 1970-01-01 00:00:00.000000000 +0000 +++ openjdk-17-17.0.18+8/test/jdk/tools/jpackage/share/UnicodeArgsTest.java 2026-01-15 15:23:06.000000000 +0000 @@ -0,0 +1,80 @@ +/* + * Copyright (c) 2020, 2024, Oracle and/or its affiliates. All rights reserved. + * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. + * + * This code is free software; you can redistribute it and/or modify it + * under the terms of the GNU General Public License version 2 only, as + * published by the Free Software Foundation. + * + * This code is distributed in the hope that it will be useful, but WITHOUT + * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or + * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License + * version 2 for more details (a copy is included in the LICENSE file that + * accompanied this code). + * + * You should have received a copy of the GNU General Public License version + * 2 along with this work; if not, write to the Free Software Foundation, + * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. + * + * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA + * or visit www.oracle.com if you need additional information or have any + * questions. + */ + + +import java.util.stream.Collectors; +import jdk.jpackage.test.TKit; +import jdk.jpackage.test.Annotations.Test; +import jdk.jpackage.test.Annotations.Parameter; +import jdk.jpackage.test.HelloApp; +import jdk.jpackage.test.JPackageCommand; + +/* + * @test + * @summary test how app launcher handles unicode command line arguments + * @library /test/jdk/tools/jpackage/helpers + * @build jdk.jpackage.test.* + * @compile UnicodeArgsTest.java + * @requires (os.family == "windows") + * @run main/othervm/timeout=720 -Xmx512m jdk.jpackage.test.Main + * --jpt-run=UnicodeArgsTest + */ + +public final class UnicodeArgsTest { + + @Parameter("true") + @Parameter("false") + @Test + public void test8246042(boolean onCommandLine) { + final String testString; + + String encoding = System.getProperty("native.encoding"); + switch (encoding) { + default: + testString = new String(Character.toChars(0x00E9)); + break; + + case "MS932": + case "SJIS": + testString = new String(Character.toChars(0x3042)); + break; + } + + TKit.trace(String.format("Test string code points: %s", testString + .codePoints() + .mapToObj(codePoint -> String.format("0x%04x", codePoint)) + .collect(Collectors.joining(",", "[", "]")))); + + JPackageCommand cmd = JPackageCommand.helloAppImage().useToolProvider(true); + if (!onCommandLine) { + cmd.addArguments("--arguments", testString); + } + cmd.executeAndAssertImageCreated(); + + if (onCommandLine) { + HelloApp.executeLauncherAndVerifyOutput(cmd, testString); + } else { + HelloApp.executeLauncherAndVerifyOutput(cmd); + } + } +} diff -Nru openjdk-17-17.0.17+10/test/jdk/tools/jpackage/share/VendorTest.java openjdk-17-17.0.18+8/test/jdk/tools/jpackage/share/VendorTest.java --- openjdk-17-17.0.17+10/test/jdk/tools/jpackage/share/VendorTest.java 1970-01-01 00:00:00.000000000 +0000 +++ openjdk-17-17.0.18+8/test/jdk/tools/jpackage/share/VendorTest.java 2026-01-15 15:23:06.000000000 +0000 @@ -0,0 +1,104 @@ +/* + * Copyright (c) 2020, 2024, Oracle and/or its affiliates. All rights reserved. + * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. + * + * This code is free software; you can redistribute it and/or modify it + * 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.jpackage.test.PackageTest; +import jdk.jpackage.test.PackageType; +import jdk.jpackage.test.Annotations.Test; + +/** + * Test --vendor parameter. Output of the test should be + * vendortest*.* package bundle. The output package should provide the + * same functionality as the default package with the default value of vendor + * property overridden. + * + * Linux DEB: + * + * Value of "Maintainer" property of .deb package should start with "Test Vendor" string. + * + * Linux RPM: + * + * Value of "Vendor" property of .rpm package should be set to "Test Vendor" string. + * + * Mac: + * + * --vendor parameter is ignored. + * + * Windows: + * + * Publisher value displayed in the Add/Remove Programs should be set + * to "Test Vendor" string. + */ + +/* + * @test + * @summary Test --vendor jpackage command option + * @library /test/jdk/tools/jpackage/helpers + * @key jpackagePlatformPackage + * @requires (os.family == "windows") + * @requires jpackage.test.SQETest != null + * @build jdk.jpackage.test.* + * @compile VendorTest.java + * @run main/othervm/timeout=360 -Xmx512m jdk.jpackage.test.Main + * --jpt-run=VendorTest + */ + +/* + * @test + * @summary Test --vendor jpackage command option + * @library /test/jdk/tools/jpackage/helpers + * @key jpackagePlatformPackage + * @requires (os.family != "mac") + * @requires jpackage.test.SQETest == null + * @build jdk.jpackage.test.* + * @compile VendorTest.java + * @run main/othervm/timeout=360 -Xmx512m jdk.jpackage.test.Main + * --jpt-run=VendorTest + */ +public class VendorTest { + + @Test + public static void test() { + final String vendorValue = "Test Vendor"; + + new PackageTest() + .configureHelloApp() + .addBundleDesktopIntegrationVerifier(false) + .addInitializer(cmd -> { + cmd.addArguments("--vendor", vendorValue); + }) + .forTypes(PackageType.LINUX_DEB) + .addBundlePropertyVerifier("Maintainer", value -> { + return value.startsWith(vendorValue + " "); + }, "starts with") + .forTypes(PackageType.LINUX_RPM) + .addBundlePropertyVerifier("Vendor", value -> { + return value.equals(vendorValue); + }, "equals to") + .forTypes(PackageType.WIN_MSI) + .addBundlePropertyVerifier("Manufacturer", value -> { + return value.equals(vendorValue); + }, "equals to") + .run(); + } +} diff -Nru openjdk-17-17.0.17+10/test/jdk/tools/jpackage/share/jdk/jpackage/tests/AppVersionTest.java openjdk-17-17.0.18+8/test/jdk/tools/jpackage/share/jdk/jpackage/tests/AppVersionTest.java --- openjdk-17-17.0.17+10/test/jdk/tools/jpackage/share/jdk/jpackage/tests/AppVersionTest.java 2025-10-13 07:48:04.000000000 +0000 +++ openjdk-17-17.0.18+8/test/jdk/tools/jpackage/share/jdk/jpackage/tests/AppVersionTest.java 1970-01-01 00:00:00.000000000 +0000 @@ -1,132 +0,0 @@ -/* - * Copyright (c) 2019, 2020, Oracle and/or its affiliates. All rights reserved. - * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. - * - * This code is free software; you can redistribute it and/or modify it - * under the terms of the GNU General Public License version 2 only, as - * published by the Free Software Foundation. - * - * This code is distributed in the hope that it will be useful, but WITHOUT - * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or - * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License - * version 2 for more details (a copy is included in the LICENSE file that - * accompanied this code). - * - * You should have received a copy of the GNU General Public License version - * 2 along with this work; if not, write to the Free Software Foundation, - * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. - * - * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA - * or visit www.oracle.com if you need additional information or have any - * questions. - */ - -package jdk.jpackage.tests; - -import java.io.IOException; -import java.util.Collection; -import java.util.ArrayList; -import java.util.List; -import javax.xml.xpath.XPathConstants; -import javax.xml.xpath.XPathExpressionException; -import javax.xml.xpath.XPathFactory; -import jdk.jpackage.internal.AppImageFile; -import jdk.jpackage.test.Annotations.Parameters; -import jdk.jpackage.test.Annotations.Test; -import jdk.jpackage.test.JPackageCommand; -import jdk.jpackage.test.PackageTest; -import jdk.jpackage.test.TKit; -import jdk.jpackage.internal.AppImageFile; -import org.w3c.dom.Document; - -/* - * @test - * @summary jpackage application version testing - * @library ../../../../helpers - * @build jdk.jpackage.test.* - * @modules jdk.jpackage/jdk.jpackage.internal - * @compile AppVersionTest.java - * @run main/othervm/timeout=360 -Xmx512m jdk.jpackage.test.Main - * --jpt-run=jdk.jpackage.tests.AppVersionTest - */ - -public final class AppVersionTest { - - @Parameters - public static Collection input() { - List data = new ArrayList<>(); - - data.addAll(List.of(new Object[][]{ - // Default jpackage version - {"1.0", "Hello", null}, - {"1.0", "com.other/com.other.Hello", null}, - // Version should be picked from --app-version - {"3.1", "Hello", new String[]{"--app-version", "3.1"}}, - {"3.2", "com.other/com.other.Hello", new String[]{"--app-version", - "3.2"}}, - // Version should be picked from the last --app-version - {"3.3", "Hello", new String[]{"--app-version", "4", "--app-version", - "3.3"}}, - {"7.8", "com.other/com.other.Hello", new String[]{"--app-version", - "4", "--app-version", "7.8"}}, - // Pick version from jar - {"3.10.17", "com.other/com.other.Hello@3.10.17", null}, - // Ignore version in jar if --app-version given - {"7.5.81", "com.other/com.other.Hello@3.10.17", new String[]{ - "--app-version", "7.5.81"}} - })); - - // These are invalid version strings. - // Don't need to test all invalid input as this is handled in - // PlatformVersionTest unit test - if (TKit.isWindows()) { - data.addAll(List.of(new Object[][]{ - {null, "Hello", new String[]{"--app-version", "256"}} - })); - } else if (TKit.isOSX()) { - data.addAll(List.of(new Object[][]{ - {null, "Hello", new String[]{"--app-version", "0.2"}} - })); - } - - return data; - } - - public AppVersionTest(String expectedVersion, String javaAppDesc, - String[] jpackageArgs) { - this.expectedVersion = expectedVersion; - this.javaAppDesc = javaAppDesc; - this.jpackageArgs = jpackageArgs; - } - - @Test - public void test() throws XPathExpressionException, IOException { - if (expectedVersion == null) { - new PackageTest() - .setExpectedExitCode(1) - .configureHelloApp(javaAppDesc) - .addInitializer(cmd -> { - cmd.addArguments(jpackageArgs); - }) - .run(); - return; - } - - JPackageCommand cmd = JPackageCommand.helloAppImage(javaAppDesc); - if (jpackageArgs != null) { - cmd.addArguments(jpackageArgs); - } - cmd.executeAndAssertHelloAppImageCreated(); - - Document xml = AppImageFile.readXml(cmd.outputBundle()); - String actualVersion = XPathFactory.newInstance().newXPath().evaluate( - "/jpackage-state/app-version/text()", xml, XPathConstants.STRING).toString(); - - TKit.assertEquals(expectedVersion, actualVersion, - "Check application version"); - } - - private final String expectedVersion; - private final String javaAppDesc; - private final String[] jpackageArgs; -} diff -Nru openjdk-17-17.0.17+10/test/jdk/tools/jpackage/share/jdk/jpackage/tests/BasicTest.java openjdk-17-17.0.18+8/test/jdk/tools/jpackage/share/jdk/jpackage/tests/BasicTest.java --- openjdk-17-17.0.17+10/test/jdk/tools/jpackage/share/jdk/jpackage/tests/BasicTest.java 2025-10-13 07:48:04.000000000 +0000 +++ openjdk-17-17.0.18+8/test/jdk/tools/jpackage/share/jdk/jpackage/tests/BasicTest.java 1970-01-01 00:00:00.000000000 +0000 @@ -1,371 +0,0 @@ -/* - * Copyright (c) 2019, 2024, Oracle and/or its affiliates. All rights reserved. - * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. - * - * This code is free software; you can redistribute it and/or modify it - * under the terms of the GNU General Public License version 2 only, as - * published by the Free Software Foundation. - * - * This code is distributed in the hope that it will be useful, but WITHOUT - * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or - * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License - * version 2 for more details (a copy is included in the LICENSE file that - * accompanied this code). - * - * You should have received a copy of the GNU General Public License version - * 2 along with this work; if not, write to the Free Software Foundation, - * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. - * - * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA - * or visit www.oracle.com if you need additional information or have any - * questions. - */ - -package jdk.jpackage.tests; - -import java.io.IOException; -import java.nio.file.Files; -import java.nio.file.Path; -import java.util.List; -import java.util.ArrayList; -import java.util.function.Function; -import java.util.function.Predicate; -import java.util.regex.Pattern; -import java.util.stream.Stream; -import jdk.jpackage.test.TKit; -import jdk.jpackage.test.JPackageCommand; -import jdk.jpackage.test.JavaAppDesc; -import jdk.jpackage.test.PackageTest; -import jdk.jpackage.test.HelloApp; -import jdk.jpackage.test.Executor; -import jdk.jpackage.test.JavaTool; -import jdk.jpackage.test.Annotations.Test; -import jdk.jpackage.test.Annotations.Parameter; - -import static jdk.jpackage.test.WindowsHelper.getTempDirectory; - -/* - * @test - * @summary jpackage basic testing - * @library ../../../../helpers - * @build jdk.jpackage.test.* - * @modules jdk.jpackage/jdk.jpackage.internal - * @compile BasicTest.java - * @run main/othervm/timeout=720 -Xmx512m jdk.jpackage.test.Main - * --jpt-run=jdk.jpackage.tests.BasicTest - */ - -public final class BasicTest { - @Test - public void testNoArgs() { - List output = - getJPackageToolProvider().executeAndGetOutput(); - TKit.assertStringListEquals(List.of("Usage: jpackage ", - "Use jpackage --help (or -h) for a list of possible options"), - output, "Check jpackage output"); - } - - @Test - public void testJpackageProps() { - String appVersion = "3.0"; - JPackageCommand cmd = JPackageCommand.helloAppImage( - JavaAppDesc.parse("Hello")) - // Disable default logic adding `--verbose` option - // to jpackage command line. - .ignoreDefaultVerbose(true) - .saveConsoleOutput(true) - .addArguments("--app-version", appVersion, "--arguments", - "jpackage.app-version jpackage.app-path") - .ignoreDefaultRuntime(true); - - cmd.executeAndAssertImageCreated(); - Path launcherPath = cmd.appLauncherPath(); - - List output = HelloApp.executeLauncher(cmd).getOutput(); - - TKit.assertTextStream("jpackage.app-version=" + appVersion).apply(output.stream()); - TKit.assertTextStream("jpackage.app-path=").apply(output.stream()); - } - - @Test - public void testVersion() { - List output = - getJPackageToolProvider() - .addArgument("--version") - .executeAndGetOutput(); - TKit.assertStringListEquals(List.of(System.getProperty("java.version")), - output, "Check jpackage output"); - } - - @Test - public void testHelp() { - List hOutput = getJPackageToolProvider() - .addArgument("-h").executeAndGetOutput(); - List helpOutput = getJPackageToolProvider() - .addArgument("--help").executeAndGetOutput(); - - TKit.assertStringListEquals(hOutput, helpOutput, - "Check -h and --help parameters produce the same output"); - - final String windowsPrefix = "--win-"; - final String linuxPrefix = "--linux-"; - final String osxPrefix = "--mac-"; - - final String expectedPrefix; - final List unexpectedPrefixes; - - if (TKit.isWindows()) { - expectedPrefix = windowsPrefix; - unexpectedPrefixes = List.of(osxPrefix, linuxPrefix); - } else if (TKit.isLinux()) { - expectedPrefix = linuxPrefix; - unexpectedPrefixes = List.of(windowsPrefix, osxPrefix); - } else if (TKit.isOSX()) { - expectedPrefix = osxPrefix; - unexpectedPrefixes = List.of(linuxPrefix, windowsPrefix); - } else { - throw TKit.throwUnknownPlatformError(); - } - - Function> createPattern = (prefix) -> { - return Pattern.compile("^ " + prefix).asPredicate(); - }; - - Function, Long> countStrings = (prefixes) -> { - return hOutput.stream().filter( - prefixes.stream().map(createPattern).reduce(x -> false, - Predicate::or)).peek(TKit::trace).count(); - }; - - TKit.trace("Check parameters in help text"); - TKit.assertNotEquals(0, countStrings.apply(List.of(expectedPrefix)), - "Check help text contains platform specific parameters"); - TKit.assertEquals(0, countStrings.apply(unexpectedPrefixes), - "Check help text doesn't contain unexpected parameters"); - } - - @Test - @SuppressWarnings("unchecked") - public void testVerbose() { - JPackageCommand cmd = JPackageCommand.helloAppImage() - // Disable default logic adding `--verbose` option - // to jpackage command line. - .ignoreDefaultVerbose(true) - .saveConsoleOutput(true) - .setFakeRuntime().executePrerequisiteActions(); - - List expectedVerboseOutputStrings = new ArrayList<>(); - expectedVerboseOutputStrings.add("Creating app package:"); - if (TKit.isWindows()) { - expectedVerboseOutputStrings.add( - "Succeeded in building Windows Application Image package"); - } else if (TKit.isLinux()) { - expectedVerboseOutputStrings.add( - "Succeeded in building Linux Application Image package"); - } else if (TKit.isOSX()) { - expectedVerboseOutputStrings.add("Preparing Info.plist:"); - expectedVerboseOutputStrings.add( - "Succeeded in building Mac Application Image package"); - } else { - TKit.throwUnknownPlatformError(); - } - - TKit.deleteDirectoryContentsRecursive(cmd.outputDir()); - List nonVerboseOutput = cmd.execute().getOutput(); - List[] verboseOutput = (List[])new List[1]; - - // Directory clean up is not 100% reliable on Windows because of - // antivirus software that can lock .exe files. Setup - // different output directory instead of cleaning the default one for - // verbose jpackage run. - TKit.withTempDirectory("verbose-output", tempDir -> { - cmd.setArgumentValue("--dest", tempDir); - cmd.addArgument("--verbose"); - verboseOutput[0] = cmd.execute().getOutput(); - }); - - TKit.assertTrue(nonVerboseOutput.size() < verboseOutput[0].size(), - "Check verbose output is longer than regular"); - - expectedVerboseOutputStrings.forEach(str -> { - TKit.assertTextStream(str).label("regular output") - .predicate(String::contains).negate() - .apply(nonVerboseOutput.stream()); - }); - - expectedVerboseOutputStrings.forEach(str -> { - TKit.assertTextStream(str).label("verbose output") - .apply(verboseOutput[0].stream()); - }); - } - - @Test - public void testNoName() { - final String mainClassName = "Greetings"; - - JPackageCommand cmd = JPackageCommand.helloAppImage(mainClassName) - .removeArgumentWithValue("--name"); - - Path expectedImageDir = cmd.outputDir().resolve(mainClassName); - if (TKit.isOSX()) { - expectedImageDir = expectedImageDir.getParent().resolve( - expectedImageDir.getFileName().toString() + ".app"); - } - - cmd.executeAndAssertHelloAppImageCreated(); - TKit.assertEquals(expectedImageDir.toAbsolutePath().normalize().toString(), - cmd.outputBundle().toAbsolutePath().normalize().toString(), - String.format( - "Check [%s] directory is filled with application image data", - expectedImageDir)); - } - - @Test - // Regular app - @Parameter("Hello") - // Modular app in .jar file - @Parameter("com.other/com.other.Hello") - // Modular app in .jmod file - @Parameter("hello.jmod:com.other/com.other.Hello") - // Modular app in exploded .jmod file - @Parameter("hello.ejmod:com.other/com.other.Hello") - public void testApp(String javaAppDesc) { - JavaAppDesc appDesc = JavaAppDesc.parse(javaAppDesc); - JPackageCommand cmd = JPackageCommand.helloAppImage(appDesc); - if (appDesc.jmodFileName() != null) { - // .jmod files are not supported at run-time. They should be - // bundled in Java run-time with jlink command, so disable - // use of external Java run-time if any configured. - cmd.ignoreDefaultRuntime(true); - } - cmd.executeAndAssertHelloAppImageCreated(); - } - - @Test - public void testWhitespaceInPaths() { - JPackageCommand.helloAppImage("a/b c.jar:Hello") - .setArgumentValue("--input", TKit.workDir().resolve("The quick brown fox")) - .setArgumentValue("--dest", TKit.workDir().resolve("jumps over the lazy dog")) - .executeAndAssertHelloAppImageCreated(); - } - - @Test - @Parameter("ALL-MODULE-PATH") - @Parameter("ALL-DEFAULT") - @Parameter("java.desktop") - @Parameter("java.desktop,jdk.jartool") - @Parameter({ "java.desktop", "jdk.jartool" }) - public void testAddModules(String... addModulesArg) { - JPackageCommand cmd = JPackageCommand - .helloAppImage("goodbye.jar:com.other/com.other.Hello") - .ignoreDefaultRuntime(true); // because of --add-modules - Stream.of(addModulesArg).map(v -> Stream.of("--add-modules", v)).flatMap( - s -> s).forEachOrdered(cmd::addArgument); - cmd.executeAndAssertHelloAppImageCreated(); - } - - public static enum TestTempType { - TEMPDIR_EMPTY, - TEMPDIR_NOT_EMPTY, - TEMPDIR_NOT_EXIST, - } - - /** - * Test --temp option. Doesn't make much sense for app image as temporary - * directory is used only on Windows. Test it in packaging mode. - */ - @Test - @Parameter("TEMPDIR_EMPTY") - @Parameter("TEMPDIR_NOT_EMPTY") - @Parameter("TEMPDIR_NOT_EXIST") - public void testTemp(TestTempType type) throws IOException { - final Path tempRoot = TKit.createTempDirectory("tmp"); - - var pkgTest = new PackageTest() - .configureHelloApp() - // Force save of package bundle in test work directory. - .addInitializer(JPackageCommand::setDefaultInputOutput) - .addInitializer(cmd -> { - Path tempDir = getTempDirectory(cmd, tempRoot); - switch (type) { - case TEMPDIR_EMPTY -> Files.createDirectories(tempDir); - case TEMPDIR_NOT_EXIST -> Files.createDirectories(tempDir.getParent()); - case TEMPDIR_NOT_EMPTY -> { - Files.createDirectories(tempDir); - TKit.createTextFile(tempDir.resolve("foo.txt"), List.of( - "Hello Duke!")); - } - } - cmd.addArguments("--temp", tempDir); - } - ); - - if (TestTempType.TEMPDIR_NOT_EMPTY.equals(type)) { - pkgTest.setExpectedExitCode(1).addBundleVerifier(cmd -> { - // Check jpackage didn't use the supplied directory. - Path tempDir = getTempDirectory(cmd, tempRoot); - String[] tempDirContents = tempDir.toFile().list(); - TKit.assertStringListEquals(List.of("foo.txt"), List.of( - tempDirContents), String.format( - "Check the contents of the supplied temporary directory [%s]", - tempDir)); - TKit.assertStringListEquals(List.of("Hello Duke!"), - Files.readAllLines(tempDir.resolve(tempDirContents[0])), - "Check the contents of the file in the supplied temporary directory"); - }); - } else { - pkgTest.addBundleVerifier(cmd -> { - // Check jpackage used the supplied directory. - Path tempDir = getTempDirectory(cmd, tempRoot); - TKit.assertDirectoryNotEmpty(tempDir); - }); - } - - pkgTest.run(PackageTest.Action.CREATE); - } - - @Test - public void testAtFile() throws IOException { - JPackageCommand cmd = JPackageCommand - .helloAppImage() - .setArgumentValue("--dest", TKit.createTempDirectory("output")); - - // Init options file with the list of options configured - // for JPackageCommand instance. - final Path optionsFile = TKit.createTempFile(Path.of("options")); - Files.write(optionsFile, - List.of(String.join(" ", cmd.getAllArguments()))); - - // Build app jar file. - cmd.executePrerequisiteActions(); - - // Instead of running jpackage command through configured - // JPackageCommand instance, run vanilla jpackage command with @ file. - getJPackageToolProvider() - .addArgument(String.format("@%s", optionsFile)) - .execute(); - - // Verify output of jpackage command. - cmd.assertImageCreated(); - HelloApp.executeLauncherAndVerifyOutput(cmd); - } - - @Test - @Parameter("1") - @Parameter("123") - public void testExitCode(int exitCode) { - JPackageCommand cmd = JPackageCommand - .helloAppImage() - .addArguments("--java-options", String.format( - "-Djpackage.test.exitCode=%d", exitCode)); - cmd.executeAndAssertHelloAppImageCreated(); - } - - private static Executor getJPackageToolProvider() { - return getToolProvider(JavaTool.JPACKAGE); - } - - private static Executor getToolProvider(JavaTool tool) { - return new Executor().dumpOutput().saveOutput().setToolProvider(tool); - } -} diff -Nru openjdk-17-17.0.17+10/test/jdk/tools/jpackage/share/jdk/jpackage/tests/CookedRuntimeTest.java openjdk-17-17.0.18+8/test/jdk/tools/jpackage/share/jdk/jpackage/tests/CookedRuntimeTest.java --- openjdk-17-17.0.17+10/test/jdk/tools/jpackage/share/jdk/jpackage/tests/CookedRuntimeTest.java 2025-10-13 07:48:04.000000000 +0000 +++ openjdk-17-17.0.18+8/test/jdk/tools/jpackage/share/jdk/jpackage/tests/CookedRuntimeTest.java 1970-01-01 00:00:00.000000000 +0000 @@ -1,142 +0,0 @@ -/* - * Copyright (c) 2020, Oracle and/or its affiliates. All rights reserved. - * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. - * - * This code is free software; you can redistribute it and/or modify it - * under the terms of the GNU General Public License version 2 only, as - * published by the Free Software Foundation. - * - * This code is distributed in the hope that it will be useful, but WITHOUT - * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or - * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License - * version 2 for more details (a copy is included in the LICENSE file that - * accompanied this code). - * - * You should have received a copy of the GNU General Public License version - * 2 along with this work; if not, write to the Free Software Foundation, - * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. - * - * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA - * or visit www.oracle.com if you need additional information or have any - * questions. - */ - -package jdk.jpackage.tests; - -import java.io.IOException; -import java.nio.file.Files; -import java.util.Collection; -import java.util.ArrayList; -import java.util.List; -import java.util.stream.Stream; -import java.nio.file.Path; -import jdk.jpackage.test.Annotations.Parameters; -import jdk.jpackage.test.Annotations.Test; -import jdk.jpackage.test.Executor; -import jdk.jpackage.test.JPackageCommand; -import jdk.jpackage.test.JavaAppDesc; -import jdk.jpackage.test.JavaTool; -import jdk.jpackage.test.TKit; - - -/* - * @test - * @summary test '--runtime-image' option of jpackage - * @library ../../../../helpers - * @build jdk.jpackage.test.* - * @modules jdk.jpackage/jdk.jpackage.internal - * @compile CookedRuntimeTest.java - * @run main/othervm/timeout=360 -Xmx512m jdk.jpackage.test.Main - * --jpt-run=jdk.jpackage.tests.CookedRuntimeTest - */ - -public final class CookedRuntimeTest { - - public CookedRuntimeTest(String javaAppDesc, String jlinkOutputSubdir, - String runtimeSubdir) { - this.javaAppDesc = javaAppDesc; - this.jlinkOutputSubdir = Path.of(jlinkOutputSubdir); - this.runtimeSubdir = Path.of(runtimeSubdir); - } - - @Test - public void test() throws IOException { - JavaAppDesc appDesc = JavaAppDesc.parse(javaAppDesc); - - JPackageCommand cmd = JPackageCommand.helloAppImage(appDesc); - - final String moduleName = appDesc.moduleName(); - - if (moduleName != null) { - // Build module jar. - cmd.executePrerequisiteActions(); - } - - final Path workDir = TKit.createTempDirectory("runtime").resolve("data"); - final Path jlinkOutputDir = workDir.resolve(jlinkOutputSubdir); - Files.createDirectories(jlinkOutputDir.getParent()); - - // List of modules required for test app. - final var modules = new String[] { - "java.base", - "java.desktop" - }; - - Executor jlink = new Executor() - .setToolProvider(JavaTool.JLINK) - .dumpOutput() - .addArguments( - "--add-modules", String.join(",", modules), - "--output", jlinkOutputDir.toString(), - "--strip-debug", - "--no-header-files", - "--no-man-pages"); - - if (moduleName != null) { - jlink.addArguments("--add-modules", moduleName, "--module-path", - Path.of(cmd.getArgumentValue("--module-path")).resolve( - "hello.jar").toString()); - } - - jlink.execute(); - - TKit.trace("jlink output BEGIN"); - try (Stream paths = Files.walk(jlinkOutputDir)) { - paths.filter(Files::isRegularFile) - .map(jlinkOutputDir::relativize) - .map(Path::toString) - .forEach(TKit::trace); - } - TKit.trace("jlink output END"); - - cmd.setArgumentValue("--runtime-image", workDir.resolve(runtimeSubdir)); - cmd.executeAndAssertHelloAppImageCreated(); - } - - @Parameters - public static Collection data() { - final List javaAppDescs = List.of("Hello", - "com.foo/com.foo.main.Aloha"); - - final List paths = new ArrayList<>(); - paths.add(new String[] { "", "" }); - if (TKit.isOSX()) { - // On OSX jpackage should accept both runtime root and runtime home - // directories. - paths.add(new String[] { "Contents/Home", "" }); - } - - List data = new ArrayList<>(); - for (var javaAppDesc : javaAppDescs) { - for (var pathCfg : paths) { - data.add(new Object[] { javaAppDesc, pathCfg[0], pathCfg[1] }); - } - } - - return data; - } - - private final String javaAppDesc; - private final Path jlinkOutputSubdir; - private final Path runtimeSubdir; -} diff -Nru openjdk-17-17.0.17+10/test/jdk/tools/jpackage/share/jdk/jpackage/tests/DotInNameTest.java openjdk-17-17.0.18+8/test/jdk/tools/jpackage/share/jdk/jpackage/tests/DotInNameTest.java --- openjdk-17-17.0.17+10/test/jdk/tools/jpackage/share/jdk/jpackage/tests/DotInNameTest.java 2025-10-13 07:48:04.000000000 +0000 +++ openjdk-17-17.0.18+8/test/jdk/tools/jpackage/share/jdk/jpackage/tests/DotInNameTest.java 1970-01-01 00:00:00.000000000 +0000 @@ -1,61 +0,0 @@ -/* - * Copyright (c) 2021, Oracle and/or its affiliates. All rights reserved. - * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. - * - * This code is free software; you can redistribute it and/or modify it - * under the terms of the GNU General Public License version 2 only, as - * published by the Free Software Foundation. - * - * This code is distributed in the hope that it will be useful, but WITHOUT - * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or - * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License - * version 2 for more details (a copy is included in the LICENSE file that - * accompanied this code). - * - * You should have received a copy of the GNU General Public License version - * 2 along with this work; if not, write to the Free Software Foundation, - * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. - * - * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA - * or visit www.oracle.com if you need additional information or have any - * questions. - */ - -package jdk.jpackage.tests; - -import jdk.jpackage.test.JPackageCommand; -import jdk.jpackage.test.HelloApp; -import jdk.jpackage.test.TKit; -import jdk.jpackage.test.Annotations.Parameters; -import jdk.jpackage.test.Annotations.Test; - - -/* - * @test - * @summary jpackage create image with --java-options test - * @library ../../../../helpers - * @build jdk.jpackage.test.* - * @modules jdk.jpackage/jdk.jpackage.internal - * @compile DotInNameTest.java - * @run main/othervm/timeout=360 -Xmx512m jdk.jpackage.test.Main - * --jpt-run=jdk.jpackage.tests.DotInNameTest - * --jpt-before-run=jdk.jpackage.test.JPackageCommand.useToolProviderByDefault - */ - -public class DotInNameTest { - - @Test - public void test() { - JPackageCommand cmd = JPackageCommand.helloAppImage("Hello"); - - cmd.setArgumentValue("--name", - cmd.getArgumentValue("--name") + ".with.dot"); - // run the jpackage command - cmd.executeAndAssertImageCreated(); - - // run the launcher it generated - HelloApp.executeLauncherAndVerifyOutput(cmd); - - } - -} diff -Nru openjdk-17-17.0.17+10/test/jdk/tools/jpackage/share/jdk/jpackage/tests/ErrorTest.java openjdk-17-17.0.18+8/test/jdk/tools/jpackage/share/jdk/jpackage/tests/ErrorTest.java --- openjdk-17-17.0.17+10/test/jdk/tools/jpackage/share/jdk/jpackage/tests/ErrorTest.java 2025-10-13 07:48:04.000000000 +0000 +++ openjdk-17-17.0.18+8/test/jdk/tools/jpackage/share/jdk/jpackage/tests/ErrorTest.java 1970-01-01 00:00:00.000000000 +0000 @@ -1,136 +0,0 @@ -/* - * Copyright (c) 2020, Oracle and/or its affiliates. All rights reserved. - * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. - * - * This code is free software; you can redistribute it and/or modify it - * under the terms of the GNU General Public License version 2 only, as - * published by the Free Software Foundation. - * - * This code is distributed in the hope that it will be useful, but WITHOUT - * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or - * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License - * version 2 for more details (a copy is included in the LICENSE file that - * accompanied this code). - * - * You should have received a copy of the GNU General Public License version - * 2 along with this work; if not, write to the Free Software Foundation, - * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. - * - * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA - * or visit www.oracle.com if you need additional information or have any - * questions. - */ - -package jdk.jpackage.tests; - -import java.util.Collection; -import java.util.List; -import jdk.jpackage.test.Annotations.Parameters; -import jdk.jpackage.test.Annotations.Test; -import jdk.jpackage.test.JPackageCommand; -import jdk.jpackage.test.TKit; - -/* - * @test - * @summary Test jpackage output for erroneous input - * @library ../../../../helpers - * @build jdk.jpackage.test.* - * @modules jdk.jpackage/jdk.jpackage.internal - * @compile ErrorTest.java - * @run main/othervm/timeout=360 -Xmx512m jdk.jpackage.test.Main - * --jpt-run=jdk.jpackage.tests.ErrorTest - * --jpt-before-run=jdk.jpackage.test.JPackageCommand.useExecutableByDefault - */ - -/* - * @test - * @summary Test jpackage output for erroneous input - * @library ../../../../helpers - * @build jdk.jpackage.test.* - * @modules jdk.jpackage/jdk.jpackage.internal - * @compile ErrorTest.java - * @run main/othervm/timeout=360 -Xmx512m jdk.jpackage.test.Main - * --jpt-run=jdk.jpackage.tests.ErrorTest - * --jpt-before-run=jdk.jpackage.test.JPackageCommand.useToolProviderByDefault - */ - -public final class ErrorTest { - - private final String expectedError; - private final JPackageCommand cmd; - - @Parameters - public static Collection input() { - return List.of(new Object[][]{ - // non-existent arg - {"Hello", - new String[]{"--no-such-argument"}, - null, - "Invalid Option: [--no-such-argument]"}, - // no main jar - {"Hello", - null, - new String[]{"--main-jar"}, - "--main-jar or --module"}, - // no main-class - {"Hello", - null, - new String[]{"--main-class"}, - "main class was not specified"}, - // non-existent main jar - {"Hello", - new String[]{"--main-jar", "non-existent.jar"}, - null, - "main jar does not exist"}, - // non-existent runtime - {"Hello", - new String[]{"--runtime-image", "non-existent.runtime"}, - null, - "does not exist"}, - // non-existent resource-dir - {"Hello", - new String[]{"--resource-dir", "non-existent.dir"}, - null, - "does not exist"}, - // invalid type - {"Hello", - new String[]{"--type", "invalid-type"}, - null, - "Invalid or unsupported type: [invalid-type]"}, - // no --input - {"Hello", - null, - new String[]{"--input"}, - "Missing argument: --input"}, - // no --module-path - {"com.other/com.other.Hello", - null, - new String[]{"--module-path"}, - "Missing argument: --runtime-image or --module-path"}, - }); - } - - public ErrorTest(String javaAppDesc, String[] jpackageArgs, - String[] removeArgs, - String expectedError) { - this.expectedError = expectedError; - - cmd = JPackageCommand.helloAppImage(javaAppDesc) - .saveConsoleOutput(true).dumpOutput(true); - if (jpackageArgs != null) { - cmd.addArguments(jpackageArgs); - } if (removeArgs != null) { - for (String arg : removeArgs) { - cmd.removeArgumentWithValue(arg); - } - } - } - - @Test - public void test() { - List output = cmd.execute(1).getOutput(); - TKit.assertNotNull(output, "output is null"); - TKit.assertTextStream(expectedError).apply(output.stream()); - } - -} diff -Nru openjdk-17-17.0.17+10/test/jdk/tools/jpackage/share/jdk/jpackage/tests/JLinkOptionsTest.java openjdk-17-17.0.18+8/test/jdk/tools/jpackage/share/jdk/jpackage/tests/JLinkOptionsTest.java --- openjdk-17-17.0.17+10/test/jdk/tools/jpackage/share/jdk/jpackage/tests/JLinkOptionsTest.java 2025-10-13 07:48:04.000000000 +0000 +++ openjdk-17-17.0.18+8/test/jdk/tools/jpackage/share/jdk/jpackage/tests/JLinkOptionsTest.java 1970-01-01 00:00:00.000000000 +0000 @@ -1,144 +0,0 @@ -/* - * Copyright (c) 2020, Oracle and/or its affiliates. All rights reserved. - * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. - * - * This code is free software; you can redistribute it and/or modify it - * under the terms of the GNU General Public License version 2 only, as - * published by the Free Software Foundation. - * - * This code is distributed in the hope that it will be useful, but WITHOUT - * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or - * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License - * version 2 for more details (a copy is included in the LICENSE file that - * accompanied this code). - * - * You should have received a copy of the GNU General Public License version - * 2 along with this work; if not, write to the Free Software Foundation, - * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. - * - * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA - * or visit www.oracle.com if you need additional information or have any - * questions. - */ - -package jdk.jpackage.tests; - -import java.util.Collection; -import java.util.List; -import jdk.jpackage.test.Annotations.Parameters; -import jdk.jpackage.test.Annotations.Test; -import jdk.jpackage.test.JPackageCommand; -import jdk.jpackage.test.TKit; - -/* - * @test - * @summary jpackage application version testing - * @library ../../../../helpers - * @build jdk.jpackage.test.* - * @modules jdk.jpackage/jdk.jpackage.internal - * @compile JLinkOptionsTest.java - * @run main/othervm/timeout=360 -Xmx512m jdk.jpackage.test.Main - * --jpt-run=jdk.jpackage.tests.JLinkOptionsTest - */ - -public final class JLinkOptionsTest { - - @Parameters - public static Collection input() { - return List.of(new Object[][]{ - // default but with strip-native-commands removed - {"Hello", new String[]{ - "--jlink-options", - "--strip-debug --no-man-pages --no-header-files", - }, - // non modular should have everything - new String[]{"jdk.jartool", "jdk.unsupported"}, - null, - }, - // multiple jlink-options - {"com.other/com.other.Hello", new String[]{ - "--jlink-options", - "--strip-debug --no-man-pages --no-header-files", - "--jlink-options", - "--bind-services", - }, - // with bind-services should have some services - new String[]{"java.smartcardio", "jdk.crypto.ec"}, - null, - }, - // bind-services - {"Hello", new String[]{ - "--jlink-options", "--bind-services", - }, - // non modular should have everything - new String[]{"jdk.jartool", "jdk.unsupported"}, - null, - }, - - // jlink-options --bind-services - {"com.other/com.other.Hello", new String[]{ - "--jlink-options", "--bind-services", - }, - // with bind-services should have some services - new String[]{"java.smartcardio", "jdk.crypto.ec"}, - null, - }, - - // limit modules - {"com.other/com.other.Hello", new String[]{ - "--jlink-options", - "--limit-modules java.base,java.datatransfer,java.xml,java.prefs,java.desktop,com.other", - }, - // should have whatever it needs - new String[]{"java.base", "com.other"}, - // should not have whatever it doesn't need - new String[]{"jdk.jpackage"}, - }, - - // bind-services and limit-options - {"com.other/com.other.Hello", new String[]{ - "--jlink-options", - "--bind-services", - "--jlink-options", - "--limit-modules java.base,java.datatransfer,java.xml,java.prefs,java.desktop,com.other,java.smartcardio", - }, - // with bind-services should have some services - new String[]{"java.smartcardio"}, - // but not limited - new String[]{"jdk.crypto.ec"}, - }, - - }); - } - - public JLinkOptionsTest(String javaAppDesc, String[] jpackageArgs, String[] required, String[] prohibited) { - this.required = required; - this.prohibited = prohibited; - cmd = JPackageCommand - .helloAppImage(javaAppDesc) - .ignoreDefaultRuntime(true) - .addArguments(jpackageArgs); - } - - @Test - public void test() { - cmd.executeAndAssertHelloAppImageCreated(); - - List release = cmd.readRuntimeReleaseFile(); - List mods = List.of(release.get(1)); - if (required != null) { - for (String s : required) { - TKit.assertTextStream(s).label("mods").apply(mods.stream()); - } - } - if (prohibited != null) { - for (String s : prohibited) { - TKit.assertTextStream(s).label("mods").negate().apply(mods.stream()); - } - } - } - - private final String[] required; - private final String[] prohibited; - private final JPackageCommand cmd; -} diff -Nru openjdk-17-17.0.17+10/test/jdk/tools/jpackage/share/jdk/jpackage/tests/JavaOptionsEqualsTest.java openjdk-17-17.0.18+8/test/jdk/tools/jpackage/share/jdk/jpackage/tests/JavaOptionsEqualsTest.java --- openjdk-17-17.0.17+10/test/jdk/tools/jpackage/share/jdk/jpackage/tests/JavaOptionsEqualsTest.java 2025-10-13 07:48:04.000000000 +0000 +++ openjdk-17-17.0.18+8/test/jdk/tools/jpackage/share/jdk/jpackage/tests/JavaOptionsEqualsTest.java 1970-01-01 00:00:00.000000000 +0000 @@ -1,96 +0,0 @@ -/* - * Copyright (c) 2018, 2020, Oracle and/or its affiliates. All rights reserved. - * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. - * - * This code is free software; you can redistribute it and/or modify it - * under the terms of the GNU General Public License version 2 only, as - * published by the Free Software Foundation. - * - * This code is distributed in the hope that it will be useful, but WITHOUT - * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or - * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License - * version 2 for more details (a copy is included in the LICENSE file that - * accompanied this code). - * - * You should have received a copy of the GNU General Public License version - * 2 along with this work; if not, write to the Free Software Foundation, - * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. - * - * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA - * or visit www.oracle.com if you need additional information or have any - * questions. - */ - -package jdk.jpackage.tests; - -import java.util.Collection; -import java.util.List; -import jdk.jpackage.test.Annotations.Parameters; -import jdk.jpackage.test.Annotations.Test; -import jdk.jpackage.test.JPackageCommand; -import jdk.jpackage.test.HelloApp; -import jdk.jpackage.test.Executor; -import jdk.jpackage.test.TKit; - -/* - * @test - * @summary jpackage create image with --java-options test - * @library ../../../../helpers - * @build jdk.jpackage.test.* - * @modules jdk.jpackage/jdk.jpackage.internal - * @compile JavaOptionsEqualsTest.java - * @run main/othervm/timeout=360 -Xmx512m jdk.jpackage.test.Main - * --jpt-run=jdk.jpackage.tests.JavaOptionsEqualsTest - * --jpt-before-run=jdk.jpackage.test.JPackageCommand.useExecutableByDefault - */ - -/* - * @test - * @summary jpackage create image with --java-options test - * @library ../../../../helpers - * @build jdk.jpackage.test.* - * @modules jdk.jpackage/jdk.jpackage.internal - * @compile JavaOptionsEqualsTest.java - * @run main/othervm/timeout=360 -Xmx512m jdk.jpackage.test.Main - * --jpt-run=jdk.jpackage.tests.JavaOptionsEqualsTest - * --jpt-before-run=jdk.jpackage.test.JPackageCommand.useToolProviderByDefault - */ - -public class JavaOptionsEqualsTest { - - private final static String OPTION1 = - "--add-exports=java.base/sun.util=me.mymodule.foo,ALL-UNNAMED"; - private final static String OPTION2 = - "--add-exports=java.base/sun.security.util=other.mod.bar,ALL-UNNAMED"; - private final static String WARNING1 = - "WARNING: Unknown module: me.mymodule.foo"; - private final static String WARNING2 = - "WARNING: Unknown module: other.mod.bar"; - - private final JPackageCommand cmd; - - @Parameters - public static Collection input() { - return List.of(new Object[][]{ - {"Hello", new String[]{"--java-options", OPTION1, - "--java-options", OPTION2 }, - }, - }); - } - - public JavaOptionsEqualsTest(String javaAppDesc, String[] jpackageArgs) { - cmd = JPackageCommand.helloAppImage(javaAppDesc); - if (jpackageArgs != null) { - cmd.addArguments(jpackageArgs); - } - } - - @Test - public void test() { - cmd.executeAndAssertHelloAppImageCreated(); - List output = HelloApp.executeLauncher(cmd).getOutput(); - TKit.assertNotNull(output, "output is null"); - TKit.assertTextStream(WARNING1).apply(output.stream()); - TKit.assertTextStream(WARNING2).apply(output.stream()); - } -} diff -Nru openjdk-17-17.0.17+10/test/jdk/tools/jpackage/share/jdk/jpackage/tests/JavaOptionsTest.java openjdk-17-17.0.18+8/test/jdk/tools/jpackage/share/jdk/jpackage/tests/JavaOptionsTest.java --- openjdk-17-17.0.17+10/test/jdk/tools/jpackage/share/jdk/jpackage/tests/JavaOptionsTest.java 2025-10-13 07:48:04.000000000 +0000 +++ openjdk-17-17.0.18+8/test/jdk/tools/jpackage/share/jdk/jpackage/tests/JavaOptionsTest.java 1970-01-01 00:00:00.000000000 +0000 @@ -1,101 +0,0 @@ -/* - * Copyright (c) 2018, 2020, Oracle and/or its affiliates. All rights reserved. - * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. - * - * This code is free software; you can redistribute it and/or modify it - * under the terms of the GNU General Public License version 2 only, as - * published by the Free Software Foundation. - * - * This code is distributed in the hope that it will be useful, but WITHOUT - * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or - * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License - * version 2 for more details (a copy is included in the LICENSE file that - * accompanied this code). - * - * You should have received a copy of the GNU General Public License version - * 2 along with this work; if not, write to the Free Software Foundation, - * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. - * - * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA - * or visit www.oracle.com if you need additional information or have any - * questions. - */ - -package jdk.jpackage.tests; - -import java.util.Collection; -import java.util.List; -import java.util.ArrayList; -import jdk.jpackage.test.Annotations.Parameters; -import jdk.jpackage.test.Annotations.Test; -import jdk.jpackage.test.JPackageCommand; -import jdk.jpackage.test.HelloApp; -import jdk.jpackage.test.TKit; - -/* - * @test - * @summary jpackage create image with --java-options test - * @library ../../../../helpers - * @build jdk.jpackage.test.* - * @modules jdk.jpackage/jdk.jpackage.internal - * @compile JavaOptionsTest.java - * @run main/othervm/timeout=360 -Xmx512m jdk.jpackage.test.Main - * --jpt-run=jdk.jpackage.tests.JavaOptionsTest - * --jpt-before-run=jdk.jpackage.test.JPackageCommand.useToolProviderByDefault - */ - -public class JavaOptionsTest { - private static final String PARAM1 = "Some Param 1"; - private static final String PARAM2 = "Some \"Param\" 2"; - private static final String PARAM3 = "Some \"Param\" with \" 3"; - private static final String ARG1 = "-Dparam1=" + "\'" + PARAM1 + "\'"; - private static final String ARG2 = "-Dparam2=" + "\'" + PARAM2 + "\'"; - private static final String ARG3 = "-Dparam3=" + "\'" + PARAM3 + "\'"; - private static final String EXPECT1 = "-Dparam1=" + PARAM1; - private static final String EXPECT2 = "-Dparam2=" + PARAM2; - private static final String EXPECT3 = "-Dparam3=" + PARAM3; - - - private final JPackageCommand cmd; - private final String[] expected; - - @Parameters - public static Collection input() { - List result = new ArrayList<>(); - for (var app : List.of("Hello", "com.other/com.other.Hello")) { - result.add(new Object[]{app, new String[]{"--java-options", ARG1}, - new String[]{EXPECT1},}); - result.add(new Object[]{app, new String[]{"--java-options", ARG2}, - new String[]{EXPECT2},}); - result.add(new Object[]{app, new String[]{"--java-options", ARG3}, - new String[]{EXPECT3},}); - result.add(new Object[]{app, new String[]{"--java-options", ARG1, - "--java-options", ARG2, "--java-options", ARG3}, new String[]{ - EXPECT1, EXPECT2, EXPECT3},}); - } - return List.of(result.toArray(Object[][]::new)); - } - - public JavaOptionsTest(String javaAppDesc, String[] jpackageArgs, - String[] expectedParams) { - cmd = JPackageCommand.helloAppImage(javaAppDesc); - if (jpackageArgs != null) { - cmd.addArguments(jpackageArgs); - } - expected = expectedParams; - } - - @Test - public void test() { - // 1.) run the jpackage command - cmd.executeAndAssertImageCreated(); - - // 2.) run the launcher it generated - List output = HelloApp.executeLauncher(cmd).getOutput(); - TKit.assertNotNull(output, "output is null"); - for (String expect : expected) { - TKit.assertTextStream(expect).apply(output.stream()); - } - } - -} diff -Nru openjdk-17-17.0.17+10/test/jdk/tools/jpackage/share/jdk/jpackage/tests/MainClassTest.java openjdk-17-17.0.18+8/test/jdk/tools/jpackage/share/jdk/jpackage/tests/MainClassTest.java --- openjdk-17-17.0.17+10/test/jdk/tools/jpackage/share/jdk/jpackage/tests/MainClassTest.java 2025-10-13 07:48:04.000000000 +0000 +++ openjdk-17-17.0.18+8/test/jdk/tools/jpackage/share/jdk/jpackage/tests/MainClassTest.java 1970-01-01 00:00:00.000000000 +0000 @@ -1,321 +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. - */ - -package jdk.jpackage.tests; - -import java.io.IOException; -import java.nio.file.Files; -import java.util.Collection; -import java.util.ArrayList; -import java.util.List; -import java.util.Set; -import java.util.jar.JarFile; -import java.util.Objects; -import java.util.stream.Collectors; -import java.util.stream.Stream; -import java.nio.file.Path; -import java.util.function.Predicate; -import java.util.jar.JarEntry; -import jdk.jpackage.test.JavaAppDesc; -import jdk.jpackage.test.JPackageCommand; -import jdk.jpackage.test.TKit; -import jdk.jpackage.test.Executor; -import jdk.jpackage.test.HelloApp; -import jdk.jpackage.test.JavaTool; -import jdk.jpackage.test.Annotations.Parameters; -import jdk.jpackage.test.Annotations.Test; -import jdk.jpackage.test.Functional.ThrowingConsumer; -import static jdk.jpackage.tests.MainClassTest.Script.MainClassType.*; - - -/* - * @test - * @summary test different settings of main class name for jpackage - * @library ../../../../helpers - * @build jdk.jpackage.test.* - * @modules jdk.jpackage/jdk.jpackage.internal - * @compile MainClassTest.java - * @run main/othervm/timeout=720 -Xmx512m jdk.jpackage.test.Main - * --jpt-run=jdk.jpackage.tests.MainClassTest - */ - -public final class MainClassTest { - - static final class Script { - Script() { - appDesc = JavaAppDesc.parse("test.Hello"); - } - - Script modular(boolean v) { - appDesc.setModuleName(v ? "com.other" : null); - return this; - } - - Script withJLink(boolean v) { - withJLink = v; - return this; - } - - Script withMainClass(MainClassType v) { - mainClass = v; - return this; - } - - Script withJarMainClass(MainClassType v) { - appDesc.setWithMainClass(v != NotSet); - jarMainClass = v; - return this; - } - - Script expectedErrorMessage(String v) { - expectedErrorMessage = v; - return this; - } - - @Override - public String toString() { - return Stream.of( - format("modular", appDesc.moduleName() != null ? 'y' : 'n'), - format("main-class", mainClass), - format("jar-main-class", jarMainClass), - format("jlink", withJLink ? 'y' : 'n'), - format("error", expectedErrorMessage) - ).filter(Objects::nonNull).collect(Collectors.joining("; ")); - } - - private static String format(String key, Object value) { - if (value == null) { - return null; - } - return String.join("=", key, value.toString()); - } - - enum MainClassType { - NotSet("n"), - SetWrong("b"), - SetRight("y"); - - MainClassType(String label) { - this.label = label; - } - - @Override - public String toString() { - return label; - } - - private final String label; - }; - - private JavaAppDesc appDesc; - private boolean withJLink; - private MainClassType mainClass; - private MainClassType jarMainClass; - private String expectedErrorMessage; - } - - public MainClassTest(Script script) { - this.script = script; - - nonExistingMainClass = Stream.of( - script.appDesc.packageName(), "ThereIsNoSuchClass").filter( - Objects::nonNull).collect(Collectors.joining(".")); - - cmd = JPackageCommand - .helloAppImage(script.appDesc) - .ignoreDefaultRuntime(true); - if (!script.withJLink) { - cmd.addArguments("--runtime-image", Path.of(System.getProperty( - "java.home"))); - } - - final String moduleName = script.appDesc.moduleName(); - switch (script.mainClass) { - case NotSet: - if (moduleName != null) { - // Don't specify class name, only module name. - cmd.setArgumentValue("--module", moduleName); - } else { - cmd.removeArgumentWithValue("--main-class"); - } - break; - - case SetWrong: - if (moduleName != null) { - cmd.setArgumentValue("--module", - String.join("/", moduleName, nonExistingMainClass)); - } else { - cmd.setArgumentValue("--main-class", nonExistingMainClass); - } - } - } - - @Parameters - public static Collection scripts() { - final var withMainClass = Set.of(SetWrong, SetRight); - - List scripts = new ArrayList<>(); - for (var withJLink : List.of(true, false)) { - for (var modular : List.of(true, false)) { - for (var mainClass : Script.MainClassType.values()) { - for (var jarMainClass : Script.MainClassType.values()) { - Script script = new Script() - .modular(modular) - .withJLink(withJLink) - .withMainClass(mainClass) - .withJarMainClass(jarMainClass); - - if (withMainClass.contains(jarMainClass) - || withMainClass.contains(mainClass)) { - } else if (modular) { - script.expectedErrorMessage( - "Error: Main application class is missing"); - } else { - script.expectedErrorMessage( - "A main class was not specified nor was one found in the jar"); - } - - scripts.add(new Script[]{script}); - } - } - } - } - return scripts; - } - - @Test - public void test() throws IOException { - if (script.jarMainClass == SetWrong) { - initJarWithWrongMainClass(); - } - - if (script.expectedErrorMessage != null) { - // This is the case when main class is not found nor in jar - // file nor on command line. - List output = cmd - .saveConsoleOutput(true) - .execute(1) - .getOutput(); - TKit.assertTextStream(script.expectedErrorMessage).apply(output.stream()); - return; - } - - // Get here only if main class is specified. - boolean appShouldSucceed = false; - - // Should succeed if valid main class is set on the command line. - appShouldSucceed |= (script.mainClass == SetRight); - - // Should succeed if main class is not set on the command line but set - // to valid value in the jar. - appShouldSucceed |= (script.mainClass == NotSet && script.jarMainClass == SetRight); - - if (appShouldSucceed) { - cmd.executeAndAssertHelloAppImageCreated(); - } else { - cmd.executeAndAssertImageCreated(); - if (!cmd.isFakeRuntime(String.format("Not running [%s]", - cmd.appLauncherPath()))) { - List output = new Executor() - .setDirectory(cmd.outputDir()) - .setExecutable(cmd.appLauncherPath()) - .dumpOutput().saveOutput() - .execute(1).getOutput(); - TKit.assertTextStream(String.format( - "Error: Could not find or load main class %s", - nonExistingMainClass)).apply(output.stream()); - } - } - } - - private void initJarWithWrongMainClass() throws IOException { - // Call JPackageCommand.executePrerequisiteActions() to build app's jar. - // executePrerequisiteActions() is called by JPackageCommand instance - // only once. - cmd.executePrerequisiteActions(); - - final Path jarFile; - if (script.appDesc.moduleName() != null) { - jarFile = Path.of(cmd.getArgumentValue("--module-path"), - script.appDesc.jarFileName()); - } else { - jarFile = cmd.inputDir().resolve(cmd.getArgumentValue("--main-jar")); - } - - // Create new jar file filtering out main class from the old jar file. - TKit.withTempDirectory("repack-jar", workDir -> { - // Extract app's class from the old jar. - explodeJar(jarFile, workDir, - jarEntry -> Path.of(jarEntry.getName()).equals( - script.appDesc.classFilePath())); - - // Create app's jar file with different main class. - var badAppDesc = JavaAppDesc - .parse(script.appDesc.toString()) - .setClassName(nonExistingMainClass); - HelloApp.createBundle(badAppDesc, jarFile.getParent()); - - // Extract new jar but skip app's class. - explodeJar(jarFile, workDir, - jarEntry -> !Path.of(jarEntry.getName()).equals( - badAppDesc.classFilePath())); - - // At this point we should have: - // 1. Manifest from the new jar referencing non-existing class - // as the main class. - // 2. Module descriptor referencing non-existing class as the main - // class in case of modular app. - // 3. App's class from the old jar. We need it to let jlink find some - // classes in the package declared in module descriptor - // in case of modular app. - - Files.delete(jarFile); - new Executor().setToolProvider(JavaTool.JAR) - .addArguments("-v", "-c", "-M", "-f", jarFile.toString()) - .addArguments("-C", workDir.toString(), ".") - .dumpOutput() - .execute(); - }); - } - - private static void explodeJar(Path jarFile, Path workDir, - Predicate filter) throws IOException { - try (var jar = new JarFile(jarFile.toFile())) { - jar.stream() - .filter(Predicate.not(JarEntry::isDirectory)) - .filter(filter) - .sequential().forEachOrdered(ThrowingConsumer.toConsumer( - jarEntry -> { - try (var in = jar.getInputStream(jarEntry)) { - Path fileName = workDir.resolve(jarEntry.getName()); - Files.createDirectories(fileName.getParent()); - Files.copy(in, fileName); - } - })); - } - } - - private final JPackageCommand cmd; - private final Script script; - private final String nonExistingMainClass; -} diff -Nru openjdk-17-17.0.17+10/test/jdk/tools/jpackage/share/jdk/jpackage/tests/ModulePathTest.java openjdk-17-17.0.18+8/test/jdk/tools/jpackage/share/jdk/jpackage/tests/ModulePathTest.java --- openjdk-17-17.0.17+10/test/jdk/tools/jpackage/share/jdk/jpackage/tests/ModulePathTest.java 2025-10-13 07:48:04.000000000 +0000 +++ openjdk-17-17.0.18+8/test/jdk/tools/jpackage/share/jdk/jpackage/tests/ModulePathTest.java 1970-01-01 00:00:00.000000000 +0000 @@ -1,147 +0,0 @@ -/* - * Copyright (c) 2019, 2020, Oracle and/or its affiliates. All rights reserved. - * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. - * - * This code is free software; you can redistribute it and/or modify it - * under the terms of the GNU General Public License version 2 only, as - * published by the Free Software Foundation. - * - * This code is distributed in the hope that it will be useful, but WITHOUT - * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or - * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License - * version 2 for more details (a copy is included in the LICENSE file that - * accompanied this code). - * - * You should have received a copy of the GNU General Public License version - * 2 along with this work; if not, write to the Free Software Foundation, - * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. - * - * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA - * or visit www.oracle.com if you need additional information or have any - * questions. - */ - -package jdk.jpackage.tests; - -import java.io.File; -import java.io.IOException; -import java.nio.file.Path; -import java.util.Collection; -import java.util.List; -import java.util.function.Function; -import java.util.stream.Collectors; -import java.util.stream.Stream; -import jdk.jpackage.test.TKit; -import jdk.jpackage.test.JavaAppDesc; -import jdk.jpackage.test.HelloApp; -import jdk.jpackage.test.JPackageCommand; -import jdk.jpackage.test.PackageType; -import jdk.jpackage.test.Annotations.Parameter; -import jdk.jpackage.test.Annotations.Parameters; -import jdk.jpackage.test.Annotations.Test; - - -/* - * @test - * @summary jpackage with --module-path testing - * @library ../../../../helpers - * @build jdk.jpackage.test.* - * @modules jdk.jpackage/jdk.jpackage.internal - * @compile ModulePathTest.java - * @run main/othervm/timeout=360 -Xmx512m jdk.jpackage.test.Main - * --jpt-run=jdk.jpackage.tests.ModulePathTest - */ - -public final class ModulePathTest { - - @Parameters - public static Collection data() { - return List.of(new String[][]{ - {GOOD_PATH, EMPTY_DIR, NON_EXISTING_DIR}, - {EMPTY_DIR, NON_EXISTING_DIR, GOOD_PATH}, - {GOOD_PATH + "/a/b/c/d", GOOD_PATH}, - {String.join(File.pathSeparator, EMPTY_DIR, NON_EXISTING_DIR, - GOOD_PATH)}, - {String.join(File.pathSeparator, EMPTY_DIR, NON_EXISTING_DIR), - String.join(File.pathSeparator, EMPTY_DIR, NON_EXISTING_DIR, - GOOD_PATH)}, - {}, - {EMPTY_DIR} - }); - } - - public ModulePathTest(String... modulePathArgs) { - this.modulePathArgs = List.of(modulePathArgs); - } - - @Test - @Parameter("benvenuto.jar:com.jar.foo/com.jar.foo.Hello") - @Parameter("benvenuto.jmod:com.jmod.foo/com.jmod.foo.JModHello") - public void test(String javaAppDesc) throws IOException { - JavaAppDesc appDesc = JavaAppDesc.parse(javaAppDesc); - - Path goodModulePath = TKit.createTempDirectory("modules"); - - Path appBundle = HelloApp.createBundle(appDesc, goodModulePath); - - JPackageCommand cmd = new JPackageCommand() - .setArgumentValue("--dest", TKit.workDir().resolve("output")) - .setDefaultAppName() - .setPackageType(PackageType.IMAGE); - - if (TKit.isWindows()) { - cmd.addArguments("--win-console"); - } - - cmd.addArguments("--module", String.join("/", appDesc.moduleName(), - appDesc.className())); - - // Ignore runtime that can be set for all tests. Usually if default - // runtime is set, it is fake one to save time on running jlink and - // copying megabytes of data from Java home to application image. - // We need proper runtime for this test. - cmd.ignoreDefaultRuntime(true); - - Path emptyDir = TKit.createTempDirectory("empty-dir"); - Path nonExistingDir = TKit.withTempDirectory("non-existing-dir", x -> {}); - - Function substitute = str -> { - String v = str; - v = v.replace(GOOD_PATH, goodModulePath.toString()); - v = v.replace(EMPTY_DIR, emptyDir.toString()); - v = v.replace(NON_EXISTING_DIR, nonExistingDir.toString()); - return v; - }; - - boolean withGoodPath = modulePathArgs.stream().anyMatch( - s -> s.contains(GOOD_PATH)); - - cmd.addArguments(modulePathArgs.stream().map(arg -> Stream.of( - "--module-path", substitute.apply(arg))).flatMap(s -> s).collect( - Collectors.toList())); - - if (withGoodPath) { - cmd.executeAndAssertHelloAppImageCreated(); - } else { - final String expectedErrorMessage; - if (modulePathArgs.isEmpty()) { - expectedErrorMessage = "Error: Missing argument: --runtime-image or --module-path"; - } else { - expectedErrorMessage = String.format( - "Failed to find %s module in module path", appDesc.moduleName()); - } - - List output = cmd - .saveConsoleOutput(true) - .execute(1) - .getOutput(); - TKit.assertTextStream(expectedErrorMessage).apply(output.stream()); - } - } - - private final List modulePathArgs; - - private final static String GOOD_PATH = "@GoodPath@"; - private final static String EMPTY_DIR = "@EmptyDir@"; - private final static String NON_EXISTING_DIR = "@NonExistingDir@"; -} diff -Nru openjdk-17-17.0.17+10/test/jdk/tools/jpackage/share/jdk/jpackage/tests/ModulePathTest2.java openjdk-17-17.0.18+8/test/jdk/tools/jpackage/share/jdk/jpackage/tests/ModulePathTest2.java --- openjdk-17-17.0.17+10/test/jdk/tools/jpackage/share/jdk/jpackage/tests/ModulePathTest2.java 2025-10-13 07:48:04.000000000 +0000 +++ openjdk-17-17.0.18+8/test/jdk/tools/jpackage/share/jdk/jpackage/tests/ModulePathTest2.java 1970-01-01 00:00:00.000000000 +0000 @@ -1,76 +0,0 @@ -/* - * Copyright (c) 2019, 2020, Oracle and/or its affiliates. All rights reserved. - * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. - * - * This code is free software; you can redistribute it and/or modify it - * under the terms of the GNU General Public License version 2 only, as - * published by the Free Software Foundation. - * - * This code is distributed in the hope that it will be useful, but WITHOUT - * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or - * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License - * version 2 for more details (a copy is included in the LICENSE file that - * accompanied this code). - * - * You should have received a copy of the GNU General Public License version - * 2 along with this work; if not, write to the Free Software Foundation, - * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. - * - * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA - * or visit www.oracle.com if you need additional information or have any - * questions. - */ - -package jdk.jpackage.tests; - -import java.io.IOException; -import java.nio.file.Path; -import jdk.jpackage.test.HelloApp; -import jdk.jpackage.test.JavaAppDesc; -import jdk.jpackage.test.Annotations.Test; -import jdk.jpackage.test.Annotations.Parameter; -import jdk.jpackage.test.JPackageCommand; -import jdk.jpackage.test.TKit; - - -/* - * @test - * @summary jpackage with --module-path testing - * @library ../../../../helpers - * @build jdk.jpackage.test.* - * @modules jdk.jpackage/jdk.jpackage.internal - * @compile ModulePathTest2.java - * @run main/othervm/timeout=360 -Xmx512m jdk.jpackage.test.Main - * --jpt-run=jdk.jpackage.tests.ModulePathTest2 - */ - -public final class ModulePathTest2 { - - /** - * Test case for JDK-8233265. - * Adding modules in .jmod files for non-modular app results in unexpected - * jpackage failure. - * @param mainAppDesc - */ - @Test - @Parameter("Hello!") - @Parameter("com.foo/com.foo.ModuleApp") - public void test8233265(String mainAppDesc) throws IOException { - JPackageCommand cmd = JPackageCommand.helloAppImage(mainAppDesc); - - // The test should make jpackage invoke jlink. - cmd.ignoreDefaultRuntime(true); - - Path modulePath = cmd.getArgumentValue("--module-path", () -> null, Path::of); - if (modulePath == null) { - modulePath = TKit.createTempDirectory("input-modules"); - cmd.addArguments("--module-path", modulePath); - } - - JavaAppDesc extraModule = JavaAppDesc.parse("x.jmod:com.x/com.x.Y"); - HelloApp.createBundle(extraModule, modulePath); - cmd.addArguments("--add-modules", extraModule.moduleName()); - - cmd.executeAndAssertHelloAppImageCreated(); - } -} diff -Nru openjdk-17-17.0.17+10/test/jdk/tools/jpackage/share/jdk/jpackage/tests/ModulePathTest3.java openjdk-17-17.0.18+8/test/jdk/tools/jpackage/share/jdk/jpackage/tests/ModulePathTest3.java --- openjdk-17-17.0.17+10/test/jdk/tools/jpackage/share/jdk/jpackage/tests/ModulePathTest3.java 2025-10-13 07:48:04.000000000 +0000 +++ openjdk-17-17.0.18+8/test/jdk/tools/jpackage/share/jdk/jpackage/tests/ModulePathTest3.java 1970-01-01 00:00:00.000000000 +0000 @@ -1,140 +0,0 @@ -/* - * Copyright (c) 2020, Oracle and/or its affiliates. All rights reserved. - * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. - * - * This code is free software; you can redistribute it and/or modify it - * under the terms of the GNU General Public License version 2 only, as - * published by the Free Software Foundation. - * - * This code is distributed in the hope that it will be useful, but WITHOUT - * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or - * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License - * version 2 for more details (a copy is included in the LICENSE file that - * accompanied this code). - * - * You should have received a copy of the GNU General Public License version - * 2 along with this work; if not, write to the Free Software Foundation, - * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. - * - * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA - * or visit www.oracle.com if you need additional information or have any - * questions. - */ - -package jdk.jpackage.tests; - -import java.io.IOException; -import java.nio.file.Files; -import java.nio.file.Path; -import java.util.ArrayList; -import java.util.Collection; -import java.util.List; -import javax.xml.xpath.XPathExpressionException; -import javax.xml.xpath.XPathConstants; -import javax.xml.xpath.XPathFactory; -import jdk.jpackage.internal.AppImageFile; -import jdk.jpackage.test.HelloApp; -import jdk.jpackage.test.JavaAppDesc; -import jdk.jpackage.test.Annotations.Test; -import jdk.jpackage.test.Annotations.Parameter; -import jdk.jpackage.test.Annotations.Parameters; -import jdk.jpackage.test.Executor; -import jdk.jpackage.test.JPackageCommand; -import jdk.jpackage.test.JavaTool; -import jdk.jpackage.test.PackageType; -import jdk.jpackage.test.TKit; -import org.w3c.dom.Document; - - -/* - * @test - * @summary jpackage for app's module linked in external runtime - * @library ../../../../helpers - * @build jdk.jpackage.test.* - * @modules jdk.jpackage/jdk.jpackage.internal - * @compile ModulePathTest3.java - * @run main/othervm/timeout=360 -Xmx512m jdk.jpackage.test.Main - * --jpt-run=jdk.jpackage.tests.ModulePathTest3 - */ - -public final class ModulePathTest3 { - - public ModulePathTest3(String jlinkOutputSubdir, String runtimeSubdir) { - this.jlinkOutputSubdir = Path.of(jlinkOutputSubdir); - this.runtimeSubdir = Path.of(runtimeSubdir); - } - - /** - * Test case for JDK-8248254. - * App's module in runtime directory. - */ - @Test - public void test8248254() throws XPathExpressionException, IOException { - testIt("me.mymodule/me.mymodule.Main"); - } - - private void testIt(String mainAppDesc) throws XPathExpressionException, - IOException { - final JavaAppDesc appDesc = JavaAppDesc.parse(mainAppDesc); - final Path moduleOutputDir = TKit.createTempDirectory("modules"); - HelloApp.createBundle(appDesc, moduleOutputDir); - - final Path workDir = TKit.createTempDirectory("runtime").resolve("data"); - final Path jlinkOutputDir = workDir.resolve(jlinkOutputSubdir); - Files.createDirectories(jlinkOutputDir.getParent()); - - new Executor() - .setToolProvider(JavaTool.JLINK) - .dumpOutput() - .addArguments( - "--add-modules", appDesc.moduleName(), - "--output", jlinkOutputDir.toString(), - "--module-path", moduleOutputDir.resolve(appDesc.jarFileName()).toString(), - "--strip-debug", - "--no-header-files", - "--no-man-pages", - "--strip-native-commands") - .execute(); - - JPackageCommand cmd = new JPackageCommand() - .setDefaultAppName() - .setPackageType(PackageType.IMAGE) - .setDefaultInputOutput() - .removeArgumentWithValue("--input") - .addArguments("--module", appDesc.moduleName() + "/" + appDesc.className()) - .setArgumentValue("--runtime-image", workDir.resolve(runtimeSubdir)); - - cmd.executeAndAssertHelloAppImageCreated(); - - if (appDesc.moduleVersion() != null) { - Document xml = AppImageFile.readXml(cmd.outputBundle()); - String actualVersion = XPathFactory.newInstance().newXPath().evaluate( - "/jpackage-state/app-version/text()", xml, - XPathConstants.STRING).toString(); - - TKit.assertEquals(appDesc.moduleVersion(), actualVersion, - "Check application version"); - } - } - - @Parameters - public static Collection data() { - final List paths = new ArrayList<>(); - paths.add(new String[] { "", "" }); - if (TKit.isOSX()) { - // On OSX jpackage should accept both runtime root and runtime home - // directories. - paths.add(new String[] { "Contents/Home", "" }); - } - - List data = new ArrayList<>(); - for (var pathCfg : paths) { - data.add(new Object[] { pathCfg[0], pathCfg[1] }); - } - - return data; - } - - private final Path jlinkOutputSubdir; - private final Path runtimeSubdir; -} diff -Nru openjdk-17-17.0.17+10/test/jdk/tools/jpackage/share/jdk/jpackage/tests/MultipleJarAppTest.java openjdk-17-17.0.18+8/test/jdk/tools/jpackage/share/jdk/jpackage/tests/MultipleJarAppTest.java --- openjdk-17-17.0.17+10/test/jdk/tools/jpackage/share/jdk/jpackage/tests/MultipleJarAppTest.java 2025-10-13 07:48:04.000000000 +0000 +++ openjdk-17-17.0.18+8/test/jdk/tools/jpackage/share/jdk/jpackage/tests/MultipleJarAppTest.java 1970-01-01 00:00:00.000000000 +0000 @@ -1,57 +0,0 @@ -/* - * Copyright (c) 2019, Oracle and/or its affiliates. All rights reserved. - * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. - * - * This code is free software; you can redistribute it and/or modify it - * under the terms of the GNU General Public License version 2 only, as - * published by the Free Software Foundation. - * - * This code is distributed in the hope that it will be useful, but WITHOUT - * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or - * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License - * version 2 for more details (a copy is included in the LICENSE file that - * accompanied this code). - * - * You should have received a copy of the GNU General Public License version - * 2 along with this work; if not, write to the Free Software Foundation, - * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. - * - * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA - * or visit www.oracle.com if you need additional information or have any - * questions. - */ - -package jdk.jpackage.tests; - -import java.nio.file.Path; -import jdk.jpackage.test.Annotations.Test; -import jdk.jpackage.test.Annotations.Parameter; -import jdk.jpackage.test.HelloApp; -import jdk.jpackage.test.JavaAppDesc; -import jdk.jpackage.test.JPackageCommand; - -/* - * @test - * @summary jpackage application packed in multiple jars - * @library ../../../../helpers - * @build jdk.jpackage.test.* - * @modules jdk.jpackage/jdk.jpackage.internal - * @compile MultipleJarAppTest.java - * @run main/othervm/timeout=360 -Xmx512m jdk.jpackage.test.Main - * --jpt-run=jdk.jpackage.tests.MultipleJarAppTest - */ - -public final class MultipleJarAppTest { - - @Test - @Parameter("B") - @Parameter("C") - public void test(String mainClass) { - JPackageCommand cmd = JPackageCommand.helloAppImage("a.jar:A"); - HelloApp.createBundle(JavaAppDesc.parse("b.jar:B"), cmd.inputDir()); - HelloApp.createBundle(JavaAppDesc.parse("c.jar:C"), cmd.inputDir()); - - cmd.setArgumentValue("--main-class", mainClass); - cmd.executeAndAssertHelloAppImageCreated(); - } -} diff -Nru openjdk-17-17.0.17+10/test/jdk/tools/jpackage/share/jdk/jpackage/tests/NoMPathRuntimeTest.java openjdk-17-17.0.18+8/test/jdk/tools/jpackage/share/jdk/jpackage/tests/NoMPathRuntimeTest.java --- openjdk-17-17.0.17+10/test/jdk/tools/jpackage/share/jdk/jpackage/tests/NoMPathRuntimeTest.java 2025-10-13 07:48:04.000000000 +0000 +++ openjdk-17-17.0.18+8/test/jdk/tools/jpackage/share/jdk/jpackage/tests/NoMPathRuntimeTest.java 1970-01-01 00:00:00.000000000 +0000 @@ -1,136 +0,0 @@ -/* - * Copyright (c) 2020, 2021, Oracle and/or its affiliates. All rights reserved. - * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. - * - * This code is free software; you can redistribute it and/or modify it - * under the terms of the GNU General Public License version 2 only, as - * published by the Free Software Foundation. - * - * This code is distributed in the hope that it will be useful, but WITHOUT - * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or - * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License - * version 2 for more details (a copy is included in the LICENSE file that - * accompanied this code). - * - * You should have received a copy of the GNU General Public License version - * 2 along with this work; if not, write to the Free Software Foundation, - * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. - * - * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA - * or visit www.oracle.com if you need additional information or have any - * questions. - */ - -package jdk.jpackage.tests; - -import java.io.IOException; -import java.nio.file.Files; -import java.util.Collection; -import java.util.ArrayList; -import java.util.List; -import java.util.stream.Stream; -import java.nio.file.Path; -import jdk.jpackage.test.Annotations.Parameters; -import jdk.jpackage.test.Annotations.Test; -import jdk.jpackage.test.Executor; -import jdk.jpackage.test.JPackageCommand; -import jdk.jpackage.test.JavaAppDesc; -import jdk.jpackage.test.JavaTool; -import jdk.jpackage.test.TKit; -import jdk.jpackage.test.HelloApp; - - -/* - * @test - * @summary test '--runtime-image' option of jpackage - * @library ../../../../helpers - * @build jdk.jpackage.test.* - * @modules jdk.jpackage/jdk.jpackage.internal - * @compile NoMPathRuntimeTest.java - * @run main/othervm/timeout=360 -Xmx512m jdk.jpackage.test.Main - * --jpt-run=jdk.jpackage.tests.NoMPathRuntimeTest - */ - -public final class NoMPathRuntimeTest { - - public NoMPathRuntimeTest(String jlinkOutputSubdir, String runtimeSubdir) { - this.jlinkOutputSubdir = Path.of(jlinkOutputSubdir); - this.runtimeSubdir = Path.of(runtimeSubdir); - } - - @Test - public void test() throws IOException { - JavaAppDesc appDesc = JavaAppDesc.parse("com.foo/com.foo.main.Aloha"); - - JPackageCommand cmd = JPackageCommand.helloAppImage(appDesc); - - // Build module jar. - cmd.executePrerequisiteActions(); - - final Path workDir = TKit.createTempDirectory("runtime").resolve("data"); - final Path jlinkOutputDir = workDir.resolve(jlinkOutputSubdir); - Files.createDirectories(jlinkOutputDir.getParent()); - - // List of modules required for test app. - final var modules = new String[] { - "java.base", - "java.desktop" - }; - - Executor jlink = new Executor() - .setToolProvider(JavaTool.JLINK) - .dumpOutput() - .addArguments( - "--add-modules", String.join(",", modules), - "--output", jlinkOutputDir.toString(), - "--strip-debug", - "--no-header-files", - "--no-man-pages"); - - jlink.addArguments("--add-modules", appDesc.moduleName(), - "--module-path", Path.of(cmd.getArgumentValue("--module-path")) - .resolve("hello.jar").toString()); - - jlink.execute(); - - // non-modular jar in current dir caused error whe no module-path given - cmd.removeArgumentWithValue("--module-path"); - - cmd.setArgumentValue("--runtime-image", workDir.resolve(runtimeSubdir)); - Path junkJar = null; - try { - // create a non-modular jar in the current directory - junkJar = HelloApp.createBundle( - JavaAppDesc.parse("junk.jar:Hello"), Path.of(".")); - - cmd.executeAndAssertHelloAppImageCreated(); - } finally { - if (junkJar != null) { - TKit.deleteIfExists(junkJar); - } - } - - } - - @Parameters - public static Collection data() { - - final List paths = new ArrayList<>(); - paths.add(new String[] { "", "" }); - if (TKit.isOSX()) { - // On OSX jpackage should accept both runtime root and runtime home - // directories. - paths.add(new String[] { "Contents/Home", "" }); - } - - List data = new ArrayList<>(); - for (var pathCfg : paths) { - data.add(new Object[] { pathCfg[0], pathCfg[1] }); - } - - return data; - } - - private final Path jlinkOutputSubdir; - private final Path runtimeSubdir; -} diff -Nru openjdk-17-17.0.17+10/test/jdk/tools/jpackage/share/jdk/jpackage/tests/NonExistentTest.java openjdk-17-17.0.18+8/test/jdk/tools/jpackage/share/jdk/jpackage/tests/NonExistentTest.java --- openjdk-17-17.0.17+10/test/jdk/tools/jpackage/share/jdk/jpackage/tests/NonExistentTest.java 2025-10-13 07:48:04.000000000 +0000 +++ openjdk-17-17.0.18+8/test/jdk/tools/jpackage/share/jdk/jpackage/tests/NonExistentTest.java 1970-01-01 00:00:00.000000000 +0000 @@ -1,93 +0,0 @@ -/* - * Copyright (c) 2020, Oracle and/or its affiliates. All rights reserved. - * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. - * - * This code is free software; you can redistribute it and/or modify it - * under the terms of the GNU General Public License version 2 only, as - * published by the Free Software Foundation. - * - * This code is distributed in the hope that it will be useful, but WITHOUT - * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or - * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License - * version 2 for more details (a copy is included in the LICENSE file that - * accompanied this code). - * - * You should have received a copy of the GNU General Public License version - * 2 along with this work; if not, write to the Free Software Foundation, - * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. - * - * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA - * or visit www.oracle.com if you need additional information or have any - * questions. - */ - -package jdk.jpackage.tests; - -import java.util.Collection; -import java.util.List; -import jdk.jpackage.test.Annotations.Parameters; -import jdk.jpackage.test.Annotations.Test; -import jdk.jpackage.test.JPackageCommand; -import jdk.jpackage.test.TKit; - -/* - * @test - * @summary jpackage application version testing - * @library ../../../../helpers - * @build jdk.jpackage.test.* - * @modules jdk.jpackage/jdk.jpackage.internal - * @compile NonExistentTest.java - * @run main/othervm/timeout=360 -Xmx512m jdk.jpackage.test.Main - * --jpt-run=jdk.jpackage.tests.NonExistentTest - */ - -public final class NonExistentTest { - - private final String expectedError; - private final JPackageCommand cmd; - - @Parameters - public static Collection input() { - return List.of(new Object[][]{ - // non-existent icon - {"Hello", - new String[]{"--icon", "non-existent"}, - "Error:"}, - {"com.other/com.other.Hello", - new String[]{"--icon", "non-existent"}, - "Error:"}, - // non-existent input - {"Hello", - new String[]{"--input", "non-existent"}, - "Exception:"}, - {"com.other/com.other.Hello", - new String[]{"--input", "non-existent"}, - "Exception:"}, - // non-existent resource-dir - {"Hello", - new String[]{"--resource-dir", "non-existent"}, - "Specified resource directory"}, - {"com.other/com.other.Hello", - new String[]{"--resource-dir", "non-existent"}, - "Specified resource directory"}, - }); - } - - public NonExistentTest(String javaAppDesc, String[] jpackageArgs, - String expectedError) { - this.expectedError = expectedError; - - cmd = JPackageCommand.helloAppImage(javaAppDesc) - .saveConsoleOutput(true).dumpOutput(true); - if (jpackageArgs != null) { - cmd.addArguments(jpackageArgs); - } - } - - @Test - public void test() { - List output = cmd.execute(1).getOutput(); - TKit.assertNotNull(output, "output is null"); - TKit.assertTextStream(expectedError).apply(output.stream()); - } -} diff -Nru openjdk-17-17.0.17+10/test/jdk/tools/jpackage/share/jdk/jpackage/tests/UnicodeArgsTest.java openjdk-17-17.0.18+8/test/jdk/tools/jpackage/share/jdk/jpackage/tests/UnicodeArgsTest.java --- openjdk-17-17.0.17+10/test/jdk/tools/jpackage/share/jdk/jpackage/tests/UnicodeArgsTest.java 2025-10-13 07:48:04.000000000 +0000 +++ openjdk-17-17.0.18+8/test/jdk/tools/jpackage/share/jdk/jpackage/tests/UnicodeArgsTest.java 1970-01-01 00:00:00.000000000 +0000 @@ -1,82 +0,0 @@ -/* - * Copyright (c) 2020, 2022, Oracle and/or its affiliates. All rights reserved. - * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. - * - * This code is free software; you can redistribute it and/or modify it - * under the terms of the GNU General Public License version 2 only, as - * published by the Free Software Foundation. - * - * This code is distributed in the hope that it will be useful, but WITHOUT - * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or - * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License - * version 2 for more details (a copy is included in the LICENSE file that - * accompanied this code). - * - * You should have received a copy of the GNU General Public License version - * 2 along with this work; if not, write to the Free Software Foundation, - * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. - * - * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA - * or visit www.oracle.com if you need additional information or have any - * questions. - */ - -package jdk.jpackage.tests; - -import java.util.stream.Collectors; -import jdk.jpackage.test.TKit; -import jdk.jpackage.test.Annotations.Test; -import jdk.jpackage.test.Annotations.Parameter; -import jdk.jpackage.test.HelloApp; -import jdk.jpackage.test.JPackageCommand; - -/* - * @test - * @summary test how app launcher handles unicode command line arguments - * @library ../../../../helpers - * @build jdk.jpackage.test.* - * @modules jdk.jpackage/jdk.jpackage.internal - * @compile UnicodeArgsTest.java - * @requires (os.family == "windows") - * @run main/othervm/timeout=720 -Xmx512m jdk.jpackage.test.Main - * --jpt-run=jdk.jpackage.tests.UnicodeArgsTest - */ - -public final class UnicodeArgsTest { - - @Parameter("true") - @Parameter("false") - @Test - public void test8246042(boolean onCommandLine) { - final String testString; - - String encoding = System.getProperty("native.encoding"); - switch (encoding) { - default: - testString = new String(Character.toChars(0x00E9)); - break; - - case "MS932": - case "SJIS": - testString = new String(Character.toChars(0x3042)); - break; - } - - TKit.trace(String.format("Test string code points: %s", testString - .codePoints() - .mapToObj(codePoint -> String.format("0x%04x", codePoint)) - .collect(Collectors.joining(",", "[", "]")))); - - JPackageCommand cmd = JPackageCommand.helloAppImage().useToolProvider(true); - if (!onCommandLine) { - cmd.addArguments("--arguments", testString); - } - cmd.executeAndAssertImageCreated(); - - if (onCommandLine) { - HelloApp.executeLauncherAndVerifyOutput(cmd, testString); - } else { - HelloApp.executeLauncherAndVerifyOutput(cmd); - } - } -} diff -Nru openjdk-17-17.0.17+10/test/jdk/tools/jpackage/share/jdk/jpackage/tests/VendorTest.java openjdk-17-17.0.18+8/test/jdk/tools/jpackage/share/jdk/jpackage/tests/VendorTest.java --- openjdk-17-17.0.17+10/test/jdk/tools/jpackage/share/jdk/jpackage/tests/VendorTest.java 2025-10-13 07:48:04.000000000 +0000 +++ openjdk-17-17.0.18+8/test/jdk/tools/jpackage/share/jdk/jpackage/tests/VendorTest.java 1970-01-01 00:00:00.000000000 +0000 @@ -1,107 +0,0 @@ -/* - * Copyright (c) 2020, Oracle and/or its affiliates. All rights reserved. - * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. - * - * This code is free software; you can redistribute it and/or modify it - * under the terms of the GNU General Public License version 2 only, as - * published by the Free Software Foundation. - * - * This code is distributed in the hope that it will be useful, but WITHOUT - * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or - * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License - * version 2 for more details (a copy is included in the LICENSE file that - * accompanied this code). - * - * You should have received a copy of the GNU General Public License version - * 2 along with this work; if not, write to the Free Software Foundation, - * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. - * - * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA - * or visit www.oracle.com if you need additional information or have any - * questions. - */ - -package jdk.jpackage.tests; - -import jdk.jpackage.test.PackageTest; -import jdk.jpackage.test.PackageType; -import jdk.jpackage.test.Annotations.Test; - -/** - * Test --vendor parameter. Output of the test should be - * vendortest*.* package bundle. The output package should provide the - * same functionality as the default package with the default value of vendor - * property overridden. - * - * Linux DEB: - * - * Value of "Maintainer" property of .deb package should start with "Test Vendor" string. - * - * Linux RPM: - * - * Value of "Vendor" property of .rpm package should be set to "Test Vendor" string. - * - * Mac: - * - * --vendor parameter is ignored. - * - * Windows: - * - * Publisher value displayed in the Add/Remove Programs should be set - * to "Test Vendor" string. - */ - -/* - * @test - * @summary Test --vendor jpackage command option - * @library ../../../../helpers - * @key jpackagePlatformPackage - * @requires (os.family == "windows") - * @requires jpackage.test.SQETest != null - * @build jdk.jpackage.test.* - * @modules jdk.jpackage/jdk.jpackage.internal - * @compile VendorTest.java - * @run main/othervm/timeout=360 -Xmx512m jdk.jpackage.test.Main - * --jpt-run=jdk.jpackage.tests.VendorTest - */ - -/* - * @test - * @summary Test --vendor jpackage command option - * @library ../../../../helpers - * @key jpackagePlatformPackage - * @requires (os.family != "mac") - * @requires jpackage.test.SQETest == null - * @build jdk.jpackage.test.* - * @modules jdk.jpackage/jdk.jpackage.internal - * @compile VendorTest.java - * @run main/othervm/timeout=360 -Xmx512m jdk.jpackage.test.Main - * --jpt-run=jdk.jpackage.tests.VendorTest - */ -public class VendorTest { - - @Test - public static void test() { - final String vendorValue = "Test Vendor"; - - new PackageTest() - .configureHelloApp() - .addBundleDesktopIntegrationVerifier(false) - .addInitializer(cmd -> { - cmd.addArguments("--vendor", vendorValue); - }) - .forTypes(PackageType.LINUX_DEB) - .addBundlePropertyVerifier("Maintainer", value -> { - return value.startsWith(vendorValue + " "); - }, "starts with") - .forTypes(PackageType.LINUX_RPM) - .addBundlePropertyVerifier("Vendor", value -> { - return value.equals(vendorValue); - }, "equals to") - .forTypes(PackageType.WIN_MSI) - .addBundlePropertyVerifier("Manufacturer", value -> { - return value.equals(vendorValue); - }, "equals to") - .run(); - } -} diff -Nru openjdk-17-17.0.17+10/test/jdk/tools/jpackage/windows/Win8282351Test.java openjdk-17-17.0.18+8/test/jdk/tools/jpackage/windows/Win8282351Test.java --- openjdk-17-17.0.17+10/test/jdk/tools/jpackage/windows/Win8282351Test.java 2025-10-13 07:48:04.000000000 +0000 +++ openjdk-17-17.0.18+8/test/jdk/tools/jpackage/windows/Win8282351Test.java 2026-01-15 15:23:06.000000000 +0000 @@ -1,5 +1,5 @@ /* - * Copyright (c) 2022, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2022, 2024, Oracle and/or its affiliates. All rights reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * * This code is free software; you can redistribute it and/or modify it @@ -39,11 +39,10 @@ /* * @test * @summary Test case for JDK-8248254 - * @library ../helpers + * @library /test/jdk/tools/jpackage/helpers * @build jdk.jpackage.test.* * @build Win8282351Test * @requires (os.family == "windows") - * @modules jdk.jpackage/jdk.jpackage.internal * @run main/othervm/timeout=360 -Xmx512m jdk.jpackage.test.Main * --jpt-run=Win8282351Test */ diff -Nru openjdk-17-17.0.17+10/test/jdk/tools/jpackage/windows/Win8301247Test.java openjdk-17-17.0.18+8/test/jdk/tools/jpackage/windows/Win8301247Test.java --- openjdk-17-17.0.17+10/test/jdk/tools/jpackage/windows/Win8301247Test.java 2025-10-13 07:48:04.000000000 +0000 +++ openjdk-17-17.0.18+8/test/jdk/tools/jpackage/windows/Win8301247Test.java 2026-01-15 15:23:06.000000000 +0000 @@ -45,11 +45,10 @@ /* * @test * @summary Test case for JDK-8301247 - * @library ../helpers + * @library /test/jdk/tools/jpackage/helpers * @build jdk.jpackage.test.* * @build Win8301247Test * @requires (os.family == "windows") - * @modules jdk.jpackage/jdk.jpackage.internal * @run main/othervm/timeout=360 -Xmx512m jdk.jpackage.test.Main * --jpt-run=Win8301247Test */ @@ -106,7 +105,7 @@ + cmd.appLauncherPath().getFileName().toString() + "'\\\" | select ProcessID,ParentProcessID"; List output = Executor.of("powershell", "-NoLogo", "-NoProfile", "-NonInteractive", "-Command", command) - .dumpOutput(true).saveOutput().executeAndGetOutput(); + .dumpOutput(true).saveOutput().setWinRunWithEnglishOutput(true).executeAndGetOutput(); if (expectedCount == 0) { if (output.size() < 1) { diff -Nru openjdk-17-17.0.17+10/test/jdk/tools/jpackage/windows/Win8365790Test.java openjdk-17-17.0.18+8/test/jdk/tools/jpackage/windows/Win8365790Test.java --- openjdk-17-17.0.17+10/test/jdk/tools/jpackage/windows/Win8365790Test.java 1970-01-01 00:00:00.000000000 +0000 +++ openjdk-17-17.0.18+8/test/jdk/tools/jpackage/windows/Win8365790Test.java 2026-01-15 15:23:06.000000000 +0000 @@ -0,0 +1,130 @@ +/* + * 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. + */ + +import static jdk.jpackage.test.HelloApp.configureAndExecute; + +import java.io.IOException; +import java.nio.file.Files; +import java.nio.file.Path; +import java.time.Duration; +import jdk.jpackage.test.AdditionalLauncher; +import jdk.jpackage.test.Annotations.Test; +import jdk.jpackage.test.CfgFile; +import jdk.jpackage.test.Executor; +import jdk.jpackage.test.JPackageCommand; +import jdk.jpackage.test.TKit; + +/** + * Test the child process has a chance to handle Ctrl+C signal. + */ + +/* + * @test + * @summary Test case for JDK-8365790 + * @library /test/jdk/tools/jpackage/helpers + * @build jdk.jpackage.test.* + * @build Win8365790Test + * @requires (os.family == "windows") + * @run main/othervm/timeout=100 -Xmx512m jdk.jpackage.test.Main + * --jpt-run=Win8365790Test + */ +public class Win8365790Test { + + @Test + public void test() throws InterruptedException, IOException { + + var outputDir = TKit.createTempDirectory("response-dir"); + + var mainOutputFile = outputDir.resolve("output.txt"); + var mainTraceFile = outputDir.resolve("trace.txt"); + + var probeOutputFile = outputDir.resolve("probe-output.txt"); + var probeTraceFile = outputDir.resolve("probe-trace.txt"); + + var cmd = JPackageCommand + .helloAppImage(TEST_APP_JAVA + "*UseShutdownHook") + .ignoreFakeRuntime() + .addArguments("--java-options", "-Djpackage.test.trace-file=" + mainTraceFile.toString()) + .addArguments("--arguments", mainOutputFile.toString()) + .addArguments("--arguments", Long.toString(Duration.ofSeconds(TETS_APP_AUTOCLOSE_TIMEOUT_SECONDS).getSeconds())); + + new AdditionalLauncher("probe") { + @Override + protected void verify(JPackageCommand cmd) { + } + }.addJavaOptions("-Djpackage.test.trace-file=" + probeTraceFile.toString()) + .addDefaultArguments(probeOutputFile.toString(), Long.toString(Duration.ofSeconds(TETS_APP_AUTOCLOSE_TIMEOUT_SECONDS).getSeconds())) + .applyTo(cmd); + + cmd.executeAndAssertImageCreated(); + + cmd.readLauncherCfgFile("probe") + .add(new CfgFile().addValue("Application", "win.norestart", Boolean.TRUE.toString())) + .save(cmd.appLauncherCfgPath("probe")); + + // Try Ctrl+C signal on a launcher with disabled restart functionality. + // It will create a single launcher process instead of the parent and the child processes. + // Ctrl+C always worked for launcher with disabled restart functionality. + var probeOutput = runLauncher(cmd, "probe", probeTraceFile, probeOutputFile); + + if (!probeOutput.equals("shutdown hook executed")) { + // Ctrl+C signal didn't make it. Test environment doesn't support Ctrl+C signal + // delivery from the prowershell process to a child process, don't run the main + // test. + TKit.throwSkippedException( + "The environment does NOT support Ctrl+C signal delivery from the prowershell process to a child process"); + } + + var mainOutput = runLauncher(cmd, null, mainTraceFile, mainOutputFile); + + TKit.assertEquals("shutdown hook executed", mainOutput, "Check shutdown hook executed"); + } + + private static String runLauncher(JPackageCommand cmd, String launcherName, Path traceFile, Path outputFile) throws IOException { + // Launch the specified launcher and send Ctrl+C signal to it. + Thread t = new Thread (() -> { + configureAndExecute(0, Executor.of("powershell", "-NonInteractive", "-NoLogo", "-NoProfile", "-ExecutionPolicy", "Unrestricted") + .addArgument("-File").addArgument(TEST_PS1) + .addArguments("-TimeoutSeconds", Long.toString(Duration.ofSeconds(5).getSeconds())) + .addArgument("-Executable").addArgument(cmd.appLauncherPath(launcherName)) + .dumpOutput()); + }); + t.start(); + + TKit.waitForFileCreated(traceFile, Duration.ofSeconds(20), Duration.ofSeconds(2)); + + try { + TKit.waitForFileCreated(outputFile, Duration.ofSeconds(TETS_APP_AUTOCLOSE_TIMEOUT_SECONDS * 2), Duration.ofSeconds(2)); + } finally { + TKit.traceFileContents(traceFile, "Test app trace"); + } + + TKit.assertFileExists(outputFile); + return Files.readString(outputFile); + } + + private static final long TETS_APP_AUTOCLOSE_TIMEOUT_SECONDS = 30; + + private static final Path TEST_APP_JAVA = TKit.TEST_SRC_ROOT.resolve("apps/UseShutdownHook.java"); + private static final Path TEST_PS1 = TKit.TEST_SRC_ROOT.resolve(Path.of("resources/Win8365790Test.ps1")).normalize(); +} diff -Nru openjdk-17-17.0.17+10/test/jdk/tools/jpackage/windows/WinChildProcessTest.java openjdk-17-17.0.18+8/test/jdk/tools/jpackage/windows/WinChildProcessTest.java --- openjdk-17-17.0.17+10/test/jdk/tools/jpackage/windows/WinChildProcessTest.java 2025-10-13 07:48:04.000000000 +0000 +++ openjdk-17-17.0.18+8/test/jdk/tools/jpackage/windows/WinChildProcessTest.java 2026-01-15 15:23:06.000000000 +0000 @@ -1,5 +1,5 @@ /* - * Copyright (c) 2024, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2024, 2025, Oracle and/or its affiliates. All rights reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * * This code is free software; you can redistribute it and/or modify it @@ -25,13 +25,10 @@ * @bug 8325203 * @summary Test that Jpackage windows executable application kills the launched 3rd party application * when System.exit(0) is invoked along with terminating java program. - * @library ../helpers - * @library /test/lib + * @library /test/jdk/tools/jpackage/helpers * @requires os.family == "windows" - * @build WinChildProcessTest * @build jdk.jpackage.test.* * @build WinChildProcessTest - * @modules jdk.jpackage/jdk.jpackage.internal * @run main/othervm -Xmx512m jdk.jpackage.test.Main * --jpt-run=WinChildProcessTest * @@ -43,29 +40,32 @@ import java.nio.file.Path; import jdk.jpackage.test.JPackageCommand; +import static jdk.jpackage.test.HelloApp.configureAndExecute; import jdk.jpackage.test.Annotations.Test; import jdk.jpackage.test.Executor; import jdk.jpackage.test.TKit; +import static jdk.jpackage.test.WindowsHelper.killProcess; public class WinChildProcessTest { private static final Path TEST_APP_JAVA = TKit.TEST_SRC_ROOT .resolve("apps/ChildProcessAppLauncher.java"); @Test - public static void test() throws Throwable { + public static void test() { long childPid = 0; try { JPackageCommand cmd = JPackageCommand - .helloAppImage(TEST_APP_JAVA + "*Hello"); + .helloAppImage(TEST_APP_JAVA + "*Hello") + .ignoreFakeRuntime(); // Create the image of the third party application launcher cmd.executeAndAssertImageCreated(); // Start the third party application launcher and dump and save the // output of the application - List output = new Executor().saveOutput().dumpOutput() - .setExecutable(cmd.appLauncherPath().toAbsolutePath()) - .execute(0).getOutput(); + List output = configureAndExecute(0, new Executor().saveOutput().dumpOutput() + .setExecutable(cmd.appLauncherPath().toAbsolutePath())) + .getOutput(); String pidStr = output.get(0); // parse child PID @@ -78,10 +78,12 @@ Optional processHandle = ProcessHandle.of(childPid); boolean isAlive = processHandle.isPresent() && processHandle.get().isAlive(); - TKit.assertTrue(isAlive, "Check is child process is alive"); + TKit.assertTrue(isAlive, "Check child process is alive"); } finally { - // Kill only a specific child instance - Runtime.getRuntime().exec("taskkill /F /PID " + childPid); + if (childPid != 0) { + // Kill only a specific child instance + killProcess(childPid); + } } } } diff -Nru openjdk-17-17.0.17+10/test/jdk/tools/jpackage/windows/WinConsoleTest.java openjdk-17-17.0.18+8/test/jdk/tools/jpackage/windows/WinConsoleTest.java --- openjdk-17-17.0.17+10/test/jdk/tools/jpackage/windows/WinConsoleTest.java 2025-10-13 07:48:04.000000000 +0000 +++ openjdk-17-17.0.18+8/test/jdk/tools/jpackage/windows/WinConsoleTest.java 2026-01-15 15:23:06.000000000 +0000 @@ -1,5 +1,5 @@ /* - * Copyright (c) 2018, 2019, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2018, 2024, Oracle and/or its affiliates. All rights reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * * This code is free software; you can redistribute it and/or modify it @@ -34,10 +34,9 @@ /* * @test * @summary jpackage with --win-console - * @library ../helpers + * @library /test/jdk/tools/jpackage/helpers * @build jdk.jpackage.test.* * @requires (os.family == "windows") - * @modules jdk.jpackage/jdk.jpackage.internal * @compile WinConsoleTest.java * * @run main/othervm/timeout=360 -Xmx512m jdk.jpackage.test.Main diff -Nru openjdk-17-17.0.17+10/test/jdk/tools/jpackage/windows/WinDirChooserTest.java openjdk-17-17.0.18+8/test/jdk/tools/jpackage/windows/WinDirChooserTest.java --- openjdk-17-17.0.17+10/test/jdk/tools/jpackage/windows/WinDirChooserTest.java 2025-10-13 07:48:04.000000000 +0000 +++ openjdk-17-17.0.18+8/test/jdk/tools/jpackage/windows/WinDirChooserTest.java 2026-01-15 15:23:06.000000000 +0000 @@ -1,5 +1,5 @@ /* - * Copyright (c) 2018, 2021, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2018, 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 @@ -36,12 +36,11 @@ /* * @test * @summary jpackage with --win-dir-chooser - * @library ../helpers + * @library /test/jdk/tools/jpackage/helpers * @key jpackagePlatformPackage * @build jdk.jpackage.test.* * @build WinDirChooserTest * @requires (os.family == "windows") - * @modules jdk.jpackage/jdk.jpackage.internal * @run main/othervm/timeout=540 -Xmx512m jdk.jpackage.test.Main * --jpt-run=WinDirChooserTest */ diff -Nru openjdk-17-17.0.17+10/test/jdk/tools/jpackage/windows/WinInstallerIconTest.java openjdk-17-17.0.18+8/test/jdk/tools/jpackage/windows/WinInstallerIconTest.java --- openjdk-17-17.0.17+10/test/jdk/tools/jpackage/windows/WinInstallerIconTest.java 2025-10-13 07:48:04.000000000 +0000 +++ openjdk-17-17.0.18+8/test/jdk/tools/jpackage/windows/WinInstallerIconTest.java 2026-01-15 15:23:06.000000000 +0000 @@ -1,5 +1,5 @@ /* - * Copyright (c) 2021, 2022, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2021, 2024, Oracle and/or its affiliates. All rights reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * * This code is free software; you can redistribute it and/or modify it @@ -38,12 +38,11 @@ /* * @test * @summary jpackage with --icon parameter for exe installer - * @library ../helpers + * @library /test/jdk/tools/jpackage/helpers * @key jpackagePlatformPackage * @build jdk.jpackage.test.* * @build WinInstallerIconTest * @requires (os.family == "windows") - * @modules jdk.jpackage/jdk.jpackage.internal * @run main/othervm/timeout=540 -Xmx512m jdk.jpackage.test.Main * --jpt-run=WinInstallerIconTest */ diff -Nru openjdk-17-17.0.17+10/test/jdk/tools/jpackage/windows/WinInstallerUiTest.java openjdk-17-17.0.18+8/test/jdk/tools/jpackage/windows/WinInstallerUiTest.java --- openjdk-17-17.0.17+10/test/jdk/tools/jpackage/windows/WinInstallerUiTest.java 2025-10-13 07:48:04.000000000 +0000 +++ openjdk-17-17.0.18+8/test/jdk/tools/jpackage/windows/WinInstallerUiTest.java 2026-01-15 15:23:06.000000000 +0000 @@ -1,5 +1,5 @@ /* - * Copyright (c) 2021, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2021, 2024, Oracle and/or its affiliates. All rights reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * * This code is free software; you can redistribute it and/or modify it @@ -39,12 +39,11 @@ /* * @test * @summary jpackage with --win-dir-chooser, --win-shortcut-prompt and --license parameters - * @library ../helpers + * @library /test/jdk/tools/jpackage/helpers * @key jpackagePlatformPackage * @build jdk.jpackage.test.* * @build WinInstallerUiTest * @requires (os.family == "windows") - * @modules jdk.jpackage/jdk.jpackage.internal * @run main/othervm/timeout=720 -Xmx512m jdk.jpackage.test.Main * --jpt-run=WinInstallerUiTest */ diff -Nru openjdk-17-17.0.17+10/test/jdk/tools/jpackage/windows/WinL10nTest.java openjdk-17-17.0.18+8/test/jdk/tools/jpackage/windows/WinL10nTest.java --- openjdk-17-17.0.17+10/test/jdk/tools/jpackage/windows/WinL10nTest.java 2025-10-13 07:48:04.000000000 +0000 +++ openjdk-17-17.0.18+8/test/jdk/tools/jpackage/windows/WinL10nTest.java 2026-01-15 15:23:06.000000000 +0000 @@ -22,6 +22,7 @@ */ import java.io.IOException; +import java.nio.file.Files; import java.nio.file.Path; import jdk.jpackage.test.TKit; import jdk.jpackage.test.PackageTest; @@ -37,14 +38,13 @@ /* * @test * @summary Custom l10n of msi installers in jpackage - * @library ../helpers + * @library /test/jdk/tools/jpackage/helpers * @key jpackagePlatformPackage * @requires (jpackage.test.SQETest == null) * @build jdk.jpackage.test.* * @requires (os.family == "windows") - * @modules jdk.jpackage/jdk.jpackage.internal * @compile WinL10nTest.java - * @run main/othervm/timeout=360 -Xmx512m jdk.jpackage.test.Main + * @run main/othervm/timeout=1440 -Xmx512m jdk.jpackage.test.Main * --jpt-run=WinL10nTest */ diff -Nru openjdk-17-17.0.17+10/test/jdk/tools/jpackage/windows/WinMenuGroupTest.java openjdk-17-17.0.18+8/test/jdk/tools/jpackage/windows/WinMenuGroupTest.java --- openjdk-17-17.0.17+10/test/jdk/tools/jpackage/windows/WinMenuGroupTest.java 2025-10-13 07:48:04.000000000 +0000 +++ openjdk-17-17.0.18+8/test/jdk/tools/jpackage/windows/WinMenuGroupTest.java 2026-01-15 15:23:06.000000000 +0000 @@ -1,5 +1,5 @@ /* - * Copyright (c) 2018, 2019, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2018, 2024, Oracle and/or its affiliates. All rights reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * * This code is free software; you can redistribute it and/or modify it @@ -39,11 +39,10 @@ /* * @test * @summary jpackage with --win-menu and --win-menu-group - * @library ../helpers + * @library /test/jdk/tools/jpackage/helpers * @key jpackagePlatformPackage * @build jdk.jpackage.test.* * @requires (os.family == "windows") - * @modules jdk.jpackage/jdk.jpackage.internal * @compile WinMenuGroupTest.java * @run main/othervm/timeout=540 -Xmx512m jdk.jpackage.test.Main * --jpt-run=WinMenuGroupTest diff -Nru openjdk-17-17.0.17+10/test/jdk/tools/jpackage/windows/WinMenuTest.java openjdk-17-17.0.18+8/test/jdk/tools/jpackage/windows/WinMenuTest.java --- openjdk-17-17.0.17+10/test/jdk/tools/jpackage/windows/WinMenuTest.java 2025-10-13 07:48:04.000000000 +0000 +++ openjdk-17-17.0.18+8/test/jdk/tools/jpackage/windows/WinMenuTest.java 2026-01-15 15:23:06.000000000 +0000 @@ -1,5 +1,5 @@ /* - * Copyright (c) 2018, 2019, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2018, 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 @@ -36,11 +36,10 @@ /* * @test * @summary jpackage with --win-menu - * @library ../helpers + * @library /test/jdk/tools/jpackage/helpers * @key jpackagePlatformPackage * @build jdk.jpackage.test.* * @requires (os.family == "windows") - * @modules jdk.jpackage/jdk.jpackage.internal * @compile WinMenuTest.java * @run main/othervm/timeout=540 -Xmx512m jdk.jpackage.test.Main * --jpt-run=WinMenuTest diff -Nru openjdk-17-17.0.17+10/test/jdk/tools/jpackage/windows/WinPerUserInstallTest.java openjdk-17-17.0.18+8/test/jdk/tools/jpackage/windows/WinPerUserInstallTest.java --- openjdk-17-17.0.17+10/test/jdk/tools/jpackage/windows/WinPerUserInstallTest.java 2025-10-13 07:48:04.000000000 +0000 +++ openjdk-17-17.0.18+8/test/jdk/tools/jpackage/windows/WinPerUserInstallTest.java 2026-01-15 15:23:06.000000000 +0000 @@ -1,5 +1,5 @@ /* - * Copyright (c) 2018, 2020, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2018, 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 @@ -37,11 +37,10 @@ /* * @test * @summary jpackage with --win-per-user-install, --win-menu, --win-menu-group - * @library ../helpers + * @library /test/jdk/tools/jpackage/helpers * @key jpackagePlatformPackage * @build jdk.jpackage.test.* * @requires (os.family == "windows") - * @modules jdk.jpackage/jdk.jpackage.internal * @compile WinPerUserInstallTest.java * @run main/othervm/timeout=540 -Xmx512m jdk.jpackage.test.Main * --jpt-run=WinPerUserInstallTest diff -Nru openjdk-17-17.0.17+10/test/jdk/tools/jpackage/windows/WinRenameTest.java openjdk-17-17.0.18+8/test/jdk/tools/jpackage/windows/WinRenameTest.java --- openjdk-17-17.0.17+10/test/jdk/tools/jpackage/windows/WinRenameTest.java 2025-10-13 07:48:04.000000000 +0000 +++ openjdk-17-17.0.18+8/test/jdk/tools/jpackage/windows/WinRenameTest.java 2026-01-15 15:23:06.000000000 +0000 @@ -1,5 +1,5 @@ /* - * Copyright (c) 2021, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2021, 2024, Oracle and/or its affiliates. All rights reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * * This code is free software; you can redistribute it and/or modify it @@ -26,19 +26,17 @@ import java.nio.file.Files; import jdk.jpackage.test.HelloApp; import jdk.jpackage.test.TKit; -import jdk.jpackage.test.Functional.ThrowingConsumer; import jdk.jpackage.test.JPackageCommand; import jdk.jpackage.test.Annotations.Test; /* * @test * @summary jpackage test app can run after changing executable's extension - * @library ../helpers + * @library /test/jdk/tools/jpackage/helpers * @key jpackagePlatformPackage * @build jdk.jpackage.test.* * @build WinRenameTest * @requires (os.family == "windows") - * @modules jdk.jpackage/jdk.jpackage.internal * @run main/othervm/timeout=360 -Xmx512m jdk.jpackage.test.Main * --jpt-run=WinRenameTest */ @@ -51,11 +49,16 @@ cmd.executeAndAssertImageCreated(); + if (!cmd.canRunLauncher("Not running the test")) { + return; + } + + HelloApp.executeLauncherAndVerifyOutput(cmd); + Path launcherPath = cmd.appLauncherPath(); - HelloApp.assertApp(launcherPath).executeAndVerifyOutput(); String lp = launcherPath.toString(); - TKit.assertTrue(lp.endsWith(".exe"), "UNexpected launcher path: " + lp); + TKit.assertTrue(lp.endsWith(".exe"), "Unexpected launcher path: " + lp); Path newLauncherPath = Path.of(lp.replaceAll(".exe", ".anything")); Files.move(launcherPath, newLauncherPath); diff -Nru openjdk-17-17.0.17+10/test/jdk/tools/jpackage/windows/WinResourceTest.java openjdk-17-17.0.18+8/test/jdk/tools/jpackage/windows/WinResourceTest.java --- openjdk-17-17.0.17+10/test/jdk/tools/jpackage/windows/WinResourceTest.java 2025-10-13 07:48:04.000000000 +0000 +++ openjdk-17-17.0.18+8/test/jdk/tools/jpackage/windows/WinResourceTest.java 2026-01-15 15:23:06.000000000 +0000 @@ -1,5 +1,5 @@ /* - * Copyright (c) 2018, 2019, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2018, 2024, Oracle and/or its affiliates. All rights reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * * This code is free software; you can redistribute it and/or modify it @@ -40,10 +40,9 @@ /* * @test * @summary jpackage with --resource-dir - * @library ../helpers + * @library /test/jdk/tools/jpackage/helpers * @build jdk.jpackage.test.* * @requires (os.family == "windows") - * @modules jdk.jpackage/jdk.jpackage.internal * @compile WinResourceTest.java * @run main/othervm/timeout=360 -Xmx512m jdk.jpackage.test.Main * --jpt-run=WinResourceTest diff -Nru openjdk-17-17.0.17+10/test/jdk/tools/jpackage/windows/WinScriptTest.java openjdk-17-17.0.18+8/test/jdk/tools/jpackage/windows/WinScriptTest.java --- openjdk-17-17.0.17+10/test/jdk/tools/jpackage/windows/WinScriptTest.java 2025-10-13 07:48:04.000000000 +0000 +++ openjdk-17-17.0.18+8/test/jdk/tools/jpackage/windows/WinScriptTest.java 2026-01-15 15:23:06.000000000 +0000 @@ -1,5 +1,5 @@ /* - * Copyright (c) 2018, 2019, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2018, 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 @@ -37,10 +37,9 @@ /* * @test usage of scripts from resource dir * @summary jpackage with - * @library ../helpers + * @library /test/jdk/tools/jpackage/helpers * @build jdk.jpackage.test.* * @requires (os.family == "windows") - * @modules jdk.jpackage/jdk.jpackage.internal * @compile WinScriptTest.java * @run main/othervm/timeout=720 -Xmx512m jdk.jpackage.test.Main * --jpt-run=WinScriptTest diff -Nru openjdk-17-17.0.17+10/test/jdk/tools/jpackage/windows/WinShortcutPromptTest.java openjdk-17-17.0.18+8/test/jdk/tools/jpackage/windows/WinShortcutPromptTest.java --- openjdk-17-17.0.17+10/test/jdk/tools/jpackage/windows/WinShortcutPromptTest.java 2025-10-13 07:48:04.000000000 +0000 +++ openjdk-17-17.0.18+8/test/jdk/tools/jpackage/windows/WinShortcutPromptTest.java 2026-01-15 15:23:06.000000000 +0000 @@ -1,5 +1,5 @@ /* - * Copyright (c) 2021, 2022, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2021, 2024, Oracle and/or its affiliates. All rights reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * * This code is free software; you can redistribute it and/or modify it @@ -37,12 +37,11 @@ /* * @test * @summary jpackage with --win-shortcut-prompt, --win-menu and --win-shortcut parameters - * @library ../helpers + * @library /test/jdk/tools/jpackage/helpers * @key jpackagePlatformPackage * @build jdk.jpackage.test.* * @build WinShortcutPromptTest * @requires (os.family == "windows") - * @modules jdk.jpackage/jdk.jpackage.internal * @run main/othervm/timeout=720 -Xmx512m jdk.jpackage.test.Main * --jpt-run=WinShortcutPromptTest */ diff -Nru openjdk-17-17.0.17+10/test/jdk/tools/jpackage/windows/WinShortcutTest.java openjdk-17-17.0.18+8/test/jdk/tools/jpackage/windows/WinShortcutTest.java --- openjdk-17-17.0.17+10/test/jdk/tools/jpackage/windows/WinShortcutTest.java 2025-10-13 07:48:04.000000000 +0000 +++ openjdk-17-17.0.18+8/test/jdk/tools/jpackage/windows/WinShortcutTest.java 2026-01-15 15:23:06.000000000 +0000 @@ -1,5 +1,5 @@ /* - * Copyright (c) 2018, 2019, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2018, 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 @@ -37,11 +37,10 @@ /* * @test * @summary jpackage with --win-shortcut - * @library ../helpers + * @library /test/jdk/tools/jpackage/helpers * @key jpackagePlatformPackage * @build jdk.jpackage.test.* * @requires (os.family == "windows") - * @modules jdk.jpackage/jdk.jpackage.internal * @compile WinShortcutTest.java * @run main/othervm/timeout=540 -Xmx512m jdk.jpackage.test.Main * --jpt-run=WinShortcutTest diff -Nru openjdk-17-17.0.17+10/test/jdk/tools/jpackage/windows/WinUpgradeUUIDTest.java openjdk-17-17.0.18+8/test/jdk/tools/jpackage/windows/WinUpgradeUUIDTest.java --- openjdk-17-17.0.17+10/test/jdk/tools/jpackage/windows/WinUpgradeUUIDTest.java 2025-10-13 07:48:04.000000000 +0000 +++ openjdk-17-17.0.18+8/test/jdk/tools/jpackage/windows/WinUpgradeUUIDTest.java 2026-01-15 15:23:06.000000000 +0000 @@ -1,5 +1,5 @@ /* - * Copyright (c) 2019, 2022, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2019, 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 @@ -46,12 +46,11 @@ /* * @test * @summary jpackage with --win-upgrade-uuid and --app-version - * @library ../helpers + * @library /test/jdk/tools/jpackage/helpers * @key jpackagePlatformPackage * @requires (jpackage.test.SQETest != null) * @build jdk.jpackage.test.* * @requires (os.family == "windows") - * @modules jdk.jpackage/jdk.jpackage.internal * @compile WinUpgradeUUIDTest.java * @run main/othervm/timeout=360 -Xmx512m jdk.jpackage.test.Main * --jpt-run=WinUpgradeUUIDTest.test @@ -60,12 +59,11 @@ /* * @test * @summary jpackage with --win-upgrade-uuid and --app-version - * @library ../helpers + * @library /test/jdk/tools/jpackage/helpers * @key jpackagePlatformPackage * @requires (jpackage.test.SQETest == null) * @build jdk.jpackage.test.* * @requires (os.family == "windows") - * @modules jdk.jpackage/jdk.jpackage.internal * @compile WinUpgradeUUIDTest.java * @run main/othervm/timeout=540 -Xmx512m jdk.jpackage.test.Main * --jpt-run=WinUpgradeUUIDTest diff -Nru openjdk-17-17.0.17+10/test/jdk/tools/jpackage/windows/WinUrlTest.java openjdk-17-17.0.18+8/test/jdk/tools/jpackage/windows/WinUrlTest.java --- openjdk-17-17.0.17+10/test/jdk/tools/jpackage/windows/WinUrlTest.java 2025-10-13 07:48:04.000000000 +0000 +++ openjdk-17-17.0.18+8/test/jdk/tools/jpackage/windows/WinUrlTest.java 2026-01-15 15:23:06.000000000 +0000 @@ -1,5 +1,5 @@ /* - * Copyright (c) 2021, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2021, 2024, Oracle and/or its affiliates. All rights reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * * This code is free software; you can redistribute it and/or modify it @@ -40,12 +40,11 @@ * @test * @summary jpackage with --about-url, --win-update-url and --win-help-url * parameters - * @library ../helpers + * @library /test/jdk/tools/jpackage/helpers * @key jpackagePlatformPackage * @build jdk.jpackage.test.* * @build WinUrlTest * @requires (os.family == "windows") - * @modules jdk.jpackage/jdk.jpackage.internal * @run main/othervm/timeout=720 -Xmx512m jdk.jpackage.test.Main * --jpt-run=WinUrlTest */ diff -Nru openjdk-17-17.0.17+10/test/jtreg-ext/requires/VMProps.java openjdk-17-17.0.18+8/test/jtreg-ext/requires/VMProps.java --- openjdk-17-17.0.17+10/test/jtreg-ext/requires/VMProps.java 2025-10-13 07:48:04.000000000 +0000 +++ openjdk-17-17.0.18+8/test/jtreg-ext/requires/VMProps.java 2026-01-15 15:23:06.000000000 +0000 @@ -127,7 +127,7 @@ map.put("vm.graal.enabled", this::isGraalEnabled); map.put("vm.compiler1.enabled", this::isCompiler1Enabled); map.put("vm.compiler2.enabled", this::isCompiler2Enabled); - map.put("docker.support", this::dockerSupport); + map.put("container.support", this::containerSupport); map.put("vm.musl", this::isMusl); map.put("release.implementor", this::implementor); map.put("jdk.containerized", this::jdkContainerized); @@ -455,16 +455,16 @@ } /** - * A simple check for docker support + * A simple check for container support * - * @return true if docker is supported in a given environment + * @return true if container is supported in a given environment */ - protected String dockerSupport() { - log("Entering dockerSupport()"); + protected String containerSupport() { + log("Entering containerSupport()"); boolean isSupported = false; if (Platform.isLinux()) { - // currently docker testing is only supported for Linux, + // currently container testing is only supported for Linux, // on certain platforms String arch = System.getProperty("os.arch"); @@ -480,17 +480,17 @@ } } - log("dockerSupport(): platform check: isSupported = " + isSupported); + log("containerSupport(): platform check: isSupported = " + isSupported); if (isSupported) { try { - isSupported = checkDockerSupport(); + isSupported = checkProgramSupport("checkContainerSupport()", Container.ENGINE_COMMAND); } catch (Exception e) { isSupported = false; } } - log("dockerSupport(): returning isSupported = " + isSupported); + log("containerSupport(): returning isSupported = " + isSupported); return "" + isSupported; } @@ -527,18 +527,17 @@ log("-------------"); }); } - - private boolean checkDockerSupport() throws IOException, InterruptedException { - log("checkDockerSupport(): entering"); - ProcessBuilder pb = new ProcessBuilder("which", Container.ENGINE_COMMAND); + private boolean checkProgramSupport(String logString, String cmd) throws IOException, InterruptedException { + log(logString + ": entering"); + ProcessBuilder pb = new ProcessBuilder("which", cmd); Map logFileNames = - redirectOutputToLogFile("checkDockerSupport(): which ", - pb, "which-container"); + redirectOutputToLogFile(logString + ": which " + cmd, + pb, "which-cmd"); Process p = pb.start(); p.waitFor(10, TimeUnit.SECONDS); int exitValue = p.exitValue(); - log(String.format("checkDockerSupport(): exitValue = %s, pid = %s", exitValue, p.pid())); + log(String.format("%s: exitValue = %s, pid = %s", logString, exitValue, p.pid())); if (exitValue != 0) { printLogfileContent(logFileNames); } diff -Nru openjdk-17-17.0.17+10/test/langtools/tools/javac/jvm/ClassRefDupInConstantPoolTest.java openjdk-17-17.0.18+8/test/langtools/tools/javac/jvm/ClassRefDupInConstantPoolTest.java --- openjdk-17-17.0.17+10/test/langtools/tools/javac/jvm/ClassRefDupInConstantPoolTest.java 2025-10-13 07:48:04.000000000 +0000 +++ openjdk-17-17.0.18+8/test/langtools/tools/javac/jvm/ClassRefDupInConstantPoolTest.java 2026-01-15 15:23:06.000000000 +0000 @@ -1,5 +1,5 @@ /* - * Copyright (c) 2014, 2015, 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 @@ -26,7 +26,7 @@ * @bug 8015927 * @summary Class reference duplicates in constant pool * @modules jdk.jdeps/com.sun.tools.classfile - * @clean ClassRefDupInConstantPoolTest$Duplicates + * @clean ClassRefDupInConstantPoolTest ClassRefDupInConstantPoolTest$Duplicates * @run main ClassRefDupInConstantPoolTest */ diff -Nru openjdk-17-17.0.17+10/test/lib/jdk/test/lib/Container.java openjdk-17-17.0.18+8/test/lib/jdk/test/lib/Container.java --- openjdk-17-17.0.17+10/test/lib/jdk/test/lib/Container.java 2025-10-13 07:48:04.000000000 +0000 +++ openjdk-17-17.0.18+8/test/lib/jdk/test/lib/Container.java 2026-01-15 15:23:06.000000000 +0000 @@ -1,5 +1,6 @@ /* * Copyright (c) 2019, Red Hat Inc. + * Copyright (c) 2024, Oracle and/or its affiliates. All rights reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * * This code is free software; you can redistribute it and/or modify it @@ -23,9 +24,9 @@ package jdk.test.lib; public class Container { - // Use this property to specify docker location on your system. + // Use this property to specify container runtime location (e.g. docker) on your system. // E.g.: "/usr/local/bin/docker". We define this constant here so - // that it can be used in VMProps as well which checks docker support + // that it can be used in VMProps as well which checks container support // via this command public static final String ENGINE_COMMAND = System.getProperty("jdk.test.container.command", "docker"); diff -Nru openjdk-17-17.0.17+10/test/lib/jdk/test/lib/cli/CommandLineOptionTest.java openjdk-17-17.0.18+8/test/lib/jdk/test/lib/cli/CommandLineOptionTest.java --- openjdk-17-17.0.17+10/test/lib/jdk/test/lib/cli/CommandLineOptionTest.java 2025-10-13 07:48:04.000000000 +0000 +++ openjdk-17-17.0.18+8/test/lib/jdk/test/lib/cli/CommandLineOptionTest.java 2026-01-15 15:23:06.000000000 +0000 @@ -122,8 +122,8 @@ outputAnalyzer.shouldHaveExitValue(exitCode.value); } catch (RuntimeException e) { String errorMessage = String.format( - "JVM process should have exit value '%d'.%n%s", - exitCode.value, exitErrorMessage); + "JVM process should have exit value '%d', but has '%d'.%n%s", + exitCode.value, outputAnalyzer.getExitValue(), exitErrorMessage); throw new AssertionError(errorMessage, e); } @@ -300,9 +300,12 @@ CommandLineOptionTest.PRINT_FLAGS_FINAL_FORMAT, optionName, expectedValue)); } catch (RuntimeException e) { + String observedValue = outputAnalyzer.firstMatch(String.format( + CommandLineOptionTest.PRINT_FLAGS_FINAL_FORMAT, + optionName, "\\S")); String errorMessage = String.format( - "Option '%s' is expected to have '%s' value%n%s", - optionName, expectedValue, + "Option '%s' is expected to have '%s' value, but is '%s'.%n%s", + optionName, expectedValue, observedValue, optionErrorString); throw new AssertionError(errorMessage, e); } diff -Nru openjdk-17-17.0.17+10/test/lib/jdk/test/lib/containers/cgroup/MetricsTesterCgroupV2.java openjdk-17-17.0.18+8/test/lib/jdk/test/lib/containers/cgroup/MetricsTesterCgroupV2.java --- openjdk-17-17.0.17+10/test/lib/jdk/test/lib/containers/cgroup/MetricsTesterCgroupV2.java 2025-10-13 07:48:04.000000000 +0000 +++ openjdk-17-17.0.18+8/test/lib/jdk/test/lib/containers/cgroup/MetricsTesterCgroupV2.java 2026-01-15 15:23:06.000000000 +0000 @@ -1,5 +1,6 @@ /* * Copyright (c) 2020, Red Hat Inc. + * 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 @@ -447,13 +448,13 @@ Metrics metrics = Metrics.systemMetrics(); long oldVal = metrics.getBlkIOServiceCount(); long newVal = getIoStatAccumulate(new String[] { "rios", "wios" }); - if (!CgroupMetricsTester.compareWithErrorMargin(oldVal, newVal)) { + if (newVal < oldVal) { fail("io.stat->rios/wios: ", oldVal, newVal); } oldVal = metrics.getBlkIOServiced(); newVal = getIoStatAccumulate(new String[] { "rbytes", "wbytes" }); - if (!CgroupMetricsTester.compareWithErrorMargin(oldVal, newVal)) { + if (newVal < oldVal) { fail("io.stat->rbytes/wbytes: ", oldVal, newVal); } } diff -Nru openjdk-17-17.0.17+10/test/lib/jdk/test/lib/security/CertificateBuilder.java openjdk-17-17.0.18+8/test/lib/jdk/test/lib/security/CertificateBuilder.java --- openjdk-17-17.0.17+10/test/lib/jdk/test/lib/security/CertificateBuilder.java 2025-10-13 07:48:04.000000000 +0000 +++ openjdk-17-17.0.18+8/test/lib/jdk/test/lib/security/CertificateBuilder.java 2026-01-15 15:23:06.000000000 +0000 @@ -26,12 +26,12 @@ package jdk.test.lib.security; import java.io.*; +import java.security.cert.*; +import java.security.cert.Extension; import java.util.*; import java.security.*; -import java.security.cert.X509Certificate; -import java.security.cert.CertificateException; -import java.security.cert.CertificateFactory; -import java.security.cert.Extension; +import java.time.temporal.ChronoUnit; +import java.time.Instant; import javax.security.auth.x500.X500Principal; import java.math.BigInteger; @@ -43,6 +43,7 @@ import sun.security.x509.AlgorithmId; import sun.security.x509.AuthorityInfoAccessExtension; import sun.security.x509.AuthorityKeyIdentifierExtension; +import sun.security.x509.IPAddressName; import sun.security.x509.SubjectKeyIdentifierExtension; import sun.security.x509.BasicConstraintsExtension; import sun.security.x509.ExtendedKeyUsageExtension; @@ -56,6 +57,7 @@ import sun.security.x509.KeyIdentifier; import sun.security.x509.X500Name; + /** * Helper class that builds and signs X.509 certificates. * @@ -100,6 +102,89 @@ private byte[] tbsCertBytes; private byte[] signatureBytes; + public enum KeyUsage { + DIGITAL_SIGNATURE, + NONREPUDIATION, + KEY_ENCIPHERMENT, + DATA_ENCIPHERMENT, + KEY_AGREEMENT, + KEY_CERT_SIGN, + CRL_SIGN, + ENCIPHER_ONLY, + DECIPHER_ONLY; + } + + /** + * Create a new CertificateBuilder instance. This method sets the subject name, + * public key, authority key id, and serial number. + * + * @param subjectName entity associated with the public key + * @param publicKey the entity's public key + * @param caKey public key of certificate signer + * @param keyUsages list of key uses + * @return + * @throws CertificateException + * @throws IOException + */ + public static CertificateBuilder newCertificateBuilder(String subjectName, + PublicKey publicKey, PublicKey caKey, KeyUsage... keyUsages) + throws CertificateException, IOException { + SecureRandom random = new SecureRandom(); + + boolean [] keyUsage = new boolean[KeyUsage.values().length]; + for (KeyUsage ku : keyUsages) { + keyUsage[ku.ordinal()] = true; + } + + CertificateBuilder builder = new CertificateBuilder() + .setSubjectName(subjectName) + .setPublicKey(publicKey) + .setSerialNumber(BigInteger.valueOf(random.nextLong(1000000)+1)) + .addSubjectKeyIdExt(publicKey) + .addAuthorityKeyIdExt(caKey); + if (keyUsages.length != 0) { + builder.addKeyUsageExt(keyUsage); + } + return builder; + } + + /** + * Create a Subject Alternative Name extension for the given DNS name + * @param critical Sets the extension to critical or non-critical + * @param dnsName DNS name to use in the extension + * @throws IOException + */ + public static SubjectAlternativeNameExtension createDNSSubjectAltNameExt( + boolean critical, String dnsName) throws IOException { + GeneralNames gns = new GeneralNames(); + gns.add(new GeneralName(new DNSName(dnsName))); + return new SubjectAlternativeNameExtension(critical, gns); + } + + /** + * Create a Subject Alternative Name extension for the given IP address + * @param critical Sets the extension to critical or non-critical + * @param ipAddress IP address to use in the extension + * @throws IOException + */ + public static SubjectAlternativeNameExtension createIPSubjectAltNameExt( + boolean critical, String ipAddress) throws IOException { + GeneralNames gns = new GeneralNames(); + gns.add(new GeneralName(new IPAddressName(ipAddress))); + return new SubjectAlternativeNameExtension(critical, gns); + } + + public static void printCertificate(X509Certificate certificate, PrintStream ps) { + try { + Base64.Encoder encoder = Base64.getEncoder(); + ps.println("-----BEGIN CERTIFICATE-----"); + ps.println(encoder.encodeToString(certificate.getEncoded())); + ps.println("-----END CERTIFICATE-----"); + } catch (CertificateEncodingException exc) { + exc.printStackTrace(ps); + } + } + /** * Default constructor for a {@code CertificateBuilder} object. * @@ -193,6 +278,11 @@ return setNotBefore(nbDate).setNotAfter(naDate); } + public CertificateBuilder setOneHourValidity() { + return setNotBefore(Date.from(Instant.now().minus(5, ChronoUnit.MINUTES))) + .setNotAfter(Date.from(Instant.now().plus(1, ChronoUnit.HOURS))); + } + /** * Set the serial number on the certificate. * diff -Nru openjdk-17-17.0.17+10/test/lib/jdk/test/lib/util/ModuleInfoWriter.java openjdk-17-17.0.18+8/test/lib/jdk/test/lib/util/ModuleInfoWriter.java --- openjdk-17-17.0.17+10/test/lib/jdk/test/lib/util/ModuleInfoWriter.java 1970-01-01 00:00:00.000000000 +0000 +++ openjdk-17-17.0.18+8/test/lib/jdk/test/lib/util/ModuleInfoWriter.java 2026-01-15 15:23:06.000000000 +0000 @@ -0,0 +1,232 @@ +/* + * Copyright (c) 2015, 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. + */ + +package jdk.test.lib.util; + +import java.io.IOException; +import java.io.OutputStream; +import java.lang.module.ModuleDescriptor; +import java.nio.ByteBuffer; +import java.util.Map; +import java.util.stream.Stream; + +import jdk.internal.org.objectweb.asm.ClassWriter; +import jdk.internal.org.objectweb.asm.ModuleVisitor; +import jdk.internal.org.objectweb.asm.Opcodes; +import jdk.internal.org.objectweb.asm.commons.ModuleResolutionAttribute; +import jdk.internal.org.objectweb.asm.commons.ModuleTargetAttribute; +import static jdk.internal.org.objectweb.asm.Opcodes.*; +import jdk.internal.module.ModuleResolution; +import jdk.internal.module.ModuleTarget; + +/** + * Utility class to write a ModuleDescriptor as a module-info.class. + */ + +public final class ModuleInfoWriter { + + private static final Map + MODULE_MODS_TO_FLAGS = Map.of( + ModuleDescriptor.Modifier.OPEN, ACC_OPEN, + ModuleDescriptor.Modifier.SYNTHETIC, ACC_SYNTHETIC, + ModuleDescriptor.Modifier.MANDATED, ACC_MANDATED + ); + + private static final Map + REQUIRES_MODS_TO_FLAGS = Map.of( + ModuleDescriptor.Requires.Modifier.TRANSITIVE, ACC_TRANSITIVE, + ModuleDescriptor.Requires.Modifier.STATIC, ACC_STATIC_PHASE, + ModuleDescriptor.Requires.Modifier.SYNTHETIC, ACC_SYNTHETIC, + ModuleDescriptor.Requires.Modifier.MANDATED, ACC_MANDATED + ); + + private static final Map + EXPORTS_MODS_TO_FLAGS = Map.of( + ModuleDescriptor.Exports.Modifier.SYNTHETIC, ACC_SYNTHETIC, + ModuleDescriptor.Exports.Modifier.MANDATED, ACC_MANDATED + ); + + private static final Map + OPENS_MODS_TO_FLAGS = Map.of( + ModuleDescriptor.Opens.Modifier.SYNTHETIC, ACC_SYNTHETIC, + ModuleDescriptor.Opens.Modifier.MANDATED, ACC_MANDATED + ); + + private static final String[] EMPTY_STRING_ARRAY = new String[0]; + + private ModuleInfoWriter() { } + + /** + * Writes the given module descriptor to a module-info.class file, + * returning it in a byte array. + */ + private static byte[] toModuleInfo(ModuleDescriptor md, + ModuleResolution mres, + ModuleTarget target) { + ClassWriter cw = new ClassWriter(0); + cw.visit(Opcodes.V10, ACC_MODULE, "module-info", null, null, null); + + int moduleFlags = md.modifiers().stream() + .map(MODULE_MODS_TO_FLAGS::get) + .reduce(0, (x, y) -> (x | y)); + String vs = md.rawVersion().orElse(null); + ModuleVisitor mv = cw.visitModule(md.name(), moduleFlags, vs); + + // requires + for (ModuleDescriptor.Requires r : md.requires()) { + int flags = r.modifiers().stream() + .map(REQUIRES_MODS_TO_FLAGS::get) + .reduce(0, (x, y) -> (x | y)); + vs = r.rawCompiledVersion().orElse(null); + mv.visitRequire(r.name(), flags, vs); + } + + // exports + for (ModuleDescriptor.Exports e : md.exports()) { + int flags = e.modifiers().stream() + .map(EXPORTS_MODS_TO_FLAGS::get) + .reduce(0, (x, y) -> (x | y)); + String[] targets = e.targets().toArray(EMPTY_STRING_ARRAY); + mv.visitExport(e.source().replace('.', '/'), flags, targets); + } + + // opens + for (ModuleDescriptor.Opens opens : md.opens()) { + int flags = opens.modifiers().stream() + .map(OPENS_MODS_TO_FLAGS::get) + .reduce(0, (x, y) -> (x | y)); + String[] targets = opens.targets().toArray(EMPTY_STRING_ARRAY); + mv.visitOpen(opens.source().replace('.', '/'), flags, targets); + } + + // uses + md.uses().stream().map(sn -> sn.replace('.', '/')).forEach(mv::visitUse); + + // provides + for (ModuleDescriptor.Provides p : md.provides()) { + mv.visitProvide(p.service().replace('.', '/'), + p.providers() + .stream() + .map(pn -> pn.replace('.', '/')) + .toArray(String[]::new)); + } + + // add the ModulePackages attribute when there are packages that aren't + // exported or open + Stream exported = md.exports().stream() + .map(ModuleDescriptor.Exports::source); + Stream open = md.opens().stream() + .map(ModuleDescriptor.Opens::source); + long exportedOrOpen = Stream.concat(exported, open).distinct().count(); + if (md.packages().size() > exportedOrOpen) { + md.packages().stream() + .map(pn -> pn.replace('.', '/')) + .forEach(mv::visitPackage); + } + + // ModuleMainClass attribute + md.mainClass() + .map(mc -> mc.replace('.', '/')) + .ifPresent(mv::visitMainClass); + + mv.visitEnd(); + + // write ModuleResolution attribute if specified + if (mres != null) { + cw.visitAttribute(new ModuleResolutionAttribute(mres.value())); + } + + // write ModuleTarget attribute if there is a target platform + if (target != null && target.targetPlatform().length() > 0) { + cw.visitAttribute(new ModuleTargetAttribute(target.targetPlatform())); + } + + cw.visitEnd(); + return cw.toByteArray(); + } + + /** + * Writes a module descriptor to the given output stream as a + * module-info.class. + */ + public static void write(ModuleDescriptor descriptor, + ModuleResolution mres, + ModuleTarget target, + OutputStream out) + throws IOException + { + byte[] bytes = toModuleInfo(descriptor, mres, target); + out.write(bytes); + } + + /** + * Writes a module descriptor to the given output stream as a + * module-info.class. + */ + public static void write(ModuleDescriptor descriptor, + ModuleResolution mres, + OutputStream out) + throws IOException + { + write(descriptor, mres, null, out); + } + + /** + * Writes a module descriptor to the given output stream as a + * module-info.class. + */ + public static void write(ModuleDescriptor descriptor, + ModuleTarget target, + OutputStream out) + throws IOException + { + write(descriptor, null, target, out); + } + + /** + * Writes a module descriptor to the given output stream as a + * module-info.class. + */ + public static void write(ModuleDescriptor descriptor, OutputStream out) + throws IOException + { + write(descriptor, null, null, out); + } + + /** + * Returns a byte array containing the given module descriptor in + * module-info.class format. + */ + public static byte[] toBytes(ModuleDescriptor descriptor) { + return toModuleInfo(descriptor, null, null); + } + + /** + * Returns a {@code ByteBuffer} containing the given module descriptor + * in module-info.class format. + */ + public static ByteBuffer toByteBuffer(ModuleDescriptor descriptor) { + byte[] bytes = toModuleInfo(descriptor, null, null); + return ByteBuffer.wrap(bytes); + } +} diff -Nru openjdk-17-17.0.17+10/test/lib/jdk/test/whitebox/WhiteBox.java openjdk-17-17.0.18+8/test/lib/jdk/test/whitebox/WhiteBox.java --- openjdk-17-17.0.17+10/test/lib/jdk/test/whitebox/WhiteBox.java 2025-10-13 07:48:04.000000000 +0000 +++ openjdk-17-17.0.18+8/test/lib/jdk/test/whitebox/WhiteBox.java 2026-01-15 15:23:06.000000000 +0000 @@ -24,7 +24,11 @@ package jdk.test.whitebox; import java.lang.management.MemoryUsage; +import java.lang.ref.Reference; import java.lang.reflect.Executable; +import java.lang.reflect.InaccessibleObjectException; +import java.lang.reflect.InvocationTargetException; +import java.lang.reflect.Method; import java.util.Arrays; import java.util.List; import java.util.function.BiFunction; @@ -434,6 +438,53 @@ // Force Full GC public native void fullGC(); + // Infrastructure for waitForReferenceProcessing() + private static volatile Method waitForReferenceProcessingMethod = null; + + private static Method getWaitForReferenceProcessingMethod() { + Method wfrp = waitForReferenceProcessingMethod; + if (wfrp == null) { + try { + wfrp = Reference.class.getDeclaredMethod("waitForReferenceProcessing"); + wfrp.setAccessible(true); + assert wfrp.getReturnType() == Boolean.class; + Class[] ev = wfrp.getExceptionTypes(); + assert ev.length == 1; + assert ev[0] == InterruptedException.class; + waitForReferenceProcessingMethod = wfrp; + } catch (InaccessibleObjectException e) { + throw new RuntimeException("Need to add @modules java.base/java.lang.ref:open to test?", e); + } catch (NoSuchMethodException e) { + throw new RuntimeException(e); + } + } + return wfrp; + } + + /** + * Wait for reference processing, via Reference.waitForReferenceProcessing(). + * Callers of this method will need the + * @modules java.base/java.lang.ref:open + * jtreg tag. + * + * This method should usually be called after a call to WhiteBox.fullGC(). + */ + public boolean waitForReferenceProcessing() throws InterruptedException { + try { + Method wfrp = getWaitForReferenceProcessingMethod(); + return (Boolean) wfrp.invoke(null); + } catch (IllegalAccessException e) { + throw new RuntimeException("Shouldn't happen, we call setAccessible()", e); + } catch (InvocationTargetException e) { + Throwable cause = e.getCause(); + if (cause instanceof InterruptedException) { + throw (InterruptedException) cause; + } else { + throw new RuntimeException(e); + } + } + } + // Returns true if the current GC supports concurrent collection control. public native boolean supportsConcurrentGCBreakpoints(); diff -Nru openjdk-17-17.0.17+10/test/lib-test/jdk/test/whitebox/vm_flags/SizeTTest.java openjdk-17-17.0.18+8/test/lib-test/jdk/test/whitebox/vm_flags/SizeTTest.java --- openjdk-17-17.0.17+10/test/lib-test/jdk/test/whitebox/vm_flags/SizeTTest.java 2025-10-13 07:48:04.000000000 +0000 +++ openjdk-17-17.0.18+8/test/lib-test/jdk/test/whitebox/vm_flags/SizeTTest.java 2026-01-15 15:23:06.000000000 +0000 @@ -1,5 +1,5 @@ /* - * Copyright (c) 2014, 2021, 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 @@ -35,7 +35,7 @@ import jdk.test.lib.Platform; public class SizeTTest { - private static final String FLAG_NAME = "ArrayAllocatorMallocLimit"; + private static final String FLAG_NAME = "LargePageHeapSizeThreshold"; private static final Long[] TESTS = {0L, 100L, (long) Integer.MAX_VALUE, (1L << 32L) - 1L, 1L << 32L}; private static final Long[] EXPECTED_64 = TESTS; diff -Nru openjdk-17-17.0.17+10/test/micro/org/openjdk/bench/java/lang/StringDecode.java openjdk-17-17.0.18+8/test/micro/org/openjdk/bench/java/lang/StringDecode.java --- openjdk-17-17.0.17+10/test/micro/org/openjdk/bench/java/lang/StringDecode.java 2025-10-13 07:48:04.000000000 +0000 +++ openjdk-17-17.0.18+8/test/micro/org/openjdk/bench/java/lang/StringDecode.java 2026-01-15 15:23:06.000000000 +0000 @@ -1,5 +1,5 @@ /* - * Copyright (c) 2021, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2021, 2022, Oracle and/or its affiliates. All rights reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * * This code is free software; you can redistribute it and/or modify it @@ -22,17 +22,7 @@ */ package org.openjdk.bench.java.lang; -import org.openjdk.jmh.annotations.Benchmark; -import org.openjdk.jmh.annotations.BenchmarkMode; -import org.openjdk.jmh.annotations.Fork; -import org.openjdk.jmh.annotations.Measurement; -import org.openjdk.jmh.annotations.Mode; -import org.openjdk.jmh.annotations.OutputTimeUnit; -import org.openjdk.jmh.annotations.Param; -import org.openjdk.jmh.annotations.Scope; -import org.openjdk.jmh.annotations.Setup; -import org.openjdk.jmh.annotations.State; -import org.openjdk.jmh.annotations.Warmup; +import org.openjdk.jmh.annotations.*; import org.openjdk.jmh.infra.Blackhole; import java.nio.charset.Charset; @@ -40,28 +30,30 @@ @BenchmarkMode(Mode.AverageTime) @OutputTimeUnit(TimeUnit.NANOSECONDS) -@Fork(value = 3) -@Warmup(iterations = 5, time = 2) +@Fork(value = 2) +@Warmup(iterations = 5, time = 3) @Measurement(iterations = 5, time = 3) @State(Scope.Thread) public class StringDecode { - @Param({"US-ASCII", "ISO-8859-1", "UTF-8", "MS932", "ISO-8859-6", "ISO-2022-KR"}) + // Reduced by default to only UTF-8, previous coverage: + // @Param({"US-ASCII", "ISO-8859-1", "UTF-8", "MS932", "ISO-8859-6", "ISO-2022-KR"}) + @Param({"UTF-8"}) private String charsetName; private Charset charset; private byte[] asciiString; + private byte[] longAsciiString; private byte[] utf16String; - private byte[] longUtf16String; + private byte[] longUtf16EndString; private byte[] longUtf16StartString; - private byte[] longLatin1String; + private byte[] longUtf16OnlyString; + private byte[] latin1String; + private byte[] longLatin1EndString; + private byte[] longLatin1StartString; + private byte[] longLatin1OnlyString; - @Setup - public void setup() { - charset = Charset.forName(charsetName); - asciiString = "ascii string".getBytes(charset); - utf16String = "UTF-\uFF11\uFF16 string".getBytes(charset); - longUtf16String = """ + private static final String LOREM = """ Lorem ipsum dolor sit amet, consectetur adipiscing elit. Aliquam ac sem eu urna egestas placerat. Etiam finibus ipsum nulla, non mattis dolor cursus a. Nulla nec nisl consectetur, lacinia neque id, accumsan ante. Curabitur et @@ -70,90 +62,145 @@ per conubia nostra, per inceptos himenaeos. Suspendisse erat diam, fringilla sed massa sed, posuere viverra orci. Suspendisse tempor libero non gravida efficitur. Vivamus lacinia risus non orci viverra, at consectetur odio laoreet. - Suspendisse potenti. + Suspendisse potenti."""; + private static final String UTF16_STRING = "\uFF11".repeat(31); + private static final String LATIN1_STRING = "\u00B6".repeat(31); - Phasellus vel nisi iaculis, accumsan quam sed, bibendum eros. Sed venenatis - nulla tortor, et eleifend urna sodales id. Nullam tempus ac metus sit amet - sollicitudin. Nam sed ex diam. Praesent vitae eros et neque condimentum - consectetur eget non tortor. Praesent bibendum vel felis nec dignissim. - Maecenas a enim diam. Suspendisse quis ligula at nisi accumsan lacinia id - hendrerit sapien. \uFF11Donec aliquam mattis lectus eu ultrices. Duis eu nisl\uFF11 - euismod, blandit mauris vel, \uFF11placerat urna. Etiam malesuada enim purus, - tristique mollis odio blandit quis.\uFF11 Vivamus posuere. \uFF11 - \uFF11 - """.getBytes(charset); - longUtf16StartString = """ - \uFF11 - Lorem ipsum dolor sit amet, \uFF11consectetur adipiscing elit. Aliquam ac sem eu - urna egestas \uFF11placerat. Etiam finibus ipsum nulla, non mattis dolor cursus a. - Nulla \uFF11nec nisl consectetur, lacinia neque id, accumsan ante. Curabitur et - sapien in \uFF11magna porta ultricies. \uFF11Sed vel pellentesque nibh. Pellentesque dictum - dignissim diam eu ultricies. Class aptent taciti sociosqu ad litora torquent - per conubia nostra, per inceptos himenaeos. Suspendisse erat diam, fringilla - sed massa sed, posuere viverra orci. Suspendisse tempor libero non gravida - efficitur. Vivamus lacinia risus non orci viverra, at consectetur odio laoreet. - Suspendisse potenti. + @Setup + public void setup() { + charset = Charset.forName(charsetName); + asciiString = LOREM.substring(0, 32).getBytes(charset); + longAsciiString = LOREM.repeat(200).getBytes(charset); + utf16String = "UTF-\uFF11\uFF16 string".getBytes(charset); + longUtf16EndString = LOREM.repeat(4).concat(UTF16_STRING).getBytes(charset); + longUtf16StartString = UTF16_STRING.concat(LOREM.repeat(4)).getBytes(charset); + longUtf16OnlyString = UTF16_STRING.repeat(10).getBytes(charset); + latin1String = LATIN1_STRING.getBytes(charset); + longLatin1EndString = LOREM.repeat(4).concat(LATIN1_STRING).getBytes(charset); + longLatin1StartString = LATIN1_STRING.concat(LOREM.repeat(4)).getBytes(charset); + longLatin1OnlyString = LATIN1_STRING.repeat(10).getBytes(charset); + } + + @Benchmark + @CompilerControl(CompilerControl.Mode.DONT_INLINE) + public void decodeAsciiShort(Blackhole bh) throws Exception { + bh.consume(new String(asciiString, charset)); + bh.consume(new String(longAsciiString, 0, 15, charset)); + bh.consume(new String(asciiString, 0, 3, charset)); + bh.consume(new String(longAsciiString, 512, 512 + 7, charset)); + } - Phasellus vel nisi iaculis, accumsan quam sed, bibendum eros. Sed venenatis - nulla tortor, et eleifend urna sodales id. Nullam tempus ac metus sit amet - sollicitudin. Nam sed ex diam. Praesent vitae eros et neque condimentum - consectetur eget non tortor. Praesent bibendum vel felis nec dignissim. - Maecenas a enim diam. Suspendisse quis ligula at nisi accumsan lacinia id - hendrerit sapien. Donec aliquam mattis lectus eu ultrices. Duis eu nisl - euismod, blandit mauris vel, placerat urna. Etiam malesuada enim purus, - tristique mollis odio blandit quis. Vivamus posuere. - """.getBytes(charset); + @Benchmark + @CompilerControl(CompilerControl.Mode.DONT_INLINE) + public void decodeAsciiLong(Blackhole bh) throws Exception { + bh.consume(new String(longAsciiString, charset)); + bh.consume(new String(longAsciiString, 0, 1024 + 31, charset)); + } + + @Benchmark + @CompilerControl(CompilerControl.Mode.DONT_INLINE) + public void decodeLatin1Short(Blackhole bh) throws Exception { + bh.consume(new String(latin1String, charset)); + bh.consume(new String(latin1String, 0, 15, charset)); + bh.consume(new String(latin1String, 0, 3, charset)); + bh.consume(new String(longLatin1OnlyString, 512, 512 + 7, charset)); + } - longLatin1String = """ - a\u00B6\u00F6\u00F6\u00F6\u00F6\u00F6\u00F6\u00F6\u00F6\u00F6\u00F6\u00F6\u00F6\u00F6\u00F6\u00F6 - b\u00F6\u00F6\u00B6\u00F6\u00F6\u00F6\u00F6\u00F6\u00F6\u00F6\u00F6\u00F6\u00F6\u00F6\u00F6\u00F6 - c\u00F6\u00F6\u00F6\u00B6\u00F6\u00F6\u00F6\u00F6\u00F6\u00F6\u00F6\u00F6\u00F6\u00F6\u00F6\u00F6 - d\u00F6\u00F6\u00F6\u00F6\u00B6\u00F6\u00F6\u00F6\u00F6\u00F6\u00F6\u00F6\u00F6\u00F6\u00F6\u00F6 - e\u00F6\u00F6\u00F6\u00F6\u00F6\u00B6\u00F6\u00F6\u00F6\u00F6\u00F6\u00F6\u00F6\u00F6\u00F6\u00F6 - f\u00F6\u00F6\u00F6\u00F6\u00F6\u00F6\u00B6\u00F6\u00F6\u00F6\u00F6\u00F6\u00F6\u00F6\u00F6\u00F6 - g\u00F6\u00F6\u00F6\u00F6\u00F6\u00F6\u00F6\u00B6\u00F6\u00F6\u00F6\u00F6\u00F6\u00F6\u00F6\u00F6 - h\u00F6\u00F6\u00F6\u00F6\u00F6\u00F6\u00F6\u00F6\u00B6\u00F6\u00F6\u00F6\u00F6\u00F6\u00F6\u00F6 - i\u00F6\u00F6\u00F6\u00F6\u00F6\u00F6\u00F6\u00F6\u00F6\u00B6\u00F6\u00F6\u00F6\u00F6\u00F6\u00F6 - j\u00F6\u00F6\u00F6\u00F6\u00F6\u00F6\u00F6\u00F6\u00F6\u00F6\u00B6\u00F6\u00F6\u00F6\u00F6\u00F6 - k\u00F6\u00F6\u00F6\u00F6\u00F6\u00F6\u00F6\u00F6\u00F6\u00F6\u00F6\u00B6\u00F6\u00F6\u00F6\u00F6 - l\u00F6\u00F6\u00F6\u00F6\u00F6\u00F6\u00F6\u00F6\u00F6\u00F6\u00F6\u00F6\u00B6\u00F6\u00F6\u00F6 - m\u00F6\u00F6\u00F6\u00F6\u00F6\u00F6\u00F6\u00F6\u00F6\u00F6\u00F6\u00F6\u00F6\u00B6\u00F6\u00F6 - """.getBytes(charset); + @Benchmark + @CompilerControl(CompilerControl.Mode.DONT_INLINE) + public String decodeLatin1LongStart() throws Exception { + return new String(longLatin1StartString, charset); } @Benchmark - public String decodeAsciiCharsetName() throws Exception { - return new String(asciiString, charsetName); + @CompilerControl(CompilerControl.Mode.DONT_INLINE) + public String decodeLatin1LongEnd() throws Exception { + return new String(longLatin1EndString, charset); } @Benchmark - public String decodeAscii() throws Exception { - return new String(asciiString, charset); + @CompilerControl(CompilerControl.Mode.DONT_INLINE) + public String decodeLatin1LongOnly() throws Exception { + return new String(longLatin1OnlyString, charset); } @Benchmark - public String decodeLatin1Long() throws Exception { - return new String(longLatin1String, charset); + @CompilerControl(CompilerControl.Mode.DONT_INLINE) + public void decodeLatin1Mixed(Blackhole bh) throws Exception { + bh.consume(new String(longLatin1EndString, charset)); + bh.consume(new String(longLatin1StartString, charset)); + bh.consume(new String(latin1String, charset)); + bh.consume(new String(longLatin1OnlyString, charset)); } @Benchmark - public String decodeUTF16Short() throws Exception { - return new String(utf16String, charset); + @CompilerControl(CompilerControl.Mode.DONT_INLINE) + public void decodeUTF16Short(Blackhole bh) throws Exception { + bh.consume(new String(utf16String, charset)); + bh.consume(new String(utf16String, 0, 15, charset)); + bh.consume(new String(utf16String, 0, 3, charset)); + bh.consume(new String(utf16String, 0, 7, charset)); } @Benchmark + @CompilerControl(CompilerControl.Mode.DONT_INLINE) public String decodeUTF16LongEnd() throws Exception { - return new String(longUtf16String, charset); + return new String(longUtf16EndString, charset); } @Benchmark + @CompilerControl(CompilerControl.Mode.DONT_INLINE) public String decodeUTF16LongStart() throws Exception { return new String(longUtf16StartString, charset); } @Benchmark - public void decodeUTF16LongMixed(Blackhole bh) throws Exception { + @CompilerControl(CompilerControl.Mode.DONT_INLINE) + public String decodeUTF16LongOnly() throws Exception { + return new String(longUtf16OnlyString, charset); + } + + @Benchmark + @CompilerControl(CompilerControl.Mode.DONT_INLINE) + public void decodeUTF16Mixed(Blackhole bh) throws Exception { + bh.consume(new String(longUtf16StartString, charset)); + bh.consume(new String(longUtf16EndString, charset)); + bh.consume(new String(utf16String, charset)); + bh.consume(new String(longUtf16OnlyString, charset)); + } + + @Benchmark + @CompilerControl(CompilerControl.Mode.DONT_INLINE) + public void decodeAllMixed(Blackhole bh) throws Exception { + bh.consume(new String(utf16String, charset)); + bh.consume(new String(longUtf16EndString, charset)); + bh.consume(new String(utf16String, 0, 15, charset)); bh.consume(new String(longUtf16StartString, charset)); - bh.consume(new String(longUtf16String, charset)); + bh.consume(new String(asciiString, 0, 3, charset)); + bh.consume(new String(longUtf16OnlyString, charset)); + bh.consume(new String(latin1String, charset)); + bh.consume(new String(longLatin1EndString, charset)); + bh.consume(new String(longLatin1StartString, charset)); + bh.consume(new String(latin1String, 0, 7, charset)); + bh.consume(new String(longLatin1OnlyString, charset)); + bh.consume(new String(asciiString, charset)); + bh.consume(new String(longAsciiString, charset)); + } + + @Benchmark + @CompilerControl(CompilerControl.Mode.DONT_INLINE) + public void decodeShortMixed(Blackhole bh) throws Exception { + bh.consume(new String(utf16String, 0, 15, charset)); + bh.consume(new String(latin1String, 0, 15, charset)); + bh.consume(new String(asciiString, charset)); + bh.consume(new String(utf16String, charset)); + bh.consume(new String(latin1String, 0, 3, charset)); + bh.consume(new String(asciiString, 0, 3, charset)); + bh.consume(new String(utf16String, 0, 7, charset)); + bh.consume(new String(latin1String, charset)); + bh.consume(new String(asciiString, 0, 7, charset)); + bh.consume(new String(utf16String, 0, 3, charset)); + bh.consume(new String(latin1String, 0, 7, charset)); + bh.consume(new String(asciiString, 0, 15, charset)); } } diff -Nru openjdk-17-17.0.17+10/test/micro/org/openjdk/bench/java/lang/StringEncode.java openjdk-17-17.0.18+8/test/micro/org/openjdk/bench/java/lang/StringEncode.java --- openjdk-17-17.0.17+10/test/micro/org/openjdk/bench/java/lang/StringEncode.java 2025-10-13 07:48:04.000000000 +0000 +++ openjdk-17-17.0.18+8/test/micro/org/openjdk/bench/java/lang/StringEncode.java 2026-01-15 15:23:06.000000000 +0000 @@ -30,97 +30,197 @@ @BenchmarkMode(Mode.AverageTime) @OutputTimeUnit(TimeUnit.NANOSECONDS) -@Fork(value = 3) -@Warmup(iterations = 5, time = 2) +@Fork(value = 2) +@Warmup(iterations = 5, time = 3) @Measurement(iterations = 5, time = 3) @State(Scope.Thread) public class StringEncode { - @Param({"US-ASCII", "ISO-8859-1", "UTF-8", "MS932", "ISO-8859-6"}) + // Reduced by default to only UTF-8, previous coverage: + // @Param({"US-ASCII", "ISO-8859-1", "UTF-8", "MS932", "ISO-8859-6", "ISO-2022-KR"}) + @Param({"UTF-8"}) private String charsetName; + private Charset charset; private String asciiString; + private String asciiString3; + private String asciiString7; + private String asciiString15; + private String longAsciiString; + private String longAsciiString1055; private String utf16String; - private String longUtf16String; + private String utf16String3; + private String utf16String7; + private String utf16String15; + private String longUtf16EndString; private String longUtf16StartString; + private String longUtf16OnlyString; + private String latin1String; + private String latin1String3; + private String latin1String7; + private String latin1String15; + private String longLatin1EndString; + private String longLatin1StartString; + private String longLatin1OnlyString; + + private static final String LOREM = """ + Lorem ipsum dolor sit amet, consectetur adipiscing elit. Aliquam ac sem eu + urna egestas placerat. Etiam finibus ipsum nulla, non mattis dolor cursus a. + Nulla nec nisl consectetur, lacinia neque id, accumsan ante. Curabitur et + sapien in magna porta ultricies. Sed vel pellentesque nibh. Pellentesque dictum + dignissim diam eu ultricies. Class aptent taciti sociosqu ad litora torquent + per conubia nostra, per inceptos himenaeos. Suspendisse erat diam, fringilla + sed massa sed, posuere viverra orci. Suspendisse tempor libero non gravida + efficitur. Vivamus lacinia risus non orci viverra, at consectetur odio laoreet. + Suspendisse potenti."""; + private static final String UTF16_STRING = "\uFF11".repeat(31); + private static final String LATIN1_STRING = "\u00B6".repeat(31); @Setup public void setup() { charset = Charset.forName(charsetName); - asciiString = "ascii string"; - utf16String = "UTF-\uFF11\uFF16 string"; - longUtf16String = """ - Lorem ipsum dolor sit amet, consectetur adipiscing elit. Aliquam ac sem eu - urna egestas placerat. Etiam finibus ipsum nulla, non mattis dolor cursus a. - Nulla nec nisl consectetur, lacinia neque id, accumsan ante. Curabitur et - sapien in magna porta ultricies. Sed vel pellentesque nibh. Pellentesque dictum - dignissim diam eu ultricies. Class aptent taciti sociosqu ad litora torquent - per conubia nostra, per inceptos himenaeos. Suspendisse erat diam, fringilla - sed massa sed, posuere viverra orci. Suspendisse tempor libero non gravida - efficitur. Vivamus lacinia risus non orci viverra, at consectetur odio laoreet. - Suspendisse potenti. - - Phasellus vel nisi iaculis, accumsan quam sed, bibendum eros. Sed venenatis - nulla tortor, et eleifend urna sodales id. Nullam tempus ac metus sit amet - sollicitudin. Nam sed ex diam. Praesent vitae eros et neque condimentum - consectetur eget non tortor. Praesent bibendum vel felis nec dignissim. - Maecenas a enim diam. Suspendisse quis ligula at nisi accumsan lacinia id - hendrerit sapien. Donec aliquam mattis lectus eu ultrices. Duis eu nisl - euismod, blandit mauris vel, placerat urna. Etiam malesuada enim purus, - tristique mollis odio blandit quis. Vivamus posuere. - \uFF11 - """; - longUtf16StartString = """ - \uFF11 - Lorem ipsum dolor sit amet, consectetur adipiscing elit. Aliquam ac sem eu - urna egestas placerat. Etiam finibus ipsum nulla, non mattis dolor cursus a. - Nulla nec nisl consectetur, lacinia neque id, accumsan ante. Curabitur et - sapien in magna porta ultricies. Sed vel pellentesque nibh. Pellentesque dictum - dignissim diam eu ultricies. Class aptent taciti sociosqu ad litora torquent - per conubia nostra, per inceptos himenaeos. Suspendisse erat diam, fringilla - sed massa sed, posuere viverra orci. Suspendisse tempor libero non gravida - efficitur. Vivamus lacinia risus non orci viverra, at consectetur odio laoreet. - Suspendisse potenti. - - Phasellus vel nisi iaculis, accumsan quam sed, bibendum eros. Sed venenatis - nulla tortor, et eleifend urna sodales id. Nullam tempus ac metus sit amet - sollicitudin. Nam sed ex diam. Praesent vitae eros et neque condimentum - consectetur eget non tortor. Praesent bibendum vel felis nec dignissim. - Maecenas a enim diam. Suspendisse quis ligula at nisi accumsan lacinia id - hendrerit sapien. Donec aliquam mattis lectus eu ultrices. Duis eu nisl - euismod, blandit mauris vel, placerat urna. Etiam malesuada enim purus, - tristique mollis odio blandit quis. Vivamus posuere. - """; + asciiString = LOREM.substring(0, 32); + asciiString3 = LOREM.substring(0, 3); + asciiString7 = LOREM.substring(0, 7); + asciiString15 = LOREM.substring(0, 15); + longAsciiString = LOREM.repeat(200); + longAsciiString1055 = longAsciiString.substring(0, 1055); + utf16String = UTF16_STRING; + utf16String3 = UTF16_STRING.substring(0, 3); + utf16String7 = UTF16_STRING.substring(0, 7); + utf16String15 = UTF16_STRING.substring(0, 15); + longUtf16EndString = LOREM.repeat(4).concat(UTF16_STRING); + longUtf16StartString = UTF16_STRING.concat(LOREM.repeat(4)); + longUtf16OnlyString = UTF16_STRING.repeat(10); + latin1String = LATIN1_STRING; + latin1String3 = LATIN1_STRING.substring(0, 3); + latin1String7 = LATIN1_STRING.substring(0, 7); + latin1String15 = LATIN1_STRING.substring(0, 15); + longLatin1EndString = LOREM.repeat(4).concat(LATIN1_STRING); + longLatin1StartString = LATIN1_STRING.concat(LOREM.repeat(4)); + longLatin1OnlyString = LATIN1_STRING.repeat(10); } @Benchmark - public byte[] encodeAsciiCharsetName() throws Exception { - return asciiString.getBytes(charset); + @CompilerControl(CompilerControl.Mode.DONT_INLINE) + public void encodeAsciiShort(Blackhole bh) throws Exception { + bh.consume(asciiString.getBytes(charset)); + bh.consume(asciiString3.getBytes(charset)); + bh.consume(asciiString15.getBytes(charset)); + bh.consume(asciiString7.getBytes(charset)); } @Benchmark - public byte[] encodeAscii() throws Exception { - return asciiString.getBytes(charset); + @CompilerControl(CompilerControl.Mode.DONT_INLINE) + public void encodeAsciiLong(Blackhole bh) throws Exception { + bh.consume(longAsciiString.getBytes(charset)); + bh.consume(longAsciiString1055.getBytes(charset)); } @Benchmark - public void encodeMix(Blackhole bh) throws Exception { - bh.consume(asciiString.getBytes(charset)); + @CompilerControl(CompilerControl.Mode.DONT_INLINE) + public void encodeUTF16Short(Blackhole bh) throws Exception { bh.consume(utf16String.getBytes(charset)); + bh.consume(utf16String3.getBytes(charset)); + bh.consume(utf16String15.getBytes(charset)); + bh.consume(utf16String7.getBytes(charset)); } @Benchmark + @CompilerControl(CompilerControl.Mode.DONT_INLINE) public byte[] encodeUTF16LongEnd() throws Exception { - return longUtf16String.getBytes(charset); + return longUtf16EndString.getBytes(charset); } @Benchmark + @CompilerControl(CompilerControl.Mode.DONT_INLINE) public byte[] encodeUTF16LongStart() throws Exception { return longUtf16StartString.getBytes(charset); } @Benchmark - public byte[] encodeUTF16() throws Exception { - return utf16String.getBytes(charset); + @CompilerControl(CompilerControl.Mode.DONT_INLINE) + public byte[] encodeUTF16LongOnly() throws Exception { + return longUtf16OnlyString.getBytes(charset); + } + + @Benchmark + @CompilerControl(CompilerControl.Mode.DONT_INLINE) + public void encodeUTF16Mixed(Blackhole bh) throws Exception { + bh.consume(utf16String.getBytes(charset)); + bh.consume(longUtf16StartString.getBytes(charset)); + bh.consume(longUtf16EndString.getBytes(charset)); + bh.consume(longUtf16OnlyString.getBytes(charset)); + } + + @Benchmark + @CompilerControl(CompilerControl.Mode.DONT_INLINE) + public void encodeLatin1Short(Blackhole bh) throws Exception { + bh.consume(latin1String.getBytes(charset)); + bh.consume(latin1String3.getBytes(charset)); + bh.consume(latin1String15.getBytes(charset)); + bh.consume(latin1String7.getBytes(charset)); + } + + @Benchmark + @CompilerControl(CompilerControl.Mode.DONT_INLINE) + public byte[] encodeLatin1LongOnly() throws Exception { + return longLatin1OnlyString.getBytes(charset); + } + + @Benchmark + @CompilerControl(CompilerControl.Mode.DONT_INLINE) + public byte[] encodeLatin1LongStart() throws Exception { + return longLatin1StartString.getBytes(charset); + } + + @Benchmark + @CompilerControl(CompilerControl.Mode.DONT_INLINE) + public byte[] encodeLatin1LongEnd() throws Exception { + return longLatin1EndString.getBytes(charset); + } + + @Benchmark + @CompilerControl(CompilerControl.Mode.DONT_INLINE) + public void encodeLatin1Mixed(Blackhole bh) throws Exception { + bh.consume(longLatin1EndString.getBytes(charset)); + bh.consume(longLatin1StartString.getBytes(charset)); + bh.consume(longLatin1OnlyString.getBytes(charset)); + bh.consume(latin1String.getBytes(charset)); + } + + @Benchmark + @CompilerControl(CompilerControl.Mode.DONT_INLINE) + public void encodeAllMixed(Blackhole bh) throws Exception { + bh.consume(utf16String.getBytes(charset)); + bh.consume(longUtf16StartString.getBytes(charset)); + bh.consume(asciiString7.getBytes(charset)); + bh.consume(longUtf16EndString.getBytes(charset)); + bh.consume(latin1String3.getBytes(charset)); + bh.consume(longUtf16OnlyString.getBytes(charset)); + bh.consume(longLatin1EndString.getBytes(charset)); + bh.consume(longLatin1StartString.getBytes(charset)); + bh.consume(utf16String15.getBytes(charset)); + bh.consume(longLatin1OnlyString.getBytes(charset)); + bh.consume(latin1String.getBytes(charset)); + bh.consume(asciiString.getBytes(charset)); + bh.consume(longAsciiString.getBytes(charset)); + } + + @Benchmark + @CompilerControl(CompilerControl.Mode.DONT_INLINE) + public void encodeShortMixed(Blackhole bh) throws Exception { + bh.consume(utf16String3.getBytes(charset)); + bh.consume(latin1String7.getBytes(charset)); + bh.consume(asciiString15.getBytes(charset)); + bh.consume(utf16String.getBytes(charset)); + bh.consume(latin1String3.getBytes(charset)); + bh.consume(asciiString7.getBytes(charset)); + bh.consume(utf16String15.getBytes(charset)); + bh.consume(latin1String.getBytes(charset)); + bh.consume(asciiString3.getBytes(charset)); + bh.consume(utf16String7.getBytes(charset)); + bh.consume(latin1String15.getBytes(charset)); + bh.consume(asciiString.getBytes(charset)); } } diff -Nru openjdk-17-17.0.17+10/test/micro/org/openjdk/bench/java/security/Signatures.java openjdk-17-17.0.18+8/test/micro/org/openjdk/bench/java/security/Signatures.java --- openjdk-17-17.0.17+10/test/micro/org/openjdk/bench/java/security/Signatures.java 2025-10-13 07:48:04.000000000 +0000 +++ openjdk-17-17.0.18+8/test/micro/org/openjdk/bench/java/security/Signatures.java 2026-01-15 15:23:06.000000000 +0000 @@ -1,5 +1,5 @@ /* - * Copyright (C) 2022 THL A29 Limited, a Tencent company. All rights reserved. + * Copyright (C) 2022, Tencent. All rights reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * * This code is free software; you can redistribute it and/or modify it @@ -194,4 +194,3 @@ } } } - diff -Nru openjdk-17-17.0.17+10/test/micro/org/openjdk/bench/java/util/concurrent/ProducerConsumer.java openjdk-17-17.0.18+8/test/micro/org/openjdk/bench/java/util/concurrent/ProducerConsumer.java --- openjdk-17-17.0.17+10/test/micro/org/openjdk/bench/java/util/concurrent/ProducerConsumer.java 2025-10-13 07:48:04.000000000 +0000 +++ openjdk-17-17.0.18+8/test/micro/org/openjdk/bench/java/util/concurrent/ProducerConsumer.java 2026-01-15 15:23:06.000000000 +0000 @@ -1,5 +1,5 @@ /* - * Copyright (c) 2014, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2014, 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,6 +32,7 @@ import org.openjdk.jmh.annotations.State; import org.openjdk.jmh.annotations.TearDown; import org.openjdk.jmh.infra.Blackhole; +import org.openjdk.jmh.infra.ThreadParams; import java.util.concurrent.ArrayBlockingQueue; import java.util.concurrent.BlockingQueue; @@ -49,7 +50,7 @@ @State(Scope.Benchmark) public class ProducerConsumer { - @Param("100") + @Param("100") // Will be expanded to at least the number of threads used private int capacity; @Param @@ -59,7 +60,9 @@ private Producer prod; @Setup - public void prepare() { + public void prepare(ThreadParams params) { + capacity = Math.max(params.getThreadCount(), capacity); + switch (type) { case ABQ_F: q = new ArrayBlockingQueue<>(capacity, true); diff -Nru openjdk-17-17.0.17+10/test/micro/org/openjdk/bench/java/util/concurrent/Queues.java openjdk-17-17.0.18+8/test/micro/org/openjdk/bench/java/util/concurrent/Queues.java --- openjdk-17-17.0.17+10/test/micro/org/openjdk/bench/java/util/concurrent/Queues.java 2025-10-13 07:48:04.000000000 +0000 +++ openjdk-17-17.0.18+8/test/micro/org/openjdk/bench/java/util/concurrent/Queues.java 2026-01-15 15:23:06.000000000 +0000 @@ -1,5 +1,5 @@ /* - * Copyright (c) 2014, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2014, 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,6 +31,7 @@ import org.openjdk.jmh.annotations.Setup; import org.openjdk.jmh.annotations.State; import org.openjdk.jmh.infra.Blackhole; +import org.openjdk.jmh.infra.ThreadParams; import java.util.concurrent.ArrayBlockingQueue; import java.util.concurrent.BlockingQueue; @@ -43,7 +44,7 @@ @State(Scope.Benchmark) public class Queues { - @Param("100") + @Param("100") // Will be expanded to at least the number of threads used private int capacity; @Param @@ -59,7 +60,9 @@ private BlockingQueue q; @Setup - public void setup() { + public void setup(ThreadParams params) { + capacity = Math.max(params.getThreadCount(), capacity); + switch (type) { case ABQ_F: q = new ArrayBlockingQueue<>(capacity, true); diff -Nru openjdk-17-17.0.17+10/test/micro/org/openjdk/bench/vm/compiler/LoopUnroll.java openjdk-17-17.0.18+8/test/micro/org/openjdk/bench/vm/compiler/LoopUnroll.java --- openjdk-17-17.0.17+10/test/micro/org/openjdk/bench/vm/compiler/LoopUnroll.java 2025-10-13 07:48:04.000000000 +0000 +++ openjdk-17-17.0.18+8/test/micro/org/openjdk/bench/vm/compiler/LoopUnroll.java 2026-01-15 15:23:06.000000000 +0000 @@ -1,5 +1,5 @@ /* - * Copyright (C) 2021 THL A29 Limited, a Tencent company. All rights reserved. + * Copyright (C) 2021, Tencent. All rights reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * * This code is free software; you can redistribute it and/or modify it