8071588: The spec for javax.script.ScriptEngineFactory.getProgram() should specify NPEs thrown
authorsundar
Wed, 19 Oct 2016 13:26:49 +0530
changeset 41587 47e38af37938
parent 41586 d6f36cdf633c
child 41588 6e66ad59f99a
8071588: The spec for javax.script.ScriptEngineFactory.getProgram() should specify NPEs thrown Reviewed-by: alanb, hannesw
jdk/src/java.scripting/share/classes/javax/script/ScriptEngineFactory.java
jdk/test/javax/script/DummyScriptEngineFactory.java
--- 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();
     }