Skip to content

Commit c2009ad

Browse files
authored
Merge branch 'openjdk:master' into backport-sendaoYan-e18e95ed-master
2 parents 796ecd7 + 4e092bd commit c2009ad

File tree

19 files changed

+780
-61
lines changed

19 files changed

+780
-61
lines changed

make/test/BuildTestLib.gmk

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -54,11 +54,9 @@ $(eval $(call SetupJavaCompilation, BUILD_TEST_LIB_JAR, \
5454
JAR := $(TEST_LIB_SUPPORT)/test-lib.jar, \
5555
DISABLED_WARNINGS := try deprecation rawtypes unchecked serial cast removal preview, \
5656
JAVAC_FLAGS := --add-exports java.base/sun.security.util=ALL-UNNAMED \
57-
--add-exports java.base/jdk.internal.classfile=ALL-UNNAMED \
58-
--add-exports java.base/jdk.internal.classfile.attribute=ALL-UNNAMED \
59-
--add-exports java.base/jdk.internal.classfile.constantpool=ALL-UNNAMED \
60-
--add-exports java.base/jdk.internal.classfile.java.lang.constant=ALL-UNNAMED \
6157
--add-exports java.base/jdk.internal.module=ALL-UNNAMED \
58+
--add-exports java.base/jdk.internal.org.objectweb.asm=ALL-UNNAMED \
59+
--add-exports java.base/jdk.internal.org.objectweb.asm.commons=ALL-UNNAMED \
6260
--enable-preview, \
6361
))
6462

src/java.desktop/windows/classes/com/sun/java/swing/plaf/windows/WindowsIconFactory.java

Lines changed: 9 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -882,8 +882,15 @@ public void paintIcon(Component c, Graphics g, int x, int y) {
882882
}
883883
}
884884
if (icon != null) {
885-
icon.paintIcon(c, g, x + VistaMenuItemCheckIconFactory.getIconWidth(),
886-
y + OFFSET);
885+
if (WindowsGraphicsUtils.isLeftToRight(c)) {
886+
icon.paintIcon(c, g,
887+
x + VistaMenuItemCheckIconFactory.getIconWidth(),
888+
y + OFFSET);
889+
} else {
890+
icon.paintIcon(c, g,
891+
x - VistaMenuItemCheckIconFactory.getIconWidth() + 2 * OFFSET,
892+
y + OFFSET);
893+
}
887894
}
888895
}
889896
private static WindowsMenuItemUIAccessor getAccessor(

src/java.desktop/windows/classes/com/sun/java/swing/plaf/windows/WindowsMenuItemUI.java

Lines changed: 17 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -43,6 +43,7 @@
4343
import javax.swing.JComponent;
4444
import javax.swing.JMenu;
4545
import javax.swing.JMenuItem;
46+
import javax.swing.SwingConstants;
4647
import javax.swing.UIManager;
4748
import javax.swing.plaf.ComponentUI;
4849
import javax.swing.plaf.UIResource;
@@ -215,8 +216,17 @@ static void paintMenuItem(WindowsMenuItemUIAccessor accessor, Graphics g,
215216

216217
if (lh.getCheckIcon() != null && lh.useCheckAndArrow()) {
217218
Rectangle rect = lr.getTextRect();
218-
219-
rect.x += lh.getAfterCheckIconGap();
219+
if (menuItem.getComponentOrientation().isLeftToRight()) {
220+
if (menuItem.getHorizontalTextPosition() != SwingConstants.LEADING
221+
&& menuItem.getHorizontalTextPosition() != SwingConstants.LEFT) {
222+
rect.x += lh.getAfterCheckIconGap();
223+
}
224+
} else {
225+
if (menuItem.getHorizontalTextPosition() != SwingConstants.LEADING
226+
&& menuItem.getHorizontalTextPosition() != SwingConstants.RIGHT) {
227+
rect.x -= lh.getAfterCheckIconGap();
228+
}
229+
}
220230

221231
lr.setTextRect(rect);
222232
}
@@ -232,7 +242,11 @@ static void paintMenuItem(WindowsMenuItemUIAccessor accessor, Graphics g,
232242
}
233243
if (lh.getCheckIcon() != null && lh.useCheckAndArrow()) {
234244
Rectangle rect = lr.getAccRect();
235-
rect.x += lh.getAfterCheckIconGap();
245+
if (menuItem.getComponentOrientation().isLeftToRight()) {
246+
rect.x += lh.getAfterCheckIconGap();
247+
} else {
248+
rect.x -= lh.getAfterCheckIconGap();
249+
}
236250
lr.setAccRect(rect);
237251
}
238252
SwingUtilities3.paintAccText(g, lh, lr, disabledForeground,

src/jdk.jpackage/windows/native/applauncher/WinLauncher.cpp

Lines changed: 24 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
/*
2-
* Copyright (c) 2020, 2024, Oracle and/or its affiliates. All rights reserved.
2+
* Copyright (c) 2020, 2025, Oracle and/or its affiliates. All rights reserved.
33
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
44
*
55
* This code is free software; you can redistribute it and/or modify it
@@ -210,6 +210,16 @@ class RunExecutorWithMsgLoop {
210210
};
211211

212212

213+
void enableConsoleCtrlHandler(bool enable) {
214+
if (!SetConsoleCtrlHandler(NULL, enable ? FALSE : TRUE)) {
215+
JP_THROW(SysError(tstrings::any() << "SetConsoleCtrlHandler(NULL, "
216+
<< (enable ? "FALSE" : "TRUE")
217+
<< ") failed",
218+
SetConsoleCtrlHandler));
219+
}
220+
}
221+
222+
213223
void launchApp() {
214224
// [RT-31061] otherwise UI can be left in back of other windows.
215225
::AllowSetForegroundWindow(ASFW_ANY);
@@ -256,6 +266,19 @@ void launchApp() {
256266
exec.arg(arg);
257267
});
258268

269+
exec.afterProcessCreated([&](HANDLE pid) {
270+
//
271+
// Ignore Ctrl+C in the current process.
272+
// This will prevent child process termination without allowing
273+
// it to handle Ctrl+C events.
274+
//
275+
// Disable the default Ctrl+C handler *after* the child process
276+
// has been created as it is inheritable and we want the child
277+
// process to have the default handler.
278+
//
279+
enableConsoleCtrlHandler(false);
280+
});
281+
259282
DWORD exitCode = RunExecutorWithMsgLoop::apply(exec);
260283

261284
exit(exitCode);

src/jdk.jpackage/windows/native/common/Executor.cpp

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
/*
2-
* Copyright (c) 2019, Oracle and/or its affiliates. All rights reserved.
2+
* Copyright (c) 2019, 2025, Oracle and/or its affiliates. All rights reserved.
33
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
44
*
55
* This code is free software; you can redistribute it and/or modify it
@@ -161,6 +161,10 @@ UniqueHandle Executor::startProcess(UniqueHandle* threadHandle) const {
161161
}
162162
}
163163

164+
if (afterProcessCreatedCallback) {
165+
afterProcessCreatedCallback(processInfo.hProcess);
166+
}
167+
164168
// Return process handle.
165169
return UniqueHandle(processInfo.hProcess);
166170
}

src/jdk.jpackage/windows/native/common/Executor.h

Lines changed: 12 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
/*
2-
* Copyright (c) 2019, Oracle and/or its affiliates. All rights reserved.
2+
* Copyright (c) 2019, 2025, Oracle and/or its affiliates. All rights reserved.
33
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
44
*
55
* This code is free software; you can redistribute it and/or modify it
@@ -26,6 +26,8 @@
2626
#ifndef EXECUTOR_H
2727
#define EXECUTOR_H
2828

29+
#include <functional>
30+
2931
#include "tstrings.h"
3032
#include "UniqueHandle.h"
3133

@@ -97,6 +99,14 @@ class Executor {
9799
*/
98100
int execAndWaitForExit() const;
99101

102+
/**
103+
* Call provided function after the process hass been created.
104+
*/
105+
Executor& afterProcessCreated(const std::function<void(HANDLE)>& v) {
106+
afterProcessCreatedCallback = v;
107+
return *this;
108+
}
109+
100110
private:
101111
UniqueHandle startProcess(UniqueHandle* threadHandle=0) const;
102112

@@ -106,6 +116,7 @@ class Executor {
106116
HANDLE jobHandle;
107117
tstring_array argsArray;
108118
std::wstring appPath;
119+
std::function<void(HANDLE)> afterProcessCreatedCallback;
109120
};
110121

111122
#endif // #ifndef EXECUTOR_H
Lines changed: 72 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,72 @@
1+
/*
2+
* Copyright Amazon.com Inc. or its affiliates. All Rights Reserved.
3+
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
4+
*
5+
* This code is free software; you can redistribute it and/or modify it
6+
* under the terms of the GNU General Public License version 2 only, as
7+
* published by the Free Software Foundation.
8+
*
9+
* This code is distributed in the hope that it will be useful, but WITHOUT
10+
* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
11+
* FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
12+
* version 2 for more details (a copy is included in the LICENSE file that
13+
* accompanied this code).
14+
*
15+
* You should have received a copy of the GNU General Public License version
16+
* 2 along with this work; if not, write to the Free Software Foundation,
17+
* Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
18+
*
19+
* Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
20+
* or visit www.oracle.com if you need additional information or have any
21+
* questions.
22+
*/
23+
24+
import java.awt.color.ColorSpace;
25+
import java.awt.color.ICC_Profile;
26+
import java.io.ByteArrayOutputStream;
27+
import java.io.ObjectOutputStream;
28+
29+
/**
30+
* @test
31+
* @bug 8369032
32+
* @summary Checks the size of the serialized ICC_Profile for standard and
33+
* non-standard profiles.
34+
*/
35+
public final class SerializedFormSize {
36+
37+
private static final ICC_Profile[] PROFILES = {
38+
ICC_Profile.getInstance(ColorSpace.CS_sRGB),
39+
ICC_Profile.getInstance(ColorSpace.CS_LINEAR_RGB),
40+
ICC_Profile.getInstance(ColorSpace.CS_CIEXYZ),
41+
ICC_Profile.getInstance(ColorSpace.CS_PYCC),
42+
ICC_Profile.getInstance(ColorSpace.CS_GRAY)
43+
};
44+
45+
public static void main(String[] args) throws Exception {
46+
for (ICC_Profile profile : PROFILES) {
47+
byte[] data = profile.getData();
48+
int dataSize = data.length;
49+
int min = 3; // At least version, name and data fields
50+
int max = 200; // Small enough to confirm no data saved
51+
52+
// Standard profile: should serialize to a small size, no data
53+
test(profile, min, max);
54+
// Non-standard profile: includes full data, but only once
55+
test(ICC_Profile.getInstance(data), dataSize, dataSize + max);
56+
}
57+
}
58+
59+
private static void test(ICC_Profile p, int min, int max) throws Exception {
60+
try (var bos = new ByteArrayOutputStream();
61+
var oos = new ObjectOutputStream(bos))
62+
{
63+
oos.writeObject(p);
64+
int size = bos.size();
65+
if (size < min || size > max) {
66+
System.err.println("Expected: >= " + min + " and <= " + max);
67+
System.err.println("Actual: " + size);
68+
throw new RuntimeException("Wrong size");
69+
}
70+
}
71+
}
72+
}
Lines changed: 64 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,64 @@
1+
/*
2+
* Copyright (c) 1999, 2025, Oracle and/or its affiliates. All rights reserved.
3+
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
4+
*
5+
* This code is free software; you can redistribute it and/or modify it
6+
* under the terms of the GNU General Public License version 2 only, as
7+
* published by the Free Software Foundation.
8+
*
9+
* This code is distributed in the hope that it will be useful, but WITHOUT
10+
* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
11+
* FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
12+
* version 2 for more details (a copy is included in the LICENSE file that
13+
* accompanied this code).
14+
*
15+
* You should have received a copy of the GNU General Public License version
16+
* 2 along with this work; if not, write to the Free Software Foundation,
17+
* Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
18+
*
19+
* Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
20+
* or visit www.oracle.com if you need additional information or have any
21+
* questions.
22+
*/
23+
24+
/*
25+
* @test
26+
* @bug 4235215
27+
* @summary Tests that Toolkit.getPrintJob() do not throw NPE
28+
* @library /java/awt/regtesthelpers
29+
* @build PassFailJFrame
30+
* @run main/manual bug4235215
31+
*/
32+
33+
import java.awt.Toolkit;
34+
import javax.swing.JButton;
35+
import javax.swing.JFrame;
36+
37+
public class bug4235215 {
38+
39+
private static final String INSTRUCTIONS = """
40+
Press "Print Dialog" button.
41+
If you see a print dialog, test passes.
42+
Click "Cancel" button to close it.""";
43+
44+
public static void main(String[] args) throws Exception {
45+
PassFailJFrame.builder()
46+
.title("bug4235215 Instructions")
47+
.instructions(INSTRUCTIONS)
48+
.columns(35)
49+
.testUI(bug4235215::createTestUI)
50+
.build()
51+
.awaitAndCheck();
52+
}
53+
54+
private static JFrame createTestUI() {
55+
JFrame frame = new JFrame("bug4235215");
56+
JButton button = new JButton("Print Dialog");
57+
button.addActionListener(ev -> {
58+
Toolkit.getDefaultToolkit().getPrintJob(frame, "Test Printing", null);
59+
});
60+
frame.add(button);
61+
frame.pack();
62+
return frame;
63+
}
64+
}

0 commit comments

Comments
 (0)