ES6 from Java, using Nashorn

2018-01-19 Thread Olivier
Hi experts, I want to run ES6 scripts from Java, using Nashorn. I have scripts involving 'let', 'const', my Java code is happy with it, I just need to use a property "nashorn.args" set to "--language=es6". Now, I'd like to move forward, use imports and modules. I have one script like this

Field Method Conflicts

2018-01-19 Thread Nathan Faulkner
Is there any way, other than reflection, to access a field that shares a name with a method? It seems that, with the Test class, instance.item returns the item() dynamic method (as does instance["item"]), and instance.item2 returns "b". public class Test { public String item = "1"; public

ES6 and JavaImporter

2018-01-19 Thread Brad Grier
Hello, I wanted to experiment with the Java 9 ES6 features in my software. Unfortunately I can't get far because of an issue involving JavaImporter. I created a simple jjs example that illustrates the problem. The script works under ES5 but fails under ES6 with: ./pg4.js:6 ReferenceError:

Re: ES6 from Java, using Nashorn

2018-01-19 Thread Hannes Wallnöfer
Hi Olivier, Support for ECMAScript 6 is quite incomplete in Nashorn unfortunately. We only support a small set of ES6 features in JDK 9: • Template strings • let, const, and block scope • Iterators and for..of loops • Map, Set, WeakMap, and WeakSet •

Re: ES6 and JavaImporter

2018-01-19 Thread Hannes Wallnöfer
Brad, I as I wrote in my last reply to this list, ES6 support is quite incomplete in Nashorn. However, that doesn’t really explain this error. I’m looking into it and will file a bug. Hannes > Am 19.01.2018 um 04:06 schrieb Brad Grier : > > Hello, > > I wanted to

Re: Field Method Conflicts

2018-01-19 Thread Attila Szegedi
No, there isn’t really. Nashorn (well, actually Dynalink that’s underlying Nashorn’s Java-binding functionality) gives preference to a method over a field as methods are more flexible, can include preconditions, can be overridden etc. There’s an assumption that whoever designs the class with