code: private Snippet checkValidSnippet(Snippet sn) {
          if (sn == null) {
              throw new NullPointerException(messageFormat("jshell.exc.null"));
          } else {
              if (sn.key().state() != this) {
                  throw new IllegalArgumentException(messageFormat("jshell.exc.alien"));
              }
              return sn;
          }
      }
docs: Check a Snippet parameter coming from the API user
  @param sn the Snippet to check
  @throws NullPointerException if Snippet parameter is null
  @throws IllegalArgumentException if Snippet is not from this JShell
  @return the input Snippet (for chained calls)