src/share/classes/javax/swing/event/EventListenerList.java

Print this page

        

*** 139,153 **** * @since 1.3 */ public <T extends EventListener> T[] getListeners(Class<T> t) { Object[] lList = listenerList; int n = getListenerCount(lList, t); T[] result = (T[])Array.newInstance(t, n); int j = 0; for (int i = lList.length-2; i>=0; i-=2) { if (lList[i] == t) { ! result[j++] = (T)lList[i+1]; } } return result; } --- 139,156 ---- * @since 1.3 */ public <T extends EventListener> T[] getListeners(Class<T> t) { Object[] lList = listenerList; int n = getListenerCount(lList, t); + @SuppressWarnings("unchecked") T[] result = (T[])Array.newInstance(t, n); int j = 0; for (int i = lList.length-2; i>=0; i-=2) { if (lList[i] == t) { ! @SuppressWarnings("unchecked") ! T tmp = (T)lList[i+1]; ! result[j++] = tmp; } } return result; }
*** 170,180 **** public int getListenerCount(Class<?> t) { Object[] lList = listenerList; return getListenerCount(lList, t); } ! private int getListenerCount(Object[] list, Class t) { int count = 0; for (int i = 0; i < list.length; i+=2) { if (t == (Class)list[i]) count++; } --- 173,183 ---- public int getListenerCount(Class<?> t) { Object[] lList = listenerList; return getListenerCount(lList, t); } ! private int getListenerCount(Object[] list, Class<?> t) { int count = 0; for (int i = 0; i < list.length; i+=2) { if (t == (Class)list[i]) count++; }
*** 286,296 **** while (null != (listenerTypeOrNull = s.readObject())) { ClassLoader cl = Thread.currentThread().getContextClassLoader(); EventListener l = (EventListener)s.readObject(); String name = (String) listenerTypeOrNull; ReflectUtil.checkPackageAccess(name); ! add((Class<EventListener>)Class.forName(name, true, cl), l); } } /** * Returns a string representation of the EventListenerList. --- 289,301 ---- while (null != (listenerTypeOrNull = s.readObject())) { ClassLoader cl = Thread.currentThread().getContextClassLoader(); EventListener l = (EventListener)s.readObject(); String name = (String) listenerTypeOrNull; ReflectUtil.checkPackageAccess(name); ! @SuppressWarnings("unchecked") ! Class<EventListener> tmp = (Class<EventListener>)Class.forName(name, true, cl); ! add(tmp, l); } } /** * Returns a string representation of the EventListenerList.