RFR: JDK-8297413: Remove easy warnings in javafx.graphics

Andy Goryachev angorya at openjdk.org
Tue Nov 22 22:29:31 UTC 2022


On Tue, 22 Nov 2022 22:15:12 GMT, Kevin Rushforth <kcr at openjdk.org> wrote:

>> Eclipse knows it is unnecessary.  Personally, I am in favor of removing such unnecessary code.
>
> If it aids readability, I don't see it as unnecessary. In this case, since the types of all of the variables are not known, you could certainly argue it doesn't matter much -- you need to look at the types to reason about what it does.

I agree.  The problem is that we will not be able to enable the warning in IDE, or it has to be @suppressed.

So the choice is either fix the code and enable warning, or keep the code as is and disable the warning.

>> 4L * w * h;
>
> I would just revert it back.

(long) width * height * 4;
is dangerous if one does not remember the precedence rules - is typecast applied to width or the end result?
4L * w * h; is unambiguous.

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

PR: https://git.openjdk.org/jfx/pull/960


More information about the openjfx-dev mailing list