This repository has been archived by the owner on Aug 31, 2019. It is now read-only.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
This is a generalization of the idea behind some recent SportBukkit changes
Objects that are prone to leakage, such as
World
,Entity
, etc, can provide aHandle
to themselves, a lightweight object that knows how to retrieve the object, but does not hold a strong reference to it. Trying to access the object beyond its natural lifespan throws an exception.Handle
s to the same object compare equal to each other, and this can be determined without dereferencing the object. A handle can also provide a dynamic proxy for the object that delegates method calls through the handle.Objects can provide
Handle
s through theHandleable
interface. This uses aWeakReference
by default, but this has the limitation that any leak of the object prevents the release of allHandle
s. Things likeWorld
orEntity
would implementHandle
s using theirUUID
.This needs a bit more work, and some implementation in SportBukkit and BungeeCord.