JDK-8143932 : [TEST_BUG] java/awt/Component/GetScreenLocTest/GetScreenLocTest.java fails
  • Type: Bug
  • Component: client-libs
  • Sub-Component: java.awt
  • Affected Version: 9
  • Priority: P3
  • Status: Closed
  • Resolution: Won't Fix
  • Submitted: 2015-11-24
  • Updated: 2015-12-01
  • Resolved: 2015-12-01
Related Reports
Relates :  
Description
The test fails because a frame which should be drawn later sometimes goes under earlier-drawn one (running on EDT).


Please run the following test code:

import java.awt.*;

public class EDT {

    public static void main(final String[] args) throws Exception {

        EventQueue.invokeAndWait(() -> {
            // delay to ensure that the red frame
            // isn't drawn before the big one
            try { Thread.currentThread().sleep(2000); }
            catch (Exception e) { System.out.println("can't sleep"); }

            Frame f = new Frame();
            f.setSize(200, 200);
            f.setLocation(0, 0);
            f.setVisible(true);
            System.out.println("1"); 
        });

        //Thread.currentThread().sleep(100);

        EventQueue.invokeAndWait(() -> {
            Frame f = new Frame();
            f.setSize(120, 150);
            f.setLocation(0, 0);
            f.setBackground(Color.red);
            f.setVisible(true);
            System.out.println("2");
        });
    }
}

behavior:
Ubuntu 14.04 linux + GNOME + JDK9 b93 (as well as Win7): red frame is always on top (as expected)

Ubuntu 15.04 linux + GNOME + JDK9 b93 + HiDPI display:
the red frame (2nd) goes under the 1st. Output is "12" (as expected).

could it be some EDT violation? please note that "invokeAndWait" is called when drawing the 1st frame. the same unexpected behavior if wrap all the code with the single "invokeAndWait"

if enable the commented delay then the expected behavior is observed
Comments
> does not fail on Ubuntu 15 it fails on GNOME > We do not support it on Ubuntu some runs for both Unity and GNOME were done as I didn't face this limitation.
01-12-2015

ok. thanks. so it seems I've waited too much from EDT (the (naive) expectation was that the 'invokeAndWait' will guarantee an ordered creation of the windows). So the issue probably should be considered as a test bug (as GetScreenLocTest.java still needs correction).
01-12-2015

this behavior is ok because the WM creates those top level windows concurrently.
01-12-2015

But this test does not fail on Ubuntu 15. Why do you use Gnome? We do not support it on Ubuntu.
01-12-2015

discovered while looking at failing reg. test java/awt/Component/GetScreenLocTest/GetScreenLocTest.java. The latter one should be refactored to run on EDT instead of use of delays.
24-11-2015