/** * Removes this Link from any chain upon finalization. Since the only way this Link could be * garbage collected is for all references to it or to any Link on its chain to be dropped (except * for the references in the Links themselves), this really is not necessary. (Depending on how * the mark-and-sweep garbage collector works, this may actually slow down the recovery of the * Links.) */ protected void finalize() throws Throwable { try { remove(); } finally { super.finalize(); } }
/** * Remove the most recently returned Link on the chain. * * @throws IllegalStateException is there is no most recently returned Link or if that Link was * already removed. */ public void remove() throws IllegalStateException { if (latest == null) { throw new IllegalStateException(); } if ((latest == origin) && latest.isChained()) { origin = null; } latest.remove(); latest = null; }