< prev index next >

src/com/sun/javatest/tool/ToolAction.java

Print this page
rev 145 : 7902237: Fixing raw use of parameterized class
Reviewed-by: jjg

@@ -191,11 +191,11 @@
     public synchronized void addPropertyChangeListener(PropertyChangeListener listener) {
         listeners = DynamicArray.append(listeners, new WeakReference<>(listener));
     }
 
     public synchronized void removePropertyChangeListener(PropertyChangeListener listener) {
-        WeakReference[] l = listeners;
+        WeakReference<PropertyChangeListener>[] l = listeners;
         int size = l.length;
         for (int i = size - 1; i >= 0; i--) {
             if (l[i].get() == listener)
                 System.arraycopy(l, i+1, l, i, (--size) - i);
         }

@@ -206,14 +206,14 @@
         }
     }
 
     private void firePropertyChangeEvent(String name, Object oldVal, Object newVal) {
         PropertyChangeEvent ev = null; // lazy create event if needed
-        WeakReference[] l = listeners;
+        WeakReference<PropertyChangeListener>[] l = listeners;
         if (l.length > 0) {
             for (int i = l.length - 1; i >= 0; i--) {
-                PropertyChangeListener pcl = (PropertyChangeListener) (l[i].get());
+                PropertyChangeListener pcl = (l[i].get());
                 if (pcl != null) {
                     if (ev == null)
                         ev = new PropertyChangeEvent(this, name, oldVal, newVal);
                     pcl.propertyChange(ev);
                 }

@@ -237,7 +237,7 @@
     private Integer mnemonic;
     private Icon icon;
     private Map<String, Object> misc;
     private boolean enabled = true;
 
-    private WeakReference[] listeners = new WeakReference[0];
+    private WeakReference<PropertyChangeListener>[] listeners = new WeakReference[0];
 }
< prev index next >