<Swing Dev> RFR: 8262085: Hovering Metal HTML Tooltips in different windows cause IllegalArgExc on Linux

Sergey Bylokhov serb at openjdk.java.net
Sat Feb 27 22:12:40 UTC 2021


On Sat, 27 Feb 2021 21:56:47 GMT, Sergey Bylokhov <serb at openjdk.org> wrote:

>> This issue occurs only under `MetalLookAndFeel` on Linux. 
>> 
>> It was introduced by [JDK-8040630](https://bugs.openjdk.java.net/browse/JDK-8040630) fix.
>> 
>>> component.setBounds(ownerX, ownerY, 1, 1);
>> 
>> This line adds an extra reshape call with `1x1` size right before getting another one with correct sizes.
>> 
>> If `MetalToolTipUI#paint()` call happens before getting correct sizes,  it calculates `paintTextR` with negative sizes for component with `1x1` size,  thus IAE is thrown.
>> 
>> The fix is to do not proceed with `paint()` for negative sizes.
>> The provided test fails for me in 0-30s interval(before the fix), other testing(client-tier1,2,3) looks good.
>
> Any idea why Linux is affected only?

BTW the test can be simplified to something like this
        UIManager.setLookAndFeel(new MetalLookAndFeel());
        JToolTip tp = new JToolTip();
        tp.setTipText("<html><h1>Hello world</h1></html>");
        tp.setMinimumSize(new Dimension(1, 1));
        tp.setMaximumSize(new Dimension(1, 1));
        tp.setPreferredSize(new Dimension(1, 1));
        tp.setBounds(100, 100, 1, 1);
        BufferedImage img = new BufferedImage(100, 100, TYPE_INT_ARGB);
        Graphics2D g2d = img.createGraphics();
        tp.paint(g2d);
        g2d.dispose();

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

PR: https://git.openjdk.java.net/jdk/pull/2761


More information about the swing-dev mailing list