8327748: Convert javax/swing/JFileChooser/6798062/bug6798062.java applet test to main#18180
8327748: Convert javax/swing/JFileChooser/6798062/bug6798062.java applet test to main#18180prsadhuk wants to merge 7 commits intoopenjdk:masterfrom
Conversation
|
👋 Welcome back psadhukhan! A progress list of the required criteria for merging this PR into |
Webrevs
|
|
|
||
| public class bug6798062 { | ||
|
|
||
| private static final String instructionsText = """ |
There was a problem hiding this comment.
instructionsText may be capitalize as using capital letter is common convention for final variables.
There was a problem hiding this comment.
That is for constant, IIRC...
There was a problem hiding this comment.
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 . """; |
There was a problem hiding this comment.
| 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(() -> { |
There was a problem hiding this comment.
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.
| passFailJFrame.awaitAndCheck(); | ||
| } | ||
|
|
||
| private JComponent initialize() { |
There was a problem hiding this comment.
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.
There was a problem hiding this comment.
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() |
There was a problem hiding this comment.
Please use the builder helper method instead of new.
| If memory usage is increasing, click Fail else click Pass . """; | ||
|
|
||
| private static JSlider slider; | ||
| private static JFrame frame; |
There was a problem hiding this comment.
frame Can be moved inside createUI().
|
|
||
| private static JSlider slider; | ||
| private static JFrame frame; | ||
| private static JTextField tfLink; |
There was a problem hiding this comment.
tfLink and btnGC can be initialized inside initialize() and moved there.
There was a problem hiding this comment.
As I understood, testUI calls the passed method in EDT so I think it's better to init the swing variables there..
There was a problem hiding this comment.
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.
| 1. Create a link | ||
| 2. Copy path to the link into TextField |
There was a problem hiding this comment.
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.
There was a problem hiding this comment.
Could you amend the instructions to clarify them?
Define what is a link.
There was a problem hiding this comment.
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.
There was a problem hiding this comment.
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"?
There was a problem hiding this comment.
Create a new bug to improve and to clean up the test then.
There was a problem hiding this comment.
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.
There was a problem hiding this comment.
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 . """; |
There was a problem hiding this comment.
| 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; |
There was a problem hiding this comment.
SwingUtilities is unused now.
|
|
||
| private static JSlider slider; | ||
| private static JFrame frame; | ||
| private static JTextField tfLink; |
There was a problem hiding this comment.
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.
| folder = ShellFolder.getShellFolder(new File(tempDir)); | ||
| folder = ShellFolder.getShellFolder(new File(".")); |
There was a problem hiding this comment.
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.
There was a problem hiding this comment.
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?
There was a problem hiding this comment.
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.
There was a problem hiding this comment.
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.
| PassFailJFrame.forceFail(); | ||
| throw new RuntimeException(msg); |
There was a problem hiding this comment.
| PassFailJFrame.forceFail(); | |
| throw new RuntimeException(msg); | |
| PassFailJFrame.forceFail(msg); |
forceFail will throw the exception on the main thread.
| .instructions(INSTRUCTIONS) | ||
| .rows(10) |
There was a problem hiding this comment.
| .instructions(INSTRUCTIONS) | |
| .rows(10) | |
| .instructions(INSTRUCTIONS) | |
| .testTimeOut(10) | |
| .rows(10) |
This test will benefit from a longer time out.
|
@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: 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
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 |
|
/integrate |
|
Going to push as commit 782206b.
Your commit was automatically rebased without conflicts. |
Conversion of manual applet test to main based using PassFailJFrame manual framework
Progress
Issue
Reviewers
Reviewing
Using
gitCheckout this PR locally:
$ git fetch https://git.openjdk.org/jdk.git pull/18180/head:pull/18180$ git checkout pull/18180Update a local copy of the PR:
$ git checkout pull/18180$ git pull https://git.openjdk.org/jdk.git pull/18180/headUsing Skara CLI tools
Checkout this PR locally:
$ git pr checkout 18180View PR using the GUI difftool:
$ git pr show -t 18180Using diff file
Download this PR as a diff file:
https://git.openjdk.org/jdk/pull/18180.diff
Webrev
Link to Webrev Comment