< prev index next >

src/jdk.scripting.nashorn.shell/share/classes/jdk/nashorn/tools/jjs/Main.java

Print this page

        

*** 31,40 **** --- 31,41 ---- import java.io.InputStream; import java.io.InputStreamReader; import java.io.IOException; import java.io.OutputStream; import java.io.PrintWriter; + import java.util.function.Consumer; import jdk.internal.jline.console.completer.Completer; import jdk.internal.jline.console.UserInterruptException; import jdk.nashorn.api.scripting.NashornException; import jdk.nashorn.internal.objects.Global; import jdk.nashorn.internal.runtime.Context;
*** 114,129 **** } global.addShellBuiltins(); if (System.getSecurityManager() == null) { ! // expose history object for reflecting on command line history ! global.addOwnProperty("history", Property.NOT_ENUMERABLE, new HistoryObject(in.getHistory())); ! ! // 'edit' command ! global.addOwnProperty("edit", Property.NOT_ENUMERABLE, new EditObject(err::println, ! str -> { // could be called from different thread (GUI), we need to handle Context set/reset final Global _oldGlobal = Context.getGlobal(); final boolean _globalChanged = (oldGlobal != global); if (_globalChanged) { Context.setGlobal(global); --- 115,125 ---- } global.addShellBuiltins(); if (System.getSecurityManager() == null) { ! final Consumer<String> evaluator = str -> { // could be called from different thread (GUI), we need to handle Context set/reset final Global _oldGlobal = Context.getGlobal(); final boolean _globalChanged = (oldGlobal != global); if (_globalChanged) { Context.setGlobal(global);
*** 133,143 **** } finally { if (_globalChanged) { Context.setGlobal(_oldGlobal); } } ! }, in)); } while (true) { String source = ""; try { --- 129,145 ---- } finally { if (_globalChanged) { Context.setGlobal(_oldGlobal); } } ! }; ! ! // expose history object for reflecting on command line history ! global.addOwnProperty("history", Property.NOT_ENUMERABLE, new HistoryObject(in.getHistory(), err, evaluator)); ! ! // 'edit' command ! global.addOwnProperty("edit", Property.NOT_ENUMERABLE, new EditObject(in, err::println, evaluator)); } while (true) { String source = ""; try {
< prev index next >