RFR: JDK-8297413: Remove easy warnings in javafx.graphics
Nir Lisker
nlisker at openjdk.org
Thu Nov 24 00:03:30 UTC 2022
On Tue, 22 Nov 2022 18:39:43 GMT, John Hendrikx <jhendrikx at openjdk.org> wrote:
> - Remove unsupported/unnecessary SuppressWarning annotations
> - Remove reduntant type specifications (use diamond operator)
> - Remove unused or duplicate imports
> - Remove unnecessary casts (type is already correct type or can be autoboxed)
> - Remove unnecessary semi-colons (at end of class definitions, or just repeated ones)
> - Remove redundant super interfaces (interface that is already inherited)
> - Remove unused type parameters
> - Remove declared checked exceptions that are never thrown
> - Add missing `@Override` annotations
I don't see a problem with removal of the unnecessary casts for numbers.
* It makes the code less cluttered.
* If only necessary casts are left, it draws the attention of the reader to a valuable operation, like rounding with an `int` cast.
* As John pointed out, if the definition of the types change, it stops being unnecessary and can hide precision loss.
* If I'm at the point where I need to reason about precision of a specific calculation, I can just hover my mouse over the variable and see its type. When just reading the code to understand what it does, the precision/exact types are not important.
In any case, unnecessary casts for non-numeric types should still be removed since the whole precision argument is irrelevant, so I don't think that the warning should be disabled.
-------------
PR: https://git.openjdk.org/jfx/pull/960
More information about the openjfx-dev
mailing list