-
Notifications
You must be signed in to change notification settings - Fork 6.2k
5015261: NPE may be thrown if JDesktopIcon is set to null on a JInternalFrame #4989
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
Conversation
|
👋 Welcome back psadhukhan! A progress list of the required criteria for merging this PR into |
Webrevs
|
|
Does the null desktop icon is actually supported? I have set it to null in the constructor of JInternalFrame, and check how the SwingSet2 work when jdesktop frame is minimized, under all L&F I got NPE. But even if we fix that npe how the user will be able to "unmimimize" the window? Probably we should state that the null icon is unsupported? |
|
Will just stating null icon is unsupported do? I think in that case should we throw IAE? |
This icon field is protected so technically it can be changed w/o constructor and set method. So we have a choice:
We can do only the first one, or both. |
|
Any more comment on the modification? |
|
JInternalFrame.JDesktopIcon seems to be a bit of a mess overall. The class doc : This component represents an iconified version of a JInternalFrame. This API should NOT BE USED by Swing applications, I am not sure what that implies -iconification of a JInternalFrame isn't the same thing as setting it. Are the setter and getter there only for the benefit of a L&F and really should not be public at all ? The words "may" throw an NPE are not clear about when - I guess we aren't throwing an NPE right We should either prevent null being set or catch all those nulls. And what if it is null some action needs to be taken - as Shannon wrote - "whatever that is" On the basis that we need an icon else more problems occur I think we should just prevent it |
What we will do if the field will be set to null directly? Throw NPE at any point later when we will found null? |
The field is protected. If a subclasser wants to destroy the functionality of a class they are subclassing there are lots of ways they can do that. Just add advisory doc on the protected field too. |
ok, this is part of what this change do, probably the text should be rephrased there? |
I did that in 1st iteration of this PR..https://github.com/openjdk/jdk/pull/4989/files/2a2ab50ded3305f3a9e0f01e90417b484a0b2db4 @prrace Should I bring that fix back?
|
You are reading my "there are two options text" and the code you propose to bring back is NOT the option
Something like "subclassers must ensure this is set to a non-null value during construction and not set this to null" |
|
@prrace Any comment on this? I am just preventing "null being set" as was recommended. |
|
/csr |
|
@mrserb has indicated that a compatibility and specification (CSR) request is needed for this pull request. |
|
Please review CSR https://bugs.openjdk.java.net/browse/JDK-8272748 |
|
Could you change the bug and CSR summary, and of course the title of this PR ? |
| /** | ||
| * The icon that is displayed when this internal frame is iconified. | ||
| * Subclassers must ensure this is set to a non-null value | ||
| * during construction and nor subsequently set this to null. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
nor->not (looks like a typo I made in the CSR) as r and t keys are adjacent. I fixed the CSR but you'll have to to fix it here, otherwise seems fine
|
@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 302 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 22ef4f0.
Your commit was automatically rebased without conflicts. |
JInternalFrame.getDesktopIcon() can be null as setDesktopIcon() can be called with null value. There are many places in JInternalFrame where getDesktopIcon() is accessed without null check which might cause NPE.
Added null check for those cases.
Progress
Issue
Reviewers
Reviewing
Using
gitCheckout this PR locally:
$ git fetch https://git.openjdk.java.net/jdk pull/4989/head:pull/4989$ git checkout pull/4989Update a local copy of the PR:
$ git checkout pull/4989$ git pull https://git.openjdk.java.net/jdk pull/4989/headUsing Skara CLI tools
Checkout this PR locally:
$ git pr checkout 4989View PR using the GUI difftool:
$ git pr show -t 4989Using diff file
Download this PR as a diff file:
https://git.openjdk.java.net/jdk/pull/4989.diff