Skip to content

Commit 9f9699e

Browse files
author
Datadog Syncup Service
committed
Merge branch 'upstream-master'
2 parents b74637c + 4c59024 commit 9f9699e

File tree

15 files changed

+528
-59
lines changed

15 files changed

+528
-59
lines changed

make/modules/java.desktop/lib/Awt2dLibraries.gmk

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -299,7 +299,7 @@ $(eval $(call SetupJdkLibrary, BUILD_LIBLCMS, \
299299
common/awt/debug \
300300
libawt/java2d, \
301301
HEADERS_FROM_SRC := $(LIBLCMS_HEADERS_FROM_SRC), \
302-
DISABLED_WARNINGS_gcc := format-nonliteral type-limits \
302+
DISABLED_WARNINGS_gcc := format-nonliteral \
303303
misleading-indentation undef unused-function stringop-truncation, \
304304
DISABLED_WARNINGS_clang := tautological-compare format-nonliteral undef, \
305305
DISABLED_WARNINGS_microsoft := 4819, \

test/hotspot/jtreg/compiler/intrinsics/string/TestStringIntrinsics.java

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -155,6 +155,7 @@ private void checkIntrinsics(Operation op, Method m, String latin1, String utf16
155155
char cL = latin1.charAt(indexL);
156156
char cU = utf16.charAt(indexU);
157157
invokeAndCheck(m, cL - cU, latin1, latin1.replace(cL, cU));
158+
invokeAndCheck(m, cU - cL, latin1.replace(cL, cU), latin1);
158159
invokeAndCheck(m, cU - cL, utf16, utf16.replace(cU, cL));
159160

160161
// Different lengths

test/jdk/java/net/InetAddress/IsReachableViaLoopbackTest.java

Lines changed: 8 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
/*
2-
* Copyright (c) 2015, 2022, Oracle and/or its affiliates. All rights reserved.
2+
* Copyright (c) 2015, 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
@@ -21,22 +21,24 @@
2121
* questions.
2222
*/
2323

24-
import java.io.*;
25-
import java.net.*;
26-
import java.util.*;
24+
import java.io.IOException;
25+
import java.net.InetAddress;
26+
import java.net.NetworkInterface;
2727

2828
/**
2929
* @test
3030
* @bug 8135305
3131
* @key intermittent
32+
* @library /test/lib
3233
* @summary ensure we can't ping external hosts via loopback if
34+
* @run main IsReachableViaLoopbackTest
3335
*/
3436

3537
public class IsReachableViaLoopbackTest {
3638
public static void main(String[] args) {
3739
try {
38-
InetAddress addr = InetAddress.getByName("localhost");
39-
InetAddress remoteAddr = InetAddress.getByName("bugs.openjdk.org");
40+
InetAddress addr = InetAddress.getLoopbackAddress();
41+
InetAddress remoteAddr = InetAddress.getByName("23.197.138.208"); // use literal address to avoid DNS checks
4042
if (!addr.isReachable(10000))
4143
throw new RuntimeException("Localhost should always be reachable");
4244
NetworkInterface inf = NetworkInterface.getByInetAddress(addr);
@@ -54,7 +56,6 @@ public static void main(String[] args) {
5456
} else {
5557
System.out.println("inf == null");
5658
}
57-
5859
} catch (IOException e) {
5960
throw new RuntimeException("Unexpected exception:" + e);
6061
}

test/jdk/java/net/InetAddress/getOriginalHostName.java

Lines changed: 12 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
/*
2-
* Copyright (c) 2015, 2018, Oracle and/or its affiliates. All rights reserved.
2+
* Copyright (c) 2015, 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
@@ -41,7 +41,9 @@ public class getOriginalHostName {
4141
public static void main(String[] args) throws Exception {
4242
final String HOST = "dummyserver.java.net";
4343
InetAddress ia = null;
44-
ia = InetAddress.getByName(HOST);
44+
ia = getInetAddress(HOST);
45+
if (ia != null) testInetAddress(ia, HOST);
46+
ia = InetAddress.getByAddress(HOST, new byte[] { 1, 2, 3, 4});
4547
testInetAddress(ia, HOST);
4648
ia = InetAddress.getByName("255.255.255.0");
4749
testInetAddress(ia, null);
@@ -53,6 +55,14 @@ public static void main(String[] args) throws Exception {
5355
testInetAddress(ia, ia.getHostName());
5456
}
5557

58+
private static InetAddress getInetAddress(String host) {
59+
try {
60+
return InetAddress.getByName(host);
61+
} catch (java.net.UnknownHostException uhe) {
62+
System.out.println("Skipping " + host + " due to " + uhe);
63+
return null;
64+
}
65+
}
5666

5767
private static void testInetAddress(InetAddress ia, String expected)
5868
throws Exception {
Lines changed: 107 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,107 @@
1+
/*
2+
* Copyright (c) 2001, 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 4140643
27+
* @summary Tests that Motif menus open with both Alt-key and Meta-key
28+
* @key headful
29+
* @run main bug4140643
30+
*/
31+
32+
import java.awt.Robot;
33+
import java.awt.event.KeyEvent;
34+
import javax.swing.JButton;
35+
import javax.swing.JFrame;
36+
import javax.swing.JMenu;
37+
import javax.swing.JMenuBar;
38+
import javax.swing.JMenuItem;
39+
import javax.swing.SwingUtilities;
40+
import javax.swing.UIManager;
41+
import javax.swing.UnsupportedLookAndFeelException;
42+
43+
public class bug4140643 {
44+
private static JFrame frame;
45+
private static JMenu menu;
46+
private static volatile boolean isPopMenuVisible;
47+
48+
public static void main(String[] args) throws Exception {
49+
Robot robot = new Robot();
50+
try {
51+
SwingUtilities.invokeAndWait(() -> {
52+
try {
53+
UIManager.setLookAndFeel(
54+
"com.sun.java.swing.plaf.motif.MotifLookAndFeel");
55+
} catch (ClassNotFoundException | InstantiationException
56+
| UnsupportedLookAndFeelException
57+
| IllegalAccessException e) {
58+
throw new RuntimeException(e);
59+
}
60+
frame = new JFrame("bug4140643");
61+
62+
menu = new JMenu("File");
63+
menu.setMnemonic(KeyEvent.VK_F);
64+
menu.add(new JMenuItem("Open..."));
65+
menu.add(new JMenuItem("Save"));
66+
67+
JMenuBar mbar = new JMenuBar();
68+
mbar.add(menu);
69+
frame.setJMenuBar(mbar);
70+
71+
frame.add(new JButton("Click Here"));
72+
frame.pack();
73+
frame.setLocationRelativeTo(null);
74+
frame.setVisible(true);
75+
});
76+
robot.waitForIdle();
77+
robot.delay(1000);
78+
if (System.getProperty("os.name").contains("OS X")) {
79+
robot.keyPress(KeyEvent.VK_CONTROL);
80+
robot.keyPress(KeyEvent.VK_ALT);
81+
robot.keyPress(KeyEvent.VK_F);
82+
robot.keyRelease(KeyEvent.VK_F);
83+
robot.keyRelease(KeyEvent.VK_ALT);
84+
robot.keyRelease(KeyEvent.VK_CONTROL);
85+
} else {
86+
robot.keyPress(KeyEvent.VK_ALT);
87+
robot.keyPress(KeyEvent.VK_F);
88+
robot.keyRelease(KeyEvent.VK_F);
89+
robot.keyRelease(KeyEvent.VK_ALT);
90+
}
91+
robot.waitForIdle();
92+
robot.delay(1000);
93+
SwingUtilities.invokeAndWait(() -> {
94+
isPopMenuVisible = menu.isPopupMenuVisible();
95+
});
96+
if (!isPopMenuVisible) {
97+
throw new RuntimeException("Menu popup is not shown");
98+
}
99+
} finally {
100+
SwingUtilities.invokeAndWait(() -> {
101+
if (frame != null) {
102+
frame.dispose();
103+
}
104+
});
105+
}
106+
}
107+
}
Lines changed: 100 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,100 @@
1+
/*
2+
* Copyright (c) 2001, 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 4146588
27+
* @summary JMenu.setMenuLocation has no effect
28+
* @key headful
29+
* @run main bug4146588
30+
*/
31+
32+
import java.awt.Point;
33+
import java.awt.Rectangle;
34+
import java.awt.Robot;
35+
import javax.swing.JFrame;
36+
import javax.swing.JMenu;
37+
import javax.swing.JMenuBar;
38+
import javax.swing.SwingUtilities;
39+
40+
public class bug4146588 {
41+
42+
private static JFrame fr;
43+
private static JMenu menu;
44+
private static volatile Point loc;
45+
private static volatile Point popupLoc;
46+
private static volatile Point menuLoc;
47+
private static volatile Rectangle frameBounds;
48+
private static volatile Rectangle popupBounds;
49+
50+
public static void main(String[] args) throws Exception {
51+
Robot robot = new Robot();
52+
try {
53+
SwingUtilities.invokeAndWait(() -> {
54+
fr = new JFrame("bug4146588 frame");
55+
56+
JMenuBar menubar = new JMenuBar();
57+
menu = new JMenu("Menu");
58+
menu.add("Item 1");
59+
menu.add("Item 2");
60+
menu.add("Item 3");
61+
menu.setMenuLocation(150, 150);
62+
menubar.add(menu);
63+
fr.setJMenuBar(menubar);
64+
65+
fr.setSize(400, 400);
66+
fr.setLocationRelativeTo(null);
67+
fr.setVisible(true);
68+
});
69+
robot.waitForIdle();
70+
robot.delay(1000);
71+
SwingUtilities.invokeAndWait(() -> {
72+
menu.doClick(0);
73+
});
74+
robot.waitForIdle();
75+
robot.delay(200);
76+
SwingUtilities.invokeAndWait(() -> {
77+
popupLoc = menu.getPopupMenu().getLocationOnScreen();
78+
menuLoc = menu.getLocationOnScreen();
79+
frameBounds = fr.getBounds();
80+
popupBounds = menu.getPopupMenu().getBounds();
81+
});
82+
System.out.println(popupLoc);
83+
System.out.println(popupBounds);
84+
System.out.println(frameBounds);
85+
System.out.println(menuLoc);
86+
if (!(popupLoc.getX()
87+
> ((frameBounds.getX() + frameBounds.getWidth() / 2) - popupBounds.getWidth()))
88+
&& (popupLoc.getY()
89+
> ((frameBounds.getY() + frameBounds.getHeight() / 2) - popupBounds.getHeight()))) {
90+
throw new RuntimeException("popup is not at center of frame");
91+
}
92+
} finally {
93+
SwingUtilities.invokeAndWait(() -> {
94+
if (fr != null) {
95+
fr.dispose();
96+
}
97+
});
98+
}
99+
}
100+
}
Lines changed: 90 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,90 @@
1+
/*
2+
* Copyright (c) 2001, 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 4342646
27+
* @summary Tests that very long menus are properly placed on the screen.
28+
* @key headful
29+
* @run main bug4342646
30+
*/
31+
32+
import java.awt.Point;
33+
import java.awt.Robot;
34+
35+
import javax.swing.JFrame;
36+
import javax.swing.JMenu;
37+
import javax.swing.JMenuBar;
38+
import javax.swing.JMenuItem;
39+
import javax.swing.SwingUtilities;
40+
41+
public class bug4342646 {
42+
43+
private static JFrame frame;
44+
private static JMenu menu;
45+
private static volatile Point popupLoc;
46+
private static volatile Point menuLoc;
47+
48+
public static void main(String[] args) throws Exception {
49+
Robot robot = new Robot();
50+
try {
51+
SwingUtilities.invokeAndWait(() -> {
52+
JMenuBar mbar = new JMenuBar();
53+
menu = new JMenu("Menu");
54+
menu.add(new JMenuItem(
55+
"AAAAAAAAAAAAAAAAAAAAAAAAAAAA" +
56+
"AAAAAAAAAAAAAAAAAAAAAAAAAAAAA" +
57+
"AAAAAAAAAAAAAAAAAAAAAAAAAAAAAA" +
58+
"AAAAAAAAAAAAAAAAAAAAAAA"));
59+
mbar.add(menu);
60+
61+
frame = new JFrame("4342646");
62+
frame.setJMenuBar(mbar);
63+
frame.setBounds(10, 10, 200, 100);
64+
frame.setVisible(true);
65+
});
66+
robot.waitForIdle();
67+
robot.delay(1000);
68+
SwingUtilities.invokeAndWait(() -> {
69+
menu.doClick();
70+
});
71+
robot.waitForIdle();
72+
robot.delay(200);
73+
SwingUtilities.invokeAndWait(() -> {
74+
popupLoc = menu.getPopupMenu().getLocationOnScreen();
75+
menuLoc = menu.getLocationOnScreen();
76+
});
77+
System.out.println(menuLoc);
78+
System.out.println(popupLoc);
79+
if (popupLoc.getX() < menuLoc.getX()) {
80+
throw new RuntimeException("PopupMenu is incorrectly placed at left of menu");
81+
}
82+
} finally {
83+
SwingUtilities.invokeAndWait(() -> {
84+
if (frame != null) {
85+
frame.dispose();
86+
}
87+
});
88+
}
89+
}
90+
}

0 commit comments

Comments
 (0)