RFR: 8279614: The left line of the TitledBorder is not painted on 150 scale factor [v25]

Alexey Ivanov aivanov at openjdk.java.net
Fri Jun 10 19:40:11 UTC 2022


On Thu, 9 Jun 2022 18:45:15 GMT, Phil Race <prr at openjdk.org> wrote:

>> src/java.desktop/share/classes/javax/swing/border/EtchedBorder.java line 158:
>> 
>>> 156:         AffineTransform at = new AffineTransform();
>>> 157:         Stroke oldStk = new BasicStroke();
>>> 158:         int stkWidth = 1;
>> 
>> Now the usage of these variables is restricted to the case where `resetTransform` is set to `true`. Therefore, they can be left uninitialised here; a value is assigned before it's used in all the code paths as far as I can see.
>> 
>> It's just a small (premature) optimisation, it avoids creating two objects. I don't insist though.
>
> I'd be inclined to remove the initialisation.

I see, the static analyser is not smart enough to notice that the variables get initialised before they're used.

To resolve the error, initialise `at` and `oldStk` with `null`.

`stkWidth` needs to be initialised by 1 as it's currently done, it's always used.

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

PR: https://git.openjdk.org/jdk/pull/7449



More information about the client-libs-dev mailing list