Interface Insight.SymbolProvider

Enclosing class:

public static interface Insight.SymbolProvider
Additional provider of symbols for Insight scripts. All available instruments are queried for implementation of this interface. If provided, they can contribute symbols with their values to be available as globals when executing the Insight scripts.

    id = "meaningOfWorld", name = "Meaning Of World", version = "demo",
    services = { Insight.SymbolProvider.class }
public final class MeaningOfWorldInstrument extends TruffleInstrument {
    protected void onCreate(Env env) {
        Map<String, Integer> symbols = Collections.singletonMap("meaning", 42);
        Insight.SymbolProvider provider = () -> symbols;

The previous instrument makes variable meanining with value 42 available to every Insight script when properly registered into the virtual machine. A typical way is to register your custom instrument is to use property truffle.class.path.append when launching the virtual machine:

 graalvm/bin/java -Dtruffle.class.path.append=meaningOfWorld.jar -jar app.jar
Take care when writing your instruments as they can alter many aspects of program execution and aren't subject to any security sandbox. See TruffleInstrument for more information about developing, using and registering instruments.
  • Method Summary

    Modifier and Type
    Map<String,? extends Object>
    Map with symbol names and their interop values.
  • Method Details

    • symbolsWithValues

      Map<String,? extends Object> symbolsWithValues() throws Exception
      Map with symbol names and their interop values.
      map mapping names to their primitive, String or TruffleObject values
      Exception - any exception is propagated as an internal error