Uploaded image for project: 'JDK'
  1. JDK
  2. JDK-8068603

NashornScriptEngine.put/get() impls don't conform to NPE, IAE spec assertions

    Details

    • Subcomponent:
    • Resolved In Build:
      b48
    • CPU:
      generic
    • OS:
      generic

      Backports

        Description

        The spec for the methods
        http://docs.oracle.com/javase/8/docs/api/javax/script/ScriptEngine.html#put-java.lang.String-java.lang.Object-
        http://docs.oracle.com/javase/8/docs/api/javax/script/ScriptEngine.html#get-java.lang.String-

        says:
        "Throws:
        NullPointerException - if key is null.
        IllegalArgumentException - if key is empty."

        However the following code executed on Oracle's JDK.

                new ScriptEngineManager().getEngineFactories()
                        .stream()
                        .map(ScriptEngineFactory::getScriptEngine)
                        .forEach(e -> {
                            e.get("");
                            e.get(null);
                            e.put("", "a");
                            e.put(null, "a");
                        });

        results in no exceptions thrown which doesn't conform to the current spec and the corresponding JCK9(b05) tests will fail on JDK9:

        api/javax_script/ScriptEngineFactory/index.html#GetParameter[get_keyIsEmpty_IAE]
        api/javax_script/ScriptEngineFactory/index.html#GetParameter[get_keyIsNull_NPE]
        api/javax_script/ScriptEngineFactory/index.html#GetParameter[put_keyIsEmpty_IAE]
        api/javax_script/ScriptEngineFactory/index.html#GetParameter[put_keyIsNull_NPE]

          Attachments

            Issue Links

              Activity

                People

                • Assignee:
                  attila Attila Szegedi
                  Reporter:
                  dbessono Dmitry Bessonov
                • Votes:
                  0 Vote for this issue
                  Watchers:
                  3 Start watching this issue

                  Dates

                  • Created:
                    Updated:
                    Resolved: