Skip to content

Commit fd8adb2

Browse files
author
Datadog Syncup Service
committed
Merge branch 'upstream-master'
2 parents 35c712f + 5a4b8cf commit fd8adb2

24 files changed

+761
-820
lines changed

test/hotspot/jtreg/serviceability/sa/TestJhsdbJstackLineNumbers.java

Lines changed: 8 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
/*
2-
* Copyright (c) 2020, 2021, Oracle and/or its affiliates. All rights reserved.
2+
* Copyright (c) 2020, 2024, 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
@@ -35,6 +35,7 @@
3535

3636
/**
3737
* @test
38+
* @bug 8214226 8243500
3839
* @requires vm.hasSA
3940
* @requires os.arch=="amd64" | os.arch=="x86_64"
4041
* @requires os.family=="windows" | os.family == "linux" | os.family == "mac"
@@ -53,7 +54,7 @@
5354
*
5455
* The test works by spawning a process that sits in a 10 line loop in the busywork() method,
5556
* all while the main test does repeated jstacks on the process. The expectation is
56-
* that at least 5 of the lines in the busywork() loop will eventually show up in at
57+
* that at least 4 of the lines in the busywork() loop will eventually show up in at
5758
* least one of the jstack runs.
5859
*/
5960

@@ -94,8 +95,11 @@ public static void main(String... args) {
9495
public class TestJhsdbJstackLineNumbers {
9596
// This is the number of lines in the busywork main loop
9697
static final int TOTAL_BUSYWORK_LOOP_LINES = 10;
97-
// The minimum number of lines that we must at some point see in the jstack output
98-
static final int MIN_BUSYWORK_LOOP_LINES = 5;
98+
// The minimum number of lines that we must see at some point in the jstack output.
99+
// There's always a chance we could see fewer, but the chances are so low that
100+
// it is unlikely to ever happen. We can always decrease the odds by lowering
101+
// the required number of lines or increasing the number of jstack runs.
102+
static final int MIN_BUSYWORK_LOOP_LINES = 4;
99103

100104
static final int MAX_NUMBER_OF_JSTACK_RUNS = 25;
101105

test/jdk/ProblemList.txt

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -701,7 +701,6 @@ javax/swing/AbstractButton/6711682/bug6711682.java 8060765 windows-all,macosx-al
701701
javax/swing/JFileChooser/6396844/TwentyThousandTest.java 8198003 generic-all
702702
javax/swing/JFileChooser/8194044/FileSystemRootTest.java 8327236 windows-all
703703
javax/swing/JPopupMenu/6800513/bug6800513.java 7184956 macosx-all
704-
javax/swing/JTabbedPane/8007563/Test8007563.java 8051591 generic-all
705704
javax/swing/JTabbedPane/4624207/bug4624207.java 8064922 macosx-all
706705
javax/swing/SwingUtilities/TestBadBreak/TestBadBreak.java 8160720 generic-all
707706
javax/swing/JFileChooser/6798062/bug6798062.java 8146446 windows-all

test/jdk/java/awt/Desktop/MailTest.java

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

24+
import java.awt.Desktop;
25+
import java.io.IOException;
26+
import java.lang.reflect.InvocationTargetException;
27+
import java.net.URI;
28+
import javax.swing.JPanel;
29+
30+
import jtreg.SkippedException;
31+
2432
/*
2533
* @test
2634
* @bug 6255196
2735
* @summary Verifies the function of methods mail() and mail(java.net.URI uri).
28-
* @library /java/awt/regtesthelpers
29-
* @build PassFailJFrame
36+
* @library /java/awt/regtesthelpers /test/lib
37+
* @build PassFailJFrame jtreg.SkippedException
3038
* @run main/manual MailTest
3139
*/
3240

33-
import java.awt.Desktop;
34-
import java.io.IOException;
35-
import java.lang.reflect.InvocationTargetException;
36-
import java.net.URI;
37-
import javax.swing.JPanel;
38-
3941
public class MailTest extends JPanel {
4042

4143
static final String INSTRUCTIONS = """
@@ -48,18 +50,7 @@ public class MailTest extends JPanel {
4850
""";
4951

5052
private MailTest() {
51-
if (!Desktop.isDesktopSupported()) {
52-
PassFailJFrame.log("Class java.awt.Desktop is not supported on " +
53-
"current platform. Farther testing will not be performed");
54-
PassFailJFrame.forcePass();
55-
}
56-
5753
Desktop desktop = Desktop.getDesktop();
58-
if (!desktop.isSupported(Desktop.Action.MAIL)) {
59-
PassFailJFrame.log("Action.MAIL is not supported.");
60-
PassFailJFrame.forcePass();
61-
}
62-
6354
/*
6455
* Part 1: launch the mail composing window without a mailto URI.
6556
*/
@@ -103,6 +94,15 @@ private MailTest() {
10394

10495
public static void main(String[] args) throws InterruptedException,
10596
InvocationTargetException {
97+
if (!Desktop.isDesktopSupported()) {
98+
throw new SkippedException("Class java.awt.Desktop is not supported " +
99+
"on current platform. Further testing will not be performed");
100+
}
101+
102+
if (!Desktop.getDesktop().isSupported(Desktop.Action.MAIL)) {
103+
throw new SkippedException("Action.MAIL is not supported.");
104+
}
105+
106106
PassFailJFrame.builder()
107107
.title("Mail Test")
108108
.splitUI(MailTest::new)
Lines changed: 141 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,141 @@
1+
/*
2+
* Copyright (c) 2003, 2024, 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+
import java.awt.BorderLayout;
25+
import java.awt.Button;
26+
import java.awt.EventQueue;
27+
import java.awt.Frame;
28+
import java.awt.Point;
29+
import java.awt.Robot;
30+
import java.awt.event.ComponentAdapter;
31+
import java.awt.event.ComponentEvent;
32+
import java.util.concurrent.CountDownLatch;
33+
import java.util.concurrent.TimeUnit;
34+
35+
/*
36+
* @test
37+
* @key headful
38+
* @bug 4009555
39+
* @summary Unit test for a new method in Container class: getMousePosition(boolean)
40+
* while Container resized.
41+
*/
42+
43+
public class ContainerResizeMousePositionTest {
44+
private static Frame frame;
45+
private static Button button;
46+
private static Robot robot;
47+
private static volatile Point frameLocation;
48+
private static volatile Point newLoc;
49+
private static boolean testSucceeded = false;
50+
51+
private static final CountDownLatch eventCaught = new CountDownLatch(1);
52+
53+
public static void main(String[] args) throws Exception {
54+
try {
55+
robot = new Robot();
56+
EventQueue.invokeAndWait(() -> createAndShowUI());
57+
robot.waitForIdle();
58+
robot.delay(1000);
59+
testUI();
60+
} finally {
61+
EventQueue.invokeAndWait(() -> {
62+
if (frame != null) {
63+
frame.dispose();
64+
}
65+
});
66+
}
67+
}
68+
69+
private static void createAndShowUI() {
70+
frame = new Frame("Testing getMousePosition() after resize");
71+
button = new Button("Button");
72+
frame.setLayout(new BorderLayout());
73+
frame.add(button);
74+
frame.setSize(200, 200);
75+
frame.setLocationRelativeTo(null);
76+
frame.setVisible(true);
77+
}
78+
79+
private static void testUI() throws Exception {
80+
EventQueue.invokeAndWait(() -> {
81+
frameLocation = frame.getLocationOnScreen();
82+
newLoc = new Point(frame.getWidth() + 10, frame.getHeight() + 10);
83+
});
84+
85+
robot.mouseMove(frameLocation.x + newLoc.x, frameLocation.y + newLoc.y);
86+
EventQueue.invokeAndWait(() -> {
87+
button.addComponentListener(new ResizeAdapter());
88+
frame.setSize(frame.getWidth() * 2, frame.getHeight() * 2);
89+
frame.validate();
90+
});
91+
robot.waitForIdle();
92+
robot.delay(500);
93+
94+
if (!eventCaught.await(2, TimeUnit.SECONDS)) {
95+
throw new RuntimeException("componentResized Event isn't"
96+
+ " received within a timeout");
97+
}
98+
99+
if (!testSucceeded) {
100+
throw new RuntimeException("Container.getMousePosition(boolean)"
101+
+ " returned incorrect result while Container resized");
102+
}
103+
}
104+
105+
static class ResizeAdapter extends ComponentAdapter {
106+
int testStageCounter = 0;
107+
@Override
108+
public void componentResized(ComponentEvent e) {
109+
Point pTrue = frame.getMousePosition(true);
110+
if (frame.getMousePosition(false) == null) {
111+
testStageCounter++;
112+
System.out.println("""
113+
TEST STAGE 1 PASSED:
114+
Container.getMousePosition(false)
115+
returned NULL over Child Component
116+
during resize.
117+
""");
118+
}
119+
if (pTrue != null) {
120+
testStageCounter++;
121+
System.out.println("""
122+
TEST STAGE 2 PASSED:
123+
Container.getMousePosition(true)
124+
returned NON-NULL over Child Component
125+
during resize.
126+
""");
127+
}
128+
if (pTrue != null && pTrue.x == newLoc.x && pTrue.y == newLoc.y) {
129+
testStageCounter++;
130+
System.out.println("""
131+
TEST STAGE 3 PASSED:
132+
Container.getMousePosition(true)
133+
returned correct result over Child Component
134+
during resize.
135+
""");
136+
}
137+
testSucceeded = testStageCounter == 3;
138+
eventCaught.countDown();
139+
}
140+
}
141+
}
10.5 KB
Loading

0 commit comments

Comments
 (0)