On Thu, 11 Mar 2021 00:26:38 GMT, Nir Lisker <nlis...@openjdk.org> wrote:

>> Ambarish Rapte has updated the pull request incrementally with one 
>> additional commit since the last revision:
>> 
>>   correct Float.valueOf()
>
> modules/javafx.controls/src/test/java/test/javafx/scene/control/ComboBoxTest.java
>  line 643:
> 
>> 641:         ComboBox cb = new ComboBox();
>> 642:         StringConverter sc = cb.getConverter();
>> 643:         assertEquals("42", sc.toString(Integer.valueOf(42)));
> 
> Autobox?

>From this test code the type of parameter of `sc.toString()` is not obvious.
`StringConverter` is a template class. `toString()` accepts a template type 
parameter.
Using autoboxing at such instances would hamper the readability.
So I think autoboxing should be used only when the type is very obvious from 
just a glance of code.

> apps/samples/Ensemble8/src/samples/java/ensemble/samples/language/swing/SampleTableModel.java
>  line 54:
> 
>> 52:         {Double.valueOf(567), Double.valueOf(956), Double.valueOf(1154)},
>> 53:         {Double.valueOf(1292), Double.valueOf(1665), 
>> Double.valueOf(1927)},
>> 54:         {Double.valueOf(1292), Double.valueOf(2559), 
>> Double.valueOf(2774)}
> 
> Autobox?

The array is of type Object. When LHS is Object then autobox chooses a suitable 
type by itself.
So here, if we autobox then the values get autoboxed to `Integer`. We do not 
intend to change the test behavior as part of this fix so let's keep this as 
`Double.valueOf`.

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

PR: https://git.openjdk.java.net/jfx/pull/423

Reply via email to