11 * This code is distributed in the hope that it will be useful, but WITHOUT 12 * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or 13 * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License 14 * version 2 for more details (a copy is included in the LICENSE file that 15 * accompanied this code). 16 * 17 * You should have received a copy of the GNU General Public License version 18 * 2 along with this work; if not, write to the Free Software Foundation, 19 * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. 20 * 21 * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA 22 * or visit www.oracle.com if you need additional information or have any 23 * questions. 24 */ 25 26 package jdk.jshell.spi; 27 28 import java.io.InputStream; 29 import java.io.PrintStream; 30 import java.util.List; 31 import jdk.jshell.EvalException; 32 import jdk.jshell.JShell; 33 import jdk.jshell.UnresolvedReferenceException; 34 35 /** 36 * Functionality made available to a pluggable JShell execution engine. It is 37 * provided to the execution engine by the core JShell implementation calling 38 * {@link ExecutionControl#start(jdk.jshell.spi.ExecutionEnv) }. 39 * <p> 40 * This interface is designed to provide the access to core JShell functionality 41 * needed to implement ExecutionControl. 42 * 43 * @see ExecutionControl 44 */ 45 public interface ExecutionEnv { 46 47 /** 48 * Returns the user's input stream. 49 * 50 * @return the user's input stream 51 */ 52 InputStream userIn(); 53 54 /** 55 * Returns the user's output stream. 56 * 57 * @return the user's output stream 58 */ 59 PrintStream userOut(); 60 61 /** 62 * Returns the user's error stream. 63 * 64 * @return the user's error stream 65 */ 66 PrintStream userErr(); 67 68 /** 69 * @return the JShell instance 70 */ 71 JShell state(); 72 73 /** 74 * Returns the additional VM options to be used when launching the remote 75 * JVM. This is advice to the execution engine. 76 * <p> 77 * Note: an execution engine need not launch a remote JVM. 78 * 79 * @return the additional options with which to launch the remote JVM 80 */ 81 List<String> extraRemoteVMOptions(); 82 83 /** 84 * Retrieves the class file bytes for the specified wrapper class. 85 * 86 * @param className the name of the wrapper class 87 * @return the current class file bytes as a byte array 88 */ 89 byte[] getClassBytes(String className); 90 91 /** 92 * Creates an {@code EvalException} corresponding to a user exception. An 93 * user exception thrown during 94 * {@link ExecutionControl#invoke(java.lang.String, java.lang.String) } 95 * should be converted to an {@code EvalException} using this method. 96 * 97 * @param message the exception message to use (from the user exception) 98 * @param exceptionClass the class name of the user exception 99 * @param stackElements the stack trace elements to install 100 * @return a user API EvalException for the user exception 101 */ 102 EvalException createEvalException(String message, String exceptionClass, 103 StackTraceElement[] stackElements); 104 105 /** 106 * Creates an {@code UnresolvedReferenceException} for the Snippet identifed 107 * by the specified identifier. An {@link SPIResolutionException} thrown 108 * during {@link ExecutionControl#invoke(java.lang.String, java.lang.String) } 109 * should be converted to an {@code UnresolvedReferenceException} using 110 * this method. 111 * <p> 112 * The identifier is an internal id, different from the id in the API. This 113 * internal id is returned by {@link SPIResolutionException#id()}. 114 * 115 * @param id the internal integer identifier 116 * @param stackElements the stack trace elements to install 117 * @return an {@code UnresolvedReferenceException} for the unresolved 118 * reference 119 */ 120 UnresolvedReferenceException createUnresolvedReferenceException(int id, 121 StackTraceElement[] stackElements); 122 123 /** 124 * Reports that the execution engine has shutdown. 125 */ 126 void closeDown(); 127 } | 11 * This code is distributed in the hope that it will be useful, but WITHOUT 12 * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or 13 * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License 14 * version 2 for more details (a copy is included in the LICENSE file that 15 * accompanied this code). 16 * 17 * You should have received a copy of the GNU General Public License version 18 * 2 along with this work; if not, write to the Free Software Foundation, 19 * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. 20 * 21 * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA 22 * or visit www.oracle.com if you need additional information or have any 23 * questions. 24 */ 25 26 package jdk.jshell.spi; 27 28 import java.io.InputStream; 29 import java.io.PrintStream; 30 import java.util.List; 31 import jdk.jshell.JShell; 32 33 /** 34 * Functionality made available to a pluggable JShell execution engine. It is 35 * provided to the execution engine by the core JShell implementation. 36 * <p> 37 * This interface is designed to provide the access to core JShell functionality 38 * needed to implement ExecutionControl. 39 * 40 * @see ExecutionControl 41 */ 42 public interface ExecutionEnv { 43 44 /** 45 * Returns the user's input stream. 46 * 47 * @return the user's input stream 48 */ 49 InputStream userIn(); 50 51 /** 52 * Returns the user's output stream. 53 * 54 * @return the user's output stream 55 */ 56 PrintStream userOut(); 57 58 /** 59 * Returns the user's error stream. 60 * 61 * @return the user's error stream 62 */ 63 PrintStream userErr(); 64 65 /** 66 * Returns the additional VM options to be used when launching the remote 67 * JVM. This is advice to the execution engine. 68 * <p> 69 * Note: an execution engine need not launch a remote JVM. 70 * 71 * @return the additional options with which to launch the remote JVM 72 */ 73 List<String> extraRemoteVMOptions(); 74 75 /** 76 * Reports that the execution engine has shutdown. 77 */ 78 void closeDown(); 79 80 } |