### Question:
WeakReferenceMatcherEditor implements MatcherEditor<E>, MatcherEditor.Listener<E> { @Override public synchronized void addMatcherEditorListener(Listener<E> listener) { this.listenerList.add(new WeakMatcherEditorListener<>(this, listener)); } WeakReferenceMatcherEditor(MatcherEditor<E> source); @Override Matcher<E> getMatcher(); @Override synchronized void addMatcherEditorListener(Listener<E> listener); @Override synchronized void removeMatcherEditorListener(Listener<E> listener); @Override synchronized void changedMatcher(Event<E> matcherEvent);  }### Answer:
@Test public void testGarbageCollectWeakListener() { final TextMatcherEditor<String> textMatcherEditor = new TextMatcherEditor<>(); MatcherEditor<String> weakMatcherEditor = Matchers.weakReferenceProxy(textMatcherEditor); CountingMatcherEditorListener<String> counter = new CountingMatcherEditorListener<>(); final WeakReference<CountingMatcherEditorListener> weakRef = new WeakReference<>(counter); weakMatcherEditor.addMatcherEditorListener(counter); counter.assertCounterState(0, 0, 0, 0, 0); textMatcherEditor.setFilterText(new String[] {"booblah"}); counter.assertCounterState(0, 0, 0, 1, 0); counter = null; System.gc(); textMatcherEditor.setFilterText(new String[] {"bibbety"}); assertNull(weakRef.get()); }
@Ignore("Fix me") @Test public void testGarbageCollectWeakReferenceProxy() { final TextMatcherEditor<String> textMatcherEditor = new TextMatcherEditor<>(); MatcherEditor<String> weakMatcherEditor = Matchers.weakReferenceProxy(textMatcherEditor); final CountingMatcherEditorListener<String> counter = new CountingMatcherEditorListener<>(); weakMatcherEditor.addMatcherEditorListener(counter); counter.assertCounterState(0, 0, 0, 0, 0); textMatcherEditor.setFilterText(new String[] {"booblah"}); counter.assertCounterState(0, 0, 0, 1, 0); weakMatcherEditor = null; System.gc(); textMatcherEditor.setFilterText(new String[] {"bibbety"}); counter.assertCounterState(0, 0, 0, 1, 0); }