From 7a889a5abd5b1bdaa7a2b9caff6efd03138b3932 Mon Sep 17 00:00:00 2001 From: Satyen Subramaniam Date: Tue, 11 Nov 2025 22:50:48 +0000 Subject: [PATCH 01/13] 8327856: Convert applet test SpanishDiacriticsTest.java to a main program Backport-of: 22f10e045b3decdb51a3cc7644c47f911aec753d --- .../InputMethods/SpanishDiacriticsTest.java | 92 +++++++++++++++++++ .../SpanishDiacriticsTest.html | 40 -------- .../SpanishDiacriticsTest.java | 57 ------------ 3 files changed, 92 insertions(+), 97 deletions(-) create mode 100644 test/jdk/java/awt/InputMethods/SpanishDiacriticsTest.java delete mode 100644 test/jdk/java/awt/InputMethods/SpanishDiacriticsTest/SpanishDiacriticsTest.html delete mode 100644 test/jdk/java/awt/InputMethods/SpanishDiacriticsTest/SpanishDiacriticsTest.java diff --git a/test/jdk/java/awt/InputMethods/SpanishDiacriticsTest.java b/test/jdk/java/awt/InputMethods/SpanishDiacriticsTest.java new file mode 100644 index 00000000000..0468f222774 --- /dev/null +++ b/test/jdk/java/awt/InputMethods/SpanishDiacriticsTest.java @@ -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 --git a/test/jdk/java/awt/InputMethods/SpanishDiacriticsTest/SpanishDiacriticsTest.html b/test/jdk/java/awt/InputMethods/SpanishDiacriticsTest/SpanishDiacriticsTest.html deleted file mode 100644 index af6cd0c7610..00000000000 --- a/test/jdk/java/awt/InputMethods/SpanishDiacriticsTest/SpanishDiacriticsTest.html +++ /dev/null @@ -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 --git a/test/jdk/java/awt/InputMethods/SpanishDiacriticsTest/SpanishDiacriticsTest.java b/test/jdk/java/awt/InputMethods/SpanishDiacriticsTest/SpanishDiacriticsTest.java deleted file mode 100644 index 78877061e60..00000000000 --- a/test/jdk/java/awt/InputMethods/SpanishDiacriticsTest/SpanishDiacriticsTest.java +++ /dev/null @@ -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); - }); - } -} - From 8b2e9f5192d0e2e2736e39a657cd82c4eff6e6af Mon Sep 17 00:00:00 2001 From: Satyen Subramaniam Date: Tue, 11 Nov 2025 22:51:12 +0000 Subject: [PATCH 02/13] 8327757: Convert javax/swing/JSlider/6524424/bug6524424.java applet to main Backport-of: ac5b6cb2d42bdb8fb1a110ad33411b50cff4ea61 --- .../swing/JSlider/6524424/bug6524424.html | 34 ---------- .../JSlider/{6524424 => }/bug6524424.java | 67 ++++++++++++------- 2 files changed, 43 insertions(+), 58 deletions(-) delete mode 100644 test/jdk/javax/swing/JSlider/6524424/bug6524424.html rename test/jdk/javax/swing/JSlider/{6524424 => }/bug6524424.java (61%) diff --git a/test/jdk/javax/swing/JSlider/6524424/bug6524424.html b/test/jdk/javax/swing/JSlider/6524424/bug6524424.html deleted file mode 100644 index 11a57b6b7fb..00000000000 --- a/test/jdk/javax/swing/JSlider/6524424/bug6524424.html +++ /dev/null @@ -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 --git a/test/jdk/javax/swing/JSlider/6524424/bug6524424.java b/test/jdk/javax/swing/JSlider/bug6524424.java similarity index 61% rename from test/jdk/javax/swing/JSlider/6524424/bug6524424.java rename to test/jdk/javax/swing/JSlider/bug6524424.java index 3cb8b69d260..3ceff68b32b 100644 --- a/test/jdk/javax/swing/JSlider/6524424/bug6524424.java +++ b/test/jdk/javax/swing/JSlider/bug6524424.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2008, 2017, Oracle and/or its affiliates. All rights reserved. + * 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 @@ -21,46 +21,65 @@ * questions. */ -/* @test +/* + * @test * @bug 6524424 * @requires (os.family == "windows") - * @summary JSlider Clicking In Tracks Behavior Inconsistent For Different Tick Spacings - * @author Pavel Porvatov + * @summary JSlider clicking in tracks behavior inconsistent for different tick spacings * @modules java.desktop/com.sun.java.swing.plaf.windows - * @run applet/manual=done bug6524424.html + * @library /java/awt/regtesthelpers + * @build PassFailJFrame + * @run main/manual bug6524424 */ -import java.awt.*; -import javax.swing.*; +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 extends JApplet { - public static void main(String[] args) { +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 e) { - e.printStackTrace(); - - return; + } catch (UnsupportedLookAndFeelException ex) { + PassFailJFrame.forceFail(ex.toString()); + return null; } TestPanel panel = new TestPanel(); - JFrame frame = new JFrame(); + JFrame frame = new JFrame("bug6524424"); 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); + return frame; } private static class TestPanel extends JPanel { From 6d2e15c890f2df025aabd120cdb64b456945ae81 Mon Sep 17 00:00:00 2001 From: Sergey Bylokhov Date: Tue, 11 Nov 2025 23:08:44 +0000 Subject: [PATCH 03/13] 8294314: Minimize disabled warnings in hotspot Reviewed-by: shade Backport-of: 7743345f6f73398f280fd18364b4cea10a6b0f2f --- make/common/MakeBase.gmk | 2 +- make/common/NativeCompilation.gmk | 7 ++- make/hotspot/lib/CompileGtest.gmk | 3 ++ make/hotspot/lib/CompileJvm.gmk | 61 ++++++++++++++++++++------- make/hotspot/lib/JvmOverrideFiles.gmk | 4 -- 5 files changed, 54 insertions(+), 23 deletions(-) diff --git a/make/common/MakeBase.gmk b/make/common/MakeBase.gmk index 2a06d8eb8b3..10ad3fa3916 100644 --- a/make/common/MakeBase.gmk +++ b/make/common/MakeBase.gmk @@ -199,7 +199,7 @@ $(eval $(call SetupLogging)) ################################################################################ -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 --git a/make/common/NativeCompilation.gmk b/make/common/NativeCompilation.gmk index af601bac1d4..75b93cef19c 100644 --- a/make/common/NativeCompilation.gmk +++ b/make/common/NativeCompilation.gmk @@ -363,18 +363,20 @@ define SetupCompileNativeFileBody 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 @@ define SetupCompileNativeFileBody 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 --git a/make/hotspot/lib/CompileGtest.gmk b/make/hotspot/lib/CompileGtest.gmk index 71fbf7c3dda..500c3f5b02a 100644 --- a/make/hotspot/lib/CompileGtest.gmk +++ b/make/hotspot/lib/CompileGtest.gmk @@ -103,9 +103,12 @@ $(eval $(call SetupJdkLibrary, BUILD_GTEST_LIBJVM, \ 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 --git a/make/hotspot/lib/CompileJvm.gmk b/make/hotspot/lib/CompileJvm.gmk index 508be109092..92a0b430c74 100644 --- a/make/hotspot/lib/CompileJvm.gmk +++ b/make/hotspot/lib/CompileJvm.gmk @@ -77,14 +77,17 @@ endif ################################################################################ # 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 @@ ifeq ($(DEBUG_LEVEL), fastdebug) 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 @@ $(eval $(call SetupJdkLibrary, BUILD_LIBJVM, \ 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 --git a/make/hotspot/lib/JvmOverrideFiles.gmk b/make/hotspot/lib/JvmOverrideFiles.gmk index d53694fb2df..377018cdb51 100644 --- a/make/hotspot/lib/JvmOverrideFiles.gmk +++ b/make/hotspot/lib/JvmOverrideFiles.gmk @@ -33,10 +33,6 @@ ifeq ($(TOOLCHAIN_TYPE), gcc) 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 - BUILD_LIBJVM_ad_$(HOTSPOT_TARGET_CPU_ARCH).cpp_CXXFLAGS := -Wno-nonnull 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 From c9f4ceb83efd55c40b164b147aaa6feb4fc4daf9 Mon Sep 17 00:00:00 2001 From: Elif Aslan Date: Wed, 12 Nov 2025 17:04:44 +0000 Subject: [PATCH 04/13] 8310915: Typo in aarch64.ad: "envcodings" Backport-of: 6f325db49365d3d06add5d194d4696a1428675fa --- src/hotspot/cpu/aarch64/aarch64.ad | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/hotspot/cpu/aarch64/aarch64.ad b/src/hotspot/cpu/aarch64/aarch64.ad index 967392b7eed..6f82608fc32 100644 --- a/src/hotspot/cpu/aarch64/aarch64.ad +++ b/src/hotspot/cpu/aarch64/aarch64.ad @@ -3398,7 +3398,7 @@ encode %{ } %} - /// mov envcodings + // mov encodings enc_class aarch64_enc_movw_imm(iRegI dst, immI src) %{ C2_MacroAssembler _masm(&cbuf); From 22fef0ac3e55d5c5f3af59b620c98a16db4c73eb Mon Sep 17 00:00:00 2001 From: Goetz Lindenmaier Date: Thu, 13 Nov 2025 17:01:45 +0000 Subject: [PATCH 05/13] 8347300: Don't exclude the "PATH" var from the environment when running app launchers in jpackage tests Reviewed-by: mbaesken Backport-of: 8374d1f6fff541bef426b668978c31186405089b --- .../helpers/jdk/jpackage/test/CfgFile.java | 115 ++++++++++++++---- .../helpers/jdk/jpackage/test/Comm.java | 39 ++++++ .../helpers/jdk/jpackage/test/Executor.java | 19 +-- .../helpers/jdk/jpackage/test/HelloApp.java | 20 ++- .../jdk/jpackage/test/JPackageCommand.java | 34 ++++-- .../helpers/jdk/jpackage/test/TKit.java | 27 ++-- .../jdk/jpackage/test/WindowsHelper.java | 95 ++++++++++++++- .../jpackage/share/AppLauncherEnvTest.java | 6 +- test/jdk/tools/jpackage/share/BasicTest.java | 2 +- .../jpackage/windows/WinChildProcessTest.java | 20 +-- 10 files changed, 295 insertions(+), 82 deletions(-) create mode 100644 test/jdk/tools/jpackage/helpers/jdk/jpackage/test/Comm.java diff --git a/test/jdk/tools/jpackage/helpers/jdk/jpackage/test/CfgFile.java b/test/jdk/tools/jpackage/helpers/jdk/jpackage/test/CfgFile.java index 31bf0520a31..2604e266d5a 100644 --- a/test/jdk/tools/jpackage/helpers/jdk/jpackage/test/CfgFile.java +++ b/test/jdk/tools/jpackage/helpers/jdk/jpackage/test/CfgFile.java @@ -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 @@ -25,53 +25,109 @@ 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); + 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)); - Map entries = data.get(section); - TKit.assertTrue(entries != null, String.format( - "Check section [%s] is found in [%s] cfg file", section, 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 void 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)); + } + + 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 void 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); + } + + 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 +136,32 @@ public static CfgFile readFromFile(Path path) throws IOException { 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 --git a/test/jdk/tools/jpackage/helpers/jdk/jpackage/test/Comm.java b/test/jdk/tools/jpackage/helpers/jdk/jpackage/test/Comm.java new file mode 100644 index 00000000000..23798f326fe --- /dev/null +++ b/test/jdk/tools/jpackage/helpers/jdk/jpackage/test/Comm.java @@ -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 --git a/test/jdk/tools/jpackage/helpers/jdk/jpackage/test/Executor.java b/test/jdk/tools/jpackage/helpers/jdk/jpackage/test/Executor.java index e94cbc79aac..c1c51f1ef55 100644 --- a/test/jdk/tools/jpackage/helpers/jdk/jpackage/test/Executor.java +++ b/test/jdk/tools/jpackage/helpers/jdk/jpackage/test/Executor.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2019, 2022, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2019, 2025, Oracle and/or its affiliates. All rights reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * * This code is free software; you can redistribute it and/or modify it @@ -54,7 +54,6 @@ public static Executor of(String... cmdline) { public Executor() { saveOutputType = new HashSet<>(Set.of(SaveOutputType.NONE)); - removePath = false; winEnglishOutput = false; } @@ -91,8 +90,8 @@ public Executor setExecutable(JavaTool v) { return setExecutable(v.getPath()); } - public Executor setRemovePath(boolean value) { - removePath = value; + public Executor removeEnvVar(String envVarName) { + removeEnvVars.add(Objects.requireNonNull(envVarName)); return this; } @@ -370,10 +369,12 @@ private Result runExecutable() throws IOException, InterruptedException { 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() + "..."); @@ -512,7 +513,7 @@ private static void trace(String msg) { private Path executable; private Set saveOutputType; private Path directory; - private boolean removePath; + private Set removeEnvVars = new HashSet<>(); private boolean winEnglishOutput; private String winTmpDir = null; diff --git a/test/jdk/tools/jpackage/helpers/jdk/jpackage/test/HelloApp.java b/test/jdk/tools/jpackage/helpers/jdk/jpackage/test/HelloApp.java index bc722e7acd9..a004dd421c1 100644 --- a/test/jdk/tools/jpackage/helpers/jdk/jpackage/test/HelloApp.java +++ b/test/jdk/tools/jpackage/helpers/jdk/jpackage/test/HelloApp.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2019, 2024, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2019, 2025, Oracle and/or its affiliates. All rights reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * * This code is free software; you can redistribute it and/or modify it @@ -464,13 +464,14 @@ private Executor getExecutor(String...args) { } final List launcherArgs = List.of(args); - return new Executor() + final var executor = new Executor() .setDirectory(outputFile.getParent()) .saveOutput(saveOutput) .dumpOutput() - .setRemovePath(removePath) .setExecutable(executablePath) - .addArguments(launcherArgs); + .addArguments(List.of(args)); + + return configureEnvironment(executor); } private boolean launcherNoExit; @@ -487,6 +488,14 @@ public static AppOutputVerifier assertApp(Path helloAppLauncher) { return new AppOutputVerifier(helloAppLauncher); } + public 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; @@ -496,4 +505,7 @@ public static AppOutputVerifier assertApp(Path helloAppLauncher) { 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 --git a/test/jdk/tools/jpackage/helpers/jdk/jpackage/test/JPackageCommand.java b/test/jdk/tools/jpackage/helpers/jdk/jpackage/test/JPackageCommand.java index d16f843988d..54532579a4f 100644 --- a/test/jdk/tools/jpackage/helpers/jdk/jpackage/test/JPackageCommand.java +++ b/test/jdk/tools/jpackage/helpers/jdk/jpackage/test/JPackageCommand.java @@ -570,8 +570,18 @@ public Path appLauncherCfgPath(String launcherName) { } 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 @@ public boolean isFakeRuntime(String msg) { 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 @@ public JPackageCommand ignoreDefaultRuntime(boolean v) { return this; } + public JPackageCommand ignoreFakeRuntime() { + if (isFakeRuntime()) { + ignoreDefaultRuntime(true); + } + return this; + } + public JPackageCommand ignoreDefaultVerbose(boolean v) { verifyMutable(); ignoreDefaultVerbose = v; @@ -876,7 +886,7 @@ public CfgFile readLauncherCfgFile(String launcherName) { if (isRuntime()) { return null; } - return ThrowingFunction.toFunction(CfgFile::readFromFile).apply( + return ThrowingFunction.toFunction(CfgFile::load).apply( appLauncherCfgPath(launcherName)); } diff --git a/test/jdk/tools/jpackage/helpers/jdk/jpackage/test/TKit.java b/test/jdk/tools/jpackage/helpers/jdk/jpackage/test/TKit.java index 45081f9efa7..e9f06e3512a 100644 --- a/test/jdk/tools/jpackage/helpers/jdk/jpackage/test/TKit.java +++ b/test/jdk/tools/jpackage/helpers/jdk/jpackage/test/TKit.java @@ -761,18 +761,18 @@ public void match(Path ... expected) { public void match(Set expected) { currentTest.notifyAssert(); var comm = Comm.compare(content, expected); - if (!comm.unique1.isEmpty() && !comm.unique2.isEmpty()) { + 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()) { + 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()) { + 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))); + baseDir, format(comm.common()), format(comm.unique2()))); } else { traceAssert(String.format( "assertDirectoryContentEquals(%s): Expected %s", @@ -785,10 +785,10 @@ public void contains(Path ... expected) { public void contains(Set expected) { currentTest.notifyAssert(); var comm = Comm.compare(content, expected); - if (!comm.unique2.isEmpty()) { + if (!comm.unique2().isEmpty()) { error(String.format( "assertDirectoryContentContains(%s): Some expected %s. Missing %s", - baseDir, format(comm.common), format(comm.unique2))); + baseDir, format(comm.common()), format(comm.unique2()))); } else { traceAssert(String.format( "assertDirectoryContentContains(%s): Expected %s", @@ -804,17 +804,6 @@ private DirectoryContentVerifier(Path baseDir, Set contents) { this.baseDir = baseDir; this.content = contents; } - private static 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); - } - } private static String format(Set paths) { return Arrays.toString( paths.stream().sorted().map(Path::toString).toArray( diff --git a/test/jdk/tools/jpackage/helpers/jdk/jpackage/test/WindowsHelper.java b/test/jdk/tools/jpackage/helpers/jdk/jpackage/test/WindowsHelper.java index 60006fc1944..7a853ca83f1 100644 --- a/test/jdk/tools/jpackage/helpers/jdk/jpackage/test/WindowsHelper.java +++ b/test/jdk/tools/jpackage/helpers/jdk/jpackage/test/WindowsHelper.java @@ -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; @@ -165,6 +168,90 @@ public static String getMsiProperty(JPackageCommand cmd, String propertyName) { .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"); } @@ -378,15 +465,15 @@ private static String queryRegistryValueCache(String keyPath, "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 --git a/test/jdk/tools/jpackage/share/AppLauncherEnvTest.java b/test/jdk/tools/jpackage/share/AppLauncherEnvTest.java index a16ff9c18f9..52016e6f4ab 100644 --- a/test/jdk/tools/jpackage/share/AppLauncherEnvTest.java +++ b/test/jdk/tools/jpackage/share/AppLauncherEnvTest.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2021, 2024, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2021, 2025, Oracle and/or its affiliates. All rights reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * * This code is free software; you can redistribute it and/or modify it @@ -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.configureEnvironment; import jdk.jpackage.test.TKit; /** @@ -53,6 +54,7 @@ public static void test() throws Exception { JPackageCommand cmd = JPackageCommand .helloAppImage(TEST_APP_JAVA + "*Hello") + .ignoreFakeRuntime() .addArguments("--java-options", "-D" + testAddDirProp + "=$APPDIR"); @@ -62,7 +64,7 @@ public static void test() throws Exception { final int attempts = 3; final int waitBetweenAttemptsSeconds = 5; - List output = new Executor() + List output = configureEnvironment(new Executor()) .saveOutput() .setExecutable(cmd.appLauncherPath().toAbsolutePath()) .addArguments("--print-env-var=" + envVarName) diff --git a/test/jdk/tools/jpackage/share/BasicTest.java b/test/jdk/tools/jpackage/share/BasicTest.java index 15c8836e7ac..0b967373dc9 100644 --- a/test/jdk/tools/jpackage/share/BasicTest.java +++ b/test/jdk/tools/jpackage/share/BasicTest.java @@ -72,7 +72,7 @@ public void testJpackageProps() { .saveConsoleOutput(true) .addArguments("--app-version", appVersion, "--arguments", "jpackage.app-version jpackage.app-path") - .ignoreDefaultRuntime(true); + .ignoreFakeRuntime(); cmd.executeAndAssertImageCreated(); Path launcherPath = cmd.appLauncherPath(); diff --git a/test/jdk/tools/jpackage/windows/WinChildProcessTest.java b/test/jdk/tools/jpackage/windows/WinChildProcessTest.java index 8bab8eac5fb..5b0ff9b1f01 100644 --- a/test/jdk/tools/jpackage/windows/WinChildProcessTest.java +++ b/test/jdk/tools/jpackage/windows/WinChildProcessTest.java @@ -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 @@ -27,7 +27,6 @@ * when System.exit(0) is invoked along with terminating java program. * @library /test/jdk/tools/jpackage/helpers * @requires os.family == "windows" - * @build WinChildProcessTest * @build jdk.jpackage.test.* * @build WinChildProcessTest * @run main/othervm -Xmx512m jdk.jpackage.test.Main @@ -41,27 +40,30 @@ import java.nio.file.Path; import jdk.jpackage.test.JPackageCommand; +import static jdk.jpackage.test.HelloApp.configureEnvironment; 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() + List output = configureEnvironment(new Executor()).saveOutput().dumpOutput() .setExecutable(cmd.appLauncherPath().toAbsolutePath()) .execute(0).getOutput(); String pidStr = output.get(0); @@ -76,10 +78,12 @@ public static void test() throws Throwable { 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); + } } } } From fadb26fbfa722692bda23cfa5a4e8599bce902d6 Mon Sep 17 00:00:00 2001 From: Elif Aslan Date: Thu, 13 Nov 2025 21:08:27 +0000 Subject: [PATCH 06/13] 8311588: C2: RepeatCompilation compiler directive does not choose stress seed randomly Backport-of: 3465179458d844fec4d0496aa3d0c31b34c4c345 --- src/hotspot/share/opto/compile.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/hotspot/share/opto/compile.cpp b/src/hotspot/share/opto/compile.cpp index 6404050b828..74074063bad 100644 --- a/src/hotspot/share/opto/compile.cpp +++ b/src/hotspot/share/opto/compile.cpp @@ -775,7 +775,7 @@ Compile::Compile( ciEnv* ci_env, ciMethod* target, int osr_bci, // 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 { From 23ee787c9e26b2b43bcab425f06908e97603fe30 Mon Sep 17 00:00:00 2001 From: Min Choi Date: Thu, 13 Nov 2025 21:30:42 +0000 Subject: [PATCH 07/13] 8324861: Exceptions::wrap_dynamic_exception() doesn't have ResourceMark Backport-of: 7d1a48807a482cd19156298ce21d9492f0d912da --- src/hotspot/share/utilities/exceptions.cpp | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/src/hotspot/share/utilities/exceptions.cpp b/src/hotspot/share/utilities/exceptions.cpp index cf9291f6dcf..499542235b9 100644 --- a/src/hotspot/share/utilities/exceptions.cpp +++ b/src/hotspot/share/utilities/exceptions.cpp @@ -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 @@ void Exceptions::wrap_dynamic_exception(bool is_indy, JavaThread* THREAD) { // 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 @@ void Exceptions::wrap_dynamic_exception(bool is_indy, JavaThread* THREAD) { // 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); } From c6186174ee609ad82e383b73eaf79430b239424d Mon Sep 17 00:00:00 2001 From: Min Choi Date: Fri, 14 Nov 2025 17:38:36 +0000 Subject: [PATCH 08/13] 8303959: tools/jpackage/share/RuntimePackageTest.java fails with java.lang.AssertionError missing files Backport-of: 5a6aa569aa279141193038dc2e61e18a8b24bc11 --- .../jpackage/share/RuntimePackageTest.java | 25 ++++++++++++++++--- 1 file changed, 21 insertions(+), 4 deletions(-) diff --git a/test/jdk/tools/jpackage/share/RuntimePackageTest.java b/test/jdk/tools/jpackage/share/RuntimePackageTest.java index cf4682fa1ac..b00d7a7be14 100644 --- a/test/jdk/tools/jpackage/share/RuntimePackageTest.java +++ b/test/jdk/tools/jpackage/share/RuntimePackageTest.java @@ -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; @@ -99,9 +100,25 @@ private static PackageTest init(Set types) { 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. From 1f14254fa7b5372e6c9497e8cc3bdfd15838e59a Mon Sep 17 00:00:00 2001 From: Elif Aslan Date: Fri, 14 Nov 2025 20:34:16 +0000 Subject: [PATCH 09/13] 8353661: Open source several swing tests batch5 Backport-of: 924638c471b0bf4a00a890ce6a3fd7e118cdd578 --- test/jdk/javax/swing/JSlider/bug4186062.java | 99 +++++++++++++ test/jdk/javax/swing/JSlider/bug4275631.java | 132 ++++++++++++++++++ test/jdk/javax/swing/JSlider/bug4382876.java | 110 +++++++++++++++ .../javax/swing/plaf/windows/bug4991587.java | 95 +++++++++++++ 4 files changed, 436 insertions(+) create mode 100644 test/jdk/javax/swing/JSlider/bug4186062.java create mode 100644 test/jdk/javax/swing/JSlider/bug4275631.java create mode 100644 test/jdk/javax/swing/JSlider/bug4382876.java create mode 100644 test/jdk/javax/swing/plaf/windows/bug4991587.java diff --git a/test/jdk/javax/swing/JSlider/bug4186062.java b/test/jdk/javax/swing/JSlider/bug4186062.java new file mode 100644 index 00000000000..1db2f1bba6c --- /dev/null +++ b/test/jdk/javax/swing/JSlider/bug4186062.java @@ -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 --git a/test/jdk/javax/swing/JSlider/bug4275631.java b/test/jdk/javax/swing/JSlider/bug4275631.java new file mode 100644 index 00000000000..4d0aa555721 --- /dev/null +++ b/test/jdk/javax/swing/JSlider/bug4275631.java @@ -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 --git a/test/jdk/javax/swing/JSlider/bug4382876.java b/test/jdk/javax/swing/JSlider/bug4382876.java new file mode 100644 index 00000000000..b9ec64aab21 --- /dev/null +++ b/test/jdk/javax/swing/JSlider/bug4382876.java @@ -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 --git a/test/jdk/javax/swing/plaf/windows/bug4991587.java b/test/jdk/javax/swing/plaf/windows/bug4991587.java new file mode 100644 index 00000000000..e4e4fde2b86 --- /dev/null +++ b/test/jdk/javax/swing/plaf/windows/bug4991587.java @@ -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); + } + } +} From cb258e5fba3767c343ed4bf54f3d2d6de6de2704 Mon Sep 17 00:00:00 2001 From: Satyen Subramaniam Date: Fri, 14 Nov 2025 23:42:07 +0000 Subject: [PATCH 10/13] 8305778: javax/swing/JTableHeader/6884066/bug6884066.java: Unexpected header's value; index = 4 value = E Backport-of: 2d7c50791bd79d9a140df12e38050c851423992c --- .../JTableHeader/6884066/bug6884066.java | 88 +++++++++++-------- 1 file changed, 53 insertions(+), 35 deletions(-) diff --git a/test/jdk/javax/swing/JTableHeader/6884066/bug6884066.java b/test/jdk/javax/swing/JTableHeader/6884066/bug6884066.java index 58926f64211..2ea4ba7f9f3 100644 --- a/test/jdk/javax/swing/JTableHeader/6884066/bug6884066.java +++ b/test/jdk/javax/swing/JTableHeader/6884066/bug6884066.java @@ -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) { From 2635b9deecbd6ec2c4324b1c67b94ab7458dab84 Mon Sep 17 00:00:00 2001 From: Goetz Lindenmaier Date: Tue, 18 Nov 2025 08:52:17 +0000 Subject: [PATCH 11/13] 8333569: jpackage tests must run app launchers with retries on Linux only Backport-of: ce312b3ecbbacaf23f4b2893898ce8de8cd53daa --- .../helpers/jdk/jpackage/test/HelloApp.java | 33 ++++++++++--------- .../jpackage/share/AppLauncherEnvTest.java | 10 ++---- .../jpackage/windows/WinChildProcessTest.java | 8 ++--- 3 files changed, 24 insertions(+), 27 deletions(-) diff --git a/test/jdk/tools/jpackage/helpers/jdk/jpackage/test/HelloApp.java b/test/jdk/tools/jpackage/helpers/jdk/jpackage/test/HelloApp.java index a004dd421c1..46aa2f1375f 100644 --- a/test/jdk/tools/jpackage/helpers/jdk/jpackage/test/HelloApp.java +++ b/test/jdk/tools/jpackage/helpers/jdk/jpackage/test/HelloApp.java @@ -351,16 +351,6 @@ public static final class AppOutputVerifier { this.outputFilePath = TKit.workDir().resolve(OUTPUT_FILENAME); this.params = new HashMap<>(); this.defaultLauncherArgs = new ArrayList<>(); - - if (TKit.isWindows()) { - // When running app launchers on Windows, clear users environment (JDK-8254920) - removePath(true); - } - } - - public AppOutputVerifier removePath(boolean v) { - removePath = v; - return this; } public AppOutputVerifier saveOutput(boolean v) { @@ -442,10 +432,7 @@ public Executor.Result execute(String... args) { if (launcherNoExit) { return getExecutor(args).executeWithoutExitCodeCheck(); } else { - final int attempts = 3; - final int waitBetweenAttemptsSeconds = 5; - return getExecutor(args).executeAndRepeatUntilExitCode(expectedExitCode, attempts, - waitBetweenAttemptsSeconds); + return HelloApp.execute(expectedExitCode, getExecutor(args)); } } @@ -475,7 +462,6 @@ private Executor getExecutor(String...args) { } private boolean launcherNoExit; - private boolean removePath; private boolean saveOutput; private final Path launcherPath; private Path outputFilePath; @@ -488,7 +474,22 @@ public static AppOutputVerifier assertApp(Path helloAppLauncher) { return new AppOutputVerifier(helloAppLauncher); } - public static Executor configureEnvironment(Executor executor) { + 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"); diff --git a/test/jdk/tools/jpackage/share/AppLauncherEnvTest.java b/test/jdk/tools/jpackage/share/AppLauncherEnvTest.java index 52016e6f4ab..772370b0f8c 100644 --- a/test/jdk/tools/jpackage/share/AppLauncherEnvTest.java +++ b/test/jdk/tools/jpackage/share/AppLauncherEnvTest.java @@ -30,7 +30,7 @@ import jdk.jpackage.test.JPackageCommand; import jdk.jpackage.test.Annotations.Test; import jdk.jpackage.test.Executor; -import static jdk.jpackage.test.HelloApp.configureEnvironment; +import static jdk.jpackage.test.HelloApp.configureAndExecute; import jdk.jpackage.test.TKit; /** @@ -62,16 +62,12 @@ public static void test() throws Exception { final String envVarName = envVarName(); - final int attempts = 3; - final int waitBetweenAttemptsSeconds = 5; - List output = configureEnvironment(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 --git a/test/jdk/tools/jpackage/windows/WinChildProcessTest.java b/test/jdk/tools/jpackage/windows/WinChildProcessTest.java index 5b0ff9b1f01..a83ef837331 100644 --- a/test/jdk/tools/jpackage/windows/WinChildProcessTest.java +++ b/test/jdk/tools/jpackage/windows/WinChildProcessTest.java @@ -40,7 +40,7 @@ import java.nio.file.Path; import jdk.jpackage.test.JPackageCommand; -import static jdk.jpackage.test.HelloApp.configureEnvironment; +import static jdk.jpackage.test.HelloApp.configureAndExecute; import jdk.jpackage.test.Annotations.Test; import jdk.jpackage.test.Executor; import jdk.jpackage.test.TKit; @@ -63,9 +63,9 @@ public static void test() { // Start the third party application launcher and dump and save the // output of the application - List output = configureEnvironment(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 From d7f888cbc1c545e0a7acbde69a209b98306731a2 Mon Sep 17 00:00:00 2001 From: Goetz Lindenmaier Date: Tue, 18 Nov 2025 08:56:44 +0000 Subject: [PATCH 12/13] 8366229: runtime/Thread/TooSmallStackSize.java runs with all collectors Backport-of: 075ebb4ee592c10879799a68ba79f782ee49b60d --- test/hotspot/jtreg/runtime/Thread/TooSmallStackSize.java | 1 + 1 file changed, 1 insertion(+) diff --git a/test/hotspot/jtreg/runtime/Thread/TooSmallStackSize.java b/test/hotspot/jtreg/runtime/Thread/TooSmallStackSize.java index 88e0e4d8d0b..1a113eb9952 100644 --- a/test/hotspot/jtreg/runtime/Thread/TooSmallStackSize.java +++ b/test/hotspot/jtreg/runtime/Thread/TooSmallStackSize.java @@ -28,6 +28,7 @@ * VMThreadStackSize values should result in an error message that shows * the minimum stack size value for each thread type. * @library /test/lib + * @requires vm.flagless * @modules java.base/jdk.internal.misc * java.management * @run driver TooSmallStackSize From a0082e675ddf14540bcdc70fb7b56663943631ca Mon Sep 17 00:00:00 2001 From: Goetz Lindenmaier Date: Tue, 18 Nov 2025 09:03:47 +0000 Subject: [PATCH 13/13] 8366844: Update and automate MouseDraggedOriginatedByScrollBarTest.java Backport-of: f1ee1b4a3d7c47b6f61b36b78504e3ec997a925a --- ...MouseDraggedOriginatedByScrollBarTest.java | 84 +++++++++++++------ 1 file changed, 57 insertions(+), 27 deletions(-) diff --git a/test/jdk/java/awt/List/MouseDraggedOriginatedByScrollBarTest.java b/test/jdk/java/awt/List/MouseDraggedOriginatedByScrollBarTest.java index 600d38fe393..6858359d6b4 100644 --- a/test/jdk/java/awt/List/MouseDraggedOriginatedByScrollBarTest.java +++ b/test/jdk/java/awt/List/MouseDraggedOriginatedByScrollBarTest.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2005, 2024, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2005, 2025, Oracle and/or its affiliates. All rights reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * * This code is free software; you can redistribute it and/or modify it @@ -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 @@ private static Frame createTestUI() { 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); } }