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

Reply via email to