code: public String varValue(VarSnippet snippet) throws IllegalStateException {
          checkIfAlive();
          checkValidSnippet(snippet);
          if (snippet.status() != Status.VALID) {
              throw new IllegalArgumentException(
                      messageFormat("jshell.exc.var.not.valid",  snippet, snippet.status()));
          }
          String value;
          try {
              value = executionControl().varValue(snippet.classFullName(), snippet.name());
          } catch (EngineTerminationException ex) {
              throw new IllegalStateException(ex.getMessage());
          } catch (ExecutionControlException ex) {
              debug(ex, "In varValue()");
              return "[" + ex.getMessage() + "]";
          }
          return expunge(value);
      }
docs: Get the current value of a variable.
  @param snippet the variable Snippet whose value is queried.
  @return the current value of the variable referenced by snippet.
  @throws IllegalStateException if this {@code JShell} instance is closed.
  @throws IllegalArgumentException if the snippet is not associated with
  this {@code JShell} instance.
  @throws IllegalArgumentException if the variable's status is anything but
  {@link jdk.jshell.Snippet.Status#VALID}.