jdk icon indicating copy to clipboard operation
jdk copied to clipboard

4797982: Setting negative size of JSplitPane divider leads to unexpected results.

Open prsadhuk opened this issue 3 years ago • 6 comments
trafficstars

Setting JSplitPane divider size to negative value leads to unexpected results and is not desirable and seems to be not practical. I guess we should return IAE but it might break existing app so fixed to clamp it to 0 incase negative value is tried to be set for divider size.


Progress

  • [x] Change must be properly reviewed (1 review required, with at least 1 Reviewer)
  • [x] Change must not contain extraneous whitespace
  • [x] Commit message must refer to an issue
  • [x] Change requires a CSR request to be approved

Issues

  • JDK-4797982: Setting negative size of JSplitPane divider leads to unexpected results.
  • JDK-8290992: Setting negative size of JSplitPane divider leads to unexpected results. (CSR)

Reviewers

Reviewing

Using git

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

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

Using Skara CLI tools

Checkout this PR locally:
$ git pr checkout 9566

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

Using diff file

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

prsadhuk avatar Jul 20 '22 09:07 prsadhuk

:wave: 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.

bridgekeeper[bot] avatar Jul 20 '22 09:07 bridgekeeper[bot]

@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[bot] avatar Jul 20 '22 09:07 openjdk[bot]

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

4797982: Setting negative size of JSplitPane divider leads to unexpected results.

Reviewed-by: azvegint, prr

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

  • 07afa3f41e937019173ef31fbc1f2a5eb4b89f90: 8294110: compiler/uncommontrap/Decompile.java fails after JDK-8293798
  • 0746bcb68fde1d59e71c573aaf448bc54a0897d3: 8294083: RISC-V: Minimal build failed with --disable-precompiled-headers
  • 95ec2eaca3845bc971d3e711e5f61052c2951fa8: 8293897: Synthetic final modifier is part of the AST for a try-with-resource resource
  • d14e96d9701dae951aa365029f58afb6687a646a: 8293493: Signal Handlers printout should show signal block state
  • da4fdfbbf4ba72ddaf4f27d95f71e95b7ebf8cc1: 8293659: Improve UnsatisfiedLinkError error message to include dlopen error details
  • cd1cdcdb0d56131d1ad1bdc453c7e261afa73a3a: 8293116: Incremental JDK build could be sped up
  • e9401e67b3f60206e6a98c1c44367b482506a4de: 8293364: IGV: Refactor Action in EditorTopComponent and fix minor bugs
  • 844a95b907aaf6ef67d7e4b1ed0998945a6152d2: 8292892: Javadoc index descriptions are not deterministic
  • 8d1dd6a6cf2bc11e0cf5ac3600e78dc192a819e4: 8294076: Improve ant detection in idea.sh
  • 4e7cb156c843ead88c0b9b01673b9d1db66f08d5: 8293480: IGV: Update Bytecode and ControlFlow Component immediately when opening a new graph
  • ... and 847 more: https://git.openjdk.org/jdk/compare/46251bc6e248a19e8d78173ff8d0502c68ee1acb...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[bot] avatar Jul 21 '22 17:07 openjdk[bot]

we need a CSR

Canyou please clarify why? Is it because we are changing the behavior?

So instead you propose to change from one un-specified behaviour to another un-specified behaviour ?

It seems to me we should be updating javadoc to say what should happen. The "just return" sounds good to me .. in javadoc terms that would be "values < 1 are ignored" ..

prrace avatar Jul 25 '22 21:07 prrace

OK. javadoc clarified and CSR raised https://bugs.openjdk.org/browse/JDK-8290992

prsadhuk avatar Jul 26 '22 04:07 prsadhuk

We were not sure if -ve divider size can be used by third party implementation. It probably will be considered a compatibility issue as mentioned earlier. @prrace Will you be ok to throw IAE instead of ignoring -ve value as suggested or should we keep it as it is now in this PR?

prsadhuk avatar Aug 18 '22 12:08 prsadhuk

We were not sure if -ve divider size can be used by third party implementation. It probably will be considered a compatibility issue as mentioned earlier. @prrace Will you be ok to throw IAE instead of ignoring -ve value as suggested or should we keep it as it is now in this PR?

IAE is just too incompatible. The program would probably stop working if anyone is actually doing that. If it had been done since day one, yes, but too late now.

I didn't get why some effect like the "visibility" of the divider in some L&F should be allowed to over-rule the specified size.

prrace avatar Aug 21 '22 21:08 prrace

All look and feels initially set the divider size to what they need. This is done here:

https://github.com/openjdk/jdk/blob/eab4c0c49934bd6f37a0b6174ca10e5c8708d13b/src/java.desktop/share/classes/javax/swing/plaf/basic/BasicSplitPaneUI.java#L357-L358

Each L&F uses its own divider size. E.g. Windows L&F uses 5:

https://github.com/openjdk/jdk/blob/0a65e8b282fd41e57108422fbd140527d9697efd/src/java.desktop/windows/classes/com/sun/java/swing/plaf/windows/WindowsLookAndFeel.java#L1247

Or Metal L&F uses 10:

https://github.com/openjdk/jdk/blob/d4b040f42dd0a9100ad1ffa55de4ae4f20e9f182/src/java.desktop/share/classes/javax/swing/plaf/metal/MetalLookAndFeel.java#L1371

So a L&F could also use divider size zero to implement an invisible divider. Don't see a reason, why divider size zero should be no longer allowed...

I didn't get why some effect like the "visibility" of the divider in some L&F should be allowed to over-rule the specified size.

If the application invokes JSplitPane.setDividerSize(int), then this overrules the divider size specified by the L&F. There is a field JSplitPane.dividerSizeSet that is used for this.

L&Fs do not invoke JSplitPane.setDividerSize(int) directly. Instead they invoke LookAndFeel.installProperty(...), which calls JSplitPane.setUIProperty(...), which checks flag dividerSizeSet and does not change divider size if the application has invoked setDividerSize(...):

https://github.com/openjdk/jdk/blob/096bca4a9c5e8ac2668dd965df92153ea1d80add/src/java.desktop/share/classes/javax/swing/JSplitPane.java#L1059-L1064

DevCharly avatar Aug 21 '22 22:08 DevCharly

@prrace Probably we could reinstate @implNote to the javadoc as I did earlier, to allow 3rd party L&F -ve divider size?

prsadhuk avatar Aug 22 '22 03:08 prsadhuk

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

bridgekeeper[bot] avatar Sep 19 '22 09:09 bridgekeeper[bot]

/integrate

prsadhuk avatar Sep 26 '22 10:09 prsadhuk

Going to push as commit 2be315877b734b70170ef6375712188d7cd64268. Since your change was applied there have been 901 commits pushed to the master branch:

  • 050eebf2e8215f1603cd89d5c205d14f71b3128b: 8294245: Make Compile::print_inlining_stream stack allocated
  • 91a23d775fbf482244ace5758f7b3084ea564460: 8294142: make test should report only on executed tests
  • 169a5d48afbc6627f36a768c17c2a5e56219d9c7: 8294193: Files.createDirectories throws FileAlreadyExistsException for a symbolic link whose target is an existing directory
  • 3675f4c2afd10b5042948fc79e62caee5f3874ce: 8293252: Shenandoah: ThreadMXBean synchronizer tests crash with aggressive heuristics
  • 543851db926469df57a8f4a2bd3458349012145f: 8289607: Change hotspot/jtreg tests to not use Thread.suspend/resume
  • e2f82514906d483b6e46ff06d8673b77c9f89f08: 8293618: x86: Wrong code generation in class Assembler
  • 6ecd08172b6f0db62af5c0955ddb175a29386faf: 8294270: make test passes awkward -status:-status:error,fail to jtreg
  • eca9749da01d732033c07f2bbb38800a9d80f18d: 8288325: [windows] Actual and Preferred Size of AWT Non-resizable frame are different
  • 2e20e7ec0fd1dbf96c88b7ef70e017506c28e14f: 8294271: Remove use of ThreadDeath from make utilities
  • e45f3d5176e4affaa08480b560ca983fdbcb2846: 8294281: Allow warnings to be disabled on a per-file basis
  • ... and 891 more: https://git.openjdk.org/jdk/compare/46251bc6e248a19e8d78173ff8d0502c68ee1acb...master

Your commit was automatically rebased without conflicts.

openjdk[bot] avatar Sep 26 '22 11:09 openjdk[bot]

@prsadhuk Pushed as commit 2be315877b734b70170ef6375712188d7cd64268.

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

openjdk[bot] avatar Sep 26 '22 11:09 openjdk[bot]