Skip to content

8327748: Convert javax/swing/JFileChooser/6798062/bug6798062.java applet test to main#18180

Closed
prsadhuk wants to merge 7 commits intoopenjdk:masterfrom
prsadhuk:JDK-8327748
Closed

8327748: Convert javax/swing/JFileChooser/6798062/bug6798062.java applet test to main#18180
prsadhuk wants to merge 7 commits intoopenjdk:masterfrom
prsadhuk:JDK-8327748

Conversation

@prsadhuk
Copy link
Contributor

@prsadhuk prsadhuk commented Mar 11, 2024

Conversion of manual applet test to main based using PassFailJFrame manual framework


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-8327748: Convert javax/swing/JFileChooser/6798062/bug6798062.java applet test to main (Bug - P4)

Reviewers

Reviewing

Using git

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

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

Using Skara CLI tools

Checkout this PR locally:
$ git pr checkout 18180

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

Using diff file

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

Webrev

Link to Webrev Comment

@bridgekeeper
Copy link

bridgekeeper bot commented Mar 11, 2024

👋 Welcome back psadhukhan! 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 openjdk bot added the rfr Pull request is ready for review label Mar 11, 2024
@openjdk
Copy link

openjdk bot commented Mar 11, 2024

@prsadhuk 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.

@openjdk openjdk bot added the client client-libs-dev@openjdk.org label Mar 11, 2024
@mlbridge
Copy link

mlbridge bot commented Mar 11, 2024


public class bug6798062 {

private static final String instructionsText = """
Copy link
Contributor

Choose a reason for hiding this comment

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

instructionsText may be capitalize as using capital letter is common convention for final variables.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

That is for constant, IIRC...

Copy link
Member

Choose a reason for hiding this comment

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

Either way is fine… And instructionsText is a constant but it's not public.

4. Press the Start button in the test window
5. Wait several minutes and observe in the Windows Task Manager
that Memory Usage of java process is not increasing
If menory usage is increasing, click Fail else click Pass . """;
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
If menory usage is increasing, click Fail else click Pass . """;
If memory usage is increasing, click Fail else click Pass . """;

.columns(35)
.build();

SwingUtilities.invokeAndWait(() -> {
Copy link
Member

Choose a reason for hiding this comment

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

I suggest using the testUI method of the builder which accepts a lambda expression that returns a frame. Calling the passed method reference or lambda expression on EDT, registering the frame with PassFailJFrame and its positioning is handled automatically.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

ok..updated...

passFailJFrame.awaitAndCheck();
}

private JComponent initialize() {
Copy link
Member

Choose a reason for hiding this comment

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

I suggest creating the files in the current directory instead of temp or home. When run with jtreg, the current directory is set to scratch which is automatically removed by jtreg, which ensures no files are left behind if the test fails to clean them up for whatever reason.

Copy link
Member

Choose a reason for hiding this comment

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

Likely, all the catch blocks which simply print stack traces should propagate the exception or rather in addition to printing the stack trace call PassFailJFrame.forceFail with a corresponding message.

The fail method of the test should also call PassFailJFrame.forceFail to fail the test.

public void init() {
add(initialize());
public static void main(String[] args) throws Exception {
PassFailJFrame passFailJFrame = new PassFailJFrame.Builder()
Copy link
Member

Choose a reason for hiding this comment

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

Please use the builder helper method instead of new.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Updated...

If memory usage is increasing, click Fail else click Pass . """;

private static JSlider slider;
private static JFrame frame;
Copy link
Contributor

Choose a reason for hiding this comment

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

frame Can be moved inside createUI().

Copy link
Contributor Author

Choose a reason for hiding this comment

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

ok


private static JSlider slider;
private static JFrame frame;
private static JTextField tfLink;
Copy link
Contributor

Choose a reason for hiding this comment

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

tfLink and btnGC can be initialized inside initialize() and moved there.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

As I understood, testUI calls the passed method in EDT so I think it's better to init the swing variables there..

Copy link
Member

Choose a reason for hiding this comment

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

As I understood, testUI calls the passed method in EDT so I think it's better to init the swing variables there..

Yes, that's true, if you pass a lambda expression to testUI, it is called on EDT.

Since initialize is called from createUI, both methods will be called on EDT.

Comment on lines +59 to +60
1. Create a link
2. Copy path to the link into TextField
Copy link
Member

Choose a reason for hiding this comment

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

I understand the instructions aren't new but I can't comprehend what it's required.

Does it mean a Windows shortcut, .lnk file? Seems like it's the case because getLinkLocation is called which resolves a shortcut to its original file.

Can the text field be pre-populated with a default? There could be shortcuts on Desktop, there are many shortcuts in the Start menu.

Copy link
Member

Choose a reason for hiding this comment

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

Could you amend the instructions to clarify them?

Define what is a link.

Copy link
Member

Choose a reason for hiding this comment

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

It seems a Windows shortcut is crucial to reproducing the original problem, if it is, the handler for the Start button could show an error message about this fact.

Perhaps, if this link cannot be converted to a file in MyThread constructor, FileNotFoundException should be propagated and caught in the Start button actionPerformed handler to show an error message and let the tester use another Windows shortcut.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

SInce this exercise is just to convert applet to main, I tried to keep the instructions same (although I agree it seems ambiguous and I also am not clear what needs to be done) which seems to be ok with the tester since 2009 when the test was written.
I think whatever test change needs to be done should be done in JDK-8146446 as till then this test will not be run..

ELse if you disagree, what you propose to be written in the "instructions"?

Copy link
Member

Choose a reason for hiding this comment

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

Create a new bug to improve and to clean up the test then.

Copy link
Member

@aivanov-jdk aivanov-jdk Mar 12, 2024

Choose a reason for hiding this comment

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

At the same time, I think you should use the term “shortcut (.lnk file)” in the instructions so that it's clear.

The thing is .lnk files are known as shortcuts for most users, even though in Windows Shell API uses link internally which is reflected in the file extension.

Copy link
Member

Choose a reason for hiding this comment

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

Create a new bug to improve and to clean up the test then.

I see, there's an existing bug—JDK-8146446—against this test. Although the bug describes that memory usage somewhat grows while the background thread is running, it actually does. It has just grown for me from 100MB to 300MB. Running System.gc reduces the memory consumption to 200 MB.

4. Press the Start button in the test window
5. Wait several minutes and observe in the Windows Task Manager
that Memory Usage of java process is not increasing
If memory usage is increasing, click Fail else click Pass . """;
Copy link
Member

Choose a reason for hiding this comment

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

Suggested change
If memory usage is increasing, click Fail else click Pass . """;
If memory usage is increasing, click Fail else click Pass.""";

import javax.swing.JPanel;
import javax.swing.JSlider;
import javax.swing.JTextField;
import javax.swing.SwingUtilities;
Copy link
Member

Choose a reason for hiding this comment

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

SwingUtilities is unused now.


private static JSlider slider;
private static JFrame frame;
private static JTextField tfLink;
Copy link
Member

Choose a reason for hiding this comment

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

As I understood, testUI calls the passed method in EDT so I think it's better to init the swing variables there..

Yes, that's true, if you pass a lambda expression to testUI, it is called on EDT.

Since initialize is called from createUI, both methods will be called on EDT.

Comment on lines +88 to +108
folder = ShellFolder.getShellFolder(new File(tempDir));
folder = ShellFolder.getShellFolder(new File("."));
Copy link
Member

Choose a reason for hiding this comment

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

I wonder if it was expected that there are files in the directory. Like yes, so I could be wrong. I assumed files were created but no file is created, instead the files in this directory is listed. The expected result is that each file in the directory creates a new ShellFolder instance.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

I think it's needed to have some files in the directory..
This test is problemlisted actually and as per this comment it needs to be tested on a directory with some files in it but sometimes, in CI system temp folder may have thousand of files so I think we should revert back to "java.io.tmpdir" for this test sprint and figure out the fix for the tmpdir in JDK-8146446...Any objection?

Copy link
Member

Choose a reason for hiding this comment

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

One way to handle it is to create a number of files in the current directory, the scratch directory that jtreg provides and then rely on jtreg to remove it. Or to create a temp directory in the current directory and create files there.

We have no control over how many files are in the temporary directory, however, in most cases it's not empty.

Copy link
Member

Choose a reason for hiding this comment

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

I think we should revert back to "java.io.tmpdir" for this test sprint and figure out the fix for the tmpdir in JDK-8146446...Any objection?

Sounds reasonable.

Comment on lines 176 to 177
PassFailJFrame.forceFail();
throw new RuntimeException(msg);
Copy link
Member

Choose a reason for hiding this comment

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

Suggested change
PassFailJFrame.forceFail();
throw new RuntimeException(msg);
PassFailJFrame.forceFail(msg);

forceFail will throw the exception on the main thread.

Comment on lines +79 to +80
.instructions(INSTRUCTIONS)
.rows(10)
Copy link
Member

Choose a reason for hiding this comment

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

Suggested change
.instructions(INSTRUCTIONS)
.rows(10)
.instructions(INSTRUCTIONS)
.testTimeOut(10)
.rows(10)

This test will benefit from a longer time out.

@openjdk
Copy link

openjdk bot commented Mar 12, 2024

@prsadhuk This change now passes all automated pre-integration checks.

ℹ️ This project also has non-automated pre-integration requirements. Please see the file CONTRIBUTING.md for details.

After integration, the commit message for the final commit will be:

8327748: Convert javax/swing/JFileChooser/6798062/bug6798062.java applet test to main

Reviewed-by: aivanov

You can use pull request commands such as /summary, /contributor and /issue to adjust it as needed.

At the time when this comment was updated there had been 94 new commits pushed to the master branch:

  • 0776fff: 8327794: RISC-V: enable extension features based on impid (Rivos specific change)
  • cfd9209: 8327751: Convert javax/swing/JInternalFrame/6726866/bug6726866.java applet test to main
  • 2cf3524: 8325433: Type annotations on primitive types are not linked
  • 5056902: 8327361: Update some comments after JDK-8139457
  • 78beb03: 8327750: Convert javax/swing/JFileChooser/FileFilterDescription/FileFilterDescription.java applet test to main
  • 1f43fa0: 8326661: sun/java2d/cmm/ColorConvertOp/ColConvTest.java assumes profiles were generated by LCMS
  • 013aff8: 8326606: Test javax/swing/text/BoxView/6494356/bug6494356.java performs a synchronization on a value based class
  • b92440f: 8247972: incorrect implementation of JVM TI GetObjectMonitorUsage
  • 139681a: 8326497: Window.toFront() fails for iconified windows on Linux
  • 9f7aff4: 8327788: G1: Improve concurrent reference processing documentation
  • ... and 84 more: https://git.openjdk.org/jdk/compare/b7540df6a4279c63e69d32b9d9834f7a427478d1...master

As there are no conflicts, your changes will automatically be rebased on top of these commits when integrating. If you prefer to avoid this automatic rebasing, please check the documentation for the /integrate command for further details.

➡️ To integrate this PR with the above commit message to the master branch, type /integrate in a new comment.

@openjdk openjdk bot added the ready Pull request is ready to be integrated label Mar 12, 2024
@prsadhuk
Copy link
Contributor Author

/integrate

@openjdk
Copy link

openjdk bot commented Mar 12, 2024

Going to push as commit 782206b.
Since your change was applied there have been 94 commits pushed to the master branch:

  • 0776fff: 8327794: RISC-V: enable extension features based on impid (Rivos specific change)
  • cfd9209: 8327751: Convert javax/swing/JInternalFrame/6726866/bug6726866.java applet test to main
  • 2cf3524: 8325433: Type annotations on primitive types are not linked
  • 5056902: 8327361: Update some comments after JDK-8139457
  • 78beb03: 8327750: Convert javax/swing/JFileChooser/FileFilterDescription/FileFilterDescription.java applet test to main
  • 1f43fa0: 8326661: sun/java2d/cmm/ColorConvertOp/ColConvTest.java assumes profiles were generated by LCMS
  • 013aff8: 8326606: Test javax/swing/text/BoxView/6494356/bug6494356.java performs a synchronization on a value based class
  • b92440f: 8247972: incorrect implementation of JVM TI GetObjectMonitorUsage
  • 139681a: 8326497: Window.toFront() fails for iconified windows on Linux
  • 9f7aff4: 8327788: G1: Improve concurrent reference processing documentation
  • ... and 84 more: https://git.openjdk.org/jdk/compare/b7540df6a4279c63e69d32b9d9834f7a427478d1...master

Your commit was automatically rebased without conflicts.

@openjdk openjdk bot added the integrated Pull request has been integrated label Mar 12, 2024
@openjdk openjdk bot closed this Mar 12, 2024
@openjdk openjdk bot removed ready Pull request is ready to be integrated rfr Pull request is ready for review labels Mar 12, 2024
@openjdk
Copy link

openjdk bot commented Mar 12, 2024

@prsadhuk Pushed as commit 782206b.

💡 You may see a message that your pull request was closed with unmerged commits. This can be safely ignored.

@prsadhuk prsadhuk deleted the JDK-8327748 branch March 12, 2024 15:18
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

client client-libs-dev@openjdk.org integrated Pull request has been integrated

Development

Successfully merging this pull request may close these issues.

4 participants