### Question:
ReferenceListeners implements JListeners<L> { @Override @Nonnull public List<L> getListeners() { final List<L> result; synchronized (listeners) { result = new ArrayList<L>(listeners.size()); for (Iterator<R> it = listeners.iterator(); it.hasNext(); ) { final R r = it.next(); final L l = r.get(); if (l == null) { it.remove(); } else { result.add(l); } } } return result; } private  ReferenceListeners(@Nonnull ReferenceProducer<R, L> referenceProducer); @Nonnull static ReferenceListeners<R, L> newInstance(@Nonnull ReferenceProducer<R, L> referenceProducer); @Nonnull static ReferenceListeners<WeakReference<L>, L> newWeakReferenceInstance(); @Nonnull static ReferenceListeners<WeakReference<L>, L> newHardReferenceInstance(); @Override boolean addListener(@Nonnull final L listener); @Override boolean removeListener(@Nonnull final L listener); @Override void removeListeners(); @Override @Nonnull List<L> getListeners(); @Nonnull @Override List<LE> getListenersOfType(@Nonnull Class<LE> type);  }### Answer:
@Test public void testGetListeners() throws Exception { final JListeners<TestListener> listeners = ReferenceListeners.newHardReferenceInstance(); final TestListener l1 = new TestListener() { @Override public void doSomething() { } }; Assert.assertTrue(listeners.addListener(l1)); Assert.assertFalse(listeners.addListener(l1)); listeners.addListener(new TestListener() { @Override public void doSomething() { } }); final Collection<TestListener> testListeners = listeners.getListeners(); Assert.assertEquals(2, testListeners.size()); testListeners.remove(l1); Assert.assertEquals(1, testListeners.size()); Assert.assertEquals(2, listeners.getListeners().size()); }