From inside jShell script, is it possible to access or register variables that are defined in code that's also creating JShell?
Currently there seems to be no mechanism to either access or register a variable to Shell instance, or return none string types from inside JShell (like objects or lambda etc.)
ex:
import jdk.jshell.JShell; import jdk.jshell.JShellException; import jdk.jshell.SnippetEvent; import java.util.List; public class Main { public static void main(String[] args) throws JShellException { var localVar = 1; JShell shell = JShell.create(); // How to register localVar variable with shell instance or access variables from scope List events = shell.eval("var x = localVar;"); SnippetEvent event = events.get(0); System.out.println("Kind: " + event.snippet().kind() + ", Value: " + event.value()); } }