-
Notifications
You must be signed in to change notification settings - Fork 6.2k
8365379: SU3.applyInsets may produce wrong results #27157
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: master
Are you sure you want to change the base?
Changes from 8 commits
5638737
fae0e8e
db91653
955297b
ff5879c
da74288
3bc19ba
6fca8bc
4d4a2a5
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Since this test has nothing to do with the public API of We no longer create directories for each test and give meaningful names to test files rather than |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,52 @@ | ||
/* | ||
* Copyright (c) 2025, Oracle and/or its affiliates. All rights reserved. | ||
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. | ||
* | ||
* This code is free software; you can redistribute it and/or modify it | ||
* under the terms of the GNU General Public License version 2 only, as | ||
* published by the Free Software Foundation. | ||
* | ||
* This code is distributed in the hope that it will be useful, but WITHOUT | ||
* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or | ||
* FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License | ||
* version 2 for more details (a copy is included in the LICENSE file that | ||
* accompanied this code). | ||
* | ||
* You should have received a copy of the GNU General Public License version | ||
* 2 along with this work; if not, write to the Free Software Foundation, | ||
* Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. | ||
* | ||
* Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA | ||
* or visit www.oracle.com if you need additional information or have any | ||
* questions. | ||
*/ | ||
|
||
import java.awt.Insets; | ||
import java.awt.Rectangle; | ||
|
||
import com.sun.java.swing.SwingUtilities3; | ||
|
||
/* | ||
* @test | ||
* @bug 8365379 | ||
* @summary Verify LineBorder edges have the same width | ||
* @modules java.desktop/com.sun.java.swing | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Can we verify it w/o using internals? There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. As you are aware existing calculation will go wrong only for non zero X & Y. As far as my understanding existing calls passing 0,0 as X,Y. so I did not find any other way w/o using internals. FYI : summary was wrong that I have corrected. Let me know if you have any suggestions. There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
This method is used menu rendering. All the current usages pass rectangles where Yet the code in the method will produce wrong result if the Since there are no other usages, it's impossible to reproduce the bug. Now that the method resides in This test is like a unit test that ensures the |
||
* @run main bug8365379 | ||
*/ | ||
|
||
public class bug8365379 { | ||
public static void main(String[] args) { | ||
Rectangle rect = new Rectangle(10, 20, 60, 60); | ||
Insets insets = new Insets(5, 10, 15, 20); | ||
Rectangle expected = new Rectangle(rect.x + insets.left, | ||
rect.y + insets.top, | ||
rect.width - (insets.left + insets.right), | ||
rect.height - (insets.top + insets.bottom)); | ||
|
||
SwingUtilities3.applyInsets(rect, insets); | ||
if (!rect.equals(expected)) { | ||
throw new RuntimeException(("Test failed: expected " + expected + " but got " + rect)); | ||
} | ||
System.out.println("Test passed."); | ||
} | ||
} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Maybe we can eliminate the creation of a new object on each paint event? Since neither method is part of the public API, how about changing the signature of SwingUtilities3.applyInsets and removing the corresponding method in SynthGraphicsUtils?"
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Agreed.
SwingUtilities3
can easily have two methods:applyInsets(Rectangle rect, Insets insets)
as well asapplyInsets(Rectangle rect, Insets insets, boolean leftToRight)
where the former calls the latter withleftToRight = true
.