<Swing Dev> Suspicious field assignment in StrikeMetrics
Andrey Turbanov
turbanoff at gmail.com
Tue Jan 5 11:40:27 UTC 2021
Hello.
I've found suspicious code in constructor sun.font.StrikeMetrics#StrikeMetrics()
StrikeMetrics() {
ascentX = ascentY = Integer.MAX_VALUE;
descentX = descentY = leadingX = leadingY = Integer.MIN_VALUE;
baselineX = baselineX = maxAdvanceX = maxAdvanceY = Integer.MIN_VALUE;
}
As you can see, basLineX field is assigned twice.
Looks like it's supposed to be like this:
baselineX = baselineY = maxAdvanceX = maxAdvanceY = Integer.MIN_VALUE;
Found by SpotBugs
https://spotbugs.readthedocs.io/en/stable/bugDescriptions.html#sa-double-assignment-of-field-sa-field-double-assignment
Andrey Turbanov
More information about the swing-dev
mailing list