Package com.oracle.truffle.api
Class ContextLocal<T>
java.lang.Object
com.oracle.truffle.api.ContextLocal<T>
A context local reference that refers to a value that is created for each polyglot context.
Context references can be used to attach data to a polyglot context. That data can be retrieved
efficiently for the current context using
get()
or for other contexts using
get(TruffleContext)
. Context locals can be created for languages and instruments. See
links below for usage examples.- Since:
- 20.3
- See Also:
-
Constructor Summary
ModifierConstructorDescriptionprotected
ContextLocal
(Object polyglotObject) Custom subclasses of context local are not allowed. -
Method Summary
-
Constructor Details
-
ContextLocal
Custom subclasses of context local are not allowed.- Since:
- 20.3
-
-
Method Details
-
get
Returns the context local value for the currently entered context. This method is intended to be used on compiled code paths. The return value is nevernull
.- Throws:
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.- Since:
- 20.3
-
get
Returns the context local value for an explicitcontext
. This method is intended to be used on compiled code paths. The return value is nevernull
.- Throws:
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.- Since:
- 20.3
-