RefWatcher { public void watch(Object watchedReference) { watch(watchedReference, ""); } RefWatcher(Executor watchExecutor, DebuggerControl debuggerControl, GcTrigger gcTrigger,
      HeapDumper heapDumper, HeapDump.Listener heapdumpListener, ExcludedRefs excludedRefs); void watch(Object watchedReference); void watch(Object watchedReference, String referenceName); static final RefWatcher DISABLED; }
@Test public void unreachableObject_noDump() { TestDumper dumper = new TestDumper(); TestExecutor executor = new TestExecutor(); RefWatcher refWatcher = defaultWatcher(dumper, executor); refWatcher.watch(new Object()); executor.command.run(); assertFalse(dumper.called); }
@Test public void retainedObject_triggersDump() { TestDumper dumper = new TestDumper(); TestExecutor executor = new TestExecutor(); RefWatcher refWatcher = defaultWatcher(dumper, executor); ref = new Object(); refWatcher.watch(ref); executor.command.run(); assertTrue(dumper.called); }