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

Spec violation: JavaScript engine (embedded in Sun's jdk) can throw not only ScriptException

    Details

    • Type: Bug
    • Status: Closed
    • Priority: P3
    • Resolution: Won't Fix
    • Affects Version/s: 6
    • Fix Version/s: 6
    • Component/s: core-libs
    • Labels:

      Description

      JavaScript engine (embedded in Sun's jdk) can throw not only ScriptException when script has a string that starts with valid operator(s) and ends with invalid one (see below example).
      This is a spec violation because spec for ScriptException class says clear:
      "The generic Exception class for the Scripting APIs. Checked exception types thrown by underlying scripting implementations must be wrapped in instances of ScriptException."

      Example:

      package test1;

      import javax.script.*;

      public class js_test {
          public static void main(String[] args) {
              String testScript = "print('Hello world');blabla;";
              ScriptEngineManager manager = new ScriptEngineManager();
              ScriptEngine jsFactory = manager.getEngineByExtension("js");
              try {
                  Object result = jsFactory.eval(testScript);
              } catch (ScriptException e) {
                  System.out.println("in ScriptException");
                  e.printStackTrace();
              } catch(Exception e) {
                  System.out.println("in Exception - bug present");
                  e.printStackTrace();
              }

          }
      }

      Above example will throw java.lang.ArrayIndexOutOfBoundsException, not ScriptException as spec required.
      ###@###.### 2005-07-13 09:44:14 GMT

        Attachments

          Activity

            People

            • Assignee:
              sundar Sundararajan Athijegannathan
              Reporter:
              vsmelovsunw Vladimir Smelov (Inactive)
            • Votes:
              0 Vote for this issue
              Watchers:
              0 Start watching this issue

              Dates

              • Created:
                Updated:
                Resolved:
                Imported:
                Indexed: