Skip to content

Commit 6955273

Browse files
authored
Merge pull request #1971 from SAP/pr-jdk-17.0.16+4
Merge to tag jdk-17.0.16+4
2 parents 2282930 + 08de2ba commit 6955273

38 files changed

+2177
-70
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/awt/Toolkit/Headless/HeadlessToolkit.java

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

24-
import javax.imageio.ImageIO;
25-
import java.awt.*;
24+
import java.awt.AWTEvent;
25+
import java.awt.Cursor;
26+
import java.awt.Dimension;
27+
import java.awt.EventQueue;
28+
import java.awt.Font;
29+
import java.awt.FontMetrics;
30+
import java.awt.Graphics2D;
31+
import java.awt.GraphicsConfiguration;
32+
import java.awt.GraphicsEnvironment;
33+
import java.awt.HeadlessException;
34+
import java.awt.Image;
35+
import java.awt.Insets;
36+
import java.awt.Point;
37+
import java.awt.Toolkit;
2638
import java.awt.datatransfer.Clipboard;
2739
import java.awt.event.AWTEventListener;
2840
import java.awt.event.KeyEvent;
@@ -35,16 +47,16 @@
3547
import java.io.File;
3648
import java.io.FileInputStream;
3749
import java.io.IOException;
38-
import java.net.URL;
3950
import java.util.Map;
4051

52+
import javax.imageio.ImageIO;
53+
4154
/*
4255
* @test
4356
* @summary Check that Toolkit methods do not throw unexpected exceptions
4457
* in headless mode
4558
* @run main/othervm -Djava.awt.headless=true HeadlessToolkit
4659
*/
47-
4860
public class HeadlessToolkit {
4961

5062
class awtEventListener implements AWTEventListener {
@@ -275,13 +287,12 @@ void doTest() throws IOException {
275287
im = tk.createImage(image.getAbsolutePath());
276288
im.flush();
277289

278-
}
279-
280-
im = tk.getImage(new URL("https://openjdk.org/images/openjdk.png"));
281-
im.flush();
290+
im = tk.getImage(image.toURI().toURL());
291+
im.flush();
282292

283-
im = tk.createImage(new URL("https://openjdk.org/images/openjdk.png"));
284-
im.flush();
293+
im = tk.createImage(image.toURI().toURL());
294+
im.flush();
295+
}
285296

286297
MemoryImageSource mis;
287298
int pixels[] = new int[50 * 50];

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: 66 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,66 @@
1+
/*
2+
* Copyright (c) 2002, 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 4614881
27+
* @summary Ensure that client decorated frames can be brought to the front
28+
* via mouse click on the title pane.
29+
* @library /java/awt/regtesthelpers
30+
* @build PassFailJFrame
31+
* @run main/manual bug4614881
32+
*/
33+
34+
import java.awt.FlowLayout;
35+
import java.awt.Toolkit;
36+
import javax.swing.JDialog;
37+
import javax.swing.JFrame;
38+
39+
public class bug4614881 {
40+
41+
private static final String INSTRUCTIONS = """
42+
Select a native window so that it obscures the client decorated frame.
43+
Select the decorated frame by clicking on the title pane.
44+
If the decorated frame is brought to the front, then test passes else fails.""";
45+
46+
public static void main(String[] args) throws Exception {
47+
PassFailJFrame.builder()
48+
.title("bug4614881 Instructions")
49+
.instructions(INSTRUCTIONS)
50+
.columns(35)
51+
.testUI(bug4614881::createTestUI)
52+
.build()
53+
.awaitAndCheck();
54+
}
55+
56+
private static JFrame createTestUI() {
57+
Toolkit.getDefaultToolkit().setDynamicLayout(true);
58+
JFrame.setDefaultLookAndFeelDecorated(true);
59+
JDialog.setDefaultLookAndFeelDecorated(true);
60+
final JFrame frame = new JFrame("4614881 - Decorated Frame");
61+
frame.setSize(600, 400);
62+
frame.setResizable(false);
63+
frame.getContentPane().setLayout(new FlowLayout());
64+
return frame;
65+
}
66+
}
Lines changed: 86 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,86 @@
1+
/*
2+
* Copyright (c) 2000, 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 4131008
27+
* @summary JInternalFrame should refresh title after it changing
28+
* @library /java/awt/regtesthelpers
29+
* @build PassFailJFrame
30+
* @run main/manual bug4131008
31+
*/
32+
33+
import java.awt.event.ActionEvent;
34+
import java.awt.event.ActionListener;
35+
36+
import javax.swing.JButton;
37+
import javax.swing.JDesktopPane;
38+
import javax.swing.JFrame;
39+
import javax.swing.JInternalFrame;
40+
import javax.swing.UIManager;
41+
42+
public class bug4131008 {
43+
44+
private static final String INSTRUCTIONS = """
45+
Press button "Change title" at the internal frame "Old".
46+
If title of this frame will replaced by "New",
47+
then test passed, else test fails.""";
48+
49+
public static void main(String[] args) throws Exception {
50+
51+
UIManager.setLookAndFeel("com.sun.java.swing.plaf.motif.MotifLookAndFeel");
52+
53+
PassFailJFrame.builder()
54+
.title("bug4131008 Instructions")
55+
.instructions(INSTRUCTIONS)
56+
.columns(50)
57+
.testUI(bug4131008::createTestUI)
58+
.build()
59+
.awaitAndCheck();
60+
}
61+
62+
private static JFrame createTestUI() {
63+
JFrame frame = new JFrame("bug4131008");
64+
JInternalFrame jif = new JInternalFrame("Old");
65+
JDesktopPane jdp = new JDesktopPane();
66+
frame.setContentPane(jdp);
67+
68+
jif.setSize(150, 100);
69+
jif.setVisible(true);
70+
JButton bt = new JButton("Change title");
71+
bt.addActionListener(new ActionListener() {
72+
public void actionPerformed(ActionEvent e) {
73+
jif.setTitle("New");
74+
}
75+
});
76+
jif.getContentPane().add(bt);
77+
jdp.add(jif);
78+
try {
79+
jif.setSelected(true);
80+
} catch (Exception e) {
81+
throw new RuntimeException(e);
82+
}
83+
frame.setSize(300, 200);
84+
return frame;
85+
}
86+
}
Lines changed: 70 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,70 @@
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 4176136
27+
* @summary Default close operation JInternalFrame.DO_NOTHING_ON_CLOSE works correctly
28+
* @library /java/awt/regtesthelpers
29+
* @build PassFailJFrame
30+
* @run main/manual bug4176136
31+
*/
32+
33+
34+
import javax.swing.JDesktopPane;
35+
import javax.swing.JFrame;
36+
import javax.swing.JInternalFrame;
37+
38+
public class bug4176136 {
39+
40+
private static final String INSTRUCTIONS = """
41+
Click the close button of the internal frame.
42+
You will see the close button activate,
43+
but nothing else should happen.
44+
If the internal frame closes, the test fails.
45+
If it doesn't close, the test passes.""";
46+
47+
public static void main(String[] args) throws Exception {
48+
PassFailJFrame.builder()
49+
.title("bug4176136 Instructions")
50+
.instructions(INSTRUCTIONS)
51+
.columns(25)
52+
.testUI(bug4176136::createTestUI)
53+
.build()
54+
.awaitAndCheck();
55+
}
56+
57+
private static JFrame createTestUI() {
58+
JFrame frame = new JFrame("bug4176136");
59+
JDesktopPane dp = new JDesktopPane();
60+
frame.add(dp);
61+
JInternalFrame inf = new JInternalFrame();
62+
dp.add(inf);
63+
inf.setDefaultCloseOperation(JInternalFrame.DO_NOTHING_ON_CLOSE);
64+
inf.setSize(100, 100);
65+
inf.setClosable(true);
66+
inf.setVisible(true);
67+
frame.setSize(200, 200);
68+
return frame;
69+
}
70+
}

0 commit comments

Comments
 (0)