WeakEventListenerList implements Serializable { @SuppressWarnings("unchecked") public <T extends EventListener> T[] getListeners(Class<T> t) { List<T> liveListeners = cleanReferences(); List<T> listeners = new ArrayList<T>(); for (int i = 0; i < liveListeners.size(); i++) { if (getClasses().get(i) == t) { listeners.add(liveListeners.get(i)); } } T[] result = (T[])Array.newInstance(t, listeners.size()); return listeners.toArray(result); }  Object[] getListenerList(); @SuppressWarnings("unchecked") T[] getListeners(Class<T> t); synchronized void add(Class<T> t, T l); synchronized void remove(Class<T> t, T l);  }
@Test public void testGetListenersInitial() { WeakEventListenerList list = new WeakEventListenerList(); assertNotNull("array must be not null", list.getListeners(ChangeListener.class)); assertEquals("array must be empty", 0, list.getListeners(ChangeListener.class).length); }