Hi Anthony,

thank you, these are good points. In fact, undefined and null should be treated 
as no input. The corresponding issue is here: 
https://bugs.openjdk.java.net/browse/JDK-8130127

Best,

Michael

> Am 25.06.2015 um 20:41 schrieb Anthony Vanelverdinghe 
> <anthony.vanelverdin...@gmail.com>:
> 
> Hi
> 
> Looking at the fix for JDK-8080490 ("add $EXECV command to Nashorn scripting 
> mode") raised a few questions concerning the stdin parameter of $EXEC:
> 
> - sample exec.js [1] uses the empty string to denote "no stdin". Why wasn't 
> undefined used instead?
> - $EXEC("someCmd", null) actually sends "null" to the process. In my opinion, 
> null should be treated the same as undefined & not send any input to the 
> process.
> - the implementation of $EXEC [2] always opens an OutputStreamWriter, even 
> when there's no stdin. I think it would be better to move the if-statement 
> out of the try-catch, like:
> 
> if (input != UNDEFINED && input != NULL) {
>    try (OutputStreamWriter outputStream = new 
> OutputStreamWriter(process.getOutputStream())) {
>        ...
>    } catch (final IOException ex) {}
> }
> 
> What do you think?
> 
> [1] 
> http://hg.openjdk.java.net/jdk9/dev/nashorn/file/a24cb0bf79bc/samples/exec.js
> [2] 
> http://hg.openjdk.java.net/jdk9/dev/nashorn/file/a24cb0bf79bc/src/jdk.scripting.nashorn/share/classes/jdk/nashorn/internal/runtime/ScriptingFunctions.java#l217
> 
> Kind regards,
> Anthony


-- 

 <http://www.oracle.com/>
Dr. Michael Haupt | Principal Member of Technical Staff
Phone: +49 331 200 7277 | Fax: +49 331 200 7561
Oracle Java Platform Group | LangTools Team | Nashorn
Oracle Deutschland B.V. & Co. KG, Schiffbauergasse 14 | 14467 Potsdam, Germany
 <http://www.oracle.com/commitment>     Oracle is committed to developing 
practices and products that help protect the environment

Reply via email to