| Modifier and Type | Field and Description |
|---|---|
| private AutoCloseable | closeable
The closeable object. |
| private String | openStackTrace
The stack trace of when the object was created. |
| private static final ReferenceQueue | queue
The queue (might be set to null at any time).
|
| private static final Set | refs
The reference set. |
| Access | Constructor and Description |
|---|---|
| public |
| Modifier and Type | Method and Description |
|---|---|
| public AutoCloseable | |
| public String | |
| public static CloseWatcher | |
| public static CloseWatcher | Returns: the close watcherthe object o, AutoCloseable the object to close closeable, boolean whether the stack trace should be registered (this is
relatively slow) stackTrace)Register an object. |
| public static void |
| closeable | back to summary |
|---|---|
| private AutoCloseable closeable The closeable object. | |
| openStackTrace | back to summary |
|---|---|
| private String openStackTrace The stack trace of when the object was created. It is converted to a string early on to avoid classloader problems (a classloader can't be garbage collected if there is a static reference to one of its classes). | |
| queue | back to summary |
|---|---|
| private static final ReferenceQueue<Object> queue Hides java. The queue (might be set to null at any time). | |
| refs | back to summary |
|---|---|
| private static final Set<CloseWatcher> refs The reference set. Must keep it, otherwise the references are garbage collected first and thus never enqueued. | |
| CloseWatcher | back to summary |
|---|---|
| public CloseWatcher(Object referent, ReferenceQueue<Object> q, AutoCloseable closeable) | |
| getCloseable | back to summary |
|---|---|
| public AutoCloseable getCloseable() | |
| getOpenStackTrace | back to summary |
|---|---|
| public String getOpenStackTrace() Get the open stack trace or null if none.
| |
| pollUnclosed | back to summary |
|---|---|
| public static CloseWatcher pollUnclosed() Check for an collected object.
| |
| register | back to summary |
|---|---|
| public static CloseWatcher register(Object o, AutoCloseable closeable, boolean stackTrace) Register an object. Before calling this method, pollUnclosed() should be called in a loop to remove old references.
| |
| unregister | back to summary |
|---|---|
| public static void unregister(CloseWatcher w) Unregister an object, so it is no longer tracked.
| |