CloseableReferenceCount { public void reference() throws ClosedChannelException { int curBits = status.incrementAndGet(); if ((curBits & STATUS_CLOSED_MASK) != 0) { status.decrementAndGet(); throw new ClosedChannelException(); } } CloseableReferenceCount(); void reference(); boolean unreference(); void unreferenceCheckClosed(); boolean isOpen(); int setClosed(); int getReferenceCount();  }
@Test public void testReference() throws ClosedChannelException { CloseableReferenceCount clr = new CloseableReferenceCount(); clr.reference(); assertEquals("Incorrect reference count", 1, clr.getReferenceCount()); }