RFR: 8017175: [TESTBUG] javax/swing/JPopupMenu/4634626/bug4634626.java sometimes failed on mac [v2]

Alexander Zuev kizune at openjdk.java.net
Thu Oct 28 02:01:08 UTC 2021


On Thu, 28 Oct 2021 01:36:40 GMT, Sergey Bylokhov <serb at openjdk.org> wrote:

>>> Unfortunately the creation should be dine on EDT as well
>> 
>> Why? Neither component or frame has peers assigned, not like their status is being changed by another thread and they do not receive any events from EDT yet. Then what is the reason for moving component creation to EDT?
>
> It does not relate to the peers(actually peers and awt components can be used on different threads), it is just a requirement for the Swing library all its api should be used only on the EDT, otherwise too many things can go wrong, which includes the simple visibility across the threads, and more complex out of order events execution - when you created a component on main thread it can post an event to EDT, and that event will be executed in parallel with your code on main.

Creation of component like instantiation? That seems to be wrong. We always had the notion of realized component vs non-realized. Before component is added to the realized container or becomes realized on its own it should not post any events on EDT. What possibly can newly created JButton want to do do with EDT? How does the instantiation on one thread can cause problem on another thread if it does not interact with that thread until later on which constitutes the Happens Before scenario. Or did we just threw the realized vs non-realized concept out of the window? If so does not it renders all the Swing code written before that change functionally incompatible and generally unstable? I have so many questions now.

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

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



More information about the client-libs-dev mailing list