Skip to content

7169951: SwingSet2 throws NullPointerException with Nimbus L&F #11984

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

Closed
wants to merge 1 commit into from

Conversation

prsadhuk
Copy link
Contributor

@prsadhuk prsadhuk commented Jan 13, 2023

It is observed that if SwingSet2 is run in Nimbus L&F and
we drag the icon tool bar (which is floatable) out of the GUI Window
and Once the tool bar is detached, click on "Look & Feel" menu option to change to any L&F (say Java L&F)
it causes NPE due to font being null when getFontMetrics() is called

In other L&F, it uses the tabPane's font whereas in Nimbus font is obtained from getStyle().getFont() which returns null when toolbar is detached from the main window.
The proposed fix is to get tabPane's font if the font passed is null alike other L&Fs.

No regression test is made as it can be verified with SwingSet2..


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-7169951: SwingSet2 throws NullPointerException with Nimbus L&F

Reviewers

Reviewing

Using git

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

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

Using Skara CLI tools

Checkout this PR locally:
$ git pr checkout 11984

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

Using diff file

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

@bridgekeeper
Copy link

bridgekeeper bot commented Jan 13, 2023

👋 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 Jan 13, 2023
@openjdk
Copy link

openjdk bot commented Jan 13, 2023

@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 Jan 13, 2023
@mlbridge
Copy link

mlbridge bot commented Jan 13, 2023

Webrevs

@mrserb
Copy link
Member

mrserb commented Jan 13, 2023

It is unclear does the "getStyle().getFont()" always returns null for that component but we call it only for "floatable" toolbar. Or "getStyle().getFont()" starts to return null for the "floatable" toolbar. If it starts to return null then why does this happen? Are we sure that the "getStyle().getFont()" and "tabPane.getFont()" always returns the same font?

@prsadhuk
Copy link
Contributor Author

getStyle().getFont() returns null as "getFontForState(context)" returns null which is because synth state for floating toolbar is invalid which is 0x201
getStyle().getFont()" and "tabPane.getFont()" in normal valid case returns same font which is javax.swing.plaf.FontUIResource[family=SansSerif,name=sansserif,style=plain,size=12]

@prsadhuk
Copy link
Contributor Author

Any more comments on this fix?

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.

Verified SwingSet2 floating toolbar with current fix.
I think copyright year can be updated else looks good to me.

@openjdk
Copy link

openjdk bot commented Feb 6, 2023

@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:

7169951: SwingSet2 throws NullPointerException with Nimbus L&F

Reviewed-by: abhiscxk, jdv

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 744 new commits pushed to the master branch:

  • a917fb3: 7033677: potential cast error in MemberEnter
  • 6120319: 8302226: failure_handler native.core should wait for coredump to finish
  • fef3eab: 8302734: Parallel: Remove unused LGRPSpace::_invalid_region
  • ea5bfea: 8302661: Parallel: Remove PSVirtualSpace::is_aligned
  • edf238b: 8302635: Race condition in HttpBodySubscriberWrapper when cancelling request
  • cd77fcf: 8290822: C2: assert in PhaseIdealLoop::do_unroll() is subject to undefined behavior
  • 57c9bc3: 8302335: IGV: Bytecode not showing
  • 57fde75: 8302113: Improve CRC32 intrinsic with crypto pmull on AArch64
  • b8c9d6c: 8302158: PPC: test/jdk/jdk/internal/vm/Continuation/Fuzz.java: AssertionError: res: false shouldPin: false
  • dc55a7f: 8302202: Incorrect desugaring of null-allowed nested patterns
  • ... and 734 more: https://git.openjdk.org/jdk/compare/ce6395a1356a3d1334aeffc70ac8e4f86dd81a4c...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 Feb 6, 2023
@mrserb
Copy link
Member

mrserb commented Feb 8, 2023

getStyle().getFont() returns null as "getFontForState(context)" returns null which is because synth state for floating toolbar is invalid which is 0x201 getStyle().getFont()" and "tabPane.getFont()" in normal valid case returns same font which is javax.swing.plaf.FontUIResource[family=SansSerif,name=sansserif,style=plain,size=12]

Where do we set this "invalid" state? Probably it is valid but we do not set the font property for it(or something like that)?

No regression test is made as it can be verified with SwingSet2..

I am not sure that people will test this usecase if we do not have an instruction to do that nor the tests.

@bridgekeeper
Copy link

bridgekeeper bot commented Mar 17, 2023

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

@prsadhuk
Copy link
Contributor Author

/integrate

@openjdk
Copy link

openjdk bot commented Mar 27, 2023

Going to push as commit 0712adc.
Since your change was applied there have been 1225 commits pushed to the master branch:

  • de1c12e: 8301012: [vectorapi]: Intrinsify CompressBitsV/ExpandBitsV and add the AArch64 SVE backend implementation
  • 10fa7d1: 8304804: Remove develop flag G1VerifyCTCleanup
  • 4acf20d: 8304809: Remove develop flag G1ExitOnExpansionFailure
  • a5ffa07: 7026262: HttpServer: improve handling of finished HTTP exchanges
  • 65e01da: 8304013: Add a fast, non-manual alternative to test/jdk/java/util/zip/ZipFile/TestTooManyEntries
  • 38e1714: 8304258: x86: Improve the code generation of VectorRearrange with int and float
  • 765a942: 8304136: Match allocation and free in sspi.cpp
  • 3f59b75: 8304898: Fix Copyright Headers for JLink Source Files
  • 501b606: 8298725: Add BitMap support for reverse iteration
  • 9764948: 8273986: JEditorPane HTML Demo - Accessibility issues
  • ... and 1215 more: https://git.openjdk.org/jdk/compare/ce6395a1356a3d1334aeffc70ac8e4f86dd81a4c...master

Your commit was automatically rebased without conflicts.

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

openjdk bot commented Mar 27, 2023

@prsadhuk Pushed as commit 0712adc.

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

@prsadhuk prsadhuk deleted the JDK-7169951 branch March 27, 2023 10: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