RFR: 8365379: SU3.applyInsets may produce wrong results [v15]
Alexey Ivanov
aivanov at openjdk.org
Fri Sep 19 10:35:12 UTC 2025
On Thu, 18 Sep 2025 06:45:02 GMT, Renjith Kannath Pariyangad <rkannathpari at openjdk.org> wrote:
>> Hi Reviewers,
>>
>> I have updated the insets calculation, similar calculation observed in **SynthGraphicsUtils.java**. Reused the **SwingUtilities3.java** modified code
>>
>> Please review and let me know your suggestions if any.
>
> Renjith Kannath Pariyangad has updated the pull request incrementally with one additional commit since the last revision:
>
> Line limited to 80 char
test/jdk/com/sun/java/swing/SwingUtilities3/ApplyInsetsTest.java line 47:
> 45: (insets.left + insets.right),
> 46: rect.height -
> 47: (insets.top + insets.bottom));
Suggestion:
rect.width
- (insets.left + insets.right),
rect.height
- (insets.top + insets.bottom));
Java Coding Style recommends wrapping lines *before* binary operators. I do prefer this style: it makes it clear that it's a continuation line rather than an independent statement.
test/jdk/com/sun/java/swing/SwingUtilities3/ApplyInsetsTest.java line 47:
> 45: (insets.left + insets.right),
> 46: rect.height -
> 47: (insets.top + insets.bottom));
Alternatively, wrap the entire initialisation:
Suggestion:
Rectangle expected =
new Rectangle(rect.x + insets.left,
rect.y + insets.top,
rect.width - (insets.left + insets.right),
rect.height - (insets.top + insets.bottom));
I'm inclined to using this style as it avoids wrapping expressions in arguments.
-------------
PR Review Comment: https://git.openjdk.org/jdk/pull/27157#discussion_r2362474845
PR Review Comment: https://git.openjdk.org/jdk/pull/27157#discussion_r2362480173
More information about the client-libs-dev
mailing list