<html><head><meta http-equiv="Content-Type" content="text/html; charset=us-ascii"></head><body style="word-wrap: break-word; -webkit-nbsp-mode: space; line-break: after-white-space;" class="">Hi Sergey,<div class=""><br class=""></div><div class="">I think we should drive device update through GraphicsEnvironment.displayChanged() and DisplayChangeListener instead of force updating bounds in GraphicsDevice.displayChanged in the constructor.</div><div class="">We can synchronise the GraphicsEnvironment.displayChanged() by calling it under CGraphicsEnvironment.initDevices() sync lock, this will force call DisplayChangeListener when devices are updated.</div><div class=""><br class=""></div><div class=""><div style="margin: 0px; font-stretch: normal; line-height: normal; color: rgb(195, 55, 32); background-color: rgb(255, 255, 255);" class=""><span style="font-variant-ligatures: no-common-ligatures; font-size: 11px;" class=""><b class="">--- a/src/java.desktop/macosx/classes/sun/awt/CGraphicsEnvironment.java Thu Oct 03 00:38:17 2019 +0300</b></span></div><div style="margin: 0px; font-stretch: normal; line-height: normal; color: rgb(52, 188, 38); background-color: rgb(255, 255, 255);" class=""><span style="font-variant-ligatures: no-common-ligatures; font-size: 11px;" class=""><b class="">+++ b/src/java.desktop/macosx/classes/sun/awt/CGraphicsEnvironment.java Thu Oct 03 13:16:12 2019 +0530</b></span></div><div style="margin: 0px; font-stretch: normal; line-height: normal; color: rgb(213, 59, 211); background-color: rgb(255, 255, 255);" class=""><span style="font-variant-ligatures: no-common-ligatures; font-size: 11px;" class="">@@ -183,8 +183,8 @@</span></div><div style="margin: 0px; font-stretch: normal; line-height: normal; background-color: rgb(255, 255, 255);" class=""><span style="font-variant-ligatures: no-common-ligatures; font-size: 11px;" class="">                 devices.put(id, old.containsKey(id) ? old.get(id)</span></div><div style="margin: 0px; font-stretch: normal; line-height: normal; background-color: rgb(255, 255, 255);" class=""><span style="font-variant-ligatures: no-common-ligatures; font-size: 11px;" class="">                                                     : new CGraphicsDevice(id));</span></div><div style="margin: 0px; font-stretch: normal; line-height: normal; background-color: rgb(255, 255, 255);" class=""><span style="font-variant-ligatures: no-common-ligatures; font-size: 11px;" class="">             }</span></div><div style="margin: 0px; font-stretch: normal; line-height: normal; color: rgb(52, 188, 38); background-color: rgb(255, 255, 255);" class=""><span style="font-variant-ligatures: no-common-ligatures; font-size: 11px;" class="">+            displayChanged();</span></div><div style="margin: 0px; font-stretch: normal; line-height: normal; background-color: rgb(255, 255, 255);" class=""><span style="font-variant-ligatures: no-common-ligatures; font-size: 11px;" class="">         }</span></div><div style="margin: 0px; font-stretch: normal; line-height: normal; color: rgb(195, 55, 32); background-color: rgb(255, 255, 255);" class=""><span style="font-variant-ligatures: no-common-ligatures; font-size: 11px;" class="">-        displayChanged();</span></div><div style="margin: 0px; font-stretch: normal; line-height: normal; background-color: rgb(255, 255, 255);" class=""><span style="font-variant-ligatures: no-common-ligatures; font-size: 11px;" class="">     }</span></div></div><div style="margin: 0px; font-stretch: normal; line-height: normal; background-color: rgb(255, 255, 255);" class=""><span style="font-variant-ligatures: no-common-ligatures; font-size: 11px;" class=""><br class=""></span></div><div class="">I made this change and tested with reproduction steps and I dont see NPE.</div><div class=""><br class=""></div><div class="">Thanks,</div><div class="">Jay<br class=""><div><br class=""><blockquote type="cite" class=""><div class="">On 03-Oct-2019, at 11:09 AM, Sergey Bylokhov <<a href="mailto:Sergey.Bylokhov@oracle.com" class="">Sergey.Bylokhov@oracle.com</a>> wrote:</div><br class="Apple-interchange-newline"><div class=""><div class="">Any volunteers to review=)?<br class=""><br class="">On 8/19/19 12:03 pm, Sergey Bylokhov wrote:<br class=""><blockquote type="cite" class="">Hello.<br class="">Please review the fix for JDK 14.<br class="">Bug: <a href="https://bugs.openjdk.java.net/browse/JDK-8229810" class="">https://bugs.openjdk.java.net/browse/JDK-8229810</a><br class="">Fix: <a href="http://cr.openjdk.java.net/~serb/8229810/webrev.00" class="">http://cr.openjdk.java.net/~serb/8229810/webrev.00</a><br class="">The root cause is a lack of synchronization in CGraphicsEnvironment,<br class="">we create the GraphicsDevice under a special lock which is used to<br class="">access the list of devices:<br class=""><a href="http://hg.openjdk.java.net/jdk/client/file/39f133168348/src/java.desktop/macosx/classes/sun/awt/CGraphicsEnvironment.java#l184" class="">http://hg.openjdk.java.net/jdk/client/file/39f133168348/src/java.desktop/macosx/classes/sun/awt/CGraphicsEnvironment.java#l184</a><br class="">but initialize the device w/o this lock.<br class="">http://hg.openjdk.java.net/jdk/client/file/39f133168348/src/java.desktop/macosx/classes/sun/awt/CGraphicsEnvironment.java#l187<br class="">So it is possible that we create the device, add it to the list of devices,<br class="">and before we initialize it the user could access the not fully initialized object.<br class="">The bug exists from the jdk7, but it was hidden because all fields in CGraphicsDevice<br class="">were primitives, so the app just used invalid data. In JDK-8211992 the object field "bounds"<br class="">was added and now we can get NPE if this field was not initialized.<br class="">As a fix, I suggest to always initialize the graphics device in the constructor.<br class="">Note that we cannot move "displayChanged" which will notify devices and all listeners<br class="">in awt/swing in the CGraphicsEnvironment under the lock, it will cause various<br class="">deadlocks in the a different listeners.<br class=""></blockquote><br class=""><br class="">-- <br class="">Best regards, Sergey.<br class=""></div></div></blockquote></div><br class=""></div></body></html>