public interface ReferenceCountedTracer extends ReferenceCounted
ReferenceCounted with tracing utilities.
Implementations record which ReferenceOwner reserved or released a
resource and can report where an unexpected release occurred. Tracing is
useful when diagnosing ClosedIllegalStateException or
ThreadingIllegalStateException thrown by misused resources.INIT, TMP| Modifier and Type | Method and Description |
|---|---|
StackTrace |
createdHere()
Retrieves the stack trace of the point where the object was created.
|
static @NotNull ReferenceCountedTracer |
onReleased(Runnable onRelease,
Supplier<String> uniqueId,
Class<?> type)
Factory method that creates a new instance of .
|
void |
throwExceptionIfNotReleased()
Throws an exception if the object has not been released.
|
default void |
throwExceptionIfReleased()
Throws an exception if the object has been released.
|
void |
warnAndReleaseIfNotReleased()
Releases any remaining references and logs a warning if there were any references to release.
|
addReferenceChangeListener, refCount, release, releaseLast, releaseLast, removeReferenceChangeListener, reserve, reserveTransfer, tryReservereferenceId, referenceName, temporary@NotNull static @NotNull ReferenceCountedTracer onReleased(Runnable onRelease, Supplier<String> uniqueId, Class<?> type)
onRelease - The Runnable that will be executed when the object is released.uniqueId - A Supplier of unique identifiers for the object. It should provide a unique
string identifier for each invocation.type - The Class representing the type of the object being reference counted.default void throwExceptionIfReleased()
throws ClosedIllegalStateException
ClosedIllegalStateException - If the resource has been released or closed.void warnAndReleaseIfNotReleased()
throws ClosedIllegalStateException
This method is intended to be called by a finalizer or in a test to confirm that references are being released correctly.
Note: This method will not trigger any ReferenceChangeListeners as it is mainly used for sanity checks.
ClosedIllegalStateException - If the object has not been released.void throwExceptionIfNotReleased()
throws IllegalStateException
IllegalStateException - If the object has not been released (i.e., its reference count is greater than 0).StackTrace createdHere()
Copyright © 2026 Chronicle Software Ltd. All rights reserved.