public abstract class ContextLocal<T> extends Object
ContextLocal.get()
or for other contexts using
ContextLocal.get(TruffleContext)
. Context locals can be created for languages and instruments. See
links below for usage examples.Usage with languages.
,
Usage with instruments.
Modifier | Constructor and Description |
---|---|
protected |
ContextLocal(Object polyglotObject)
Custom subclasses of context local are not allowed.
|
Modifier and Type | Method and Description |
---|---|
abstract T |
get()
Returns the context local value for the currently entered context.
|
abstract T |
get(TruffleContext context)
Returns the context local value for an explicit
context . |
protected ContextLocal(Object polyglotObject)
public abstract T get()
null
.IllegalStateException
- if assertions (-ea) are enabled and no current context is
entered on the current thread, context locals have already been cleared for the
current context, the corresponding instrument is not initialized, or the
corresponding language is not created.public abstract T get(TruffleContext context)
context
. This method
is intended to be used on compiled code paths. The return value is never null
.IllegalStateException
- if assertions (-ea) are enabled and context locals have already
been cleared for the specified context, the corresponding instrument is not
initialized, or the corresponding language is not created.