Skip to content
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

8272148: JDesktopPane:getComponentCount() returns one extra than expected with GTKLookAndFeel #5121

Closed
wants to merge 2 commits into from

Conversation

pankaj-bansal
Copy link

@pankaj-bansal pankaj-bansal commented Aug 16, 2021

A container may include few default components as children, which are added to it during creation. Due to this, calling function getChildrenCount on a new created instance may return non zero value. This behaviour may vary according to L&F also, as some L&F may add some default components to a container, but other L&F may choose not to do so.

The current bugs reports that this behaviour looks suspicious as it is expected that a newly created container will have zero children.

Current specification is not clear on this whether it is allowed for a container to contain default components or not. The fix make changes to the specification to clarify the same.

Note: I think this will need a CSR, I will file one after the review is completed


Progress

  • Change must not contain extraneous whitespace
  • Commit message must refer to an issue
  • Change must be properly reviewed

Issue

  • JDK-8272148: JDesktopPane:getComponentCount() returns one extra than expected with GTKLookAndFeel

Reviewers

Reviewing

Using git

Checkout this PR locally:
$ git fetch https://git.openjdk.java.net/jdk pull/5121/head:pull/5121
$ git checkout pull/5121

Update a local copy of the PR:
$ git checkout pull/5121
$ git pull https://git.openjdk.java.net/jdk pull/5121/head

Using Skara CLI tools

Checkout this PR locally:
$ git pr checkout 5121

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

Using diff file

Download this PR as a diff file:
https://git.openjdk.java.net/jdk/pull/5121.diff

@bridgekeeper
Copy link

bridgekeeper bot commented Aug 16, 2021

👋 Welcome back pbansal! 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
Copy link

openjdk bot commented Aug 16, 2021

@pankaj-bansal The following label will be automatically applied to this pull request:

  • swing

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 swing client-libs-dev@openjdk.org label Aug 16, 2021
@pankaj-bansal pankaj-bansal marked this pull request as ready for review August 16, 2021 09:20
@openjdk openjdk bot added the rfr Pull request is ready for review label Aug 16, 2021
@mlbridge
Copy link

mlbridge bot commented Aug 16, 2021

Webrevs

@mrserb
Copy link
Member

mrserb commented Aug 16, 2021

Can you please clarify why the GTK L&F is affected only?

@pankaj-bansal
Copy link
Author

Can you please clarify why the GTK L&F is affected only?

Synth L&F is adding a Taskbar in SynthDesktopPaneUI class if the "InternalFrame.useTaskBar" is set true. The "InternalFrame.useTaskBar" is set true in case of GTKL&F only, so this issue is happening. I think L&Fs are allowed to customize these things.
I think this happening in GTK L&F is not really much to do with GTK L&F. This can happen for any default/custom container for any L&F which adds some default components as children. The spec does not stop anyone from doing so. So the spec should be modified to clarify the expected behaviour.

https://github.com/openjdk/jdk/blob/master/src/java.desktop/share/classes/javax/swing/plaf/synth/SynthDesktopPaneUI.java#L109
https://github.com/openjdk/jdk/blob/master/src/java.desktop/share/classes/com/sun/java/swing/plaf/gtk/GTKLookAndFeel.java#L660

@prsadhuk
Copy link
Contributor

The "InternalFrame.useTaskBar" is set true in case of GTKL&F only,

What if we set this property to false and only set under some condition for GTK L&F, what sort of problem we can expect? Does any jtreg/jck test gets affected if we set it to false?

@pankaj-bansal
Copy link
Author

The "InternalFrame.useTaskBar" is set true in case of GTKL&F only,

What if we set this property to false and only set under some condition for GTK L&F, what sort of problem we can expect? Does any jtreg/jck test gets affected if we set it to false?

I just ran a mach5 job with the "InternalFrame.useTaskBar" set to true with GTKL&F. Link in JBS. I do not see any issue due to this. The failures are not related to this change.

My point is that, as discussed in the meeting, this is not related to GTKL&F. Anyone can make a custom container and add some default components and this test will fail for that container. So rather than setting "InternalFrame.useTaskBar" to TRUE for GTL L&F just to solve this issue quickly but wrong way, we should make changes to the spec and state that this is allowed. Similar things could have been done in other components for other L&Fs, which may have not yet been reported.

@mrserb
Copy link
Member

mrserb commented Aug 19, 2021

I wonder how the other components handle that. For example, the JComboBox in Aqua L&F is a "compound" element and it contains a text field and button, what does the "getComponentCount" return in that case, wIll we hide internal data from the user?

@pankaj-bansal
Copy link
Author

I wonder how the other components handle that. For example, the JComboBox in Aqua L&F is a "compound" element and it contains a text field and button, what does the "getComponentCount" return in that case, wIll we hide internal data from the user?

I just ran the following test for JComboBox for all L&Fs on my Mac. It fails for everyone of them. The test and output is as below. Looks like this test is not being run for all components for all L&Fs. It should give lot of failures I guess.

`

    public static void main(String[] args) throws Exception{
    for (UIManager.LookAndFeelInfo info : UIManager.getInstalledLookAndFeels()) {
        JComboBox<String> container = new JComboBox();
        System.out.println("**************");
        UIManager.setLookAndFeel(info.getClassName());
        System.out.println("Current Look and Feel is "+info.getName());
        if (container.getComponentCount() == 0) {
            System.out.println("Expected : no child components present");
        } else {
            System.out.println("Unexpected : by default the Container has components size " + container.getComponentCount());
            System.out.println("Following are the components present");
            for (Component c : container.getComponents())
                System.out.println(c);
        }
        System.out.println("**************");
        System.out.println();
    }
}

`

`


Current Look and Feel is Metal
Unexpected : by default the Container has components size 2
Following are the components present
com.apple.laf.AquaComboBoxButton[,0,0,0x0,invalid,alignmentX=0.0,alignmentY=0.5,border=com.apple.laf.AquaButtonBorder$Named@3bfdc050,flags=12583200,maximumSize=,minimumSize=,preferredSize=,defaultIcon=,disabledIcon=,disabledSelectedIcon=,margin=javax.swing.plaf.InsetsUIResource[top=0,left=2,bottom=0,right=2],paintBorder=true,paintFocus=true,pressedIcon=,rolloverEnabled=false,rolloverIcon=,rolloverSelectedIcon=,selectedIcon=,text=,defaultCapable=true]
javax.swing.CellRendererPane[,0,0,0x0,invalid,hidden]



Current Look and Feel is Nimbus
Unexpected : by default the Container has components size 2
Following are the components present
javax.swing.plaf.metal.MetalComboBoxButton[,0,0,0x0,invalid,alignmentX=0.0,alignmentY=0.5,border=javax.swing.plaf.BorderUIResource$CompoundBorderUIResource@5bb21b69,flags=12583208,maximumSize=,minimumSize=,preferredSize=,defaultIcon=,disabledIcon=,disabledSelectedIcon=,margin=java.awt.Insets[top=0,left=1,bottom=1,right=3],paintBorder=true,paintFocus=false,pressedIcon=,rolloverEnabled=true,rolloverIcon=,rolloverSelectedIcon=,selectedIcon=,text=,defaultCapable=true]
javax.swing.CellRendererPane[,0,0,0x0,invalid,hidden]



Current Look and Feel is CDE/Motif
Unexpected : by default the Container has components size 2
Following are the components present
javax.swing.plaf.synth.SynthArrowButton[ComboBox.arrowButton,0,0,0x0,invalid,alignmentX=0.0,alignmentY=0.5,border=javax.swing.plaf.synth.SynthBorder@4690b489,flags=12583200,maximumSize=,minimumSize=,preferredSize=,defaultIcon=,disabledIcon=,disabledSelectedIcon=,margin=javax.swing.plaf.InsetsUIResource[top=0,left=0,bottom=0,right=0],paintBorder=true,paintFocus=true,pressedIcon=,rolloverEnabled=true,rolloverIcon=,rolloverSelectedIcon=,selectedIcon=,text=,defaultCapable=false]
javax.swing.CellRendererPane[,0,0,0x0,invalid,hidden]



Current Look and Feel is Mac OS X
Unexpected : by default the Container has components size 1
Following are the components present
javax.swing.CellRendererPane[,0,0,0x0,invalid,hidden]


`

@pankaj-bansal
Copy link
Author

Gentle Reminder to the reviewers

@prrace
Copy link
Contributor

prrace commented Aug 23, 2021

/label csr

@openjdk
Copy link

openjdk bot commented Aug 23, 2021

@prrace The label csr is not a valid label. These labels are valid:

  • serviceability
  • hotspot
  • sound
  • hotspot-compiler
  • ide-support
  • kulla
  • i18n
  • shenandoah
  • jdk
  • javadoc
  • security
  • 2d
  • swing
  • hotspot-runtime
  • jmx
  • nio
  • build
  • beans
  • core-libs
  • compiler
  • net
  • hotspot-gc
  • hotspot-jfr
  • awt

Copy link
Contributor

@prrace prrace left a comment

Choose a reason for hiding this comment

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

I wonder how the other components handle that. For example, the JComboBox in Aqua L&F is a "compound" element and it contains a text field and button, what does the "getComponentCount" return in that case, wIll we hide internal data from the user?

I just ran the following test for JComboBox for all L&Fs on my Mac. It fails for everyone of them. The test and output is as below. Looks like this test is not being run for all components for all L&Fs. It should give lot of failures I guess.

Yep not unexpected which is why I said this needed to be documented at least as high up as JComponent.
And FWIW since nothing said that JComponents are created with no children it is a very weak bug/complaint to begin with !

@pankaj-bansal
Copy link
Author

/label csr

@openjdk
Copy link

openjdk bot commented Aug 25, 2021

@pankaj-bansal The label csr is not a valid label. These labels are valid:

  • serviceability
  • hotspot
  • sound
  • hotspot-compiler
  • ide-support
  • kulla
  • i18n
  • shenandoah
  • jdk
  • javadoc
  • security
  • 2d
  • swing
  • hotspot-runtime
  • jmx
  • nio
  • build
  • beans
  • core-libs
  • compiler
  • net
  • hotspot-gc
  • hotspot-jfr
  • awt

@mrserb
Copy link
Member

mrserb commented Aug 26, 2021

/csr

@openjdk openjdk bot added the csr Pull request needs approved CSR before integration label Aug 26, 2021
@openjdk
Copy link

openjdk bot commented Aug 26, 2021

@mrserb has indicated that a compatibility and specification (CSR) request is needed for this pull request.
@pankaj-bansal please create a CSR request for issue JDK-8272148. This pull request cannot be integrated until the CSR request is approved.

@pankaj-bansal
Copy link
Author

pankaj-bansal commented Sep 4, 2021

Gentle Reminder to the reviewers @prrace @mrserb

@pankaj-bansal
Copy link
Author

The CSR is created for this issue https://bugs.openjdk.java.net/browse/JDK-8273356

@openjdk openjdk bot removed the csr Pull request needs approved CSR before integration label Sep 10, 2021
@openjdk
Copy link

openjdk bot commented Sep 10, 2021

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

8272148: JDesktopPane:getComponentCount() returns one extra than expected with GTKLookAndFeel

Reviewed-by: prr, serb

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

  • 08f0be8: 8272608: java_lang_System::allow_security_manager() doesn't set its initialization flag
  • 2e321dc: 8273528: Avoid ByteArrayOutputStream.toByteArray when converting stream to String
  • 54dee13: 8273188: java/lang/instrument/BootClassPath/BootClassPathTest.sh fails with "FATAL ERROR in native method: processing of -javaagent failed, processJavaStart failed"
  • 4020a60: 8273550: Replace os::cgc_thread/pgc_thread with os::gc_thread
  • 185eaca: 8273545: Remove Thread::is_GC_task_thread()
  • dd1209e: 8268885: duplicate checkcast when destination type is not first type of intersection type
  • ef4a532: 8263773: Reenable German localization for builds at Oracle
  • 96614da: 8272903: Missing license header in ArenaAllocator.java
  • e3bda63: 8273489: Zero: Handle UseHeavyMonitors on all monitorenter paths
  • c81690d: 8273498: compiler/c2/Test7179138_1.java timed out
  • ... and 251 more: https://git.openjdk.java.net/jdk/compare/36e2ddad4d2ef3ce27475af6244d0246a8315c0c...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 Sep 10, 2021
@pankaj-bansal
Copy link
Author

/integrate

@openjdk
Copy link

openjdk bot commented Sep 10, 2021

Going to push as commit 70c9e02.
Since your change was applied there have been 261 commits pushed to the master branch:

  • 08f0be8: 8272608: java_lang_System::allow_security_manager() doesn't set its initialization flag
  • 2e321dc: 8273528: Avoid ByteArrayOutputStream.toByteArray when converting stream to String
  • 54dee13: 8273188: java/lang/instrument/BootClassPath/BootClassPathTest.sh fails with "FATAL ERROR in native method: processing of -javaagent failed, processJavaStart failed"
  • 4020a60: 8273550: Replace os::cgc_thread/pgc_thread with os::gc_thread
  • 185eaca: 8273545: Remove Thread::is_GC_task_thread()
  • dd1209e: 8268885: duplicate checkcast when destination type is not first type of intersection type
  • ef4a532: 8263773: Reenable German localization for builds at Oracle
  • 96614da: 8272903: Missing license header in ArenaAllocator.java
  • e3bda63: 8273489: Zero: Handle UseHeavyMonitors on all monitorenter paths
  • c81690d: 8273498: compiler/c2/Test7179138_1.java timed out
  • ... and 251 more: https://git.openjdk.java.net/jdk/compare/36e2ddad4d2ef3ce27475af6244d0246a8315c0c...master

Your commit was automatically rebased without conflicts.

@openjdk openjdk bot closed this Sep 10, 2021
@openjdk openjdk bot added integrated Pull request has been integrated and removed ready Pull request is ready to be integrated rfr Pull request is ready for review labels Sep 10, 2021
@openjdk
Copy link

openjdk bot commented Sep 10, 2021

@pankaj-bansal Pushed as commit 70c9e02.

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

@pankaj-bansal pankaj-bansal deleted the JDK-8272148 branch September 10, 2021 06:14
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
integrated Pull request has been integrated swing client-libs-dev@openjdk.org
4 participants