< prev index next >

## src/jdk.scripting.nashorn/share/classes/jdk/nashorn/tools/Shell.java

Print this page

     153     /**
     154      * Run method logic.
     155      *
     156      * @param in input stream for Shell
     157      * @param out output stream for Shell
     158      * @param err error stream for Shell
     159      * @param args arguments to Shell
     160      *
     161      * @return exit code
     162      *
     163      * @throws IOException if there's a problem setting up the streams
     164      */
     165     protected final int run(final InputStream in, final OutputStream out, final OutputStream err, final String[] args) throws IOException {
     166         final Context context = makeContext(in, out, err, args);
     167         if (context == null) {
     168             return COMMANDLINE_ERROR;
     169         }
     170
     171         final Global global = context.createGlobal();
     172         final ScriptEnvironment env = context.getEnv();

     173         final List<String> files = env.getFiles();
     174         if (files.isEmpty()) {
     175             return readEvalPrint(context, global);
     176         }
     177
     178         if (env._compile_only) {
     179             return compileScripts(context, global, files);
     180         }
     181
     182         if (env._fx) {
     183             return runFXScripts(context, global, files);
     184         }
     185
     186         return runScripts(context, global, files);
     187     }
     188
     189     /**
     190      * Make a new Nashorn Context to compile and/or run JavaScript files.
     191      *
     192      * @param in input stream for Shell
     153     /**
     154      * Run method logic.
     155      *
     156      * @param in input stream for Shell
     157      * @param out output stream for Shell
     158      * @param err error stream for Shell
     159      * @param args arguments to Shell
     160      *
     161      * @return exit code
     162      *
     163      * @throws IOException if there's a problem setting up the streams
     164      */
     165     protected final int run(final InputStream in, final OutputStream out, final OutputStream err, final String[] args) throws IOException {
     166         final Context context = makeContext(in, out, err, args);
     167         if (context == null) {
     168             return COMMANDLINE_ERROR;
     169         }
     170
     171         final Global global = context.createGlobal();
     172         final ScriptEnvironment env = context.getEnv();
     173         if (!env._no_deprecation_warning) {
     174             System.err.println("Warning: The jjs tool is planned to be removed from a future JDK release");
     175         }
     176         final List<String> files = env.getFiles();
     177         if (files.isEmpty()) {
     178             return readEvalPrint(context, global);
     179         }
     180
     181         if (env._compile_only) {
     182             return compileScripts(context, global, files);
     183         }
     184
     185         if (env._fx) {
     186             return runFXScripts(context, global, files);
     187         }
     188
     189         return runScripts(context, global, files);
     190     }
     191
     192     /**
     193      * Make a new Nashorn Context to compile and/or run JavaScript files.
     194      *
     195      * @param in input stream for Shell

< prev index next >