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

JavaScript execution with Nashorn fails with ScriptException

    Details

    • Subcomponent:
    • Introduced In Version:
    • CPU:
      generic
    • OS:
      generic

      Description

      FULL PRODUCT VERSION :
      java version "1.8.0_92"
      Java(TM) SE Runtime Environment (build 1.8.0_92-b14)
      Java HotSpot(TM) 64-Bit Server VM (build 25.92-b14, mixed mode)

      ADDITIONAL OS VERSION INFORMATION :
      Linux 3.13.0-85-generic #129-Ubuntu SMP Thu Mar 17 20:50:15 UTC 2016 x86_64 GNU/Linux

      A DESCRIPTION OF THE PROBLEM :
      Problem detected while running raml-java-parser-2 (https://github.com/raml-org/raml-java-parser-2/commit/4b7e4459a553813201148abbf9571900662cd616).

      Launching a JS script that contains 'console.log' fails, stack trace below.

      Works with java 1.8.0_66 but not anymore since 1.8.0_77.
      Tested on Mac OS El capitan too.


      REGRESSION. Last worked in version 8u73

      ADDITIONAL REGRESSION INFORMATION:
      java version "1.8.0_66"
      Java(TM) SE Runtime Environment (build 1.8.0_66-b17)
      Java HotSpot(TM) 64-Bit Server VM (build 25.66-b17, mixed mode)

      STEPS TO FOLLOW TO REPRODUCE THE PROBLEM :
      1/ Clone: https://github.com/raml-org/raml-java-parser-2
      2/ Launch 'mvn clean install'


      EXPECTED VERSUS ACTUAL BEHAVIOR :
      EXPECTED -
      Tests should pass.
      ACTUAL -
      Tests fail.

      ERROR MESSAGES/STACK TRACES THAT OCCUR :
      Running com.mulesoft.raml1.java.patser.test.Raml1Test
      Instance created: Wrapper
      Instance created: JavaPathResolverHolder
      Instance created: JSZ
      Instance created: JSSchema
      Instance created: JSFileSystem
      Instance created: JSReportManager
      Instance created: JSConsole
      Instance created: JSHttp
      Instance created: JSHttp
      Instance created: JSPlatformExecution
      Instance created: JSChildProcess

      Instance created: JSChildProcess

      Instance created: JSHolder
      Instance created: JSHolder
      javax.script.ScriptException: ReferenceError: "console" is not defined in <eval> at line number 5909
      at jdk.nashorn.api.scripting.NashornScriptEngine.throwAsScriptException(NashornScriptEngine.java:467)
      at jdk.nashorn.api.scripting.NashornScriptEngine.evalImpl(NashornScriptEngine.java:451)
      at jdk.nashorn.api.scripting.NashornScriptEngine.evalImpl(NashornScriptEngine.java:403)
      at jdk.nashorn.api.scripting.NashornScriptEngine.evalImpl(NashornScriptEngine.java:399)
      at jdk.nashorn.api.scripting.NashornScriptEngine.eval(NashornScriptEngine.java:155)
      at javax.script.AbstractScriptEngine.eval(AbstractScriptEngine.java:233)
      at com.mulesoft.raml1.java.parser.core.Wrapper.getApiJsObject(Wrapper.java:44)
      at com.mulesoft.raml1.java.parser.core.JavaNodeFactory.createApi(JavaNodeFactory.java:57)
      at com.mulesoft.raml1.java.patser.test.Raml1Test.beforeClass(Raml1Test.java:34)
      at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
      at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62)
      at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
      at java.lang.reflect.Method.invoke(Method.java:498)
      at org.junit.runners.model.FrameworkMethod$1.runReflectiveCall(FrameworkMethod.java:50)
      at org.junit.internal.runners.model.ReflectiveCallable.run(ReflectiveCallable.java:12)
      at org.junit.runners.model.FrameworkMethod.invokeExplosively(FrameworkMethod.java:47)
      at org.junit.internal.runners.statements.RunBefores.evaluate(RunBefores.java:24)
      at org.junit.runners.ParentRunner.run(ParentRunner.java:363)
      at org.apache.maven.surefire.junit4.JUnit4Provider.execute(JUnit4Provider.java:252)
      at org.apache.maven.surefire.junit4.JUnit4Provider.executeTestSet(JUnit4Provider.java:141)
      at org.apache.maven.surefire.junit4.JUnit4Provider.invoke(JUnit4Provider.java:112)
      at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
      at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62)
      at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
      at java.lang.reflect.Method.invoke(Method.java:498)
      at org.apache.maven.surefire.util.ReflectionUtils.invokeMethodWithArray(ReflectionUtils.java:189)
      at org.apache.maven.surefire.booter.ProviderFactory$ProviderProxy.invoke(ProviderFactory.java:165)
      at org.apache.maven.surefire.booter.ProviderFactory.invokeProvider(ProviderFactory.java:85)
      at org.apache.maven.surefire.booter.ForkedBooter.runSuitesInProcess(ForkedBooter.java:115)
      at org.apache.maven.surefire.booter.ForkedBooter.main(ForkedBooter.java:75)
      Caused by: <eval>:5909 ReferenceError: "console" is not defined
      at jdk.nashorn.internal.runtime.ECMAErrors.error(ECMAErrors.java:57)
      at jdk.nashorn.internal.runtime.ECMAErrors.referenceError(ECMAErrors.java:319)
      at jdk.nashorn.internal.runtime.ECMAErrors.referenceError(ECMAErrors.java:291)
      at jdk.nashorn.internal.objects.Global.__noSuchProperty__(Global.java:1426)
      at jdk.nashorn.internal.scripts.Script$Recompilation$919$189952AAAAAA$\^eval\_.L:4609$ASTNode$ASTNode(<eval>:5909)
      at jdk.nashorn.internal.scripts.Script$Recompilation$944$209290AAA$\^eval\_.L:4609$ASTNode$children(<eval>:6470)
      at jdk.nashorn.internal.scripts.Script$Recompilation$944$209290AAA$\^eval\_.L:4609$ASTNode$children(<eval>:6440)
      at jdk.nashorn.internal.scripts.Script$Recompilation$1018$365810$\^eval\_.L:10065$LowLevelValueTransformingNode$children(<eval>:10389)
      at jdk.nashorn.internal.scripts.Script$Recompilation$1044$342791A$\^eval\_.L:9464$serialize(<eval>:9690)
      at jdk.nashorn.internal.scripts.Script$Recompilation$1045$343202A$\^eval\_.L:9464$serialize$L:9705(<eval>:9706)
      at jdk.nashorn.internal.runtime.ScriptFunctionData.invoke(ScriptFunctionData.java:639)
      at jdk.nashorn.internal.runtime.ScriptFunction.invoke(ScriptFunction.java:494)
      at jdk.nashorn.internal.runtime.ScriptRuntime.apply(ScriptRuntime.java:393)
      at jdk.nashorn.internal.objects.NativeArray$9.forEach(NativeArray.java:1615)
      at jdk.nashorn.internal.runtime.arrays.IteratorAction.apply(IteratorAction.java:110)
      at jdk.nashorn.internal.objects.NativeArray.forEach(NativeArray.java:1618)
      at jdk.nashorn.internal.scripts.Script$Recompilation$1044$342791A$\^eval\_.L:9464$serialize(<eval>:9705)
      at jdk.nashorn.internal.scripts.Script$Recompilation$1045$343202A$\^eval\_.L:9464$serialize$L:9705(<eval>:9706)
      at jdk.nashorn.internal.runtime.ScriptFunctionData.invoke(ScriptFunctionData.java:639)
      at jdk.nashorn.internal.runtime.ScriptFunction.invoke(ScriptFunction.java:494)
      at jdk.nashorn.internal.runtime.ScriptRuntime.apply(ScriptRuntime.java:393)
      at jdk.nashorn.internal.objects.NativeArray$9.forEach(NativeArray.java:1615)
      at jdk.nashorn.internal.runtime.arrays.IteratorAction.apply(IteratorAction.java:110)
      at jdk.nashorn.internal.objects.NativeArray.forEach(NativeArray.java:1618)
      at jdk.nashorn.internal.scripts.Script$Recompilation$1044$342791A$\^eval\_.L:9464$serialize(<eval>:9705)
      at jdk.nashorn.internal.scripts.Script$Recompilation$1045$343202A$\^eval\_.L:9464$serialize$L:9705(<eval>:9706)
      at jdk.nashorn.internal.runtime.ScriptFunctionData.invoke(ScriptFunctionData.java:639)
      at jdk.nashorn.internal.runtime.ScriptFunction.invoke(ScriptFunction.java:494)
      at jdk.nashorn.internal.runtime.ScriptRuntime.apply(ScriptRuntime.java:393)
      at jdk.nashorn.internal.objects.NativeArray$9.forEach(NativeArray.java:1615)
      at jdk.nashorn.internal.runtime.arrays.IteratorAction.apply(IteratorAction.java:110)
      at jdk.nashorn.internal.objects.NativeArray.forEach(NativeArray.java:1618)
      at jdk.nashorn.internal.scripts.Script$Recompilation$1044$342791A$\^eval\_.L:9464$serialize(<eval>:9705)
      at jdk.nashorn.internal.scripts.Script$Recompilation$1045$343202A$\^eval\_.L:9464$serialize$L:9705(<eval>:9706)
      at jdk.nashorn.internal.runtime.ScriptFunctionData.invoke(ScriptFunctionData.java:639)
      at jdk.nashorn.internal.runtime.ScriptFunction.invoke(ScriptFunction.java:494)
      at jdk.nashorn.internal.runtime.ScriptRuntime.apply(ScriptRuntime.java:393)
      at jdk.nashorn.internal.objects.NativeArray$9.forEach(NativeArray.java:1615)
      at jdk.nashorn.internal.runtime.arrays.IteratorAction.apply(IteratorAction.java:110)
      at jdk.nashorn.internal.objects.NativeArray.forEach(NativeArray.java:1618)
      at jdk.nashorn.internal.scripts.Script$Recompilation$1044$342791A$\^eval\_.L:9464$serialize(<eval>:9705)
      at jdk.nashorn.internal.scripts.Script$Recompilation$1043$361759A$\^eval\_.L:10065$LowLevelCompositeNode$buildKey(<eval>:10286)
      at jdk.nashorn.internal.scripts.Script$Recompilation$1042$361112A$\^eval\_.L:10065$LowLevelCompositeNode$children$L:10268$L:10268-1(<eval>:10269)
      at jdk.nashorn.internal.runtime.ScriptFunctionData.invoke(ScriptFunctionData.java:639)
      at jdk.nashorn.internal.runtime.ScriptFunction.invoke(ScriptFunction.java:494)
      at jdk.nashorn.internal.runtime.ScriptRuntime.apply(ScriptRuntime.java:393)
      at jdk.nashorn.internal.objects.NativeArray$9.forEach(NativeArray.java:1615)
      at jdk.nashorn.internal.runtime.arrays.IteratorAction.apply(IteratorAction.java:110)
      at jdk.nashorn.internal.objects.NativeArray.forEach(NativeArray.java:1618)
      at jdk.nashorn.internal.scripts.Script$Recompilation$1040$361027AA$\^eval\_.L:10065$LowLevelCompositeNode$children$L:10268(<eval>:10268)
      at jdk.nashorn.internal.runtime.ScriptFunctionData.invoke(ScriptFunctionData.java:641)
      at jdk.nashorn.internal.runtime.ScriptFunction.invoke(ScriptFunction.java:494)
      at jdk.nashorn.internal.runtime.ScriptRuntime.apply(ScriptRuntime.java:393)
      at jdk.nashorn.internal.objects.NativeArray$9.forEach(NativeArray.java:1615)
      at jdk.nashorn.internal.runtime.arrays.IteratorAction.apply(IteratorAction.java:110)
      at jdk.nashorn.internal.objects.NativeArray.forEach(NativeArray.java:1618)
      at jdk.nashorn.internal.scripts.Script$Recompilation$1016$360299$\^eval\_.L:10065$LowLevelCompositeNode$children(<eval>:10268)
      at jdk.nashorn.internal.scripts.Script$Recompilation$964$640506A$\^eval\_.L:18303$BasicNodeBuilder$processChildren$L:18499(<eval>:18569)
      at jdk.nashorn.internal.runtime.ScriptFunctionData.invoke(ScriptFunctionData.java:639)
      at jdk.nashorn.internal.runtime.ScriptFunction.invoke(ScriptFunction.java:494)
      at jdk.nashorn.internal.runtime.ScriptRuntime.apply(ScriptRuntime.java:393)
      at jdk.nashorn.internal.objects.NativeArray$9.forEach(NativeArray.java:1615)
      at jdk.nashorn.internal.runtime.arrays.IteratorAction.apply(IteratorAction.java:110)
      at jdk.nashorn.internal.objects.NativeArray.forEach(NativeArray.java:1618)
      at jdk.nashorn.internal.scripts.Script$Recompilation$961$640431AAAAA$\^eval\_.L:18303$BasicNodeBuilder$processChildren(<eval>:18499)
      at jdk.nashorn.internal.scripts.Script$Recompilation$946$634541AA$\^eval\_.L:18303$BasicNodeBuilder$process(<eval>:18479)
      at jdk.nashorn.internal.scripts.Script$Recompilation$943$302608$\^eval\_.L:7062$ASTNodeImpl$children(<eval>:8755)
      at jdk.nashorn.internal.scripts.Script$Recompilation$942$309124$\^eval\_.L:7062$ASTNodeImpl$elements(<eval>:8908)
      at jdk.nashorn.internal.scripts.Script$Recompilation$1015$309476A$\^eval\_.L:7062$ASTNodeImpl$elementsOfKind(<eval>:8918)
      at jdk.nashorn.internal.scripts.Script$Recompilation$1014$447902A$\^eval\_.L:13136$BasicSuperNodeImpl$elements(<eval>:13180)
      at jdk.nashorn.internal.scripts.Script$Recompilation$1013$104411$\^eval\_.L:129$ApiImpl$resources(<eval>:3752)
      at jdk.nashorn.internal.scripts.Script$Recompilation$932$121535A$\^eval\_.L:4283$TraitsAndResourceTypesExpander$expandTraitsAndResourceTypes(<eval>:4326)
      at jdk.nashorn.internal.scripts.Script$Recompilation$930$121055A$\^eval\_.L:4283$expandTraitsAndResourceTypes(<eval>:4297)
      at jdk.nashorn.internal.scripts.Script$Recompilation$869$2944A$\^eval\_.L:45$loadApi$L:91(<eval>:94)
      at jdk.nashorn.internal.runtime.ScriptFunctionData.invoke(ScriptFunctionData.java:639)
      at jdk.nashorn.internal.runtime.ScriptFunction.invoke(ScriptFunction.java:494)
      at jdk.nashorn.internal.runtime.ScriptRuntime.apply(ScriptRuntime.java:393)
      at jdk.nashorn.api.scripting.ScriptObjectMirror.call(ScriptObjectMirror.java:117)
      at jdk.nashorn.internal.objects.NativeArray$9.forEach(NativeArray.java:1615)
      at jdk.nashorn.internal.runtime.arrays.IteratorAction.apply(IteratorAction.java:110)
      at jdk.nashorn.internal.objects.NativeArray.forEach(NativeArray.java:1618)
      at jdk.nashorn.internal.runtime.ScriptFunctionData.invoke(ScriptFunctionData.java:661)
      at jdk.nashorn.internal.runtime.ScriptFunction.invoke(ScriptFunction.java:494)
      at jdk.nashorn.internal.runtime.ScriptRuntime.apply(ScriptRuntime.java:393)
      at jdk.nashorn.api.scripting.ScriptObjectMirror.call(ScriptObjectMirror.java:117)
      at jdk.nashorn.internal.scripts.Script$Recompilation$848$2573A$\^eval\_.L:45$loadApi(<eval>:91)
      at jdk.nashorn.internal.scripts.Script$Recompilation$847$1958A$\^eval\_.L:45$run$func(<eval>:61)
      at jdk.nashorn.internal.runtime.ScriptFunctionData.invoke(ScriptFunctionData.java:639)
      at jdk.nashorn.internal.runtime.ScriptFunction.invoke(ScriptFunction.java:494)
      at jdk.nashorn.internal.runtime.ScriptRuntime.apply(ScriptRuntime.java:393)
      at jdk.nashorn.api.scripting.ScriptObjectMirror.call(ScriptObjectMirror.java:117)
      at jdk.nashorn.internal.scripts.Script$846$\^eval\_.:program(<eval>:1)
      at jdk.nashorn.internal.runtime.ScriptFunctionData.invoke(ScriptFunctionData.java:637)
      at jdk.nashorn.internal.runtime.ScriptFunction.invoke(ScriptFunction.java:494)
      at jdk.nashorn.internal.runtime.ScriptRuntime.apply(ScriptRuntime.java:393)
      at jdk.nashorn.api.scripting.NashornScriptEngine.evalImpl(NashornScriptEngine.java:446)
      ... 28 more
      javax.script.ScriptException: TypeError: null has no such function "securedBy" in <eval> at line number 1
      at jdk.nashorn.api.scripting.NashornScriptEngine.throwAsScriptException(NashornScriptEngine.java:467)
      at jdk.nashorn.api.scripting.NashornScriptEngine.evalImpl(NashornScriptEngine.java:451)
      at jdk.nashorn.api.scripting.NashornScriptEngine.evalImpl(NashornScriptEngine.java:403)
      at jdk.nashorn.api.scripting.NashornScriptEngine.evalImpl(NashornScriptEngine.java:399)
      at jdk.nashorn.api.scripting.NashornScriptEngine.eval(NashornScriptEngine.java:155)
      at javax.script.AbstractScriptEngine.eval(AbstractScriptEngine.java:233)
      at com.mulesoft.raml1.java.parser.core.JavaNodeFactory.getValueList(JavaNodeFactory.java:138)
      at com.mulesoft.raml1.java.parser.core.JavaNodeFactory.getAttributes(JavaNodeFactory.java:65)
      at com.mulesoft.raml1.java.parser.core.JavaElementNode.getAttributes(JavaElementNode.java:30)
      at com.mulesoft.raml1.java.parser.impl.api.ApiImpl.securedBy(ApiImpl.java:77)
      at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
      at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62)
      at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
      at java.lang.reflect.Method.invoke(Method.java:498)
      at com.mulesoft.raml1.java.parser.core.JavaElementNode.toJSON(JavaElementNode.java:67)
      at com.mulesoft.raml1.java.parser.core.JavaElementNode.toJSON(JavaElementNode.java:46)
      at com.mulesoft.raml1.java.patser.test.Raml1Test.beforeClass(Raml1Test.java:36)
      at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
      at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62)
      at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
      at java.lang.reflect.Method.invoke(Method.java:498)
      at org.junit.runners.model.FrameworkMethod$1.runReflectiveCall(FrameworkMethod.java:50)
      at org.junit.internal.runners.model.ReflectiveCallable.run(ReflectiveCallable.java:12)
      at org.junit.runners.model.FrameworkMethod.invokeExplosively(FrameworkMethod.java:47)
      at org.junit.internal.runners.statements.RunBefores.evaluate(RunBefores.java:24)
      at org.junit.runners.ParentRunner.run(ParentRunner.java:363)
      at org.apache.maven.surefire.junit4.JUnit4Provider.execute(JUnit4Provider.java:252)
      at org.apache.maven.surefire.junit4.JUnit4Provider.executeTestSet(JUnit4Provider.java:141)
      at org.apache.maven.surefire.junit4.JUnit4Provider.invoke(JUnit4Provider.java:112)
      at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
      at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62)
      at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
      at java.lang.reflect.Method.invoke(Method.java:498)
      at org.apache.maven.surefire.util.ReflectionUtils.invokeMethodWithArray(ReflectionUtils.java:189)
      at org.apache.maven.surefire.booter.ProviderFactory$ProviderProxy.invoke(ProviderFactory.java:165)
      at org.apache.maven.surefire.booter.ProviderFactory.invokeProvider(ProviderFactory.java:85)
      at org.apache.maven.surefire.booter.ForkedBooter.runSuitesInProcess(ForkedBooter.java:115)
      at org.apache.maven.surefire.booter.ForkedBooter.main(ForkedBooter.java:75)
      Caused by: <eval>:1 TypeError: null has no such function "securedBy"

      After that, there's one exception "null has such function" for each call to class Api's functions.

      REPRODUCIBILITY :
      This bug can be reproduced always.

      ---------- BEGIN SOURCE ----------
      Java file:

      ```
      package com.mulesoft.raml1.java.parser;

      import com.mulesoft.raml1.java.parser.core.JavaNodeFactory;

      import javax.script.ScriptException;

      public class Test {

          public static void main(String[] args) throws ScriptException {
              JavaNodeFactory factory = new JavaNodeFactory();
              factory.createApi("/path/to/raml/file");
          }
      }
      ```

      RAML file:

      ```
      #%RAML 1.0

      title: A CRUD API for Users and Groups
      mediaType: application/json
      ```
      ---------- END SOURCE ----------

      CUSTOMER SUBMITTED WORKAROUND :
      Only downgrading Java version worked.

        Attachments

          Issue Links

            Activity

              People

              • Assignee:
                hannesw Hannes Wallnoefer
                Reporter:
                webbuggrp Webbug Group
              • Votes:
                0 Vote for this issue
                Watchers:
                4 Start watching this issue

                Dates

                • Created:
                  Updated:
                  Resolved: