src/share/classes/java/awt/EventQueue.java

Print this page

        

@@ -169,11 +169,11 @@
 
     /**
      * The modifiers field of the current event, if the current event is an
      * InputEvent or ActionEvent.
      */
-    private WeakReference currentEvent;
+    private WeakReference<AWTEvent> currentEvent;
 
     /*
      * Non-zero if a thread is waiting in getNextEvent(int) for an event of
      * a particular ID to be posted to the queue.
      */

@@ -807,11 +807,11 @@
     }
     private AWTEvent getCurrentEventImpl() {
         pushPopLock.lock();
         try {
                 return (Thread.currentThread() == dispatchThread)
-                ? ((AWTEvent)currentEvent.get())
+                ? currentEvent.get()
                 : null;
         } finally {
             pushPopLock.unlock();
         }
     }

@@ -1165,11 +1165,11 @@
         try {
             if (Thread.currentThread() != dispatchThread) {
                 return;
             }
 
-            currentEvent = new WeakReference(e);
+            currentEvent = new WeakReference<>(e);
 
             // This series of 'instanceof' checks should be replaced with a
             // polymorphic type (for example, an interface which declares a
             // getWhen() method). However, this would require us to make such
             // a type public, or to place it in sun.awt. Both of these approaches