public interface GroovyClassValue<T>
Abstraction for Java version dependent ClassValue implementations.
| Modifiers | Name | Description |
|---|---|---|
interface |
GroovyClassValue.ComputeValue |
| Type Params | Return Type | Name and description |
|---|---|---|
|
public T |
get(Class<?> type) |
|
public void |
pin(Class<?> type, T value)Keeps value strongly reachable from its own key's
association until unpin or remove. |
|
public void |
remove(Class<?> type) |
|
public void |
unpin(Class<?> type, T value)Reverts pin: the association holds value reclaimably
again. |
|
public boolean |
valuesReclaimable()Whether an association's value can be collected while its key class is still alive (GROOVY-12281, -Dgroovy.use.classvalue=soft). |
Keeps value strongly reachable from its own key's
association until unpin or remove. The value then
lives exactly as long as type — like a plain
java.lang.ClassValue association: an immortal key retains it,
a collectible key releases it together with its loader. Implementations
must not root the value globally, which would extend a collectible key's
lifetime to the runtime's. No-op unless valuesReclaimable().
type - the key classvalue - the current value for type Reverts pin: the association holds value reclaimably
again. No-op when value is not the currently pinned value, and
unless valuesReclaimable().
type - the key classvalue - the value to release Whether an association's value can be collected while its key class is
still alive (GROOVY-12281, -Dgroovy.use.classvalue=soft). The
default — a value lives exactly as long as its key class — answers
false. Implementations answering true must honor
pin so callers can exempt values whose state cannot be rebuilt
by recomputation.
true if values may be collected before their key class