Changes in Java 9

Nils Kilden-Pedersen nilskp at gmail.com
Mon Dec 4 15:56:45 UTC 2017


Thanks for bringing this up. It made me realize that my post was incomplete.

These are the steps I take:

   1. Initial step: Call engine.compile with the CS compiler source +
CoffeeScript.compile(coffeeCode,
   {runtime: 'none'}); which returns CompiledScript that is retained and
   re-used. This works fine, also on JDK 9.0.1.
   2. For subsequent Coffeescript -> Javascript transpilation, I then call
   engine.createBindings()
   3. Then bindings.put("coffeeCode", csCode) to associate the CS code with
   the JS variable coffeeCode mentioned in initial step
   4. Call CompiledScript.eval(bindings). This is the step that fails in
   9.0.1.

I’m open to better ways to achieve this, if it’s inefficient or plain wrong.
​

On Mon, Dec 4, 2017 at 8:47 AM, Hannes Wallnöfer <
hannes.wallnoefer at oracle.com> wrote:

> Hi Nils,
>
> Are you just evaluating the script files you linked in your first message,
> or trying to do some further processing?
>
> Using the jjs tool from JDK 9.0.1 I see no errors running both versions of
> CoffeeScript.
>
> Hannes
>
> > Am 03.12.2017 um 21:08 schrieb Nils Kilden-Pedersen <nilskp at gmail.com>:
> >
> > Ok, the minified vs non-minified may not be identical. I cannot find the
> > default parameters in the minified version, so perhaps those are removed.
> >
> > What does remain however, is that I can compile minified cs2
> > <http://coffeescript.org/v2/browser-compiler/coffeescript.js> on JDK
> 8_144,
> > but not on 9.0.1.
> >
> >
> > On Sun, Dec 3, 2017 at 1:39 PM, Nils Kilden-Pedersen <nilskp at gmail.com>
> > wrote:
> >
> >> Further testing with the un-minified code (cs2
> >> <https://unpkg.com/coffeescript@2.0.3/lib/coffeescript/browser.js>, cs1
> >> <https://unpkg.com/coffeescript@1.12.7/lib/coffee-script/browser.js>)
> >> reveals the true problems in JDK 9.0.1
> >>
> >> In cs2, it’s ES6 syntax (default args), which (unexpectedly for me at
> >> least), works in JDK 8:
> >>
> >>    <eval>:46:45 Expected , but found =
> >>  CoffeeScript.eval = function(code, options = {}) {
> >>                                             ^ in <eval> at line number
> 46 at column number 45
> >>
> >> And in cs1 it’s require that’s unresolved (also works in JDK 8):
> >>
> >> ReferenceError: "require" is not defined in <eval> at line number 7
> >>
> >> ​
> >>
> >> On Sun, Dec 3, 2017 at 11:02 AM, Nils Kilden-Pedersen <nilskp at gmail.com
> >
> >> wrote:
> >>
> >>> I just switched to the Java 9.0.1 runtime, and Nashorn now fails to
> parse
> >>> the Coffeescript compiler, which worked fine in Java 8_144.
> >>>
> >>> Coffeescript 2 compiler: http://coffeescript.org/v2/bro
> >>> wser-compiler/coffeescript.js
> >>>
> >>> v1 also fails: http://coffeescript.org/v1/bro
> >>> wser-compiler/coffee-script.js
> >>>
> >>> Exception is:
> >>>
> >>> javax.script.ScriptException: SyntaxError: unexpected  in <eval> at
> line number 39 at column number 249736
> >>>  at jdk.scripting.nashorn/jdk.nashorn.api.scripting.
> NashornScriptEngine.throwAsScriptException(NashornScriptEngine.java:469)
> >>>  at jdk.scripting.nashorn/jdk.nashorn.api.scripting.
> NashornScriptEngine.evalImpl(NashornScriptEngine.java:425)
> >>>  at jdk.scripting.nashorn/jdk.nashorn.api.scripting.
> NashornScriptEngine.access$300(NashornScriptEngine.java:72)
> >>>  at jdk.scripting.nashorn/jdk.nashorn.api.scripting.
> NashornScriptEngine$3.eval(NashornScriptEngine.java:513)
> >>>  at java.scripting/javax.script.CompiledScript.eval(
> CompiledScript.java:92)
> >>>  at scuff.js.CoffeeScriptCompiler.compile(CoffeeScriptCompiler.
> scala:115)
> >>>  at scuff.js.TestCoffeeScriptCompiler.cs2(TestCoffeeScriptCompiler.
> scala:114)
> >>>  at java.base/jdk.internal.reflect.NativeMethodAccessorImpl.invoke0(Native
> Method)
> >>>  at java.base/jdk.internal.reflect.NativeMethodAccessorImpl.invoke(
> NativeMethodAccessorImpl.java:62)
> >>>  at java.base/jdk.internal.reflect.DelegatingMethodAccessorImpl.
> invoke(DelegatingMethodAccessorImpl.java:43)
> >>>  at java.base/java.lang.reflect.Method.invoke(Method.java:564)
> >>>  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.InvokeMethod.
> evaluate(InvokeMethod.java:17)
> >>>  at org.junit.runners.ParentRunner.runLeaf(ParentRunner.java:325)
> >>>  at org.junit.runners.BlockJUnit4ClassRunner.runChild(
> BlockJUnit4ClassRunner.java:78)
> >>>  at org.junit.runners.BlockJUnit4ClassRunner.runChild(
> BlockJUnit4ClassRunner.java:57)
> >>>  at org.junit.runners.ParentRunner$3.run(ParentRunner.java:290)
> >>>  at org.junit.runners.ParentRunner$1.schedule(ParentRunner.java:71)
> >>>  at org.junit.runners.ParentRunner.runChildren(ParentRunner.java:288)
> >>>  at org.junit.runners.ParentRunner.access$000(ParentRunner.java:58)
> >>>  at org.junit.runners.ParentRunner$2.evaluate(ParentRunner.java:268)
> >>>  at org.junit.runners.ParentRunner.run(ParentRunner.java:363)
> >>>  at org.eclipse.jdt.internal.junit4.runner.JUnit4TestReference.run(
> JUnit4TestReference.java:86)
> >>>  at org.eclipse.jdt.internal.junit.runner.TestExecution.
> run(TestExecution.java:38)
> >>>  at org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.
> runTests(RemoteTestRunner.java:539)
> >>>  at org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.
> runTests(RemoteTestRunner.java:761)
> >>>  at org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.
> run(RemoteTestRunner.java:461)
> >>>  at org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.
> main(RemoteTestRunner.java:207)
> >>> Caused by: <eval>:39:249736 SyntaxError: unexpected
> >>>  at jdk.scripting.nashorn/jdk.nashorn.internal.objects.
> NativeError.initException(NativeError.java:135)
> >>>  at jdk.scripting.nashorn/jdk.nashorn.internal.objects.
> NativeSyntaxError.<init>(NativeSyntaxError.java:73)
> >>>  at jdk.scripting.nashorn/jdk.nashorn.internal.objects.
> NativeSyntaxError.<init>(NativeSyntaxError.java:77)
> >>>  at jdk.scripting.nashorn/jdk.nashorn.internal.objects.
> NativeSyntaxError.constructor(NativeSyntaxError.java:98)
> >>>  at jdk.scripting.nashorn.scripts/jdk.nashorn.internal.scripts.
> Script$Recompilation$2368$6956AA$\^eval\_.L:39-1#a#L:39-
> 1#L:39#throwSyntaxError(<eval>:39)
> >>>  at jdk.scripting.nashorn.scripts/jdk.nashorn.internal.scripts.
> Script$Recompilation$2364$253073AA$\^eval\_$cu1$restOf.
> L:39-1#a#L:39-8#L:39#parseError(<eval>:39)
> >>>  at jdk.scripting.nashorn.scripts/jdk.nashorn.internal.scripts.
> Script$Recompilation$2359$\^eval\_$cu1$restOf.L:39-1#a#L:
> 39-4#o#parse(<eval>:39)
> >>>  at jdk.scripting.nashorn.scripts/jdk.nashorn.internal.scripts.
> Script$Recompilation$2343$\^eval\_$cu1$restOf.L:39-1#a#L:
> 39-8#L:39#p(<eval>:39)
> >>>  at jdk.scripting.nashorn.scripts/jdk.nashorn.internal.scripts.
> Script$Recompilation$2056$250675AA$\^eval\_.L:39-1#a#L:
> 39-8#L:39#T#L:39(<eval>:39)
> >>>  at jdk.scripting.nashorn.scripts/jdk.nashorn.internal.scripts.
> Script$Recompilation$1572$\^eval\_.:program(<eval>:41)
> >>>  at jdk.scripting.nashorn/jdk.nashorn.internal.runtime.
> ScriptFunctionData.invoke(ScriptFunctionData.java:652)
> >>>  at jdk.scripting.nashorn/jdk.nashorn.internal.runtime.
> ScriptFunction.invoke(ScriptFunction.java:513)
> >>>  at jdk.scripting.nashorn/jdk.nashorn.internal.runtime.
> ScriptRuntime.apply(ScriptRuntime.java:517)
> >>>  at jdk.scripting.nashorn/jdk.nashorn.api.scripting.
> NashornScriptEngine.evalImpl(NashornScriptEngine.java:420)
> >>>  ... 28 more
> >>>
> >>> ​
> >>>
> >>
> >>
>
>


More information about the nashorn-dev mailing list