8004148: NPE in sun.awt.SunToolkit.getWindowDeactivationTime
authorant
Fri, 14 Nov 2014 12:32:43 +0300
changeset 27715 58e23e39e064
parent 27557 82f4cb44b2d7
child 27716 01f9b7007718
8004148: NPE in sun.awt.SunToolkit.getWindowDeactivationTime Reviewed-by: serb
jdk/src/java.desktop/share/classes/sun/awt/SunToolkit.java
--- a/jdk/src/java.desktop/share/classes/sun/awt/SunToolkit.java	Wed Jul 05 20:07:55 2017 +0200
+++ b/jdk/src/java.desktop/share/classes/sun/awt/SunToolkit.java	Fri Nov 14 12:32:43 2014 +0300
@@ -1882,6 +1882,9 @@
 
     public synchronized void setWindowDeactivationTime(Window w, long time) {
         AppContext ctx = getAppContext(w);
+        if (ctx == null) {
+            return;
+        }
         @SuppressWarnings("unchecked")
         WeakHashMap<Window, Long> map = (WeakHashMap<Window, Long>)ctx.get(DEACTIVATION_TIMES_MAP_KEY);
         if (map == null) {
@@ -1893,6 +1896,9 @@
 
     public synchronized long getWindowDeactivationTime(Window w) {
         AppContext ctx = getAppContext(w);
+        if (ctx == null) {
+            return -1;
+        }
         @SuppressWarnings("unchecked")
         WeakHashMap<Window, Long> map = (WeakHashMap<Window, Long>)ctx.get(DEACTIVATION_TIMES_MAP_KEY);
         if (map == null) {