You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
I've came into a problem with updating JSONata version that is used in Java Nashorn.
Simple expressions (without {}) are properly evaluated, but the execution of complex expressions (with {}) ends with an exception: Caused by: jdk.nashorn.internal.runtime.ECMAException: TypeError: Cannot call undefined
Simple expression is evaluated correctly.
@Test
public void testJsonMerge(){
String actual = nashornJsonataEvaluator.evaluateString("{\"name\":\"John\"}", "$.name");
Assert.assertEquals("Name should be john", "John", actual);
}
Complex expression that fails.
@Test
public void testJsonMergeComplex(){
String actual = nashornJsonataEvaluator.evaluateString("{\"name\":\"John\"}", "$.{\"name\": name}");
Assert.assertEquals("Name should be JSOn with name John", "{\"name\":\"John\"}", actual);
}
Below there is a stacktrace of failed execution:
at jdk.nashorn.internal.scripts.Script$Recompilation$245$90543A$jsonata_es5.L:1$L:1-1$L:1$L:2$jsonata$evaluateGroupExpression$evaluateGroupExpression$(/jsonata/jsonata-es5.js:2384) ~[?:?]
at jdk.nashorn.internal.scripts.Script$Recompilation$209$262558AAA$jsonata_es5.L:1$L:1-1$L:6859$L:6860$L:6871$tryCatch(/jsonata/jsonata-es5.js:6925) ~[?:?]
at jdk.nashorn.internal.scripts.Script$Recompilation$208$270231AA$jsonata_es5.L:1$L:1-1$L:6859$L:6860$L:6871$makeInvokeMethod$invoke(/jsonata/jsonata-es5.js:7163) ~[?:?]
at jdk.nashorn.internal.scripts.Script$Recompilation$207$264651A$jsonata_es5.L:1$L:1-1$L:6859$L:6860$L:6871$defineIteratorMethods$L:6975$L:6976(/jsonata/jsonata-es5.js:6977) ~[?:?]
at jdk.nashorn.internal.scripts.Script$Recompilation$209$262558AAA$jsonata_es5.L:1$L:1-1$L:6859$L:6860$L:6871$tryCatch(/jsonata/jsonata-es5.js:6925) ~[?:?]
at jdk.nashorn.internal.scripts.Script$Recompilation$236$272741AA$jsonata_es5.L:1$L:1-1$L:6859$L:6860$L:6871$maybeInvokeDelegate(/jsonata/jsonata-es5.js:7225) ~[?:?]
at jdk.nashorn.internal.scripts.Script$Recompilation$208$270231AA$jsonata_es5.L:1$L:1-1$L:6859$L:6860$L:6871$makeInvokeMethod$invoke(/jsonata/jsonata-es5.js:7137) ~[?:?]
at jdk.nashorn.internal.scripts.Script$Recompilation$207$264651A$jsonata_es5.L:1$L:1-1$L:6859$L:6860$L:6871$defineIteratorMethods$L:6975$L:6976(/jsonata/jsonata-es5.js:6977) ~[?:?]
at jdk.nashorn.internal.scripts.Script$Recompilation$209$262558AAA$jsonata_es5.L:1$L:1-1$L:6859$L:6860$L:6871$tryCatch(/jsonata/jsonata-es5.js:6925) ~[?:?]
at jdk.nashorn.internal.scripts.Script$Recompilation$236$272741AA$jsonata_es5.L:1$L:1-1$L:6859$L:6860$L:6871$maybeInvokeDelegate(/jsonata/jsonata-es5.js:7225) ~[?:?]
at jdk.nashorn.internal.scripts.Script$Recompilation$208$270231AA$jsonata_es5.L:1$L:1-1$L:6859$L:6860$L:6871$makeInvokeMethod$invoke(/jsonata/jsonata-es5.js:7137) ~[?:?]
at jdk.nashorn.internal.scripts.Script$Recompilation$207$264651A$jsonata_es5.L:1$L:1-1$L:6859$L:6860$L:6871$defineIteratorMethods$L:6975$L:6976(/jsonata/jsonata-es5.js:6977) ~[?:?]
at jdk.nashorn.internal.scripts.Script$Recompilation$209$262558AAA$jsonata_es5.L:1$L:1-1$L:6859$L:6860$L:6871$tryCatch(/jsonata/jsonata-es5.js:6925) ~[?:?]
at jdk.nashorn.internal.scripts.Script$Recompilation$236$272741AA$jsonata_es5.L:1$L:1-1$L:6859$L:6860$L:6871$maybeInvokeDelegate(/jsonata/jsonata-es5.js:7225) ~[?:?]
at jdk.nashorn.internal.scripts.Script$Recompilation$208$270231AA$jsonata_es5.L:1$L:1-1$L:6859$L:6860$L:6871$makeInvokeMethod$invoke(/jsonata/jsonata-es5.js:7137) ~[?:?]
at jdk.nashorn.internal.scripts.Script$Recompilation$207$264651A$jsonata_es5.L:1$L:1-1$L:6859$L:6860$L:6871$defineIteratorMethods$L:6975$L:6976(/jsonata/jsonata-es5.js:6977) ~[?:?]
at jdk.nashorn.internal.scripts.Script$Recompilation$209$262558AAA$jsonata_es5.L:1$L:1-1$L:6859$L:6860$L:6871$tryCatch(/jsonata/jsonata-es5.js:6925) ~[?:?]
at jdk.nashorn.internal.scripts.Script$Recompilation$236$272741AA$jsonata_es5.L:1$L:1-1$L:6859$L:6860$L:6871$maybeInvokeDelegate(/jsonata/jsonata-es5.js:7225) ~[?:?]
at jdk.nashorn.internal.scripts.Script$Recompilation$208$270231AA$jsonata_es5.L:1$L:1-1$L:6859$L:6860$L:6871$makeInvokeMethod$invoke(/jsonata/jsonata-es5.js:7137) ~[?:?]
at jdk.nashorn.internal.scripts.Script$Recompilation$207$264651A$jsonata_es5.L:1$L:1-1$L:6859$L:6860$L:6871$defineIteratorMethods$L:6975$L:6976(/jsonata/jsonata-es5.js:6977) ~[?:?]
at jdk.nashorn.internal.scripts.Script$Recompilation$209$262558AAA$jsonata_es5.L:1$L:1-1$L:6859$L:6860$L:6871$tryCatch(/jsonata/jsonata-es5.js:6925) ~[?:?]
at jdk.nashorn.internal.scripts.Script$Recompilation$236$272741AA$jsonata_es5.L:1$L:1-1$L:6859$L:6860$L:6871$maybeInvokeDelegate(/jsonata/jsonata-es5.js:7225) ~[?:?]
at jdk.nashorn.internal.scripts.Script$Recompilation$208$270231AA$jsonata_es5.L:1$L:1-1$L:6859$L:6860$L:6871$makeInvokeMethod$invoke(/jsonata/jsonata-es5.js:7137) ~[?:?]
at jdk.nashorn.internal.scripts.Script$Recompilation$207$264651A$jsonata_es5.L:1$L:1-1$L:6859$L:6860$L:6871$defineIteratorMethods$L:6975$L:6976(/jsonata/jsonata-es5.js:6977) ~[?:?]
at jdk.nashorn.internal.scripts.Script$Recompilation$232$188977AAA$jsonata_es5.L:1$L:1-1$L:1$L:2$jsonata$jsonata$evaluate(/jsonata/jsonata-es5.js:5096) ~[?:?]
The problem is caused by the line 2384 it = allPromises.values(); and the values() function is an ES6 syntax.
It's all about lack of polyfill for iterable in ES5.
I've just recreated this in node v0.10 and come to the same conclusion as you on the polyfill. It was falling over on the allPromises.entries() call for me.
Object.entries() and Object.values() are in ES2017, which is one of the things that the Babel env preset (which is being used) should transform. Adding:
require('core-js');
To the top of jsonata.js fixes the problem. We could introduce a build step to do that, but that's what I though Babel (specifically babel-plugin-transform-runtime) is meant to be for.
There might be a bug in Babel, but more likely there is a subtle usage error. Perhaps the next step would be to find a project that has this working, and compare.
HI,
I've came into a problem with updating JSONata version that is used in Java Nashorn.
Simple expressions (without {}) are properly evaluated, but the execution of complex expressions (with {}) ends with an exception: Caused by: jdk.nashorn.internal.runtime.ECMAException: TypeError: Cannot call undefined
Simple expression is evaluated correctly.
Complex expression that fails.
Below there is a stacktrace of failed execution:
I'n using jsonata-es5.js file and nashorn-commonjs-modules.
The previous version of JSONata (currently 1.1.1) works well and this issue is blocking migration to higher version of JSONata library.
Thanks for help
The text was updated successfully, but these errors were encountered: