-
Notifications
You must be signed in to change notification settings - Fork 5.4k
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
8278620: properties installed by javax.swing.LookAndFeel installColors and installColorsAndFont are not uninstalled #10565
Conversation
…s and installColorsAndFont are not uninstalled Many installDefaults methods set the font, foreground, and background on objects but their inverse methods uninstallDefaults do not remove them. I've added an inverse method to remove the colors and font to call for the uninstallDefaults methods that install defaults. AquaButtonUI can call its super since it would otherwise be repeated code. BasicComboBoxUI (weirdly) installs the properties again when it should be uninstalling them, so I changed. I noticed that, in a few subclasses, only one of calls to the super of installDefaults and uninstallDefaults are made. That is, an overridden installDefaults may call its super while the overridden uninstallDefaults does not call its super (or vise versa). These classes are: AquaTabbedPaneUI, SynthMenuItemUI, SynthSplitPaneUI, and XTextAreaPeer.
👋 Welcome back SWinxy! A progress list of the required criteria for merging this PR into |
Webrevs
|
@SWinxy This pull request has been inactive for more than 4 weeks and will be automatically closed if another 4 weeks passes without any activity. To avoid this, simply add a new comment to the pull request. Feel free to ask for assistance if you need help with progressing this pull request towards integration! |
I've started looking at this. It looks good, yet I just skimmed through the changes without thoroughly reviewing, I haven't run the tests yet. |
Same as Alexey. It looks OK. I was not sure about new public API for the convenience method but |
/csr |
@prrace has indicated that a compatibility and specification (CSR) request is needed for this pull request. @SWinxy please create a CSR request for issue JDK-8278620 with the correct fix version. This pull request cannot be integrated until the CSR request is approved. |
Can the CSR be skipped if the methods are made package-private? |
Well, yes, except you can't do that because they are called from other packages. |
You could move the methods to some internal place like SwingUtilities2.java. |
@SWinxy This pull request has been inactive for more than 4 weeks and will be automatically closed if another 4 weeks passes without any activity. To avoid this, simply add a new comment to the pull request. Feel free to ask for assistance if you need help with progressing this pull request towards integration! |
CSR at https://bugs.openjdk.org/browse/JDK-8298350, no worries |
I have made a number of edits to the CSR. |
Only difference is that I added an Oxford comma
Done. The only thing I want is the oxford comma in the documentation to separate the background color and font wording. |
This change cause 23 test cases to fail across the platforms:
One JCK test fails; from a quick look, it's because the font is now uninstalled where it wasn't previously. |
So I thought we'd got past the testing since a CSR was proposed. The CSR should have waited.
So all the test failures are blocker problem .. @aivanov-jdk, do any of the jtreg test failures characterise the JCK failure ? |
100%. I'll see what I can learn from the failed tests, but my hunch is that many fail due to incorrect assumptions. |
I confirmed it's a test problem. The JCK test needs to be updated. Details are in a confidential comment in JBS. Do I need to submit a bug against JCK?
The failure of The test calls The failure in As for the closed test failure, it doesn't look related. A component being painted is null. It shouldn't happen. |
@SWinxy This pull request has been inactive for more than 4 weeks and will be automatically closed if another 4 weeks passes without any activity. To avoid this, simply add a new comment to the pull request. Feel free to ask for assistance if you need help with progressing this pull request towards integration! |
I'm really not sure how to fix these. I've tried digging into the tests. It looks like uninstalling the fonts from the components screws with other parts of Swing, specifically that delegates are calling |
Found 👏 the 👏 problem! Removing the font from the JPanel causes a cascade of other components not getting the correct font objects when the component tree is updated. That is, the second time the font is installed, it is somehow different. In |
Heh, stuff like this happens much too often when you work on the JDK ;) |
Figured it out. When setting a |
Good to know but ..
Sorry, but I don't think we should do this. FontUIResource is something devised by Swing, for Swing. Did you actually try all 3 platforms ? And if a default font prevents the FontUIResource from being installed, how does it get installed the in the first place ? It seems you would have to explicitly track whether the app set the font omn the JComponent rather than using this mechanism .. and if it did not then ignore whatever the font is ?? |
The font is null when it's created. Calling
D'oh.
Sounds like the path would be to undo my last commit and just put a note in the code. |
That is what I guessed. Accidental or deliberate ? I'd have to spend time to know.
But then there'd either be the correct font not installed or something else bad ? Maybe we are going about this all wrong ? This is code relied upon by tens of thousands of applications written over a period of 25 years. Testing on every platform of every test we have is a bare minimum. In the end my point is that unless (and until) we see some application complain, these proactive changes are a bad trade-off. |
This is the code of jdk/src/java.desktop/share/classes/java/awt/Component.java Lines 1912 to 1927 in b4ea807
Until the UI is shown, there's no heavyweight peer, so the default font doesn't get set. Even more, a jdk/src/java.desktop/share/classes/javax/swing/JLabel.java Lines 176 to 182 in b4ea807
jdk/src/java.desktop/share/classes/javax/swing/JPanel.java Lines 85 to 90 in b4ea807
Thus, a font is (always) set on a However, if the font is reset to The default font gets set in jdk/src/java.desktop/windows/classes/sun/awt/windows/WComponentPeer.java Lines 640 to 643 in b4ea807
jdk/src/java.desktop/unix/classes/sun/awt/X11/XWindow.java Lines 380 to 383 in b4ea807
I agree. AWT should not depend on Swing.
With where the testing led us, I'm inclined to think that the omission of nullifying the font in Yes, a The common rule for Swing: if a property is There are issues where font doesn't get reset even though it should. The latest example that comes to my mind is JDK-6753661 and #12180. Were there others? This current bug JDK-8278620 was submitted as the result of work on JDK-8277817 and #6603 where an object had been serialized, if I remember correctly, but the serialized form cannot be read because a class is removed in a later version of JDK. (The The description of JDK-8278620 states
Perhaps, font property should be left untouched just like it is now. However, resetting the color properties — foreground and background — doesn't seem to cause any issues. As such, the scope of this PR could be reduced to adding the As a matter of fact, I ran the client tests with the latest changeset. The set of failing tests remains the same:
Only the So, this hasn't helped. |
This reverts commit 1cc4222.
@SWinxy this pull request can not be integrated into git checkout 8278620
git fetch https://git.openjdk.org/jdk master
git merge FETCH_HEAD
# resolve conflicts and follow the instructions given by git merge
git commit -m "Merge master"
git push |
# Conflicts: # src/java.desktop/macosx/classes/com/apple/laf/AquaButtonUI.java
Apologies for the delay. I wrongly assumed that making the fonts FontUIResources would fix it. I only ran the tests on macOS, which is absolutely my fault. I'm not testing enough before submitting PRs. 😔
I don't think it was deliberate. Probably this same issue was ran into back then, and the easiest thing to do was to not remove the font.
And I'm also not sure why! I'll do some more investigating. Thanks for the writeup, Alexey. |
@SWinxy This pull request has been inactive for more than 4 weeks and will be automatically closed if another 4 weeks passes without any activity. To avoid this, simply add a new comment to the pull request. Feel free to ask for assistance if you need help with progressing this pull request towards integration! |
@SWinxy This pull request has been inactive for more than 8 weeks and will now be automatically closed. If you would like to continue working on this pull request in the future, feel free to reopen it! This can be done using the |
Many
installDefaults
methods set the font, foreground, and background on objects but their inverse methodsuninstallDefaults
do not remove them. I've added an inverse method to remove the colors and font to call for theuninstallDefaults
methods that install defaults.AquaButtonUI
can call its super since it would otherwise be repeated code.BasicComboBoxUI
(weirdly) installs the properties again when it should be uninstalling them, so I changed.I noticed that, in a few subclasses, only one of calls to the super of
installDefaults
anduninstallDefaults
are made. That is, an overriddeninstallDefaults
may call its super while the overriddenuninstallDefaults
does not call its super (or vise versa). These classes are:AquaTabbedPaneUI
,SynthMenuItemUI
,SynthSplitPaneUI
, andXTextAreaPeer
.Sorry I couldn't write a test; I wasn't sure how I should have accessed the protected variable aside from creating extending classes for each class that changed.
See also #6603, where this issue was discovered.
Progress
Issues
Reviewing
Using
git
Checkout this PR locally:
$ git fetch https://git.openjdk.org/jdk.git pull/10565/head:pull/10565
$ git checkout pull/10565
Update a local copy of the PR:
$ git checkout pull/10565
$ git pull https://git.openjdk.org/jdk.git pull/10565/head
Using Skara CLI tools
Checkout this PR locally:
$ git pr checkout 10565
View PR using the GUI difftool:
$ git pr show -t 10565
Using diff file
Download this PR as a diff file:
https://git.openjdk.org/jdk/pull/10565.diff
Webrev
Link to Webrev Comment