8071588: The spec for javax.script.ScriptEngineFactory.getProgram() should specify NPEs thrown

Reviewed-by: alanb, hannesw
This commit is contained in:
Athijegannathan Sundararajan 2016-10-19 13:26:49 +05:30
parent 8d889c2a92
commit b82ec86107
2 changed files with 5 additions and 3 deletions

View File

@ -216,8 +216,9 @@ public interface ScriptEngineFactory {
* @param statements The statements to be executed. May be return values of * @param statements The statements to be executed. May be return values of
* calls to the <code>getMethodCallSyntax</code> and <code>getOutputStatement</code> methods. * calls to the <code>getMethodCallSyntax</code> and <code>getOutputStatement</code> methods.
* @return The Program * @return The Program
*
* @throws NullPointerException if the <code>statements</code> array or any of its elements is null
*/ */
public String getProgram(String... statements); public String getProgram(String... statements);
/** /**

View File

@ -91,9 +91,10 @@ public class DummyScriptEngineFactory implements ScriptEngineFactory {
} }
public String getProgram(String... statements) { public String getProgram(String... statements) {
Objects.requireNonNull(statements);
StringBuffer buf = new StringBuffer(); StringBuffer buf = new StringBuffer();
for (int i = 0; i < statements.length; i++) { for (String stat : statements) {
buf.append(statements[i]); buf.append(Objects.requireNonNull(stat));
} }
return buf.toString(); return buf.toString();
} }