langtools/src/jdk.jshell/share/classes/jdk/jshell/JShell.java
changeset 46185 f4c981fc7818
parent 45045 834233132ab1
equal deleted inserted replaced
46184:f1325703ea85 46185:f4c981fc7818
   860 
   860 
   861     /**
   861     /**
   862      * Check if this JShell has been closed
   862      * Check if this JShell has been closed
   863      * @throws IllegalStateException if it is closed
   863      * @throws IllegalStateException if it is closed
   864      */
   864      */
   865     private void checkIfAlive()  throws IllegalStateException {
   865     void checkIfAlive()  throws IllegalStateException {
   866         if (closed) {
   866         if (closed) {
   867             throw new IllegalStateException(messageFormat("jshell.exc.closed", this));
   867             throw new IllegalStateException(messageFormat("jshell.exc.closed", this));
   868         }
   868         }
   869     }
   869     }
   870 
   870 
   877      */
   877      */
   878     private Snippet checkValidSnippet(Snippet sn) {
   878     private Snippet checkValidSnippet(Snippet sn) {
   879         if (sn == null) {
   879         if (sn == null) {
   880             throw new NullPointerException(messageFormat("jshell.exc.null"));
   880             throw new NullPointerException(messageFormat("jshell.exc.null"));
   881         } else {
   881         } else {
   882             if (sn.key().state() != this) {
   882             if (sn.key().state() != this || sn.id() == Snippet.UNASSOCIATED_ID) {
   883                 throw new IllegalArgumentException(messageFormat("jshell.exc.alien"));
   883                 throw new IllegalArgumentException(messageFormat("jshell.exc.alien", sn.toString()));
   884             }
   884             }
   885             return sn;
   885             return sn;
   886         }
   886         }
   887     }
   887     }
   888 
   888