tmpB = new Object();
SoftReference sr = new SoftReference(tmpA, new ReferenceQueue());
WeakReference wr = new WeakReference(tmpB, new ReferenceQueue());
assertTrue("Start: Object not cleared.", (sr.get() != null)
&& (wr.get() != null));
sr.clear();
wr.clear();
assertTrue("End: Object cleared.", (sr.get() == null)
&& (wr.get() == null));
// Must reference tmpA and tmpB so the jit does not optimize them away
assertTrue("should always pass", tmpA != sr.get() && tmpB != wr.get());