8071588: The spec for javax.script.ScriptEngineFactory.getProgram() should specify NPEs thrown
Reviewed-by: alanb, hannesw
--- a/jdk/src/java.scripting/share/classes/javax/script/ScriptEngineFactory.java Wed Oct 19 11:45:43 2016 +0800
+++ b/jdk/src/java.scripting/share/classes/javax/script/ScriptEngineFactory.java Wed Oct 19 13:26:49 2016 +0530
@@ -216,8 +216,9 @@
* @param statements The statements to be executed. May be return values of
* calls to the <code>getMethodCallSyntax</code> and <code>getOutputStatement</code> methods.
* @return The Program
+ *
+ * @throws NullPointerException if the <code>statements</code> array or any of its elements is null
*/
-
public String getProgram(String... statements);
/**
--- a/jdk/test/javax/script/DummyScriptEngineFactory.java Wed Oct 19 11:45:43 2016 +0800
+++ b/jdk/test/javax/script/DummyScriptEngineFactory.java Wed Oct 19 13:26:49 2016 +0530
@@ -91,9 +91,10 @@
}
public String getProgram(String... statements) {
+ Objects.requireNonNull(statements);
StringBuffer buf = new StringBuffer();
- for (int i = 0; i < statements.length; i++) {
- buf.append(statements[i]);
+ for (String stat : statements) {
+ buf.append(Objects.requireNonNull(stat));
}
return buf.toString();
}