RFR: JDK-8297413: Remove easy warnings in javafx.graphics [v2]
Nir Lisker
nlisker at openjdk.org
Wed Nov 30 03:15:31 UTC 2022
On Tue, 29 Nov 2022 17:11:51 GMT, Kevin Rushforth <kcr at openjdk.org> wrote:
>> John Hendrikx has updated the pull request incrementally with one additional commit since the last revision:
>>
>> Fix indentation
>
> modules/javafx.graphics/src/main/java/com/sun/javafx/tk/quantum/WindowStage.java line 422:
>
>> 420: }
>> 421: double similarity = (width - adjw) / (double) width +
>> 422: (height - adjh) / (double) height + //Large padding is bad
>
> This change _must_ be reverted. There are cases where doing integer arithmetic on intermediate results is not equivalent to doing double arithmetic.
>
> Consider this:
>
>
> int i = Integer.MAX_VALUE;
> int j = -1;
> double d1 = (double) i - (double) j;
> double d2 = i - j;
>
>
> `d1` will be `2147483648` and `d2` will be `-2147483648`.
>
> I can't say whether it is possible in practice, but this change is not acceptable, and is a good example of the general concern I raised.
If the casts in the numerator actually matter, then the cast in the denominator can be removed. The latter are the ones that Eclipse flags for me as unnecessary.
-------------
PR: https://git.openjdk.org/jfx/pull/960
More information about the openjfx-dev
mailing list