Skip to content

8339791: Refactor MiscUndecorated/ActiveAWTWindowTest.java #26471

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
wants to merge 1 commit into
base: master
Choose a base branch
from

Conversation

srmandal
Copy link

@srmandal srmandal commented Jul 25, 2025

The java/awt/Frame/MiscUndecorated/ActiveAWTWindowTest.java test uses object monitors and wait/notify to synchronise actions in the test.

Using CountDownLatch could make the test simpler, shorter, clearer.
Tested the code on a windows-x64, macos-x64 and lnux-x64 machines and the test is working as expected.


Progress

  • Change must be properly reviewed (1 review required, with at least 1 Reviewer)
  • Change must not contain extraneous whitespace
  • Commit message must refer to an issue

Issue

  • JDK-8339791: Refactor MiscUndecorated/ActiveAWTWindowTest.java (Bug - P4)

Reviewing

Using git

Checkout this PR locally:
$ git fetch https://git.openjdk.org/jdk.git pull/26471/head:pull/26471
$ git checkout pull/26471

Update a local copy of the PR:
$ git checkout pull/26471
$ git pull https://git.openjdk.org/jdk.git pull/26471/head

Using Skara CLI tools

Checkout this PR locally:
$ git pr checkout 26471

View PR using the GUI difftool:
$ git pr show -t 26471

Using diff file

Download this PR as a diff file:
https://git.openjdk.org/jdk/pull/26471.diff

Using Webrev

Link to Webrev Comment

@bridgekeeper
Copy link

bridgekeeper bot commented Jul 25, 2025

👋 Welcome back smandalika! A progress list of the required criteria for merging this PR into master will be added to the body of your pull request. There are additional pull request commands available for use with this pull request.

@openjdk
Copy link

openjdk bot commented Jul 25, 2025

❗ This change is not yet ready to be integrated.
See the Progress checklist in the description for automated requirements.

@openjdk openjdk bot added the rfr Pull request is ready for review label Jul 25, 2025
@openjdk
Copy link

openjdk bot commented Jul 25, 2025

@srmandal The following label will be automatically applied to this pull request:

  • client

When this pull request is ready to be reviewed, an "RFR" email will be sent to the corresponding mailing list. If you would like to change these labels, use the /label pull request command.

@mlbridge
Copy link

mlbridge bot commented Jul 25, 2025

Webrevs

@srmandal
Copy link
Author

Can someone take a quick look and provide feedback on this simple refactoring change ?

private final Object lock3 = new Object();
private static final CountDownLatch windowActivatedLatch = new CountDownLatch(1);
private static final CountDownLatch windowDeactivatedLatch = new CountDownLatch(1);
private static final CountDownLatch windowFocusGainedLatch = new CountDownLatch(1);
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I see where we decrement this latch but i do not see where we check it or wait on it. Is it really needed?

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

also no need to use ExtendedRobot as all I can see is mousePress/mouseRelease which can be used from java.awt.Robot class itself..

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

static final variables can be capitalized.

Copy link
Contributor

@kumarabhi006 kumarabhi006 left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Few more observations :

  1. Add a space wherever application. At L76... try {
  2. Don't think it is required to print stack trace, you can throw it in RTE.
  3. At L165, robot.waitForIdle(5 * delay);
  4. Access UI components on EDT. e.g L166 etc.
  5. Can remove //captureScreenAndSave(); and System.err.println("Test failed!"); lines

private final Object lock3 = new Object();
private static final CountDownLatch windowActivatedLatch = new CountDownLatch(1);
private static final CountDownLatch windowDeactivatedLatch = new CountDownLatch(1);
private static final CountDownLatch windowFocusGainedLatch = new CountDownLatch(1);
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

static final variables can be capitalized.

private final Object lock3 = new Object();
private static final CountDownLatch windowActivatedLatch = new CountDownLatch(1);
private static final CountDownLatch windowDeactivatedLatch = new CountDownLatch(1);
private static final CountDownLatch windowFocusGainedLatch = new CountDownLatch(1);
private boolean passed = true;
private final int delay = 150;
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
private final int delay = 150;
private final int DELAY = 150;

@@ -93,13 +97,7 @@ private void initializeGUI() {
frame.addWindowFocusListener(new WindowFocusListener() {
public void windowGainedFocus(WindowEvent event) {
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

add @OverRide for all overridden methods.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
client [email protected] rfr Pull request is ready for review
Development

Successfully merging this pull request may close these issues.

4 participants