--- a/langtools/src/jdk.jshell/share/classes/jdk/jshell/JShell.java Tue Aug 15 13:16:32 2017 -0700
+++ b/langtools/src/jdk.jshell/share/classes/jdk/jshell/JShell.java Wed Aug 16 18:42:11 2017 -0700
@@ -862,7 +862,7 @@
* Check if this JShell has been closed
* @throws IllegalStateException if it is closed
*/
- private void checkIfAlive() throws IllegalStateException {
+ void checkIfAlive() throws IllegalStateException {
if (closed) {
throw new IllegalStateException(messageFormat("jshell.exc.closed", this));
}
@@ -879,8 +879,8 @@
if (sn == null) {
throw new NullPointerException(messageFormat("jshell.exc.null"));
} else {
- if (sn.key().state() != this) {
- throw new IllegalArgumentException(messageFormat("jshell.exc.alien"));
+ if (sn.key().state() != this || sn.id() == Snippet.UNASSOCIATED_ID) {
+ throw new IllegalArgumentException(messageFormat("jshell.exc.alien", sn.toString()));
}
return sn;
}