RFR: 8257512: Remove use of deprecated primitive constructors in JavaFX [v2]

Kevin Rushforth kcr at openjdk.java.net
Wed Mar 10 19:40:10 UTC 2021


On Wed, 10 Mar 2021 19:24:22 GMT, Ambarish Rapte <arapte at openjdk.org> wrote:

>> The following primitive constructors were deprecated in JDK 9 and are deprecated for removal in JDK 16.
>> 
>> java.lang.Byte
>> java.lang.Short
>> java.lang.Integer
>> java.lang.Long
>> java.lang.Float
>> java.lang.Double
>> java.lang.Character
>> java.lang.Boolean
>> 
>> This change removes call to the primitive constructors with the `valueOf()` factory method of respective class.
>> Calls like the following to create array get autoboxed so it does not require a change.
>> 
>> `Double dArr[] = new Double[] {10.1, 20.2};`
>
> Ambarish Rapte has updated the pull request incrementally with one additional commit since the last revision:
> 
>   use autoboxing when obvious

Looks good with a couple problems (in code that we must not be building) noted below.

apps/samples/Ensemble8/src/samples/java/ensemble/samples/language/swing/SwingInterop.java line 222:

> 220:     private Pane createBrowser() {
> 221:         Double widthDouble = Integer.valueOf(PANEL_WIDTH).doubleValue();
> 222:         Double heightDouble = Integer.valueOf(PANEL_HEIGHT).doubleValue();

I think `Double.valueof(PANEL_WIDTH)` would be simpler? Or, you can use auto-boxing and just say:

    Double widthDouble = PANEL_WIDTH;
    Double heightDouble = PANEL_HEIGHT;

modules/javafx.graphics/src/test/jslc/com/sun/scenario/effect/compiler/parser/PrimaryExprTest.java line 68:

> 66:         Expr tree = parseTreeFor("1.234");
> 67:         assertTrue(tree instanceof LiteralExpr);
> 68:         assertEquals(((LiteralExpr)tree).getValue(), Float.valueOf(1.234));

We must not be  building or running these tests. This won't compile without casting to `float` or using a float constant, `1.234f`.

modules/javafx.graphics/src/test/jslc/com/sun/scenario/effect/compiler/parser/UnaryExprTest.java line 62:

> 60:         UnaryExpr tree = parseTreeFor("+72.4");
> 61:         assertEquals(tree.getOp(), UnaryOpType.PLUS);
> 62:         assertEquals(((LiteralExpr)tree.getExpr()).getValue(), Float.valueOf(72.4));

Same problem here (and in the next method). This needs to be `72.4f`

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

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


More information about the openjfx-dev mailing list