Mercurial > people > rkennke > jdk9-shenandoah-final > nashorn
changeset 281:288ff54da2a5
8014827: readLine should accept a prompt as an argument
Reviewed-by: sundar, hannesw
Contributed-by: james.laskey@oracle.com
author | jlaskey |
---|---|
date | Tue, 21 May 2013 10:17:09 -0300 |
parents | 833a9a584b64 |
children | 07cefc062032 |
files | src/jdk/nashorn/internal/runtime/ScriptingFunctions.java |
diffstat | 1 files changed, 7 insertions(+), 3 deletions(-) [+] |
line wrap: on
line diff
--- a/src/jdk/nashorn/internal/runtime/ScriptingFunctions.java Tue May 21 13:40:12 2013 +0200 +++ b/src/jdk/nashorn/internal/runtime/ScriptingFunctions.java Tue May 21 10:17:09 2013 -0300 @@ -46,7 +46,7 @@ public final class ScriptingFunctions { /** Handle to implementation of {@link ScriptingFunctions#readLine} - Nashorn extension */ - public static final MethodHandle READLINE = findOwnMH("readLine", Object.class, Object.class); + public static final MethodHandle READLINE = findOwnMH("readLine", Object.class, Object.class, Object.class); /** Handle to implementation of {@link ScriptingFunctions#readFully} - Nashorn extension */ public static final MethodHandle READFULLY = findOwnMH("readFully", Object.class, Object.class, Object.class); @@ -78,13 +78,17 @@ * Nashorn extension: global.readLine (scripting-mode-only) * Read one line of input from the standard input. * - * @param self self reference + * @param self self reference + * @param prompt String used as input prompt * * @return line that was read * * @throws IOException if an exception occurs */ - public static Object readLine(final Object self) throws IOException { + public static Object readLine(final Object self, final Object prompt) throws IOException { + if (prompt != UNDEFINED) { + System.out.print(JSType.toString(prompt)); + } final BufferedReader reader = new BufferedReader(new InputStreamReader(System.in)); return reader.readLine(); }