On Tue, 21 Nov 2023 03:33:21 GMT, Prasanta Sadhukhan <psadhuk...@openjdk.org> 
wrote:

>> javadoc contract for JComponent.setMinimumSize(Dimension) states:
>> 
>> "Sets the minimum size of this component to a constant value. Subsequent 
>> calls to getMinimumSize will always return this value..."
>> 
>> However, JScrollBar overrides getMinimumSize() and breaks this contract - it 
>> always returns a minimum size derived from the preferred size even if you 
>> have previously called setMinimumSize()
>> 
>> Fix is made to check if mnimumSize is set and if so, honour it..
>
> Prasanta Sadhukhan has updated the pull request incrementally with one 
> additional commit since the last revision:
> 
>   Override set*Methods and update spec

> > That is we preserve the current behaviour of `getMinimumSize()` and 
> > `getMaximumSize()` methods in `JScrollBar`, yet if `setMinimumSize()` or 
> > `setMaximumSize()` is called, the corresponding `get-` methods return the 
> > set value and thus they follow the contract specified in `JComponent`.
> > @prrace, could you confirm, please?
> 
> I already mentioned to him in this comment [#15325 
> (comment)](https://github.com/openjdk/jdk/pull/15325#issuecomment-1818768822) 
> that moving back to initial fix iteration will cause the same problem as you 
> mentioned [#15325 
> (comment)](https://github.com/openjdk/jdk/pull/15325#issuecomment-1796167220) 
> which is the same what we observed when we removed these 2 getXXX methods 
> (which was mentioned in hmuller comment) so if we are OK with the change in 
> behaviour as compared to current, then removing these 2 methods may be 
> considered as compared to moving to 1st iteration of this fix...

Right. The change in behaviour will still be there.

Personally, I think we should keep the current behaviour and document it. At 
the same time, I accept what Phil suggested: the behaviour remains the same 
unless `setMinimumSize()` or `setMaximumSize()` are called. The latter relies 
on [the 
assumptions](https://github.com/openjdk/jdk/pull/15325#issuecomment-1816933906):

> I suspect very few apps actually call these since they are complete no-ops 
> today.

Phil notes: 

> If we do that, then yes, you'll still see differences if you do call those 
> APIs and forgot about it because it didn't make a difference.

Hence, there's a risk to break those few apps.

This is why I prefer Phil's second suggestion:

> If that isn't going to work, then, I think we should fall back to the pure 
> documentation solution.  
> Well, almost pure docs, but not quite, because we need a no-op over-ride of 
> `set*` on which to place the docs.

This way, no app could be broken because the behaviour doesn't change, but the 
specification for `JScrollBar` changes.

-------------

PR Comment: https://git.openjdk.org/jdk/pull/15325#issuecomment-1874490256

Reply via email to