From sundararajan.athijegannathan at oracle.com Tue Jan 3 05:17:05 2017 From: sundararajan.athijegannathan at oracle.com (Sundararajan Athijegannathan) Date: Tue, 03 Jan 2017 10:47:05 +0530 Subject: RFR 8172183: Provide a javadoc description for jdk.dynalink module Message-ID: <586B33D1.9010402@oracle.com> Please review http://cr.openjdk.java.net/~sundar/8172183/webrev.00/ for https://bugs.openjdk.java.net/browse/JDK-8172183 Piggybacking couple of README cleanups in nashorn repo. Thanks, -Sundar From james.laskey at oracle.com Tue Jan 3 12:47:31 2017 From: james.laskey at oracle.com (Jim Laskey (Oracle)) Date: Tue, 3 Jan 2017 08:47:31 -0400 Subject: RFR 8172183: Provide a javadoc description for jdk.dynalink module In-Reply-To: <586B33D1.9010402@oracle.com> References: <586B33D1.9010402@oracle.com> Message-ID: <0B5382B0-66B5-4225-9D9D-0EAC359BFEEE@oracle.com> +1 > On Jan 3, 2017, at 1:17 AM, Sundararajan Athijegannathan wrote: > > Please review http://cr.openjdk.java.net/~sundar/8172183/webrev.00/ for https://bugs.openjdk.java.net/browse/JDK-8172183 > > Piggybacking couple of README cleanups in nashorn repo. > > Thanks, > -Sundar From szegedia at gmail.com Tue Jan 3 13:08:08 2017 From: szegedia at gmail.com (Attila Szegedi) Date: Tue, 3 Jan 2017 14:08:08 +0100 Subject: RFR 8172183: Provide a javadoc description for jdk.dynalink module In-Reply-To: <586B33D1.9010402@oracle.com> References: <586B33D1.9010402@oracle.com> Message-ID: + * Contains interfaces and classes that are used to link a {@code invokedynamic} call site. should be ?an? invokedynamic call site. Attila. > On 03 Jan 2017, at 06:17, Sundararajan Athijegannathan wrote: > > Please review http://cr.openjdk.java.net/~sundar/8172183/webrev.00/ for https://bugs.openjdk.java.net/browse/JDK-8172183 > > Piggybacking couple of README cleanups in nashorn repo. > > Thanks, > -Sundar From sundararajan.athijegannathan at oracle.com Tue Jan 3 14:07:58 2017 From: sundararajan.athijegannathan at oracle.com (Sundararajan Athijegannathan) Date: Tue, 03 Jan 2017 19:37:58 +0530 Subject: RFR 8172183: Provide a javadoc description for jdk.dynalink module In-Reply-To: References: <586B33D1.9010402@oracle.com> Message-ID: <586BB03E.7020603@oracle.com> Thanks Attila. I'll fix that article. Can I consider your comment as a review? Thanks, -Sundar On 03/01/17, 6:38 PM, Attila Szegedi wrote: > + * Contains interfaces and classes that are used to link a {@code invokedynamic} call site. > > should be ?an? invokedynamic call site. > > Attila. > >> On 03 Jan 2017, at 06:17, Sundararajan Athijegannathan wrote: >> >> Please review http://cr.openjdk.java.net/~sundar/8172183/webrev.00/ for https://bugs.openjdk.java.net/browse/JDK-8172183 >> >> Piggybacking couple of README cleanups in nashorn repo. >> >> Thanks, >> -Sundar From sundararajan.athijegannathan at oracle.com Tue Jan 3 15:04:01 2017 From: sundararajan.athijegannathan at oracle.com (Sundararajan Athijegannathan) Date: Tue, 03 Jan 2017 20:34:01 +0530 Subject: RFR 8172183: Provide a javadoc description for jdk.dynalink module In-Reply-To: <586BB03E.7020603@oracle.com> References: <586B33D1.9010402@oracle.com> <586BB03E.7020603@oracle.com> Message-ID: <586BBD61.8090100@oracle.com> Fixed. Updated webrev: http://cr.openjdk.java.net/~sundar/8172183/webrev.01/ Thanks, -Sundar On 03/01/17, 7:37 PM, Sundararajan Athijegannathan wrote: > Thanks Attila. > > I'll fix that article. Can I consider your comment as a review? > > Thanks, > -Sundar > > On 03/01/17, 6:38 PM, Attila Szegedi wrote: >> + * Contains interfaces and classes that are used to link a {@code >> invokedynamic} call site. >> >> should be ?an? invokedynamic call site. >> >> Attila. >> >>> On 03 Jan 2017, at 06:17, Sundararajan >>> Athijegannathan wrote: >>> >>> Please review http://cr.openjdk.java.net/~sundar/8172183/webrev.00/ >>> for https://bugs.openjdk.java.net/browse/JDK-8172183 >>> >>> Piggybacking couple of README cleanups in nashorn repo. >>> >>> Thanks, >>> -Sundar From szegedia at gmail.com Tue Jan 3 16:03:24 2017 From: szegedia at gmail.com (Attila Szegedi) Date: Tue, 3 Jan 2017 17:03:24 +0100 Subject: RFR 8172183: Provide a javadoc description for jdk.dynalink module In-Reply-To: <586BBD61.8090100@oracle.com> References: <586B33D1.9010402@oracle.com> <586BB03E.7020603@oracle.com> <586BBD61.8090100@oracle.com> Message-ID: <7164DB50-0D0C-4C12-934B-24105255A7EC@gmail.com> My preference would be to move all the prose from package-info.java to module-info.java. At the time I wrote the documentation, I didn't consider module-info as it wasn?t picked up by javadoc back then, so the entry point into the documentation was the top-level packaage?s package-info. The intent of all of it, though, is to act as a comprehensive overview of Dynalink. It works best as a single unit of prose. My recommendation would be to move all of text in package-info to module-info (presumably, module-info also can contain links etc.), and only leave that one-sentence description you just added in package-info. Thanks, Attila. > On 03 Jan 2017, at 16:04, Sundararajan Athijegannathan wrote: > > Fixed. Updated webrev: http://cr.openjdk.java.net/~sundar/8172183/webrev.01/ > > Thanks, > -Sundar > > On 03/01/17, 7:37 PM, Sundararajan Athijegannathan wrote: >> Thanks Attila. >> >> I'll fix that article. Can I consider your comment as a review? >> >> Thanks, >> -Sundar >> >> On 03/01/17, 6:38 PM, Attila Szegedi wrote: >>> + * Contains interfaces and classes that are used to link a {@code invokedynamic} call site. >>> >>> should be ?an? invokedynamic call site. >>> >>> Attila. >>> >>>> On 03 Jan 2017, at 06:17, Sundararajan Athijegannathan wrote: >>>> >>>> Please review http://cr.openjdk.java.net/~sundar/8172183/webrev.00/ for https://bugs.openjdk.java.net/browse/JDK-8172183 >>>> >>>> Piggybacking couple of README cleanups in nashorn repo. >>>> >>>> Thanks, >>>> -Sundar From sundararajan.athijegannathan at oracle.com Tue Jan 3 16:37:15 2017 From: sundararajan.athijegannathan at oracle.com (Sundararajan Athijegannathan) Date: Tue, 03 Jan 2017 22:07:15 +0530 Subject: RFR 8172183: Provide a javadoc description for jdk.dynalink module In-Reply-To: <7164DB50-0D0C-4C12-934B-24105255A7EC@gmail.com> References: <586B33D1.9010402@oracle.com> <586BB03E.7020603@oracle.com> <586BBD61.8090100@oracle.com> <7164DB50-0D0C-4C12-934B-24105255A7EC@gmail.com> Message-ID: <586BD33B.8050800@oracle.com> Updated: http://cr.openjdk.java.net/~sundar/8172183/webrev.02/ Thanks -Sundar On 03/01/17, 9:33 PM, Attila Szegedi wrote: > My preference would be to move all the prose from package-info.java to module-info.java. > > At the time I wrote the documentation, I didn't consider module-info as it wasn?t picked up by javadoc back then, so the entry point into the documentation was the top-level packaage?s package-info. The intent of all of it, though, is to act as a comprehensive overview of Dynalink. It works best as a single unit of prose. My recommendation would be to move all of text in package-info to module-info (presumably, module-info also can contain links etc.), and only leave that one-sentence description you just added in package-info. > > Thanks, > Attila. > >> On 03 Jan 2017, at 16:04, Sundararajan Athijegannathan wrote: >> >> Fixed. Updated webrev: http://cr.openjdk.java.net/~sundar/8172183/webrev.01/ >> >> Thanks, >> -Sundar >> >> On 03/01/17, 7:37 PM, Sundararajan Athijegannathan wrote: >>> Thanks Attila. >>> >>> I'll fix that article. Can I consider your comment as a review? >>> >>> Thanks, >>> -Sundar >>> >>> On 03/01/17, 6:38 PM, Attila Szegedi wrote: >>>> + * Contains interfaces and classes that are used to link a {@code invokedynamic} call site. >>>> >>>> should be ?an? invokedynamic call site. >>>> >>>> Attila. >>>> >>>>> On 03 Jan 2017, at 06:17, Sundararajan Athijegannathan wrote: >>>>> >>>>> Please review http://cr.openjdk.java.net/~sundar/8172183/webrev.00/ for https://bugs.openjdk.java.net/browse/JDK-8172183 >>>>> >>>>> Piggybacking couple of README cleanups in nashorn repo. >>>>> >>>>> Thanks, >>>>> -Sundar From szegedia at gmail.com Tue Jan 3 16:26:25 2017 From: szegedia at gmail.com (Attila Szegedi) Date: Tue, 3 Jan 2017 17:26:25 +0100 Subject: RFR 8172183: Provide a javadoc description for jdk.dynalink module In-Reply-To: <586BD33B.8050800@oracle.com> References: <586B33D1.9010402@oracle.com> <586BB03E.7020603@oracle.com> <586BBD61.8090100@oracle.com> <7164DB50-0D0C-4C12-934B-24105255A7EC@gmail.com> <586BD33B.8050800@oracle.com> Message-ID: +1 Thanks! Attila. > On 03 Jan 2017, at 17:37, Sundararajan Athijegannathan wrote: > > Updated: http://cr.openjdk.java.net/~sundar/8172183/webrev.02/ > > Thanks > -Sundar > > On 03/01/17, 9:33 PM, Attila Szegedi wrote: >> My preference would be to move all the prose from package-info.java to module-info.java. >> >> At the time I wrote the documentation, I didn't consider module-info as it wasn?t picked up by javadoc back then, so the entry point into the documentation was the top-level packaage?s package-info. The intent of all of it, though, is to act as a comprehensive overview of Dynalink. It works best as a single unit of prose. My recommendation would be to move all of text in package-info to module-info (presumably, module-info also can contain links etc.), and only leave that one-sentence description you just added in package-info. >> >> Thanks, >> Attila. >> >>> On 03 Jan 2017, at 16:04, Sundararajan Athijegannathan wrote: >>> >>> Fixed. Updated webrev: http://cr.openjdk.java.net/~sundar/8172183/webrev.01/ >>> >>> Thanks, >>> -Sundar >>> >>> On 03/01/17, 7:37 PM, Sundararajan Athijegannathan wrote: >>>> Thanks Attila. >>>> >>>> I'll fix that article. Can I consider your comment as a review? >>>> >>>> Thanks, >>>> -Sundar >>>> >>>> On 03/01/17, 6:38 PM, Attila Szegedi wrote: >>>>> + * Contains interfaces and classes that are used to link a {@code invokedynamic} call site. >>>>> >>>>> should be ?an? invokedynamic call site. >>>>> >>>>> Attila. >>>>> >>>>>> On 03 Jan 2017, at 06:17, Sundararajan Athijegannathan wrote: >>>>>> >>>>>> Please review http://cr.openjdk.java.net/~sundar/8172183/webrev.00/ for https://bugs.openjdk.java.net/browse/JDK-8172183 >>>>>> >>>>>> Piggybacking couple of README cleanups in nashorn repo. >>>>>> >>>>>> Thanks, >>>>>> -Sundar From sundararajan.athijegannathan at oracle.com Wed Jan 4 10:40:25 2017 From: sundararajan.athijegannathan at oracle.com (Sundararajan Athijegannathan) Date: Wed, 04 Jan 2017 16:10:25 +0530 Subject: RFR 8164391: Provide a javadoc description for jdk.scripting.nashorn Message-ID: <586CD119.4080100@oracle.com> Please review http://cr.openjdk.java.net/~sundar/8164391/webrev.00/ for https://bugs.openjdk.java.net/browse/JDK-8164391 Thanks, -Sundar From szegedia at gmail.com Wed Jan 4 11:25:38 2017 From: szegedia at gmail.com (Attila Szegedi) Date: Wed, 4 Jan 2017 12:25:38 +0100 Subject: RFR 8164391: Provide a javadoc description for jdk.scripting.nashorn In-Reply-To: <586CD119.4080100@oracle.com> References: <586CD119.4080100@oracle.com> Message-ID: +1 > On 04 Jan 2017, at 11:40, Sundararajan Athijegannathan wrote: > > Please review http://cr.openjdk.java.net/~sundar/8164391/webrev.00/ for https://bugs.openjdk.java.net/browse/JDK-8164391 > > Thanks, > -Sundar From james.laskey at oracle.com Wed Jan 4 13:04:35 2017 From: james.laskey at oracle.com (Jim Laskey (Oracle)) Date: Wed, 4 Jan 2017 09:04:35 -0400 Subject: RFR 8164391: Provide a javadoc description for jdk.scripting.nashorn In-Reply-To: References: <586CD119.4080100@oracle.com> Message-ID: +1 > On Jan 4, 2017, at 7:25 AM, Attila Szegedi wrote: > > +1 > >> On 04 Jan 2017, at 11:40, Sundararajan Athijegannathan wrote: >> >> Please review http://cr.openjdk.java.net/~sundar/8164391/webrev.00/ for https://bugs.openjdk.java.net/browse/JDK-8164391 >> >> Thanks, >> -Sundar > From esben at esbena.dk Fri Jan 6 11:27:18 2017 From: esben at esbena.dk (Esben Andreasen) Date: Fri, 06 Jan 2017 11:27:18 +0000 Subject: Minor discepancy for multiline regexps Message-ID: Hi I stumbled upon a minor discrepancy between Nashorn and other JavaScript engines when doing regexp matching with the multiline flag enabled. Nashorn ``` $ jjs -version nashorn 1.8.0_111 jjs> String.prototype.replace.apply("a\nb\rc\n\rd\r\ne", [/^(.*)/gm,"*$1"]); *a *c ** *e ``` Notice that the characters 'b' and 'd' are gone from the output. Node: ``` $ node --version v5.5.0 $ node > String.prototype.replace.apply("a\nb\rc\n\rd\r\ne", [/^(.*)/gm,"*$1"]); '*a\n*b\r*c\n*\r*d\r*\n*e' ``` Firefox & Chrome console: ``` > String.prototype.replace.apply("a\nb\rc\n\rd\r\ne", [/^(.*)/gm,"*$1"]); "*a *b *c * *d * *e" ``` Notice that the characters 'b' and 'd' are in the output. - I suspect the cause is that nashorn does treat the character after '\r' as being at the start of a line. - Esben From james.laskey at oracle.com Fri Jan 6 13:34:31 2017 From: james.laskey at oracle.com (Jim Laskey (Oracle)) Date: Fri, 6 Jan 2017 09:34:31 -0400 Subject: Minor discepancy for multiline regexps In-Reply-To: References: Message-ID: Bug filed on your behalf. https://bugs.openjdk.java.net/browse/JDK-8172353 ? Jim > On Jan 6, 2017, at 7:27 AM, Esben Andreasen wrote: > > Hi > > I stumbled upon a minor discrepancy between Nashorn and other > JavaScript engines when doing regexp matching with the multiline flag > enabled. > > Nashorn > ``` > $ jjs -version > nashorn 1.8.0_111 > jjs> String.prototype.replace.apply("a\nb\rc\n\rd\r\ne", [/^(.*)/gm,"*$1"]); > *a > *c > ** > *e > ``` > > Notice that the characters 'b' and 'd' are gone from the output. > > Node: > ``` > $ node --version > v5.5.0 > $ node >> String.prototype.replace.apply("a\nb\rc\n\rd\r\ne", [/^(.*)/gm,"*$1"]); > '*a\n*b\r*c\n*\r*d\r*\n*e' > ``` > > Firefox & Chrome console: > ``` >> String.prototype.replace.apply("a\nb\rc\n\rd\r\ne", [/^(.*)/gm,"*$1"]); > "*a > *b > *c > * > *d > * > *e" > ``` > > Notice that the characters 'b' and 'd' are in the output. > > - > > I suspect the cause is that nashorn does treat the character after > '\r' as being at the start of a line. > > - > Esben From Rony.Flatscher at wu.ac.at Fri Jan 6 14:07:02 2017 From: Rony.Flatscher at wu.ac.at (Rony G. Flatscher) Date: Fri, 6 Jan 2017 15:07:02 +0100 Subject: Nashorn's javax.script.ScriptEngineFactory produces wrong code In-Reply-To: <9bc6202f-7a5c-e9f2-7e41-da8e90bfccec@wu.ac.at> References: <9bc6202f-7a5c-e9f2-7e41-da8e90bfccec@wu.ac.at> Message-ID: <5471cfe8-5956-a749-1ba8-842e4fa7d066@wu.ac.at> Besides Java 1.8.0_111 the problem exists in 9ea-+134 (engine version: "9ea", language version: "ECMA 262 - Edition 5.1" ) as well: Nashorn's javax.script factory is used to get an output statement and then it is used to execute it: ---> language [ECMAScript]: ----------------------------------------> 1) output statement to process: hello world, this is "ECMAScript" speaking! --> testing getOutputStatement(String), produced the following [ECMAScript] output statement print(hello world, this is "ECMAScript" speaking! ) ... now running "eval(code)" using the scripting engine [ECMAScript]: javax.script.ScriptException: :1:12 Expected , but found world print(hello world, this is "ECMAScript" speaking! ) ^ in at line number 1 at column number 12 while eval() the code: print(hello world, this is "ECMAScript" speaking! ) This time trying to not format the Java code, so hopefully the mailer will not render it illegible: ... cut ... // create an output statement and execute output statement with the script engine static void testEngine(String name, ScriptEngineFactory sef, ScriptEngine se) { System.out.println("---> language ["+name+"]: ---------------------------------------->\n"); String text="hello world, this is \""+name+"\" speaking! "; String code=sef.getOutputStatement(text); System.out.println("\t1) output statement to process: "+text+"\n"); System.out.print("\t--> testing getOutputStatement(String)"); System.out.println(", produced the following ["+name+"] output statement \n\n"+code+"\n"); System.out.println("\t... now running \"eval(code)\" using the scripting engine ["+name+"]: \n\n"); try { se.eval(code); System.out.println("\n"); } catch (ScriptException sexc) { System.err.println(sexc+" while eval() the code: "+code+"\n"); } System.out.print("\t2) testing getMethodCallSyntax(obj, meth, arg...)"); String methCode=sef.getMethodCallSyntax("object", "method", "arg1", "arg2"); System.out.println(", produced the following ["+name+"] method call statement: \n\n"+methCode+"\n"); System.out.print("\t3) testing getProgram(String...)"); String programCode=sef.getProgram(code, methCode); System.out.println(" produced the following ["+name+"] program: \n\n"+programCode+"\n"); System.out.println("<--- end of testing language ["+name+"]. <----------------------------------------\n"); } ... cut ... If I should file a bug then please advise where and how. ---rony On 08.12.2016 16:17, Rony G. Flatscher wrote: > Unfortunately, the mailing list seems to behave as if it was running in the 1970's such that the > formatted text (indented, partially colorized and formatted to preformat and Courier) has turned to > become illegible, unfortunately (using the Thunderbird e-Mail client)! > :( > > The meat is right in the first two paragraphs and the last paragraph before the signature. Should > anyone be interested in the Java-utility, please drop me a personal e-mail and I will send that Java > program as an attachment to you. > > ---rony > > > > On 08.12.2016 16:05, Rony G. Flatscher wrote: >> Hi there, was directed to this list to report an error with Nashorn's implementation of >> javax.script.ScriptEngineFactory.getOutputStatement(String toDisplay). >> >> The test is simple: one supplies a string, containing double quotes, and immediately use the Nashort >> script engine to carry out the output statement produced by its factory, yielding a runtime error. >> In order for you to reproduce, I list the Java utility (it lists all available javax.script engines >> and tests them with the -t switch and is a little example of how one can take advantage of >> javax.script very easily) after my signature below to study the code and run it to double-check: >> >> F:\work\svn\bsf4oorexx\trunk\samples\Java\jsr223>java RunScript -t ---> language [ECMAScript]: >> ----------------------------------------> 1) output statement to process: hello world, this is >> "ECMAScript" speaking! --> testing getOutputStatement(String), produced the following >> [ECMAScript] output statement *print(hello world, this is "ECMAScript" speaking! )* ... now >> running "eval(code)" using the scripting engine [ECMAScript]: *javax.script.ScriptException: >> :1:12 Expected , but found world print(hello world, this is "ECMAScript" speaking! ) ^ in >> at line number 1 at column number 12 while eval() the code: print(hello world, this is >> "ECMAScript" speaking! )* 2) testing getMethodCallSyntax(obj, meth, arg...), produced the >> following [ECMAScript] method call statement: object.method(arg1,arg2) 3) testing >> getProgram(String...) produced the following [ECMAScript] program: print(hello world, this is >> "ECMAScript" speaking! );object.method(arg1,arg2); <--- end of testing language [ECMAScript]. >> <---------------------------------------- ---> language [ooRexx]: >> ----------------------------------------> ... cut ... >> >> The specification for javax.script created by the Java specification request group 223 (a.k.a. >> JSR-223) can be consulted. BTW, "jrunscript[.exe]" (from the JDK) seems to be broken, it only is be >> able to execute the Nashorn script engine, despite switches that allow other script engines to be >> employed. >> >> ---rony >> >> Code of "RunScript.java" (little utility to list the currently available javax.script languages, run >> any javax.script program, give helpful information about each javax.script engine and test each one >> using its own factory means): just compile it and run it with "java RunScript -t": >> >> ------------------ cut here ------------------ >> import java.io.File; import java.io.FileReader; import java.util.ArrayList; import java.util.Arrays; >> import java.util.List; import java.util.HashMap; import java.util.SortedSet; import >> java.util.TreeSet; import javax.script.Bindings; import javax.script.ScriptContext; import >> javax.script.ScriptEngine; import javax.script.ScriptEngineFactory; import >> javax.script.ScriptEngineManager; import javax.script.ScriptException; import >> javax.script.SimpleScriptContext; /* ------------------------ Apache Version 2.0 license >> ------------------------- Copyright 2015-2016 Rony G. Flatscher Licensed under the Apache License, >> Version 2.0 (the "License"); you may not use this file except in compliance with the License. You >> may obtain a copy of the License at http://www.apache.org/licenses/LICENSE-2.0 Unless required by >> applicable law or agreed to in writing, software distributed under the License is distributed on an >> "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the >> License for the specific language governing permissions and limitations under the License. >> ----------------------------------------------------------------------------- changed: 2016-12-06, >> rgf: if no argument is given, show the help after the list of currently available javax.script >> engines */ /** A command line Java utility to query, test and evaluate {@link javax.script} >> scripting engines that * gets distributed via the beta BSF4ooRexx package from Sourceforge. * * >>

Usage: java RunScript [{-i | -t | -e enginename filename [args...] | filename >> [args...]}] *
*

    *
  • ... no arguments: lists the currently available >> javax.script engines * *
  • -h ... 'help', lists and briefly explains >> the command line options * *
  • -i ... lists the available javax.script >> engines and informs about their properties * *
  • -t ... lists the available >> javax.script engines and tests evaluating their factory's >> "getOutputStatement(String)" method * *
  • -e enginename filename >> [args...] ... uses "enginename" to evaluate >> "filename" supplying the arguments "args..." * *
  • >> filename [args...] ... the "filename" extension determines the >> script engine to evaluate it, supplying the arguments "args..." *
* * * >> @author Rony G. Flatscher * @since 2015-05-20 */ public class RunScript { public static void >> main(String args[]) { ScriptEngineManager manager = new ScriptEngineManager(); >> List factories = manager.getEngineFactories(); >> HashMap n2sef=new HashMap (); >> HashMap n2se =new HashMap (); // create the Maps for >> (ScriptEngineFactory factory : factories) { String name=factory.getLanguageName(); // String >> name=factory.getEngineName(); n2sef.put(name, factory); n2se .put(name, factory.getScriptEngine()); >> } // create a sorted set of key names SortedSet keys = new TreeSet(n2sef.keySet()); >> int argsStartAt=-1; // arguments - if any - for filenmae to execute start at this position >> ScriptEngine scriptEngineToUse=null; String filename=null; if (args.length==0) // list all available >> javax.script engines { System.out.println("The following javax.script engines are currently >> available:\n"); for (String key : keys) { System.out.println('\t'+key); } System.out.println(); >> showHelp(); return; } else // process the first argument to decide what we need to do { String >> firstWord=args[0]; // get first value if (firstWord.startsWith("-")==true) // a switch at hand! { if >> (firstWord.length()!=2) // oops an error, we need excactly two chars (-i, -t, -e) { throw new >> IllegalArgumentException("switch '-' must be followed by one of the letters 'i', 't', or 'e'"); } >> String uSwitch=firstWord.substring(1).toUpperCase(); // get switch in uppercase if >> (uSwitch.equals("I")) // list all engines, list all their standard properties { for (String key : >> keys) // list all engines in order{ { showEngineProperties(key, n2sef.get(key)); } return; } else if >> (uSwitch.equals("T")) // list all engines, test them { for (String key : keys) // list all engines >> in order{ { testEngine(key, n2sef.get(key), n2se.get(key)); } return; } else if >> (uSwitch.equals("H")) // -h ... help text { showHelp(); return; } else if (uSwitch.equals("E")) // >> -e engineName fileName [arg... ] { if (args.length<3) { throw new IllegalArgumentException("too few >> command line arguments ("+args.length+"), minimum needed is 3: \"-e enginename filename\""); } // >> check whether engine is available, if so, then load it filename=args[2]; // assign filename String >> errMsg="no \""+args[1]+"\" javax.script engine available"; try { >> scriptEngineToUse=manager.getEngineByName(args[1]); // fetch script engine } catch (Exception exc) { >> throw new IllegalArgumentException(errMsg); } if (scriptEngineToUse==null) { throw new >> IllegalArgumentException(errMsg); } argsStartAt=3; // fourth argument! } else // unknown switch { >> throw new IllegalArgumentException("unknown switch '"+firstWord+"', must be followed by one of '-h', >> '-i', '-t', or '-e'"); } } else // a filename in hand, check whether we have a suitable engine >> available { // - check whether suitable engine is available, if not raise an exception >> filename=args[0]; // assign filename int lastIdx=filename.lastIndexOf('.'); if (lastIdx==0) { throw >> new IllegalArgumentException("filename \"filename\" does not have an extension, cannot determine >> scripting engine"); } String errMsg="cannot determine scripting engine from the filename extension >> in \""+filename+"\""; try { String extension=filename.substring(lastIdx+1); // get extension >> scriptEngineToUse=manager.getEngineByExtension(extension); // fetch script engine } catch (Exception >> exc) // if substring() causes an exception { throw new IllegalArgumentException(errMsg); } if >> (scriptEngineToUse==null) // no scripting engine found { throw new IllegalArgumentException(errMsg); >> } argsStartAt=1; // second argument! } } // now setup the remainder and eval() the "filename" with >> the script engine // - check whether file exists, if not raise an exception File f=null; try { f=new >> File (filename); } catch (Exception exc) { throw new IllegalArgumentException(exc); } if >> (f.exists()==false) { throw new IllegalArgumentException("filename \""+filename+"\" does not >> exist"); } // - supply filename ScriptContext sc=scriptEngineToUse.getContext(); // get the default >> context sc.setAttribute(ScriptEngine.FILENAME, filename, ScriptContext.ENGINE_SCOPE); // - if >> arguments, setup ARGV in ENGINE_SCOPE if (args.length>argsStartAt) // do we have command line >> arguments to supply? { String argArr []=new String [args.length-argsStartAt]; // determine array >> size int k=0; for (int i=argsStartAt; i> sc.setAttribute(ScriptEngine.ARGV, argArr, ScriptContext.ENGINE_SCOPE); } // - eval the script try { >> scriptEngineToUse.eval(new FileReader(f)); } catch (Exception exc) { throw new >> IllegalArgumentException(exc); } } // show information about the script engine static void >> showEngineProperties(String name, ScriptEngineFactory sef) { System.out.println(name); >> System.out.print ("\tgetEngineName() : "); try { System.out.println(sef.getEngineName() ); } catch >> (Exception e) { System.out.println("--> FAILED!"); } System.out.print ("\tgetEngineVersion() : "); >> try { System.out.println(sef.getEngineVersion() ); } catch (Exception e) { System.out.println("--> >> FAILED!"); } System.out.print ("\tgetExtensions() : "); try { System.out.println(sef.getExtensions >> ()); } catch (Exception e) { System.out.println("--> FAILED!"); } System.out.print >> ("\tgetLanguageName() : "); try { System.out.println(sef.getLanguageName () ); } catch (Exception e) >> { System.out.println("--> FAILED!"); } System.out.print ("\tgetLanguageVersion() : "); try { >> System.out.println(sef.getLanguageVersion()); } catch (Exception e) { System.out.println("--> >> FAILED!"); } System.out.print ("\tgetMimeTypes() : "); try { System.out.println(sef.getMimeTypes >> ()); } catch (Exception e) { System.out.println("--> FAILED!"); } System.out.print ("\tgetNames() : >> "); try { System.out.println(sef.getNames() ); } catch (Exception e) { System.out.println("--> >> FAILED!"); } System.out.print ("\tgetParameter(\"THREADING\"): "); try { >> System.out.println(sef.getParameter("THREADING")); } catch (Exception e) { System.out.println("--> >> FAILED!"); } } // create an output statement and execute output statement for each available script >> engine static void testEngine(String name, ScriptEngineFactory sef, ScriptEngine se) { >> System.out.println("---> language ["+name+"]: ---------------------------------------->\n"); String >> text="hello world, this is \""+name+"\" speaking! "; String code=sef.getOutputStatement(text); >> System.out.println("\t1) output statement to process: "+text+"\n"); System.out.print("\t--> testing >> getOutputStatement(String)"); System.out.println(", produced the following ["+name+"] output >> statement \n\n"+code+"\n"); System.out.println("\t... now running \"eval(code)\" using the scripting >> engine ["+name+"]: \n\n"); try { se.eval(code); System.out.println("\n"); } catch (ScriptException >> sexc) { System.err.println(sexc+" while eval() the code: "+code+"\n"); } System.out.print("\t2) >> testing getMethodCallSyntax(obj, meth, arg...)"); String methCode=sef.getMethodCallSyntax("object", >> "method", "arg1", "arg2"); System.out.println(", produced the following ["+name+"] method call >> statement: \n\n"+methCode+"\n"); System.out.print("\t3) testing getProgram(String...)"); String >> programCode=sef.getProgram(code, methCode); System.out.println(" produced the following ["+name+"] >> program: \n\n"+programCode+"\n"); System.out.println("<--- end of testing language ["+name+"]. >> <----------------------------------------\n"); } // allow us to call this from different parts >> static void showHelp() { System.out.println("usage: java RunScript [{-i | -t | -e enginename >> filename [args...] | filename [args...]}]\n"); System.out.println(" ... no arguments lists the >> available javax.script engines"); System.out.println(" -h ... 'help', gives this usage text"); >> System.out.println(" -i ... lists the available javax.script engines and informs about their >> properties"); System.out.println(" -t ... lists the available javax.script engines and tests >> evaluating their \"getOutputStatement(String)\" method"); System.out.println(" -e enginename >> filename [args...] ... uses \"enginename\" to evaluate \"filename\" supplying the arguments >> \"args...\""); System.out.println(" filename [args...] ... the \"filename\" extension determines the >> script engine to evaluate it, supplying the arguments \"args...\""); return; } } ------------------ >> cut here ------------------ >> >> From ekemokai at gmail.com Fri Jan 6 15:07:20 2017 From: ekemokai at gmail.com (Edmond Kemokai) Date: Fri, 6 Jan 2017 10:07:20 -0500 Subject: Nashorn's javax.script.ScriptEngineFactory produces wrong code In-Reply-To: <5471cfe8-5956-a749-1ba8-842e4fa7d066@wu.ac.at> References: <9bc6202f-7a5c-e9f2-7e41-da8e90bfccec@wu.ac.at> <5471cfe8-5956-a749-1ba8-842e4fa7d066@wu.ac.at> Message-ID: Hi Rony, I am the developer of HiveMind, it is a web app platform that relies entirely on scripting engines via JSR-223. You can access a demo instance: http://demo.crudzilla.com:7000/ Login with: developer/developer I have created a test file in: /com/crudzilla/cloudTest/web/rony-groovy.ste Put your code (the original one you pasted) in there and save, I'll take a look to see what might be missing. On Fri, Jan 6, 2017 at 9:07 AM, Rony G. Flatscher wrote: > Besides Java 1.8.0_111 the problem exists in 9ea-+134 (engine version: > "9ea", language version: > "ECMA 262 - Edition 5.1" ) as well: Nashorn's javax.script factory is used > to get an output > statement and then it is used to execute it: > > ---> language [ECMAScript]: ----------------------------------------> > > 1) output statement to process: hello world, this is > "ECMAScript" speaking! > > --> testing getOutputStatement(String), produced the following > [ECMAScript] output statement > > print(hello world, this is "ECMAScript" speaking! ) > > ... now running "eval(code)" using the scripting engine > [ECMAScript]: > > > javax.script.ScriptException: :1:12 Expected , but found world > print(hello world, this is "ECMAScript" speaking! ) > ^ in at line number 1 at column number 12 while > eval() the code: print(hello > world, this is "ECMAScript" speaking! ) > > This time trying to not format the Java code, so hopefully the mailer will > not render it illegible: > > ... cut ... > > // create an output statement and execute output statement with the > script engine > static void testEngine(String name, ScriptEngineFactory sef, > ScriptEngine se) > { > System.out.println("---> language ["+name+"]: > ---------------------------------------->\n"); > String text="hello world, this is \""+name+"\" speaking! "; > String code=sef.getOutputStatement(text); > System.out.println("\t1) output statement to process: > "+text+"\n"); > > System.out.print("\t--> testing getOutputStatement(String)"); > System.out.println(", produced the following ["+name+"] output > statement \n\n"+code+"\n"); > System.out.println("\t... now running \"eval(code)\" using the > scripting engine > ["+name+"]: \n\n"); > try > { > se.eval(code); > System.out.println("\n"); > } > catch (ScriptException sexc) > { > System.err.println(sexc+" while eval() the code: > "+code+"\n"); > } > > System.out.print("\t2) testing getMethodCallSyntax(obj, meth, > arg...)"); > String methCode=sef.getMethodCallSyntax("object", "method", > "arg1", "arg2"); > System.out.println(", produced the following ["+name+"] method > call statement: > \n\n"+methCode+"\n"); > > System.out.print("\t3) testing getProgram(String...)"); > String programCode=sef.getProgram(code, methCode); > System.out.println(" produced the following ["+name+"] > program: \n\n"+programCode+"\n"); > > System.out.println("<--- end of testing language ["+name+"]. > <----------------------------------------\n"); > } > > ... cut ... > > If I should file a bug then please advise where and how. > > ---rony > > > On 08.12.2016 16:17, Rony G. Flatscher wrote: > > Unfortunately, the mailing list seems to behave as if it was running in > the 1970's such that the > > formatted text (indented, partially colorized and formatted to preformat > and Courier) has turned to > > become illegible, unfortunately (using the Thunderbird e-Mail client)! > > :( > > > > The meat is right in the first two paragraphs and the last paragraph > before the signature. Should > > anyone be interested in the Java-utility, please drop me a personal > e-mail and I will send that Java > > program as an attachment to you. > > > > ---rony > > > > > > > > On 08.12.2016 16:05, Rony G. Flatscher wrote: > >> Hi there, was directed to this list to report an error with Nashorn's > implementation of > >> javax.script.ScriptEngineFactory.getOutputStatement(String toDisplay). > >> > >> The test is simple: one supplies a string, containing double quotes, > and immediately use the Nashort > >> script engine to carry out the output statement produced by its > factory, yielding a runtime error. > >> In order for you to reproduce, I list the Java utility (it lists all > available javax.script engines > >> and tests them with the -t switch and is a little example of how one > can take advantage of > >> javax.script very easily) after my signature below to study the code > and run it to double-check: > >> > >> F:\work\svn\bsf4oorexx\trunk\samples\Java\jsr223>java RunScript -t > ---> language [ECMAScript]: > >> ----------------------------------------> 1) output statement to > process: hello world, this is > >> "ECMAScript" speaking! --> testing getOutputStatement(String), > produced the following > >> [ECMAScript] output statement *print(hello world, this is > "ECMAScript" speaking! )* ... now > >> running "eval(code)" using the scripting engine [ECMAScript]: > *javax.script.ScriptException: > >> :1:12 Expected , but found world print(hello world, this is > "ECMAScript" speaking! ) ^ in > >> at line number 1 at column number 12 while eval() the code: > print(hello world, this is > >> "ECMAScript" speaking! )* 2) testing getMethodCallSyntax(obj, meth, > arg...), produced the > >> following [ECMAScript] method call statement: > object.method(arg1,arg2) 3) testing > >> getProgram(String...) produced the following [ECMAScript] program: > print(hello world, this is > >> "ECMAScript" speaking! );object.method(arg1,arg2); <--- end of > testing language [ECMAScript]. > >> <---------------------------------------- ---> language [ooRexx]: > >> ----------------------------------------> ... cut ... > >> > >> The specification for javax.script created by the Java specification > request group 223 (a.k.a. > >> JSR-223) can be consulted. BTW, "jrunscript[.exe]" (from the JDK) seems > to be broken, it only is be > >> able to execute the Nashorn script engine, despite switches that allow > other script engines to be > >> employed. > >> > >> ---rony > >> > >> Code of "RunScript.java" (little utility to list the currently > available javax.script languages, run > >> any javax.script program, give helpful information about each > javax.script engine and test each one > >> using its own factory means): just compile it and run it with "java > RunScript -t": > >> > >> ------------------ cut here ------------------ > >> import java.io.File; import java.io.FileReader; import > java.util.ArrayList; import java.util.Arrays; > >> import java.util.List; import java.util.HashMap; import > java.util.SortedSet; import > >> java.util.TreeSet; import javax.script.Bindings; import > javax.script.ScriptContext; import > >> javax.script.ScriptEngine; import javax.script.ScriptEngineFactory; > import > >> javax.script.ScriptEngineManager; import javax.script.ScriptException; > import > >> javax.script.SimpleScriptContext; /* ------------------------ Apache > Version 2.0 license > >> ------------------------- Copyright 2015-2016 Rony G. Flatscher > Licensed under the Apache License, > >> Version 2.0 (the "License"); you may not use this file except in > compliance with the License. You > >> may obtain a copy of the License at http://www.apache.org/ > licenses/LICENSE-2.0 Unless required by > >> applicable law or agreed to in writing, software distributed under the > License is distributed on an > >> "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either > express or implied. See the > >> License for the specific language governing permissions and limitations > under the License. > >> ----------------------------------------------------------------------------- > changed: 2016-12-06, > >> rgf: if no argument is given, show the help after the list of currently > available javax.script > >> engines */ /** A command line Java utility to query, test and evaluate > {@link javax.script} > >> scripting engines that * gets distributed via the beta BSF4ooRexx > package from Sourceforge. * * > >>

Usage: java RunScript [{-i | -t | -e enginename filename > [args...] | filename > >> [args...]}] *
*

    *
  • ... no arguments: lists the > currently available > >> javax.script engines * *
  • -h ... 'help', > lists and briefly explains > >> the command line options * *
  • -i ... lists the > available javax.script > >> engines and informs about their properties * *
  • -t ... > lists the available > >> javax.script engines and tests evaluating their factory's > >> "getOutputStatement(String)" method * *
  • > -e enginename filename > >> [args...] ... uses "enginename" to > evaluate > >> "filename" supplying the arguments > "args..." * *
  • > >> filename [args...] ... the "filename" > extension determines the > >> script engine to evaluate it, supplying the arguments > "args..." *
* * * > >> @author Rony G. Flatscher * @since 2015-05-20 */ public class RunScript > { public static void > >> main(String args[]) { ScriptEngineManager manager = new > ScriptEngineManager(); > >> List factories = manager.getEngineFactories(); > >> HashMap n2sef=new HashMap > (); > >> HashMap n2se =new HashMap (); > // create the Maps for > >> (ScriptEngineFactory factory : factories) { String > name=factory.getLanguageName(); // String > >> name=factory.getEngineName(); n2sef.put(name, factory); n2se .put(name, > factory.getScriptEngine()); > >> } // create a sorted set of key names SortedSet keys = new > TreeSet(n2sef.keySet()); > >> int argsStartAt=-1; // arguments - if any - for filenmae to execute > start at this position > >> ScriptEngine scriptEngineToUse=null; String filename=null; if > (args.length==0) // list all available > >> javax.script engines { System.out.println("The following javax.script > engines are currently > >> available:\n"); for (String key : keys) { System.out.println('\t'+key); > } System.out.println(); > >> showHelp(); return; } else // process the first argument to decide what > we need to do { String > >> firstWord=args[0]; // get first value if (firstWord.startsWith("-")==true) > // a switch at hand! { if > >> (firstWord.length()!=2) // oops an error, we need excactly two chars > (-i, -t, -e) { throw new > >> IllegalArgumentException("switch '-' must be followed by one of the > letters 'i', 't', or 'e'"); } > >> String uSwitch=firstWord.substring(1).toUpperCase(); // get switch in > uppercase if > >> (uSwitch.equals("I")) // list all engines, list all their standard > properties { for (String key : > >> keys) // list all engines in order{ { showEngineProperties(key, > n2sef.get(key)); } return; } else if > >> (uSwitch.equals("T")) // list all engines, test them { for (String key > : keys) // list all engines > >> in order{ { testEngine(key, n2sef.get(key), n2se.get(key)); } return; } > else if > >> (uSwitch.equals("H")) // -h ... help text { showHelp(); return; } else > if (uSwitch.equals("E")) // > >> -e engineName fileName [arg... ] { if (args.length<3) { throw new > IllegalArgumentException("too few > >> command line arguments ("+args.length+"), minimum needed is 3: \"-e > enginename filename\""); } // > >> check whether engine is available, if so, then load it > filename=args[2]; // assign filename String > >> errMsg="no \""+args[1]+"\" javax.script engine available"; try { > >> scriptEngineToUse=manager.getEngineByName(args[1]); // fetch script > engine } catch (Exception exc) { > >> throw new IllegalArgumentException(errMsg); } if > (scriptEngineToUse==null) { throw new > >> IllegalArgumentException(errMsg); } argsStartAt=3; // fourth argument! > } else // unknown switch { > >> throw new IllegalArgumentException("unknown switch '"+firstWord+"', > must be followed by one of '-h', > >> '-i', '-t', or '-e'"); } } else // a filename in hand, check whether we > have a suitable engine > >> available { // - check whether suitable engine is available, if not > raise an exception > >> filename=args[0]; // assign filename int lastIdx=filename.lastIndexOf('.'); > if (lastIdx==0) { throw > >> new IllegalArgumentException("filename \"filename\" does not have an > extension, cannot determine > >> scripting engine"); } String errMsg="cannot determine scripting engine > from the filename extension > >> in \""+filename+"\""; try { String extension=filename.substring(lastIdx+1); > // get extension > >> scriptEngineToUse=manager.getEngineByExtension(extension); // fetch > script engine } catch (Exception > >> exc) // if substring() causes an exception { throw new > IllegalArgumentException(errMsg); } if > >> (scriptEngineToUse==null) // no scripting engine found { throw new > IllegalArgumentException(errMsg); > >> } argsStartAt=1; // second argument! } } // now setup the remainder and > eval() the "filename" with > >> the script engine // - check whether file exists, if not raise an > exception File f=null; try { f=new > >> File (filename); } catch (Exception exc) { throw new > IllegalArgumentException(exc); } if > >> (f.exists()==false) { throw new IllegalArgumentException("filename > \""+filename+"\" does not > >> exist"); } // - supply filename ScriptContext sc=scriptEngineToUse.getContext(); > // get the default > >> context sc.setAttribute(ScriptEngine.FILENAME, filename, > ScriptContext.ENGINE_SCOPE); // - if > >> arguments, setup ARGV in ENGINE_SCOPE if (args.length>argsStartAt) // > do we have command line > >> arguments to supply? { String argArr []=new String > [args.length-argsStartAt]; // determine array > >> size int k=0; for (int i=argsStartAt; i argArr[k]=args[i]; } > >> sc.setAttribute(ScriptEngine.ARGV, argArr, > ScriptContext.ENGINE_SCOPE); } // - eval the script try { > >> scriptEngineToUse.eval(new FileReader(f)); } catch (Exception exc) { > throw new > >> IllegalArgumentException(exc); } } // show information about the script > engine static void > >> showEngineProperties(String name, ScriptEngineFactory sef) { > System.out.println(name); > >> System.out.print ("\tgetEngineName() : "); try { System.out.println(sef.getEngineName() > ); } catch > >> (Exception e) { System.out.println("--> FAILED!"); } System.out.print > ("\tgetEngineVersion() : "); > >> try { System.out.println(sef.getEngineVersion() ); } catch (Exception > e) { System.out.println("--> > >> FAILED!"); } System.out.print ("\tgetExtensions() : "); try { > System.out.println(sef.getExtensions > >> ()); } catch (Exception e) { System.out.println("--> FAILED!"); } > System.out.print > >> ("\tgetLanguageName() : "); try { System.out.println(sef.getLanguageName > () ); } catch (Exception e) > >> { System.out.println("--> FAILED!"); } System.out.print > ("\tgetLanguageVersion() : "); try { > >> System.out.println(sef.getLanguageVersion()); } catch (Exception e) { > System.out.println("--> > >> FAILED!"); } System.out.print ("\tgetMimeTypes() : "); try { > System.out.println(sef.getMimeTypes > >> ()); } catch (Exception e) { System.out.println("--> FAILED!"); } > System.out.print ("\tgetNames() : > >> "); try { System.out.println(sef.getNames() ); } catch (Exception e) { > System.out.println("--> > >> FAILED!"); } System.out.print ("\tgetParameter(\"THREADING\"): "); try > { > >> System.out.println(sef.getParameter("THREADING")); } catch (Exception > e) { System.out.println("--> > >> FAILED!"); } } // create an output statement and execute output > statement for each available script > >> engine static void testEngine(String name, ScriptEngineFactory sef, > ScriptEngine se) { > >> System.out.println("---> language ["+name+"]: > ---------------------------------------->\n"); String > >> text="hello world, this is \""+name+"\" speaking! "; String > code=sef.getOutputStatement(text); > >> System.out.println("\t1) output statement to process: "+text+"\n"); > System.out.print("\t--> testing > >> getOutputStatement(String)"); System.out.println(", produced the > following ["+name+"] output > >> statement \n\n"+code+"\n"); System.out.println("\t... now running > \"eval(code)\" using the scripting > >> engine ["+name+"]: \n\n"); try { se.eval(code); > System.out.println("\n"); } catch (ScriptException > >> sexc) { System.err.println(sexc+" while eval() the code: "+code+"\n"); > } System.out.print("\t2) > >> testing getMethodCallSyntax(obj, meth, arg...)"); String methCode=sef. > getMethodCallSyntax("object", > >> "method", "arg1", "arg2"); System.out.println(", produced the following > ["+name+"] method call > >> statement: \n\n"+methCode+"\n"); System.out.print("\t3) testing > getProgram(String...)"); String > >> programCode=sef.getProgram(code, methCode); System.out.println(" > produced the following ["+name+"] > >> program: \n\n"+programCode+"\n"); System.out.println("<--- end of > testing language ["+name+"]. > >> <----------------------------------------\n"); } // allow us to call > this from different parts > >> static void showHelp() { System.out.println("usage: java RunScript [{-i > | -t | -e enginename > >> filename [args...] | filename [args...]}]\n"); System.out.println(" ... > no arguments lists the > >> available javax.script engines"); System.out.println(" -h ... 'help', > gives this usage text"); > >> System.out.println(" -i ... lists the available javax.script engines > and informs about their > >> properties"); System.out.println(" -t ... lists the available > javax.script engines and tests > >> evaluating their \"getOutputStatement(String)\" method"); > System.out.println(" -e enginename > >> filename [args...] ... uses \"enginename\" to evaluate \"filename\" > supplying the arguments > >> \"args...\""); System.out.println(" filename [args...] ... the > \"filename\" extension determines the > >> script engine to evaluate it, supplying the arguments \"args...\""); > return; } } ------------------ > >> cut here ------------------ > >> > >> > > From Rony.Flatscher at wu.ac.at Fri Jan 6 15:21:16 2017 From: Rony.Flatscher at wu.ac.at (Rony G. Flatscher) Date: Fri, 6 Jan 2017 16:21:16 +0100 Subject: Nashorn's javax.script.ScriptEngineFactory produces wrong code In-Reply-To: References: <9bc6202f-7a5c-e9f2-7e41-da8e90bfccec@wu.ac.at> <5471cfe8-5956-a749-1ba8-842e4fa7d066@wu.ac.at> Message-ID: <1d616490-9317-57d2-348e-708ee82abc5e@wu.ac.at> Hi Ed, On 06.01.2017 16:07, Edmond Kemokai wrote: > > I am the developer of HiveMind, it is a web app platform that relies entirely on scripting engines > via JSR-223. > > You can access a demo instance: http://demo.crudzilla.com:7000/ > Login with: developer/developer > > I have created a test file in: /com/crudzilla/cloudTest/web/rony-groovy.ste > > Put your code (the original one you pasted) in there and save, I'll take a look to see what might > be missing. Done. After compiling just run it as "java RunScript" (make sure your CLASSPATH picks up the directory that contains RunScript.class, which does not define any package name, e.g. "."). It will list all JSR-223 scripting languages on your system and give the help. E.g. currently on my Windows system: F:\work\svn\bsf4oorexx\trunk\samples\Java\javax.script>java RunScript The following javax.script engines are currently available: ECMAScript ooRexx usage: java RunScript [{-i | -t | -e enginename filename [args...] | filename [args...]}] ... no arguments lists the available javax.script engines -h ... 'help', gives this usage text -i ... lists the available javax.script engines and informs about their properties -t ... lists the available javax.script engines and tests evaluating their "getOutputStatement(String)" method -e enginename filename [args...] ... uses "enginename" to evaluate "filename" supplying the arguments "args..." filename [args...] ... the "filename" extension determines the script engine to evaluate it, supplying the arguments "args..." Running with the "-t" switch tests the code generated by the script engine's factories by letting it eval()'ed. ---rony > > > On Fri, Jan 6, 2017 at 9:07 AM, Rony G. Flatscher > wrote: > > Besides Java 1.8.0_111 the problem exists in 9ea-+134 (engine version: "9ea", language version: > "ECMA 262 - Edition 5.1" ) as well: Nashorn's javax.script factory is used to get an output > statement and then it is used to execute it: > > ---> language [ECMAScript]: ----------------------------------------> > > 1) output statement to process: hello world, this is "ECMAScript" speaking! > > --> testing getOutputStatement(String), produced the following [ECMAScript] output > statement > > print(hello world, this is "ECMAScript" speaking! ) > > ... now running "eval(code)" using the scripting engine [ECMAScript]: > > > javax.script.ScriptException: :1:12 Expected , but found world > print(hello world, this is "ECMAScript" speaking! ) > ^ in at line number 1 at column number 12 while eval() the code: > print(hello > world, this is "ECMAScript" speaking! ) > > This time trying to not format the Java code, so hopefully the mailer will not render it > illegible: > > ... cut ... > > // create an output statement and execute output statement with the script engine > static void testEngine(String name, ScriptEngineFactory sef, ScriptEngine se) > { > System.out.println("---> language ["+name+"]: > ---------------------------------------->\n"); > String text="hello world, this is \""+name+"\" speaking! "; > String code=sef.getOutputStatement(text); > System.out.println("\t1) output statement to process: "+text+"\n"); > > System.out.print("\t--> testing getOutputStatement(String)"); > System.out.println(", produced the following ["+name+"] output statement > \n\n"+code+"\n"); > System.out.println("\t... now running \"eval(code)\" using the scripting engine > ["+name+"]: \n\n"); > try > { > se.eval(code); > System.out.println("\n"); > } > catch (ScriptException sexc) > { > System.err.println(sexc+" while eval() the code: "+code+"\n"); > } > > System.out.print("\t2) testing getMethodCallSyntax(obj, meth, arg...)"); > String methCode=sef.getMethodCallSyntax("object", "method", "arg1", "arg2"); > System.out.println(", produced the following ["+name+"] method call statement: > \n\n"+methCode+"\n"); > > System.out.print("\t3) testing getProgram(String...)"); > String programCode=sef.getProgram(code, methCode); > System.out.println(" produced the following ["+name+"] program: > \n\n"+programCode+"\n"); > > System.out.println("<--- end of testing language ["+name+"]. > <----------------------------------------\n"); > } > > ... cut ... > > If I should file a bug then please advise where and how. > > ---rony > > > On 08.12.2016 16:17, Rony G. Flatscher wrote: > > Unfortunately, the mailing list seems to behave as if it was running in the 1970's such that the > > formatted text (indented, partially colorized and formatted to preformat and Courier) has > turned to > > become illegible, unfortunately (using the Thunderbird e-Mail client)! > > :( > > > > The meat is right in the first two paragraphs and the last paragraph before the signature. > Should > > anyone be interested in the Java-utility, please drop me a personal e-mail and I will send > that Java > > program as an attachment to you. > > > > ---rony > > > > > > > > On 08.12.2016 16:05, Rony G. Flatscher wrote: > >> Hi there, was directed to this list to report an error with Nashorn's implementation of > >> javax.script.ScriptEngineFactory.getOutputStatement(String toDisplay). > >> > >> The test is simple: one supplies a string, containing double quotes, and immediately use > the Nashort > >> script engine to carry out the output statement produced by its factory, yielding a runtime > error. > >> In order for you to reproduce, I list the Java utility (it lists all available javax.script > engines > >> and tests them with the -t switch and is a little example of how one can take advantage of > >> javax.script very easily) after my signature below to study the code and run it to > double-check: > >> > >> F:\work\svn\bsf4oorexx\trunk\samples\Java\jsr223>java RunScript -t ---> language > [ECMAScript]: > >> ----------------------------------------> 1) output statement to process: hello world, > this is > >> "ECMAScript" speaking! --> testing getOutputStatement(String), produced the following > >> [ECMAScript] output statement *print(hello world, this is "ECMAScript" speaking! )* ... now > >> running "eval(code)" using the scripting engine [ECMAScript]: > *javax.script.ScriptException: > >> :1:12 Expected , but found world print(hello world, this is "ECMAScript" > speaking! ) ^ in > >> at line number 1 at column number 12 while eval() the code: print(hello world, > this is > >> "ECMAScript" speaking! )* 2) testing getMethodCallSyntax(obj, meth, arg...), produced the > >> following [ECMAScript] method call statement: object.method(arg1,arg2) 3) testing > >> getProgram(String...) produced the following [ECMAScript] program: print(hello world, > this is > >> "ECMAScript" speaking! );object.method(arg1,arg2); <--- end of testing language > [ECMAScript]. > >> <---------------------------------------- ---> language [ooRexx]: > >> ----------------------------------------> ... cut ... > >> > >> The specification for javax.script created by the Java specification request group 223 (a.k.a. > >> JSR-223) can be consulted. BTW, "jrunscript[.exe]" (from the JDK) seems to be broken, it > only is be > >> able to execute the Nashorn script engine, despite switches that allow other script engines > to be > >> employed. > >> > >> ---rony > >> > >> Code of "RunScript.java" (little utility to list the currently available javax.script > languages, run > >> any javax.script program, give helpful information about each javax.script engine and test > each one > >> using its own factory means): just compile it and run it with "java RunScript -t": > >> > >> ------------------ cut here ------------------ > >> import java.io.File; import java.io.FileReader; import java.util.ArrayList; import > java.util.Arrays; > >> import java.util.List; import java.util.HashMap; import java.util.SortedSet; import > >> java.util.TreeSet; import javax.script.Bindings; import javax.script.ScriptContext; import > >> javax.script.ScriptEngine; import javax.script.ScriptEngineFactory; import > >> javax.script.ScriptEngineManager; import javax.script.ScriptException; import > >> javax.script.SimpleScriptContext; /* ------------------------ Apache Version 2.0 license > >> ------------------------- Copyright 2015-2016 Rony G. Flatscher Licensed under the Apache > License, > >> Version 2.0 (the "License"); you may not use this file except in compliance with the > License. You > >> may obtain a copy of the License at http://www.apache.org/licenses/LICENSE-2.0 > Unless required by > >> applicable law or agreed to in writing, software distributed under the License is > distributed on an > >> "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the > >> License for the specific language governing permissions and limitations under the License. > >> ----------------------------------------------------------------------------- changed: > 2016-12-06, > >> rgf: if no argument is given, show the help after the list of currently available javax.script > >> engines */ /** A command line Java utility to query, test and evaluate {@link javax.script} > >> scripting engines that * gets distributed via the beta BSF4ooRexx package from Sourceforge. * * > >>

Usage: java RunScript [{-i | -t | -e enginename filename [args...] | filename > >> [args...]}] *
*

    *
  • ... no arguments: lists the currently available > >> javax.script engines * *
  • -h ... 'help', lists and briefly > explains > >> the command line options * *
  • -i ... lists the available > javax.script > >> engines and informs about their properties * *
  • -t ... lists the available > >> javax.script engines and tests evaluating their factory's > >> "getOutputStatement(String)" method * *
  • -e enginename > filename > >> [args...] ... uses "enginename" to evaluate > >> "filename" supplying the arguments "args..." > * *
  • > >> filename [args...] ... the "filename" extension > determines the > >> script engine to evaluate it, supplying the arguments "args..." * >
* * * > >> @author Rony G. Flatscher * @since 2015-05-20 */ public class RunScript { public static void > >> main(String args[]) { ScriptEngineManager manager = new ScriptEngineManager(); > >> List factories = manager.getEngineFactories(); > >> HashMap n2sef=new HashMap (); > >> HashMap n2se =new HashMap (); // create the Maps for > >> (ScriptEngineFactory factory : factories) { String name=factory.getLanguageName(); // String > >> name=factory.getEngineName(); n2sef.put(name, factory); n2se .put(name, > factory.getScriptEngine()); > >> } // create a sorted set of key names SortedSet keys = new > TreeSet(n2sef.keySet()); > >> int argsStartAt=-1; // arguments - if any - for filenmae to execute start at this position > >> ScriptEngine scriptEngineToUse=null; String filename=null; if (args.length==0) // list all > available > >> javax.script engines { System.out.println("The following javax.script engines are currently > >> available:\n"); for (String key : keys) { System.out.println('\t'+key); } System.out.println(); > >> showHelp(); return; } else // process the first argument to decide what we need to do { String > >> firstWord=args[0]; // get first value if (firstWord.startsWith("-")==true) // a switch at > hand! { if > >> (firstWord.length()!=2) // oops an error, we need excactly two chars (-i, -t, -e) { throw new > >> IllegalArgumentException("switch '-' must be followed by one of the letters 'i', 't', or > 'e'"); } > >> String uSwitch=firstWord.substring(1).toUpperCase(); // get switch in uppercase if > >> (uSwitch.equals("I")) // list all engines, list all their standard properties { for (String > key : > >> keys) // list all engines in order{ { showEngineProperties(key, n2sef.get(key)); } return; > } else if > >> (uSwitch.equals("T")) // list all engines, test them { for (String key : keys) // list all > engines > >> in order{ { testEngine(key, n2sef.get(key), n2se.get(key)); } return; } else if > >> (uSwitch.equals("H")) // -h ... help text { showHelp(); return; } else if > (uSwitch.equals("E")) // > >> -e engineName fileName [arg... ] { if (args.length<3) { throw new > IllegalArgumentException("too few > >> command line arguments ("+args.length+"), minimum needed is 3: \"-e enginename > filename\""); } // > >> check whether engine is available, if so, then load it filename=args[2]; // assign filename > String > >> errMsg="no \""+args[1]+"\" javax.script engine available"; try { > >> scriptEngineToUse=manager.getEngineByName(args[1]); // fetch script engine } catch > (Exception exc) { > >> throw new IllegalArgumentException(errMsg); } if (scriptEngineToUse==null) { throw new > >> IllegalArgumentException(errMsg); } argsStartAt=3; // fourth argument! } else // unknown > switch { > >> throw new IllegalArgumentException("unknown switch '"+firstWord+"', must be followed by one > of '-h', > >> '-i', '-t', or '-e'"); } } else // a filename in hand, check whether we have a suitable engine > >> available { // - check whether suitable engine is available, if not raise an exception > >> filename=args[0]; // assign filename int lastIdx=filename.lastIndexOf('.'); if (lastIdx==0) > { throw > >> new IllegalArgumentException("filename \"filename\" does not have an extension, cannot > determine > >> scripting engine"); } String errMsg="cannot determine scripting engine from the filename > extension > >> in \""+filename+"\""; try { String extension=filename.substring(lastIdx+1); // get extension > >> scriptEngineToUse=manager.getEngineByExtension(extension); // fetch script engine } catch > (Exception > >> exc) // if substring() causes an exception { throw new IllegalArgumentException(errMsg); } if > >> (scriptEngineToUse==null) // no scripting engine found { throw new > IllegalArgumentException(errMsg); > >> } argsStartAt=1; // second argument! } } // now setup the remainder and eval() the > "filename" with > >> the script engine // - check whether file exists, if not raise an exception File f=null; > try { f=new > >> File (filename); } catch (Exception exc) { throw new IllegalArgumentException(exc); } if > >> (f.exists()==false) { throw new IllegalArgumentException("filename \""+filename+"\" does not > >> exist"); } // - supply filename ScriptContext sc=scriptEngineToUse.getContext(); // get the > default > >> context sc.setAttribute(ScriptEngine.FILENAME, filename, ScriptContext.ENGINE_SCOPE); // - if > >> arguments, setup ARGV in ENGINE_SCOPE if (args.length>argsStartAt) // do we have command line > >> arguments to supply? { String argArr []=new String [args.length-argsStartAt]; // determine > array > >> size int k=0; for (int i=argsStartAt; i >> sc.setAttribute(ScriptEngine.ARGV, argArr, ScriptContext.ENGINE_SCOPE); } // - eval the > script try { > >> scriptEngineToUse.eval(new FileReader(f)); } catch (Exception exc) { throw new > >> IllegalArgumentException(exc); } } // show information about the script engine static void > >> showEngineProperties(String name, ScriptEngineFactory sef) { System.out.println(name); > >> System.out.print ("\tgetEngineName() : "); try { System.out.println(sef.getEngineName() ); > } catch > >> (Exception e) { System.out.println("--> FAILED!"); } System.out.print > ("\tgetEngineVersion() : "); > >> try { System.out.println(sef.getEngineVersion() ); } catch (Exception e) { > System.out.println("--> > >> FAILED!"); } System.out.print ("\tgetExtensions() : "); try { > System.out.println(sef.getExtensions > >> ()); } catch (Exception e) { System.out.println("--> FAILED!"); } System.out.print > >> ("\tgetLanguageName() : "); try { System.out.println(sef.getLanguageName () ); } catch > (Exception e) > >> { System.out.println("--> FAILED!"); } System.out.print ("\tgetLanguageVersion() : "); try { > >> System.out.println(sef.getLanguageVersion()); } catch (Exception e) { System.out.println("--> > >> FAILED!"); } System.out.print ("\tgetMimeTypes() : "); try { > System.out.println(sef.getMimeTypes > >> ()); } catch (Exception e) { System.out.println("--> FAILED!"); } System.out.print > ("\tgetNames() : > >> "); try { System.out.println(sef.getNames() ); } catch (Exception e) { System.out.println("--> > >> FAILED!"); } System.out.print ("\tgetParameter(\"THREADING\"): "); try { > >> System.out.println(sef.getParameter("THREADING")); } catch (Exception e) { > System.out.println("--> > >> FAILED!"); } } // create an output statement and execute output statement for each > available script > >> engine static void testEngine(String name, ScriptEngineFactory sef, ScriptEngine se) { > >> System.out.println("---> language ["+name+"]: > ---------------------------------------->\n"); String > >> text="hello world, this is \""+name+"\" speaking! "; String code=sef.getOutputStatement(text); > >> System.out.println("\t1) output statement to process: "+text+"\n"); System.out.print("\t--> > testing > >> getOutputStatement(String)"); System.out.println(", produced the following ["+name+"] output > >> statement \n\n"+code+"\n"); System.out.println("\t... now running \"eval(code)\" using the > scripting > >> engine ["+name+"]: \n\n"); try { se.eval(code); System.out.println("\n"); } catch > (ScriptException > >> sexc) { System.err.println(sexc+" while eval() the code: "+code+"\n"); } System.out.print("\t2) > >> testing getMethodCallSyntax(obj, meth, arg...)"); String > methCode=sef.getMethodCallSyntax("object", > >> "method", "arg1", "arg2"); System.out.println(", produced the following ["+name+"] method call > >> statement: \n\n"+methCode+"\n"); System.out.print("\t3) testing getProgram(String...)"); String > >> programCode=sef.getProgram(code, methCode); System.out.println(" produced the following > ["+name+"] > >> program: \n\n"+programCode+"\n"); System.out.println("<--- end of testing language ["+name+"]. > >> <----------------------------------------\n"); } // allow us to call this from different parts > >> static void showHelp() { System.out.println("usage: java RunScript [{-i | -t | -e enginename > >> filename [args...] | filename [args...]}]\n"); System.out.println(" ... no arguments lists the > >> available javax.script engines"); System.out.println(" -h ... 'help', gives this usage text"); > >> System.out.println(" -i ... lists the available javax.script engines and informs about their > >> properties"); System.out.println(" -t ... lists the available javax.script engines and tests > >> evaluating their \"getOutputStatement(String)\" method"); System.out.println(" -e enginename > >> filename [args...] ... uses \"enginename\" to evaluate \"filename\" supplying the arguments > >> \"args...\""); System.out.println(" filename [args...] ... the \"filename\" extension > determines the > >> script engine to evaluate it, supplying the arguments \"args...\""); return; } } > ------------------ > >> cut here ------------------ > >> > >> > From ekemokai at gmail.com Fri Jan 6 16:49:05 2017 From: ekemokai at gmail.com (Edmond Kemokai) Date: Fri, 6 Jan 2017 11:49:05 -0500 Subject: Nashorn's javax.script.ScriptEngineFactory produces wrong code In-Reply-To: <1d616490-9317-57d2-348e-708ee82abc5e@wu.ac.at> References: <9bc6202f-7a5c-e9f2-7e41-da8e90bfccec@wu.ac.at> <5471cfe8-5956-a749-1ba8-842e4fa7d066@wu.ac.at> <1d616490-9317-57d2-348e-708ee82abc5e@wu.ac.at> Message-ID: The issue seems to go away after I quote the string. You can run the code in the browser by right clicking and choosing "Test" then click "Run". On the top right, click the dropdown button and choose "Log Viewer" to see the output. Ouput: INFO Invocation - ---> language [ECMAScript]: ----------------------------------------> INFO Invocation - 1) output statement to process: "hello world, this is ECMAScript speaking! " INFO Invocation - --> testing getOutputStatement(String) INFO Invocation - , produced the following [ECMAScript] output statement print("hello world, this is ECMAScript speaking! ") INFO Invocation - ... now running "eval(code)" using the scripting engine [ECMAScript]: INFO Invocation - INFO Invocation - 2) testing getMethodCallSyntax(obj, meth, arg...) INFO Invocation - , produced the following [ECMAScript] method call statement: object.method(arg1,arg2) INFO Invocation - 3) testing getProgram(String...) INFO Invocation - produced the following [ECMAScript] program: print("hello world, this is ECMAScript speaking! ");object.method(arg1,arg2); INFO Invocation - <--- end of testing language [ECMAScript]. <---------------------------------------- On Fri, Jan 6, 2017 at 10:21 AM, Rony G. Flatscher wrote: > Hi Ed, > On 06.01.2017 16:07, Edmond Kemokai wrote: > > > I am the developer of HiveMind, it is a web app platform that relies > entirely on scripting engines via JSR-223. > > You can access a demo instance: http://demo.crudzilla.com:7000/ > Login with: developer/developer > > I have created a test file in: /com/crudzilla/cloudTest/web/ > rony-groovy.ste > > Put your code (the original one you pasted) in there and save, I'll take a > look to see what might be missing. > > Done. > > After compiling just run it as "java RunScript" (make sure your CLASSPATH > picks up the directory that contains RunScript.class, which does not define > any package name, e.g. "."). It will list all JSR-223 scripting languages > on your system and give the help. E.g. currently on my Windows system: > > F:\work\svn\bsf4oorexx\trunk\samples\Java\javax.script>java RunScript > The following javax.script engines are currently available: > > ECMAScript > ooRexx > > usage: java RunScript [{-i | -t | -e enginename filename [args...] | > filename [args...]}] > > ... no arguments lists the available javax.script engines > -h ... 'help', gives this usage text > -i ... lists the available javax.script engines and informs about > their properties > -t ... lists the available javax.script engines and tests > evaluating their "getOutputStatement(String)" method > -e enginename filename [args...] ... uses "enginename" to evaluate > "filename" supplying the arguments "args..." > filename [args...] ... the "filename" extension determines the > script engine to evaluate it, supplying the arguments "args..." > > Running with the "-t" switch tests the code generated by the script > engine's factories by letting it eval()'ed. > > ---rony > > > > > > On Fri, Jan 6, 2017 at 9:07 AM, Rony G. Flatscher > wrote: > >> Besides Java 1.8.0_111 the problem exists in 9ea-+134 (engine version: >> "9ea", language version: >> "ECMA 262 - Edition 5.1" ) as well: Nashorn's javax.script factory is >> used to get an output >> statement and then it is used to execute it: >> >> ---> language [ECMAScript]: ----------------------------------------> >> >> 1) output statement to process: hello world, this is >> "ECMAScript" speaking! >> >> --> testing getOutputStatement(String), produced the >> following [ECMAScript] output statement >> >> print(hello world, this is "ECMAScript" speaking! ) >> >> ... now running "eval(code)" using the scripting engine >> [ECMAScript]: >> >> >> javax.script.ScriptException: :1:12 Expected , but found world >> print(hello world, this is "ECMAScript" speaking! ) >> ^ in at line number 1 at column number 12 while >> eval() the code: print(hello >> world, this is "ECMAScript" speaking! ) >> >> This time trying to not format the Java code, so hopefully the mailer >> will not render it illegible: >> >> ... cut ... >> >> // create an output statement and execute output statement with the >> script engine >> static void testEngine(String name, ScriptEngineFactory sef, >> ScriptEngine se) >> { >> System.out.println("---> language ["+name+"]: >> ---------------------------------------->\n"); >> String text="hello world, this is \""+name+"\" speaking! "; >> String code=sef.getOutputStatement(text); >> System.out.println("\t1) output statement to process: >> "+text+"\n"); >> >> System.out.print("\t--> testing getOutputStatement(String)"); >> System.out.println(", produced the following ["+name+"] >> output statement \n\n"+code+"\n"); >> System.out.println("\t... now running \"eval(code)\" using >> the scripting engine >> ["+name+"]: \n\n"); >> try >> { >> se.eval(code); >> System.out.println("\n"); >> } >> catch (ScriptException sexc) >> { >> System.err.println(sexc+" while eval() the code: >> "+code+"\n"); >> } >> >> System.out.print("\t2) testing getMethodCallSyntax(obj, meth, >> arg...)"); >> String methCode=sef.getMethodCallSyntax("object", "method", >> "arg1", "arg2"); >> System.out.println(", produced the following ["+name+"] >> method call statement: >> \n\n"+methCode+"\n"); >> >> System.out.print("\t3) testing getProgram(String...)"); >> String programCode=sef.getProgram(code, methCode); >> System.out.println(" produced the following ["+name+"] >> program: \n\n"+programCode+"\n"); >> >> System.out.println("<--- end of testing language ["+name+"]. >> <----------------------------------------\n"); >> } >> >> ... cut ... >> >> If I should file a bug then please advise where and how. >> >> ---rony >> >> >> On 08.12.2016 16:17, Rony G. Flatscher wrote: >> > Unfortunately, the mailing list seems to behave as if it was running in >> the 1970's such that the >> > formatted text (indented, partially colorized and formatted to >> preformat and Courier) has turned to >> > become illegible, unfortunately (using the Thunderbird e-Mail client)! >> > :( >> > >> > The meat is right in the first two paragraphs and the last paragraph >> before the signature. Should >> > anyone be interested in the Java-utility, please drop me a personal >> e-mail and I will send that Java >> > program as an attachment to you. >> > >> > ---rony >> > >> > >> > >> > On 08.12.2016 16:05, Rony G. Flatscher wrote: >> >> Hi there, was directed to this list to report an error with Nashorn's >> implementation of >> >> javax.script.ScriptEngineFactory.getOutputStatement(String toDisplay). >> >> >> >> The test is simple: one supplies a string, containing double quotes, >> and immediately use the Nashort >> >> script engine to carry out the output statement produced by its >> factory, yielding a runtime error. >> >> In order for you to reproduce, I list the Java utility (it lists all >> available javax.script engines >> >> and tests them with the -t switch and is a little example of how one >> can take advantage of >> >> javax.script very easily) after my signature below to study the code >> and run it to double-check: >> >> >> >> F:\work\svn\bsf4oorexx\trunk\samples\Java\jsr223>java RunScript >> -t ---> language [ECMAScript]: >> >> ----------------------------------------> 1) output statement to >> process: hello world, this is >> >> "ECMAScript" speaking! --> testing getOutputStatement(String), >> produced the following >> >> [ECMAScript] output statement *print(hello world, this is >> "ECMAScript" speaking! )* ... now >> >> running "eval(code)" using the scripting engine [ECMAScript]: >> *javax.script.ScriptException: >> >> :1:12 Expected , but found world print(hello world, this is >> "ECMAScript" speaking! ) ^ in >> >> at line number 1 at column number 12 while eval() the code: >> print(hello world, this is >> >> "ECMAScript" speaking! )* 2) testing getMethodCallSyntax(obj, >> meth, arg...), produced the >> >> following [ECMAScript] method call statement: >> object.method(arg1,arg2) 3) testing >> >> getProgram(String...) produced the following [ECMAScript] program: >> print(hello world, this is >> >> "ECMAScript" speaking! );object.method(arg1,arg2); <--- end of >> testing language [ECMAScript]. >> >> <---------------------------------------- ---> language [ooRexx]: >> >> ----------------------------------------> ... cut ... >> >> >> >> The specification for javax.script created by the Java specification >> request group 223 (a.k.a. >> >> JSR-223) can be consulted. BTW, "jrunscript[.exe]" (from the JDK) >> seems to be broken, it only is be >> >> able to execute the Nashorn script engine, despite switches that allow >> other script engines to be >> >> employed. >> >> >> >> ---rony >> >> >> >> Code of "RunScript.java" (little utility to list the currently >> available javax.script languages, run >> >> any javax.script program, give helpful information about each >> javax.script engine and test each one >> >> using its own factory means): just compile it and run it with "java >> RunScript -t": >> >> >> >> ------------------ cut here ------------------ >> >> import java.io.File; import java.io.FileReader; import >> java.util.ArrayList; import java.util.Arrays; >> >> import java.util.List; import java.util.HashMap; import >> java.util.SortedSet; import >> >> java.util.TreeSet; import javax.script.Bindings; import >> javax.script.ScriptContext; import >> >> javax.script.ScriptEngine; import javax.script.ScriptEngineFactory; >> import >> >> javax.script.ScriptEngineManager; import >> javax.script.ScriptException; import >> >> javax.script.SimpleScriptContext; /* ------------------------ Apache >> Version 2.0 license >> >> ------------------------- Copyright 2015-2016 Rony G. Flatscher >> Licensed under the Apache License, >> >> Version 2.0 (the "License"); you may not use this file except in >> compliance with the License. You >> >> may obtain a copy of the License at http://www.apache.org/licenses >> /LICENSE-2.0 Unless required by >> >> applicable law or agreed to in writing, software distributed under the >> License is distributed on an >> >> "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either >> express or implied. See the >> >> License for the specific language governing permissions and >> limitations under the License. >> >> ----------------------------------------------------------------------------- >> changed: 2016-12-06, >> >> rgf: if no argument is given, show the help after the list of >> currently available javax.script >> >> engines */ /** A command line Java utility to query, test and evaluate >> {@link javax.script} >> >> scripting engines that * gets distributed via the beta BSF4ooRexx >> package from Sourceforge. * * >> >>

Usage: java RunScript [{-i | -t | -e enginename filename >> [args...] | filename >> >> [args...]}] *
*

    *
  • ... no arguments: lists the >> currently available >> >> javax.script engines * *
  • -h ... 'help', >> lists and briefly explains >> >> the command line options * *
  • -i ... lists the >> available javax.script >> >> engines and informs about their properties * *
  • -t >> ... lists the available >> >> javax.script engines and tests evaluating their factory's >> >> "getOutputStatement(String)" method * *
  • >> -e enginename filename >> >> [args...] ... uses "enginename" to >> evaluate >> >> "filename" supplying the arguments >> "args..." * *
  • >> >> filename [args...] ... the "filename" >> extension determines the >> >> script engine to evaluate it, supplying the arguments >> "args..." *
* * * >> >> @author Rony G. Flatscher * @since 2015-05-20 */ public class >> RunScript { public static void >> >> main(String args[]) { ScriptEngineManager manager = new >> ScriptEngineManager(); >> >> List factories = manager.getEngineFactories(); >> >> HashMap n2sef=new >> HashMap (); >> >> HashMap n2se =new HashMap >> (); // create the Maps for >> >> (ScriptEngineFactory factory : factories) { String >> name=factory.getLanguageName(); // String >> >> name=factory.getEngineName(); n2sef.put(name, factory); n2se >> .put(name, factory.getScriptEngine()); >> >> } // create a sorted set of key names SortedSet keys = new >> TreeSet(n2sef.keySet()); >> >> int argsStartAt=-1; // arguments - if any - for filenmae to execute >> start at this position >> >> ScriptEngine scriptEngineToUse=null; String filename=null; if >> (args.length==0) // list all available >> >> javax.script engines { System.out.println("The following javax.script >> engines are currently >> >> available:\n"); for (String key : keys) { >> System.out.println('\t'+key); } System.out.println(); >> >> showHelp(); return; } else // process the first argument to decide >> what we need to do { String >> >> firstWord=args[0]; // get first value if (firstWord.startsWith("-")==true) >> // a switch at hand! { if >> >> (firstWord.length()!=2) // oops an error, we need excactly two chars >> (-i, -t, -e) { throw new >> >> IllegalArgumentException("switch '-' must be followed by one of the >> letters 'i', 't', or 'e'"); } >> >> String uSwitch=firstWord.substring(1).toUpperCase(); // get switch in >> uppercase if >> >> (uSwitch.equals("I")) // list all engines, list all their standard >> properties { for (String key : >> >> keys) // list all engines in order{ { showEngineProperties(key, >> n2sef.get(key)); } return; } else if >> >> (uSwitch.equals("T")) // list all engines, test them { for (String key >> : keys) // list all engines >> >> in order{ { testEngine(key, n2sef.get(key), n2se.get(key)); } return; >> } else if >> >> (uSwitch.equals("H")) // -h ... help text { showHelp(); return; } else >> if (uSwitch.equals("E")) // >> >> -e engineName fileName [arg... ] { if (args.length<3) { throw new >> IllegalArgumentException("too few >> >> command line arguments ("+args.length+"), minimum needed is 3: \"-e >> enginename filename\""); } // >> >> check whether engine is available, if so, then load it >> filename=args[2]; // assign filename String >> >> errMsg="no \""+args[1]+"\" javax.script engine available"; try { >> >> scriptEngineToUse=manager.getEngineByName(args[1]); // fetch script >> engine } catch (Exception exc) { >> >> throw new IllegalArgumentException(errMsg); } if >> (scriptEngineToUse==null) { throw new >> >> IllegalArgumentException(errMsg); } argsStartAt=3; // fourth >> argument! } else // unknown switch { >> >> throw new IllegalArgumentException("unknown switch '"+firstWord+"', >> must be followed by one of '-h', >> >> '-i', '-t', or '-e'"); } } else // a filename in hand, check whether >> we have a suitable engine >> >> available { // - check whether suitable engine is available, if not >> raise an exception >> >> filename=args[0]; // assign filename int lastIdx=filename.lastIndexOf('.'); >> if (lastIdx==0) { throw >> >> new IllegalArgumentException("filename \"filename\" does not have an >> extension, cannot determine >> >> scripting engine"); } String errMsg="cannot determine scripting engine >> from the filename extension >> >> in \""+filename+"\""; try { String extension=filename.substring(lastIdx+1); >> // get extension >> >> scriptEngineToUse=manager.getEngineByExtension(extension); // fetch >> script engine } catch (Exception >> >> exc) // if substring() causes an exception { throw new >> IllegalArgumentException(errMsg); } if >> >> (scriptEngineToUse==null) // no scripting engine found { throw new >> IllegalArgumentException(errMsg); >> >> } argsStartAt=1; // second argument! } } // now setup the remainder >> and eval() the "filename" with >> >> the script engine // - check whether file exists, if not raise an >> exception File f=null; try { f=new >> >> File (filename); } catch (Exception exc) { throw new >> IllegalArgumentException(exc); } if >> >> (f.exists()==false) { throw new IllegalArgumentException("filename >> \""+filename+"\" does not >> >> exist"); } // - supply filename ScriptContext >> sc=scriptEngineToUse.getContext(); // get the default >> >> context sc.setAttribute(ScriptEngine.FILENAME, filename, >> ScriptContext.ENGINE_SCOPE); // - if >> >> arguments, setup ARGV in ENGINE_SCOPE if (args.length>argsStartAt) // >> do we have command line >> >> arguments to supply? { String argArr []=new String >> [args.length-argsStartAt]; // determine array >> >> size int k=0; for (int i=argsStartAt; i> argArr[k]=args[i]; } >> >> sc.setAttribute(ScriptEngine.ARGV, argArr, >> ScriptContext.ENGINE_SCOPE); } // - eval the script try { >> >> scriptEngineToUse.eval(new FileReader(f)); } catch (Exception exc) { >> throw new >> >> IllegalArgumentException(exc); } } // show information about the >> script engine static void >> >> showEngineProperties(String name, ScriptEngineFactory sef) { >> System.out.println(name); >> >> System.out.print ("\tgetEngineName() : "); try { >> System.out.println(sef.getEngineName() ); } catch >> >> (Exception e) { System.out.println("--> FAILED!"); } System.out.print >> ("\tgetEngineVersion() : "); >> >> try { System.out.println(sef.getEngineVersion() ); } catch (Exception >> e) { System.out.println("--> >> >> FAILED!"); } System.out.print ("\tgetExtensions() : "); try { >> System.out.println(sef.getExtensions >> >> ()); } catch (Exception e) { System.out.println("--> FAILED!"); } >> System.out.print >> >> ("\tgetLanguageName() : "); try { System.out.println(sef.getLanguageName >> () ); } catch (Exception e) >> >> { System.out.println("--> FAILED!"); } System.out.print >> ("\tgetLanguageVersion() : "); try { >> >> System.out.println(sef.getLanguageVersion()); } catch (Exception e) { >> System.out.println("--> >> >> FAILED!"); } System.out.print ("\tgetMimeTypes() : "); try { >> System.out.println(sef.getMimeTypes >> >> ()); } catch (Exception e) { System.out.println("--> FAILED!"); } >> System.out.print ("\tgetNames() : >> >> "); try { System.out.println(sef.getNames() ); } catch (Exception e) >> { System.out.println("--> >> >> FAILED!"); } System.out.print ("\tgetParameter(\"THREADING\"): "); >> try { >> >> System.out.println(sef.getParameter("THREADING")); } catch (Exception >> e) { System.out.println("--> >> >> FAILED!"); } } // create an output statement and execute output >> statement for each available script >> >> engine static void testEngine(String name, ScriptEngineFactory sef, >> ScriptEngine se) { >> >> System.out.println("---> language ["+name+"]: >> ---------------------------------------->\n"); String >> >> text="hello world, this is \""+name+"\" speaking! "; String >> code=sef.getOutputStatement(text); >> >> System.out.println("\t1) output statement to process: "+text+"\n"); >> System.out.print("\t--> testing >> >> getOutputStatement(String)"); System.out.println(", produced the >> following ["+name+"] output >> >> statement \n\n"+code+"\n"); System.out.println("\t... now running >> \"eval(code)\" using the scripting >> >> engine ["+name+"]: \n\n"); try { se.eval(code); >> System.out.println("\n"); } catch (ScriptException >> >> sexc) { System.err.println(sexc+" while eval() the code: "+code+"\n"); >> } System.out.print("\t2) >> >> testing getMethodCallSyntax(obj, meth, arg...)"); String >> methCode=sef.getMethodCallSyntax("object", >> >> "method", "arg1", "arg2"); System.out.println(", produced the >> following ["+name+"] method call >> >> statement: \n\n"+methCode+"\n"); System.out.print("\t3) testing >> getProgram(String...)"); String >> >> programCode=sef.getProgram(code, methCode); System.out.println(" >> produced the following ["+name+"] >> >> program: \n\n"+programCode+"\n"); System.out.println("<--- end of >> testing language ["+name+"]. >> >> <----------------------------------------\n"); } // allow us to call >> this from different parts >> >> static void showHelp() { System.out.println("usage: java RunScript >> [{-i | -t | -e enginename >> >> filename [args...] | filename [args...]}]\n"); System.out.println(" >> ... no arguments lists the >> >> available javax.script engines"); System.out.println(" -h ... 'help', >> gives this usage text"); >> >> System.out.println(" -i ... lists the available javax.script engines >> and informs about their >> >> properties"); System.out.println(" -t ... lists the available >> javax.script engines and tests >> >> evaluating their \"getOutputStatement(String)\" method"); >> System.out.println(" -e enginename >> >> filename [args...] ... uses \"enginename\" to evaluate \"filename\" >> supplying the arguments >> >> \"args...\""); System.out.println(" filename [args...] ... the >> \"filename\" extension determines the >> >> script engine to evaluate it, supplying the arguments \"args...\""); >> return; } } ------------------ >> >> cut here ------------------ >> >> >> >> >> >> > From asashour at yahoo.com Sat Jan 7 01:39:59 2017 From: asashour at yahoo.com (Ahmed Ashour) Date: Sat, 7 Jan 2017 02:39:59 +0100 Subject: [PATCH] typos Message-ID: <17d83339-58cb-2279-fb9d-fbdd16177e0c@yahoo.com> Hi all, Please find below a proposed patch, for some typos. Thanks, Ahmed Ashour diff --git a/README b/README --- a/README +++ b/README @@ -18,7 +18,7 @@ http://mercurial.selenic.com/wiki/ForestExtension -and downlaoded using +and downloaded using hg clone https://bitbucket.org/gxti/hgforest @@ -39,7 +39,7 @@ - How to build? To build Nashorn, you need to install JDK 9. You may use the Nashorn -forest build (recommended) or down load from java.net. You will need to +forest build (recommended) or download from java.net. You will need to set JAVA_HOME environmental variable to point to your JDK installation directory. diff --git a/src/jdk.scripting.nashorn/share/classes/jdk/nashorn/api/linker/NashornLinkerExporter.java b/src/jdk.scripting.nashorn/share/classes/jdk/nashorn/api/linker/NashornLinkerExporter.java --- a/src/jdk.scripting.nashorn/share/classes/jdk/nashorn/api/linker/NashornLinkerExporter.java +++ b/src/jdk.scripting.nashorn/share/classes/jdk/nashorn/api/linker/NashornLinkerExporter.java @@ -38,7 +38,7 @@ /** * This linker exporter is a service provider that exports Nashorn Dynalink - * linkers to external users. Other languague runtimes that use Dynalink + * linkers to external users. Other language runtimes that use Dynalink * can use the linkers exported by this provider to support tight integration * of Nashorn objects. */ diff --git a/src/jdk.scripting.nashorn/share/classes/jdk/nashorn/internal/runtime/ScriptFunction.java b/src/jdk.scripting.nashorn/share/classes/jdk/nashorn/internal/runtime/ScriptFunction.java --- a/src/jdk.scripting.nashorn/share/classes/jdk/nashorn/internal/runtime/ScriptFunction.java +++ b/src/jdk.scripting.nashorn/share/classes/jdk/nashorn/internal/runtime/ScriptFunction.java @@ -735,7 +735,7 @@ /** * Name getter - ECMA Function.name * - * @param self self refence + * @param self self reference * @return the name, or undefined if none */ public static Object G$name(final Object self) { From asashour at yahoo.com Sat Jan 7 10:08:01 2017 From: asashour at yahoo.com (Ahmed Ashour) Date: Sat, 7 Jan 2017 11:08:01 +0100 Subject: Build fails in Windows Message-ID: <54ad7374-e76a-ca2f-b911-e7a7e6771188@yahoo.com> Hi all, Nashorn build tests in Windows fails, two issues are identified: 1- Executing JDK-8130127.js hangs the process, simply it waits forever at: [testng] Test(compile, run): test\script\nosecurity\JDK-8130127.js 2- Handling double quotes and spaces in JAVA_HOME is not handled Versions used: - Windows 7 - Java 9 build 151 (64-bit) - Ant 1.10.0 I couldn't get around issue #1, so I ended up commenting the last call of JDK-8130127.js. Far below are the two scenarios of JAVA_HOME setting. Hope you find this useful. Thanks, Ahmed scenario #1: double quotes with spaces C:\nashorn\make>SET JAVA_HOME="c:\Program Files\Java\jdk-9" C:\nashorn\make>ant test Files\Java\jdk-9"" was unexpected at this time. scenario #2: double quotes without spaces, and commenting the last call of JDK-8130127.js C:\nashorn\make>SET JAVA_HOME="c:\Progra~1\Java\jdk-9" there is an error int report document: runTest "java.nio.file.InvalidPathException: Illegal char <"> at index 0: "c:\Progra~1\Java\jdk-9"\bin\jjs.exe at java.base/sun.nio.fs.WindowsPathParser.normalize(WindowsPathParser.java:182) at java.base/sun.nio.fs.WindowsPathParser.parse(WindowsPathParser.java:153) at java.base/sun.nio.fs.WindowsPathParser.parse(WindowsPathParser.java:77) which is different if no double quotes is used: C:\nashorn\make>SET JAVA_HOME=c:\Progra~1\Java\jdk-9 which gives the expected error: Caused by: java.lang.AssertionError: Program output for test\script\nosecurity\JDK-8130127.js ends prematurely at line 5 From asashour at yahoo.com Sat Jan 7 11:09:55 2017 From: asashour at yahoo.com (Ahmed Ashour) Date: Sat, 7 Jan 2017 12:09:55 +0100 Subject: [PATCH] check-java-version for Java9 Message-ID: Hi all, The current build checks for Java 8 in check-java-version target, however this should be for Java 9. So the user gets the message: check-java-version: BUILD FAILED C:\nashorn\make\build.xml:137: Unsupported Java version: 1.8. Please use Java version 1.9 or greater. Instead of: compile: [javac] Compiling 1 source file to C:\nashorn\build\classes\jdk.dynalink [javac] javac: invalid target release: 1.9 [javac] Usage: javac [javac] use -help for a list of possible options BUILD FAILED C:\nashorn\make\build.xml:179: Compile failed; see the compiler error output for details. Thanks a lot, Ahmed diff --git a/make/build.xml b/make/build.xml --- a/make/build.xml +++ b/make/build.xml @@ -129,12 +129,12 @@ - + - + - - + + From Rony.Flatscher at wu.ac.at Sat Jan 7 13:52:33 2017 From: Rony.Flatscher at wu.ac.at (Rony G. Flatscher) Date: Sat, 7 Jan 2017 14:52:33 +0100 Subject: Nashorn's javax.script.ScriptEngineFactory produces wrong code In-Reply-To: References: <9bc6202f-7a5c-e9f2-7e41-da8e90bfccec@wu.ac.at> <5471cfe8-5956-a749-1ba8-842e4fa7d066@wu.ac.at> <1d616490-9317-57d2-348e-708ee82abc5e@wu.ac.at> Message-ID: <9288cf99-a185-e205-883f-d54c6be41ae9@wu.ac.at> Hi Ed, On 06.01.2017 17:49, Edmond Kemokai wrote: > The issue seems to go away after I quote the string. If you supplied a Javascript encoded string to the Nashorn ScriptEngineFactory.getOutputStatement() you removed the cause of demonstrating that Nashorn ScriptEngineFactory creates wrong output statements! The problem is that Nashorn's ScriptEngineFactory.getOutputStatement() does not analyze the received string (which may be any sequence of characters) to see whether escaping needs to take place (e.g. containing quotes or backslashes) and finally enquoting the received (maybe escape processed) string to make it acceptable as an argument to its print() function! The task at hand is to create an output statement that will be able to output the received string as is (no matter what the string contains), character by character! --- Background: the JSR-223/javax.script package was *not* created with a specific scripting language in mind. A scripting factory cannot assume that a supplied string adheres to the specific rules of that particular scripting language. The getOutputStatement() method is there to get an output statement adhering to the syntax rules of the script language that outputs (shows) the string exactly as received, character by character! Each script language may have different syntax, escaping rules etc., therefore the ScriptEngineFactory knowing its ScriptEngines syntax and rules is asked to create a proper output statement. It is the script factory's responsibility to analyze the received string and to escape characters in order to have the script engine output the string exactly as received, character by character. To test this, my test program feeds any available javax.script language with a string containing quotes around the script engine name (to test quote escaping) and has the script engine take its own medicine by executing the returned output statement. In the case of Nashorn the script engine is not able to reliably run the output statement generated by its own ScriptEngineFactory! So, if getOutputStatement() receives the following string value to output: abc "def" ghi it needs to analyze and in this case escape the string first to match the rules of JavaScript: abc \"def\" ghi and then produce the output statement by enquoting the escaped string: print("abc \"def\" ghi") This way, this statement can be run correctly by Nashorn and it gives exactly the received string as output: abc "def" ghi Also in the case of Nashorn/Javascript I would add a trailing '\n' character as usually script engine's output statements supply a trailing new line character. However, this is not defined/mandated and left to the implementation. ---rony P.S.: The Rexx/ooRexx ScriptEngineFactory would create the following output statement and be able to successfully run it, yielding exactly the string that was supplied to getOutputStatement(): say "abc ""def"" ghi" running that statement yields the output: abc "def" ghi (The Rexx/ooRexx language escapes quotes in strings by doubling them.) > You can run the code in the browser by right clicking and choosing "Test" then click "Run". On the > top right, click the dropdown button and choose "Log Viewer" to see the output. > > > > Ouput: > > INFO Invocation - ---> language [ECMAScript]: > ----------------------------------------> > > INFO Invocation - 1) output statement to process: "hello world, this is > ECMAScript speaking! " > > INFO Invocation - --> testing getOutputStatement(String) > INFO Invocation - , produced the following [ECMAScript] output statement > > print("hello world, this is ECMAScript speaking! ") > > INFO Invocation - ... now running "eval(code)" using the scripting engine > [ECMAScript]: > > > INFO Invocation - > > INFO Invocation - 2) testing getMethodCallSyntax(obj, meth, arg...) > INFO Invocation - , produced the following [ECMAScript] method call statement: > > object.method(arg1,arg2) > > INFO Invocation - 3) testing getProgram(String...) > INFO Invocation - produced the following [ECMAScript] program: > > print("hello world, this is ECMAScript speaking! ");object.method(arg1,arg2); > > INFO Invocation - <--- end of testing language [ECMAScript]. > <---------------------------------------- > > > > > On Fri, Jan 6, 2017 at 10:21 AM, Rony G. Flatscher > wrote: > > Hi Ed, > > On 06.01.2017 16:07, Edmond Kemokai wrote: >> >> I am the developer of HiveMind, it is a web app platform that relies entirely on scripting >> engines via JSR-223. >> >> You can access a demo instance: http://demo.crudzilla.com:7000/ >> Login with: developer/developer >> >> I have created a test file in: /com/crudzilla/cloudTest/web/rony-groovy.ste >> >> Put your code (the original one you pasted) in there and save, I'll take a look to see what >> might be missing. > Done. > > After compiling just run it as "java RunScript" (make sure your CLASSPATH picks up the > directory that contains RunScript.class, which does not define any package name, e.g. "."). It > will list all JSR-223 scripting languages on your system and give the help. E.g. currently on > my Windows system: > > F:\work\svn\bsf4oorexx\trunk\samples\Java\javax.script>java RunScript > The following javax.script engines are currently available: > > ECMAScript > ooRexx > > usage: java RunScript [{-i | -t | -e enginename filename [args...] | filename [args...]}] > > ... no arguments lists the available javax.script engines > -h ... 'help', gives this usage text > -i ... lists the available javax.script engines and informs about their properties > -t ... lists the available javax.script engines and tests evaluating their > "getOutputStatement(String)" method > -e enginename filename [args...] ... uses "enginename" to evaluate "filename" > supplying the arguments "args..." > filename [args...] ... the "filename" extension determines the script engine to > evaluate it, supplying the arguments "args..." > > Running with the "-t" switch tests the code generated by the script engine's factories by > letting it eval()'ed. > > ---rony > > > >> >> >> On Fri, Jan 6, 2017 at 9:07 AM, Rony G. Flatscher > > wrote: >> >> Besides Java 1.8.0_111 the problem exists in 9ea-+134 (engine version: "9ea", language >> version: >> "ECMA 262 - Edition 5.1" ) as well: Nashorn's javax.script factory is used to get an output >> statement and then it is used to execute it: >> >> ---> language [ECMAScript]: ----------------------------------------> >> >> 1) output statement to process: hello world, this is "ECMAScript" speaking! >> >> --> testing getOutputStatement(String), produced the following [ECMAScript] >> output statement >> >> print(hello world, this is "ECMAScript" speaking! ) >> >> ... now running "eval(code)" using the scripting engine [ECMAScript]: >> >> >> javax.script.ScriptException: :1:12 Expected , but found world >> print(hello world, this is "ECMAScript" speaking! ) >> ^ in at line number 1 at column number 12 while eval() the code: >> print(hello >> world, this is "ECMAScript" speaking! ) >> >> This time trying to not format the Java code, so hopefully the mailer will not render it >> illegible: >> >> ... cut ... >> >> // create an output statement and execute output statement with the script engine >> static void testEngine(String name, ScriptEngineFactory sef, ScriptEngine se) >> { >> System.out.println("---> language ["+name+"]: >> ---------------------------------------->\n"); >> String text="hello world, this is \""+name+"\" speaking! "; >> String code=sef.getOutputStatement(text); >> System.out.println("\t1) output statement to process: "+text+"\n"); >> >> System.out.print("\t--> testing getOutputStatement(String)"); >> System.out.println(", produced the following ["+name+"] output statement >> \n\n"+code+"\n"); >> System.out.println("\t... now running \"eval(code)\" using the scripting engine >> ["+name+"]: \n\n"); >> try >> { >> se.eval(code); >> System.out.println("\n"); >> } >> catch (ScriptException sexc) >> { >> System.err.println(sexc+" while eval() the code: "+code+"\n"); >> } >> >> System.out.print("\t2) testing getMethodCallSyntax(obj, meth, arg...)"); >> String methCode=sef.getMethodCallSyntax("object", "method", "arg1", "arg2"); >> System.out.println(", produced the following ["+name+"] method call statement: >> \n\n"+methCode+"\n"); >> >> System.out.print("\t3) testing getProgram(String...)"); >> String programCode=sef.getProgram(code, methCode); >> System.out.println(" produced the following ["+name+"] program: >> \n\n"+programCode+"\n"); >> >> System.out.println("<--- end of testing language ["+name+"]. >> <----------------------------------------\n"); >> } >> >> ... cut ... >> >> If I should file a bug then please advise where and how. >> >> ---rony >> >> >> On 08.12.2016 16:17, Rony G. Flatscher wrote: >> > Unfortunately, the mailing list seems to behave as if it was running in the 1970's such >> that the >> > formatted text (indented, partially colorized and formatted to preformat and Courier) >> has turned to >> > become illegible, unfortunately (using the Thunderbird e-Mail client)! >> > :( >> > >> > The meat is right in the first two paragraphs and the last paragraph before the >> signature. Should >> > anyone be interested in the Java-utility, please drop me a personal e-mail and I will >> send that Java >> > program as an attachment to you. >> > >> > ---rony >> > >> > >> From ekemokai at gmail.com Sat Jan 7 14:02:32 2017 From: ekemokai at gmail.com (Edmond Kemokai) Date: Sat, 7 Jan 2017 09:02:32 -0500 Subject: Nashorn's javax.script.ScriptEngineFactory produces wrong code In-Reply-To: <9288cf99-a185-e205-883f-d54c6be41ae9@wu.ac.at> References: <9bc6202f-7a5c-e9f2-7e41-da8e90bfccec@wu.ac.at> <5471cfe8-5956-a749-1ba8-842e4fa7d066@wu.ac.at> <1d616490-9317-57d2-348e-708ee82abc5e@wu.ac.at> <9288cf99-a185-e205-883f-d54c6be41ae9@wu.ac.at> Message-ID: Ah, I see your point. I'll say file a bug. If you look at the NashornScriptEngineFactory.java, you'll see that it simply concatenates the supplied string between a print statement, the current implementation requires proper escaping of input. On Jan 7, 2017 8:52 AM, "Rony G. Flatscher" wrote: Hi Ed, On 06.01.2017 17:49, Edmond Kemokai wrote: The issue seems to go away after I quote the string. If you supplied a Javascript encoded string to the Nashorn ScriptEngineFactory.getOutputStatement() you removed the cause of demonstrating that Nashorn ScriptEngineFactory creates wrong output statements! The problem is that Nashorn's ScriptEngineFactory.getOutputStatement() does not analyze the received string (which may be any sequence of characters) to see whether escaping needs to take place (e.g. containing quotes or backslashes) and finally enquoting the received (maybe escape processed) string to make it acceptable as an argument to its print() function! The task at hand is to create an output statement that will be able to output the received string as is (no matter what the string contains), character by character! --- Background: the JSR-223/javax.script package was *not* created with a specific scripting language in mind. A scripting factory cannot assume that a supplied string adheres to the specific rules of that particular scripting language. The getOutputStatement() method is there to get an output statement adhering to the syntax rules of the script language that outputs (shows) the string exactly as received, character by character! Each script language may have different syntax, escaping rules etc., therefore the ScriptEngineFactory knowing its ScriptEngines syntax and rules is asked to create a proper output statement. It is the script factory's responsibility to analyze the received string and to escape characters in order to have the script engine output the string exactly as received, character by character. To test this, my test program feeds any available javax.script language with a string containing quotes around the script engine name (to test quote escaping) and has the script engine take its own medicine by executing the returned output statement. In the case of Nashorn the script engine is not able to reliably run the output statement generated by its own ScriptEngineFactory! So, if getOutputStatement() receives the following string value to output: abc "def" ghi it needs to analyze and in this case escape the string first to match the rules of JavaScript: abc \"def\" ghi and then produce the output statement by enquoting the escaped string: print("abc \"def\" ghi") This way, this statement can be run correctly by Nashorn and it gives exactly the received string as output: abc "def" ghi Also in the case of Nashorn/Javascript I would add a trailing '\n' character as usually script engine's output statements supply a trailing new line character. However, this is not defined/mandated and left to the implementation. ---rony P.S.: The Rexx/ooRexx ScriptEngineFactory would create the following output statement and be able to successfully run it, yielding exactly the string that was supplied to getOutputStatement(): say "abc ""def"" ghi" running that statement yields the output: abc "def" ghi (The Rexx/ooRexx language escapes quotes in strings by doubling them.) You can run the code in the browser by right clicking and choosing "Test" then click "Run". On the top right, click the dropdown button and choose "Log Viewer" to see the output. Ouput: INFO Invocation - ---> language [ECMAScript]: ----------------------------------------> INFO Invocation - 1) output statement to process: "hello world, this is ECMAScript speaking! " INFO Invocation - --> testing getOutputStatement(String) INFO Invocation - , produced the following [ECMAScript] output statement print("hello world, this is ECMAScript speaking! ") INFO Invocation - ... now running "eval(code)" using the scripting engine [ECMAScript]: INFO Invocation - INFO Invocation - 2) testing getMethodCallSyntax(obj, meth, arg...) INFO Invocation - , produced the following [ECMAScript] method call statement: object.method(arg1,arg2) INFO Invocation - 3) testing getProgram(String...) INFO Invocation - produced the following [ECMAScript] program: print("hello world, this is ECMAScript speaking! ");object.method(arg1,arg2); INFO Invocation - <--- end of testing language [ECMAScript]. <---------------------------------------- On Fri, Jan 6, 2017 at 10:21 AM, Rony G. Flatscher wrote: > Hi Ed, > On 06.01.2017 16:07, Edmond Kemokai wrote: > > > I am the developer of HiveMind, it is a web app platform that relies > entirely on scripting engines via JSR-223. > > You can access a demo instance: http://demo.crudzilla.com:7000/ > Login with: developer/developer > > I have created a test file in: /com/crudzilla/cloudTest/web/r > ony-groovy.ste > > Put your code (the original one you pasted) in there and save, I'll take a > look to see what might be missing. > > Done. > > After compiling just run it as "java RunScript" (make sure your CLASSPATH > picks up the directory that contains RunScript.class, which does not define > any package name, e.g. "."). It will list all JSR-223 scripting languages > on your system and give the help. E.g. currently on my Windows system: > > F:\work\svn\bsf4oorexx\trunk\samples\Java\javax.script>java RunScript > The following javax.script engines are currently available: > > ECMAScript > ooRexx > > usage: java RunScript [{-i | -t | -e enginename filename [args...] | > filename [args...]}] > > ... no arguments lists the available javax.script engines > -h ... 'help', gives this usage text > -i ... lists the available javax.script engines and informs about > their properties > -t ... lists the available javax.script engines and tests > evaluating their "getOutputStatement(String)" method > -e enginename filename [args...] ... uses "enginename" to evaluate > "filename" supplying the arguments "args..." > filename [args...] ... the "filename" extension determines the > script engine to evaluate it, supplying the arguments "args..." > > Running with the "-t" switch tests the code generated by the script > engine's factories by letting it eval()'ed. > > ---rony > > > > > > On Fri, Jan 6, 2017 at 9:07 AM, Rony G. Flatscher > wrote: > >> Besides Java 1.8.0_111 the problem exists in 9ea-+134 (engine version: >> "9ea", language version: >> "ECMA 262 - Edition 5.1" ) as well: Nashorn's javax.script factory is >> used to get an output >> statement and then it is used to execute it: >> >> ---> language [ECMAScript]: ----------------------------------------> >> >> 1) output statement to process: hello world, this is >> "ECMAScript" speaking! >> >> --> testing getOutputStatement(String), produced the >> following [ECMAScript] output statement >> >> print(hello world, this is "ECMAScript" speaking! ) >> >> ... now running "eval(code)" using the scripting engine >> [ECMAScript]: >> >> >> javax.script.ScriptException: :1:12 Expected , but found world >> print(hello world, this is "ECMAScript" speaking! ) >> ^ in at line number 1 at column number 12 while >> eval() the code: print(hello >> world, this is "ECMAScript" speaking! ) >> >> This time trying to not format the Java code, so hopefully the mailer >> will not render it illegible: >> >> ... cut ... >> >> // create an output statement and execute output statement with the >> script engine >> static void testEngine(String name, ScriptEngineFactory sef, >> ScriptEngine se) >> { >> System.out.println("---> language ["+name+"]: >> ---------------------------------------->\n"); >> String text="hello world, this is \""+name+"\" speaking! "; >> String code=sef.getOutputStatement(text); >> System.out.println("\t1) output statement to process: >> "+text+"\n"); >> >> System.out.print("\t--> testing getOutputStatement(String)"); >> System.out.println(", produced the following ["+name+"] >> output statement \n\n"+code+"\n"); >> System.out.println("\t... now running \"eval(code)\" using >> the scripting engine >> ["+name+"]: \n\n"); >> try >> { >> se.eval(code); >> System.out.println("\n"); >> } >> catch (ScriptException sexc) >> { >> System.err.println(sexc+" while eval() the code: >> "+code+"\n"); >> } >> >> System.out.print("\t2) testing getMethodCallSyntax(obj, meth, >> arg...)"); >> String methCode=sef.getMethodCallSyntax("object", "method", >> "arg1", "arg2"); >> System.out.println(", produced the following ["+name+"] >> method call statement: >> \n\n"+methCode+"\n"); >> >> System.out.print("\t3) testing getProgram(String...)"); >> String programCode=sef.getProgram(code, methCode); >> System.out.println(" produced the following ["+name+"] >> program: \n\n"+programCode+"\n"); >> >> System.out.println("<--- end of testing language ["+name+"]. >> <----------------------------------------\n"); >> } >> >> ... cut ... >> >> If I should file a bug then please advise where and how. >> >> ---rony >> >> >> On 08.12.2016 16:17, Rony G. Flatscher wrote: >> > Unfortunately, the mailing list seems to behave as if it was running in >> the 1970's such that the >> > formatted text (indented, partially colorized and formatted to >> preformat and Courier) has turned to >> > become illegible, unfortunately (using the Thunderbird e-Mail client)! >> > :( >> > >> > The meat is right in the first two paragraphs and the last paragraph >> before the signature. Should >> > anyone be interested in the Java-utility, please drop me a personal >> e-mail and I will send that Java >> > program as an attachment to you. >> > >> > ---rony >> > >> > >> > From Rony.Flatscher at wu.ac.at Sat Jan 7 14:54:55 2017 From: Rony.Flatscher at wu.ac.at (Rony G. Flatscher) Date: Sat, 7 Jan 2017 15:54:55 +0100 Subject: Nashorn's javax.script.ScriptEngineFactory produces wrong code In-Reply-To: References: <9bc6202f-7a5c-e9f2-7e41-da8e90bfccec@wu.ac.at> <5471cfe8-5956-a749-1ba8-842e4fa7d066@wu.ac.at> <1d616490-9317-57d2-348e-708ee82abc5e@wu.ac.at> <9288cf99-a185-e205-883f-d54c6be41ae9@wu.ac.at> Message-ID: <8d03bf80-79cb-2194-f43e-f916b39e7e78@wu.ac.at> On 07.01.2017 15:02, Edmond Kemokai wrote: > Ah, I see your point. > > I'll say file a bug. If you look at the NashornScriptEngineFactory.java, you'll see that it simply > concatenates the supplied string between a print statement, the current implementation requires > proper escaping of input. Where would be the appropriate place to file a bug for Nashorn? Would you have an URL by any chance? ---rony > > > On Jan 7, 2017 8:52 AM, "Rony G. Flatscher" > wrote: > > Hi Ed, > > > On 06.01.2017 17:49, Edmond Kemokai wrote: >> The issue seems to go away after I quote the string. > If you supplied a Javascript encoded string to the Nashorn > ScriptEngineFactory.getOutputStatement() you removed the cause of demonstrating that Nashorn > ScriptEngineFactory creates wrong output statements! > > The problem is that Nashorn's ScriptEngineFactory.getOutputStatement() does not analyze the > received string (which may be any sequence of characters) to see whether escaping needs to > take place (e.g. containing quotes or backslashes) and finally enquoting the received (maybe > escape processed) string to make it acceptable as an argument to its print() function! > > The task at hand is to create an output statement that will be able to output the received > string as is (no matter what the string contains), character by character! > > --- > > Background: the JSR-223/javax.script package was *not* created with a specific scripting > language in mind. A scripting factory cannot assume that a supplied string adheres to the > specific rules of that particular scripting language. The getOutputStatement() method is there > to get an output statement adhering to the syntax rules of the script language that outputs > (shows) the string exactly as received, character by character! Each script language may have > different syntax, escaping rules etc., therefore the ScriptEngineFactory knowing its > ScriptEngines syntax and rules is asked to create a proper output statement. > > It is the script factory's responsibility to analyze the received string and to escape > characters in order to have the script engine output the string exactly as received, character > by character. > > To test this, my test program feeds any available javax.script language with a string > containing quotes around the script engine name (to test quote escaping) and has the script > engine take its own medicine by executing the returned output statement. > > In the case of Nashorn the script engine is not able to reliably run the output statement > generated by its own ScriptEngineFactory! > > So, if getOutputStatement() receives the following string value to output: > > abc "def" ghi > > it needs to analyze and in this case escape the string first to match the rules of JavaScript: > > abc \"def\" ghi > > and then produce the output statement by enquoting the escaped string: > > print("abc \"def\" ghi") > > This way, this statement can be run correctly by Nashorn and it gives exactly the received > string as output: > > abc "def" ghi > > Also in the case of Nashorn/Javascript I would add a trailing '\n' character as usually script > engine's output statements supply a trailing new line character. However, this is not > defined/mandated and left to the implementation. > > ---rony > > P.S.: The Rexx/ooRexx ScriptEngineFactory would create the following output statement and be > able to successfully run it, yielding exactly the string that was supplied to > getOutputStatement(): > > say "abc ""def"" ghi" > > running that statement yields the output: > > abc "def" ghi > > (The Rexx/ooRexx language escapes quotes in strings by doubling them.) > > > > > >> You can run the code in the browser by right clicking and choosing "Test" then click "Run". >> On the top right, click the dropdown button and choose "Log Viewer" to see the output. >> >> >> >> Ouput: >> >> INFO Invocation - ---> language [ECMAScript]: >> ----------------------------------------> >> >> INFO Invocation - 1) output statement to process: "hello world, this >> is ECMAScript speaking! " >> >> INFO Invocation - --> testing getOutputStatement(String) >> INFO Invocation - , produced the following [ECMAScript] output statement >> >> print("hello world, this is ECMAScript speaking! ") >> >> INFO Invocation - ... now running "eval(code)" using the scripting >> engine [ECMAScript]: >> >> >> INFO Invocation - >> >> INFO Invocation - 2) testing getMethodCallSyntax(obj, meth, arg...) >> INFO Invocation - , produced the following [ECMAScript] method call >> statement: >> >> object.method(arg1,arg2) >> >> INFO Invocation - 3) testing getProgram(String...) >> INFO Invocation - produced the following [ECMAScript] program: >> >> print("hello world, this is ECMAScript speaking! ");object.method(arg1,arg2); >> >> INFO Invocation - <--- end of testing language [ECMAScript]. >> <---------------------------------------- >> >> >> >> >> On Fri, Jan 6, 2017 at 10:21 AM, Rony G. Flatscher > > wrote: >> >> Hi Ed, >> >> On 06.01.2017 16:07, Edmond Kemokai wrote: >>> >>> I am the developer of HiveMind, it is a web app platform that relies entirely on >>> scripting engines via JSR-223. >>> >>> You can access a demo instance: http://demo.crudzilla.com:7000/ >>> >>> Login with: developer/developer >>> >>> I have created a test file in: /com/crudzilla/cloudTest/web/rony-groovy.ste >>> >>> Put your code (the original one you pasted) in there and save, I'll take a look to see >>> what might be missing. >> Done. >> >> After compiling just run it as "java RunScript" (make sure your CLASSPATH picks up the >> directory that contains RunScript.class, which does not define any package name, e.g. >> "."). It will list all JSR-223 scripting languages on your system and give the help. E.g. >> currently on my Windows system: >> >> F:\work\svn\bsf4oorexx\trunk\samples\Java\javax.script>java RunScript >> The following javax.script engines are currently available: >> >> ECMAScript >> ooRexx >> >> usage: java RunScript [{-i | -t | -e enginename filename [args...] | filename [args...]}] >> >> ... no arguments lists the available javax.script engines >> -h ... 'help', gives this usage text >> -i ... lists the available javax.script engines and informs about their properties >> -t ... lists the available javax.script engines and tests evaluating their >> "getOutputStatement(String)" method >> -e enginename filename [args...] ... uses "enginename" to evaluate "filename" >> supplying the arguments "args..." >> filename [args...] ... the "filename" extension determines the script engine >> to evaluate it, supplying the arguments "args..." >> >> Running with the "-t" switch tests the code generated by the script engine's factories by >> letting it eval()'ed. >> >> ---rony >> >> >> >>> >>> >>> On Fri, Jan 6, 2017 at 9:07 AM, Rony G. Flatscher >> > wrote: >>> >>> Besides Java 1.8.0_111 the problem exists in 9ea-+134 (engine version: "9ea", >>> language version: >>> "ECMA 262 - Edition 5.1" ) as well: Nashorn's javax.script factory is used to get an >>> output >>> statement and then it is used to execute it: >>> >>> ---> language [ECMAScript]: ----------------------------------------> >>> >>> 1) output statement to process: hello world, this is "ECMAScript" speaking! >>> >>> --> testing getOutputStatement(String), produced the following >>> [ECMAScript] output statement >>> >>> print(hello world, this is "ECMAScript" speaking! ) >>> >>> ... now running "eval(code)" using the scripting engine [ECMAScript]: >>> >>> >>> javax.script.ScriptException: :1:12 Expected , but found world >>> print(hello world, this is "ECMAScript" speaking! ) >>> ^ in at line number 1 at column number 12 while eval() the >>> code: print(hello >>> world, this is "ECMAScript" speaking! ) >>> >>> This time trying to not format the Java code, so hopefully the mailer will not >>> render it illegible: >>> >>> ... cut ... >>> >>> // create an output statement and execute output statement with the script engine >>> static void testEngine(String name, ScriptEngineFactory sef, ScriptEngine se) >>> { >>> System.out.println("---> language ["+name+"]: >>> ---------------------------------------->\n"); >>> String text="hello world, this is \""+name+"\" speaking! "; >>> String code=sef.getOutputStatement(text); >>> System.out.println("\t1) output statement to process: "+text+"\n"); >>> >>> System.out.print("\t--> testing getOutputStatement(String)"); >>> System.out.println(", produced the following ["+name+"] output statement >>> \n\n"+code+"\n"); >>> System.out.println("\t... now running \"eval(code)\" using the scripting >>> engine >>> ["+name+"]: \n\n"); >>> try >>> { >>> se.eval(code); >>> System.out.println("\n"); >>> } >>> catch (ScriptException sexc) >>> { >>> System.err.println(sexc+" while eval() the code: "+code+"\n"); >>> } >>> >>> System.out.print("\t2) testing getMethodCallSyntax(obj, meth, arg...)"); >>> String methCode=sef.getMethodCallSyntax("object", "method", "arg1", "arg2"); >>> System.out.println(", produced the following ["+name+"] method call >>> statement: >>> \n\n"+methCode+"\n"); >>> >>> System.out.print("\t3) testing getProgram(String...)"); >>> String programCode=sef.getProgram(code, methCode); >>> System.out.println(" produced the following ["+name+"] program: >>> \n\n"+programCode+"\n"); >>> >>> System.out.println("<--- end of testing language ["+name+"]. >>> <----------------------------------------\n"); >>> } >>> >>> ... cut ... >>> >>> If I should file a bug then please advise where and how. >>> >>> ---rony >>> >>> >>> On 08.12.2016 16:17, Rony G. Flatscher wrote: >>> > Unfortunately, the mailing list seems to behave as if it was running in the 1970's >>> such that the >>> > formatted text (indented, partially colorized and formatted to preformat and >>> Courier) has turned to >>> > become illegible, unfortunately (using the Thunderbird e-Mail client)! >>> > :( >>> > >>> > The meat is right in the first two paragraphs and the last paragraph before the >>> signature. Should >>> > anyone be interested in the Java-utility, please drop me a personal e-mail and I >>> will send that Java >>> > program as an attachment to you. >>> > >>> > ---rony >>> > >>> > >>> > > From sundararajan.athijegannathan at oracle.com Mon Jan 9 13:25:54 2017 From: sundararajan.athijegannathan at oracle.com (Sundararajan Athijegannathan) Date: Mon, 09 Jan 2017 18:55:54 +0530 Subject: [PATCH] check-java-version for Java9 In-Reply-To: References: Message-ID: <58738F62.2010808@oracle.com> Team is back from vacation only today.. Please expect some delay in accepting patches.. -Sundar On 07/01/17, 4:39 PM, Ahmed Ashour wrote: > Hi all, > > > The current build checks for Java 8 in check-java-version target, > however this should be for Java 9. > > So the user gets the message: > > check-java-version: > > BUILD FAILED > C:\nashorn\make\build.xml:137: Unsupported Java version: 1.8. > Please use Java version 1.9 or greater. > > > Instead of: > > compile: > [javac] Compiling 1 source file to > C:\nashorn\build\classes\jdk.dynalink > [javac] javac: invalid target release: 1.9 > [javac] Usage: javac > [javac] use -help for a list of possible options > > BUILD FAILED > C:\nashorn\make\build.xml:179: Compile failed; see the compiler > error output for details. > > > Thanks a lot, > > Ahmed > > > diff --git a/make/build.xml b/make/build.xml > --- a/make/build.xml > +++ b/make/build.xml > @@ -129,12 +129,12 @@ > > > > - > + > > - > + > > - > - > + > + > > > > From jluzon at riotgames.com Mon Jan 9 22:44:01 2017 From: jluzon at riotgames.com (Jesus Luzon) Date: Mon, 9 Jan 2017 14:44:01 -0800 Subject: Can't get Multithreaded Nashorn uses to Scale In-Reply-To: References: <31833CD9-8263-478E-9400-87D5D561C29A@oracle.com> Message-ID: Hey folks, Looked at the ticket and noticed it has been marked as fixed. woot! Thank you so much! My team has been asking me if I can find out the date this fix will get released. I noticed the version on there (version 9) states it has no release date yet. Is there any tentative date you all have for the net release this would be included in? Even a ballpark figure would be awesome. Thanks. On Fri, Dec 9, 2016 at 2:49 AM, Jesus Luzon wrote: > Wow I totally missed the var. Thanks for that! I actually had changed our > code to use ThreadLocal ScriptObjectMirrors created from the CompiledScript > with the following code: > > ScriptObjectMirror mirror = mirrorThreadLocal.get(); >> >> if (mirror == null) { >> >> Bindings bindings = compiledScript.getEngine().createBindings(); >> >> compiledScript.eval(bindings); >> >> mirror = (ScriptObjectMirror) bindings.get("transform"); >> >> mirrorThreadLocal.set(mirror); >> >> } >> >> return (String) mirror.call(null, something); >> >> > Given that we will always run standalone functions to filter data, is > there one we should be using over the other? > > Lastly thanks for filing the bug. I'll keep track of it so I can make sure > to upgrade when a fix comes out. > > On Fri, Dec 9, 2016 at 2:37 AM, Hannes Walln?fer < > hannes.wallnoefer at oracle.com> wrote: > >> Jesus, >> >> I looked at this issue more in depth and there are two problems here, one >> on your side and one on ours: >> >> The problem with your code is that you left out the ?var? declaration of >> the ?response? variable in the third line of your function. This means that >> ?response? is allocated as a global variable outside the scope of the >> function. When you run this in parallel with multiple threads you actually >> access the same object from multiple threads, meaning your output will be >> corrupt. >> >> Because of things like this, it is actually a good idea to run JavaScript >> in strict mode (e.g. by using ?use strict? directive in your JavaScript >> code, or by creating the engine with -strict option). Another solution >> would be to use multiple engines or bindings, which should not have a big >> performance impact once the other problem is fixed. >> >> Which leads us to the problem on our side, which is performance of sparse >> arrays. As you have noticed, using something that is not a valid array >> index greatly improves performance, and that is because some array element >> assignment are implemented very inefficiently in Nashorn. I?ve filed a bug >> for this: >> >> https://bugs.openjdk.java.net/browse/JDK-8170977 >> >> Once this bug is fixed, using numeric keys should be roughly as fast as >> using non-numeric ones. >> >> Hannes >> >> >> > Am 09.12.2016 um 04:47 schrieb Jesus Luzon : >> > >> > I came up with a workaround which is getting us through this but it >> definitely seems like this is a bug. The gist is I append an arbitrary >> string (we made it complex on our end to make it unlikely something else >> has this string inside) to the key and then remove all instances of said >> string on the JSON String resulting from calling stringify. We are leaving >> this for overnight testing but it showed promising results immediately. >> > >> > String script = "function transform(input) {" + >> > "var result = JSON.parse(input);" + >> > "response = {};\n" + >> > "for (var i = 0; i < result.length; i++) {\n" + >> > " var summoner = {};\n" + >> > " summoner.id = result[i].id;\n" + >> > " summoner.name = result[i].name;\n" + >> > " summoner.profileIconId = >> result[i].profileIconId;\n" + >> > " summoner.revisionDate = result[i].revisionDate;\n" >> + >> > " summoner.summonerLevel = result[i].level;\n" + >> > " response[\"someArbitraryString\" + summoner.id] = >> summoner;\n" + >> > "}\n" + >> > "var stringy = JSON.stringify(response);" + >> > "result = stringy.replace(/someArbitraryString/g, >> \"\");" + >> > "return result;" + >> > "};"; >> > >> > On Thu, Dec 8, 2016 at 4:54 PM, Jesus Luzon >> wrote: >> > It doesn't seem like changing to a string fixed it. We dug deeper and >> found a very interesting issue though. After running the invocable a few >> thousand times, when we put a breakpoint in ArrayData.computerIteratorKeys() >> and we found that it would stop at an execution from SparseArrayData with >> an underlying array of size 923392, stored length of 461672 (this is one of >> our IDs, the largest 6 digit one). Because of this we tried a run changing >> all the IDs in the array we pass in to number from 1-38 and this thing went >> blazing fast. When putting a break point in the same place, this array in >> SpareArrayData was now of size 39. We then changed an id in the array we >> take in to be 1337 and the size of the array in the SparseArrayData was >> 1338. >> > >> > I don't understand why or how to prevent but it's using this ID as an >> index for SpareArrayData underlying array. If someone can help me find a >> workaround for this I would be extremely grateful. >> > >> > On Thu, Dec 8, 2016 at 3:52 AM, Hannes Walln?fer < >> hannes.wallnoefer at oracle.com> wrote: >> > Yes, this is very likely to be the cause of the problem. However, I do >> think we should be able to handle sparse array data better, so it?s quite >> possible that you exposed some weak spot in our implementation. I?ll have a >> look into what?s going on. >> > >> > Hannes >> > >> > >> > > Am 08.12.2016 um 00:40 schrieb Jesus Luzon : >> > > >> > > Looks like the memory leak is due to the way we wrote our code and >> how javascript works. I was expecting the line response[summoner.id] = >> summoner; to build a map but it turns out that if you use a number as the >> "key", javscript automatically fills the indexes in the middle with null >> (Undefined type?). When these IDs are very large, it is creating huge >> arrays that take longer to garbage collect than the code executing. I am >> about to start testing this on our end to make sure we see the improvements >> we expect. >> > > >> > > Does this idea seem like it is reasonably possible? >> > > >> > > On Wed, Dec 7, 2016 at 11:23 AM, Jesus Luzon >> wrote: >> > > Yes, it's an array of objects which I'll paste. And yes, I'm just >> calling invokeFunction from many many different threads. I'm also going to >> go back and take a look at all the heap dumps we have to re-confirm what I >> mentioned. >> > > >> > > "[\n" + >> > > " {\n" + >> > > " \"id\": 6011511,\n" + >> > > " \"accountId\": 203192481,\n" + >> > > " \"name\": \"Adam Pro Qarda?\",\n" + >> > > " \"profileIconId\": 25,\n" + >> > > " \"level\": 5,\n" + >> > > " \"expPoints\": 83,\n" + >> > > " \"infPoints\": 1475,\n" + >> > > " \"revisionDate\": 1406631727000\n" + >> > > " },\n" + >> > > " {\n" + >> > > " \"id\": 2810674,\n" + >> > > " \"accountId\": 200706913,\n" + >> > > " \"name\": \"ABZ Devrim\",\n" + >> > > " \"profileIconId\": 663,\n" + >> > > " \"level\": 13,\n" + >> > > " \"expPoints\": 982,\n" + >> > > " \"infPoints\": 10472,\n" + >> > > " \"revisionDate\": 1450791227000\n" + >> > > " },\n" + >> > > " {\n" + >> > > " \"id\": 5411195,\n" + >> > > " \"accountId\": 202647689,\n" + >> > > " \"name\": \"Ace HypcronN\",\n" + >> > > " \"profileIconId\": 911,\n" + >> > > " \"level\": 30,\n" + >> > > " \"expPoints\": 73,\n" + >> > > " \"infPoints\": 182445,\n" + >> > > " \"revisionDate\": 1480781650000\n" + >> > > " },\n" + >> > > " {\n" + >> > > " \"id\": 1363020,\n" + >> > > " \"accountId\": 1357837,\n" + >> > > " \"name\": \"AdanaLee\",\n" + >> > > " \"profileIconId\": 502,\n" + >> > > " \"level\": 30,\n" + >> > > " \"expPoints\": 125,\n" + >> > > " \"infPoints\": 719299,\n" + >> > > " \"revisionDate\": 1480530778000\n" + >> > > " },\n" + >> > > " {\n" + >> > > " \"id\": 8261198,\n" + >> > > " \"accountId\": 205027096,\n" + >> > > " \"name\": \"Achilehuz\",\n" + >> > > " \"profileIconId\": 1381,\n" + >> > > " \"level\": 30,\n" + >> > > " \"expPoints\": 10,\n" + >> > > " \"infPoints\": 158603,\n" + >> > > " \"revisionDate\": 1480770307000\n" + >> > > " },\n" + >> > > " {\n" + >> > > " \"id\": 12685857,\n" + >> > > " \"accountId\": 207591166,\n" + >> > > " \"name\": \"ac?mas?zpicc\",\n" + >> > > " \"profileIconId\": 9,\n" + >> > > " \"level\": 21,\n" + >> > > " \"expPoints\": 840,\n" + >> > > " \"infPoints\": 16659,\n" + >> > > " \"revisionDate\": 1480515325000\n" + >> > > " },\n" + >> > > " {\n" + >> > > " \"id\": 10860127,\n" + >> > > " \"accountId\": 206507727,\n" + >> > > " \"name\": \"AAngelFlyy\",\n" + >> > > " \"profileIconId\": 1395,\n" + >> > > " \"level\": 30,\n" + >> > > " \"expPoints\": 10,\n" + >> > > " \"infPoints\": 73111,\n" + >> > > " \"revisionDate\": 1480787870000\n" + >> > > " },\n" + >> > > " {\n" + >> > > " \"id\": 3292376,\n" + >> > > " \"accountId\": 201048714,\n" + >> > > " \"name\": \"ACAB1907\",\n" + >> > > " \"profileIconId\": 20,\n" + >> > > " \"level\": 6,\n" + >> > > " \"expPoints\": 305,\n" + >> > > " \"infPoints\": 2107,\n" + >> > > " \"revisionDate\": 1402448089000\n" + >> > > " },\n" + >> > > " {\n" + >> > > " \"id\": 461671,\n" + >> > > " \"accountId\": 446571,\n" + >> > > " \"name\": \"Acta Est Fabul?\",\n" + >> > > " \"profileIconId\": 1435,\n" + >> > > " \"level\": 30,\n" + >> > > " \"expPoints\": 47,\n" + >> > > " \"infPoints\": 644672,\n" + >> > > " \"revisionDate\": 1480626505000\n" + >> > > " },\n" + >> > > " {\n" + >> > > " \"id\": 394183,\n" + >> > > " \"accountId\": 379083,\n" + >> > > " \"name\": \"acekse4\",\n" + >> > > " \"profileIconId\": 27,\n" + >> > > " \"level\": 5,\n" + >> > > " \"expPoints\": 223,\n" + >> > > " \"infPoints\": 908,\n" + >> > > " \"revisionDate\": 1348116544000\n" + >> > > " },\n" + >> > > " {\n" + >> > > " \"id\": 5941247,\n" + >> > > " \"accountId\": 203106300,\n" + >> > > " \"name\": \"abdul7878\",\n" + >> > > " \"profileIconId\": 26,\n" + >> > > " \"level\": 3,\n" + >> > > " \"expPoints\": 10,\n" + >> > > " \"infPoints\": 401,\n" + >> > > " \"revisionDate\": 1406029148000\n" + >> > > " },\n" + >> > > " {\n" + >> > > " \"id\": 2467446,\n" + >> > > " \"accountId\": 200459837,\n" + >> > > " \"name\": \"ActionC\",\n" + >> > > " \"profileIconId\": 986,\n" + >> > > " \"level\": 30,\n" + >> > > " \"expPoints\": 74,\n" + >> > > " \"infPoints\": 401367,\n" + >> > > " \"revisionDate\": 1480808608000\n" + >> > > " },\n" + >> > > " {\n" + >> > > " \"id\": 9402979,\n" + >> > > " \"accountId\": 205698832,\n" + >> > > " \"name\": \"Ablenia \",\n" + >> > > " \"profileIconId\": 1129,\n" + >> > > " \"level\": 30,\n" + >> > > " \"expPoints\": 19,\n" + >> > > " \"infPoints\": 163518,\n" + >> > > " \"revisionDate\": 1480687603000\n" + >> > > " },\n" + >> > > " {\n" + >> > > " \"id\": 13187505,\n" + >> > > " \"accountId\": 207898213,\n" + >> > > " \"name\": \"aDaMiYiM\",\n" + >> > > " \"profileIconId\": 1301,\n" + >> > > " \"level\": 30,\n" + >> > > " \"expPoints\": 116,\n" + >> > > " \"infPoints\": 45214,\n" + >> > > " \"revisionDate\": 1480793258000\n" + >> > > " },\n" + >> > > " {\n" + >> > > " \"id\": 4141059,\n" + >> > > " \"accountId\": 201688290,\n" + >> > > " \"name\": \"Abimin?ar?\",\n" + >> > > " \"profileIconId\": 898,\n" + >> > > " \"level\": 30,\n" + >> > > " \"expPoints\": 152,\n" + >> > > " \"infPoints\": 752477,\n" + >> > > " \"revisionDate\": 1480635961000\n" + >> > > " },\n" + >> > > " {\n" + >> > > " \"id\": 5702134,\n" + >> > > " \"accountId\": 202899395,\n" + >> > > " \"name\": \"Above the Clouds\",\n" + >> > > " \"profileIconId\": 684,\n" + >> > > " \"level\": 30,\n" + >> > > " \"expPoints\": 110,\n" + >> > > " \"infPoints\": 288096,\n" + >> > > " \"revisionDate\": 1471011372000\n" + >> > > " },\n" + >> > > " {\n" + >> > > " \"id\": 5810740,\n" + >> > > " \"accountId\": 202985228,\n" + >> > > " \"name\": \"aBimm\",\n" + >> > > " \"profileIconId\": 11,\n" + >> > > " \"level\": 13,\n" + >> > > " \"expPoints\": 1180,\n" + >> > > " \"infPoints\": 10736,\n" + >> > > " \"revisionDate\": 1409832684000\n" + >> > > " },\n" + >> > > " {\n" + >> > > " \"id\": 5817751,\n" + >> > > " \"accountId\": 203050678,\n" + >> > > " \"name\": \"AD Glor?am\",\n" + >> > > " \"profileIconId\": 982,\n" + >> > > " \"level\": 30,\n" + >> > > " \"expPoints\": 111,\n" + >> > > " \"infPoints\": 304658,\n" + >> > > " \"revisionDate\": 1480795250000\n" + >> > > " },\n" + >> > > " {\n" + >> > > " \"id\": 9851802,\n" + >> > > " \"accountId\": 206011054,\n" + >> > > " \"name\": \"AdarAllame\",\n" + >> > > " \"profileIconId\": 911,\n" + >> > > " \"level\": 30,\n" + >> > > " \"expPoints\": 48,\n" + >> > > " \"infPoints\": 73763,\n" + >> > > " \"revisionDate\": 1479422812000\n" + >> > > " },\n" + >> > > " {\n" + >> > > " \"id\": 12735622,\n" + >> > > " \"accountId\": 207587019,\n" + >> > > " \"name\": \"absinthe666\",\n" + >> > > " \"profileIconId\": 903,\n" + >> > > " \"level\": 30,\n" + >> > > " \"expPoints\": 83,\n" + >> > > " \"infPoints\": 40302,\n" + >> > > " \"revisionDate\": 1480782923000\n" + >> > > " },\n" + >> > > " {\n" + >> > > " \"id\": 6371389,\n" + >> > > " \"accountId\": 203416952,\n" + >> > > " \"name\": \"adamsat?c?\",\n" + >> > > " \"profileIconId\": 3,\n" + >> > > " \"level\": 4,\n" + >> > > " \"expPoints\": 17,\n" + >> > > " \"infPoints\": 685,\n" + >> > > " \"revisionDate\": 1409320171000\n" + >> > > " },\n" + >> > > " {\n" + >> > > " \"id\": 7828139,\n" + >> > > " \"accountId\": 204927980,\n" + >> > > " \"name\": \"AbsoluteForce\",\n" + >> > > " \"profileIconId\": 950,\n" + >> > > " \"level\": 30,\n" + >> > > " \"expPoints\": 139,\n" + >> > > " \"infPoints\": 208789,\n" + >> > > " \"revisionDate\": 1480804396000\n" + >> > > " },\n" + >> > > " {\n" + >> > > " \"id\": 1373229,\n" + >> > > " \"accountId\": 1358441,\n" + >> > > " \"name\": \"AbsoluteDeath\",\n" + >> > > " \"profileIconId\": 7,\n" + >> > > " \"level\": 30,\n" + >> > > " \"expPoints\": 34,\n" + >> > > " \"infPoints\": 223655,\n" + >> > > " \"revisionDate\": 1471867646000\n" + >> > > " },\n" + >> > > " {\n" + >> > > " \"id\": 7694972,\n" + >> > > " \"accountId\": 204803668,\n" + >> > > " \"name\": \"ac pnp\",\n" + >> > > " \"profileIconId\": 937,\n" + >> > > " \"level\": 30,\n" + >> > > " \"expPoints\": 161,\n" + >> > > " \"infPoints\": 249681,\n" + >> > > " \"revisionDate\": 1480801507000\n" + >> > > " },\n" + >> > > " {\n" + >> > > " \"id\": 1373524,\n" + >> > > " \"accountId\": 1350474,\n" + >> > > " \"name\": \"Abd??\",\n" + >> > > " \"profileIconId\": 1301,\n" + >> > > " \"level\": 30,\n" + >> > > " \"expPoints\": 103,\n" + >> > > " \"infPoints\": 286803,\n" + >> > > " \"revisionDate\": 1476621827000\n" + >> > > " },\n" + >> > > " {\n" + >> > > " \"id\": 1650227,\n" + >> > > " \"accountId\": 200000503,\n" + >> > > " \"name\": \"AD Ambrosia\",\n" + >> > > " \"profileIconId\": 1152,\n" + >> > > " \"level\": 30,\n" + >> > > " \"expPoints\": 139,\n" + >> > > " \"infPoints\": 156333,\n" + >> > > " \"revisionDate\": 1480805320000\n" + >> > > " },\n" + >> > > " {\n" + >> > > " \"id\": 8331358,\n" + >> > > " \"accountId\": 205073925,\n" + >> > > " \"name\": \"acarmanyust2\",\n" + >> > > " \"profileIconId\": 0,\n" + >> > > " \"level\": 2,\n" + >> > > " \"expPoints\": 43,\n" + >> > > " \"infPoints\": 318,\n" + >> > > " \"revisionDate\": 1423915139000\n" + >> > > " },\n" + >> > > " {\n" + >> > > " \"id\": 1862106,\n" + >> > > " \"accountId\": 200139838,\n" + >> > > " \"name\": \"aboU\",\n" + >> > > " \"profileIconId\": 1155,\n" + >> > > " \"level\": 30,\n" + >> > > " \"expPoints\": 0,\n" + >> > > " \"infPoints\": 412616,\n" + >> > > " \"revisionDate\": 1480771055000\n" + >> > > " },\n" + >> > > " {\n" + >> > > " \"id\": 2362628,\n" + >> > > " \"accountId\": 685649,\n" + >> > > " \"name\": \"Ac?F?sT?k\",\n" + >> > > " \"profileIconId\": 1074,\n" + >> > > " \"level\": 30,\n" + >> > > " \"expPoints\": 48,\n" + >> > > " \"infPoints\": 233882,\n" + >> > > " \"revisionDate\": 1480786233000\n" + >> > > " },\n" + >> > > " {\n" + >> > > " \"id\": 4323909,\n" + >> > > " \"accountId\": 201917672,\n" + >> > > " \"name\": \"Addrenalin\",\n" + >> > > " \"profileIconId\": 603,\n" + >> > > " \"level\": 30,\n" + >> > > " \"expPoints\": 55,\n" + >> > > " \"infPoints\": 220605,\n" + >> > > " \"revisionDate\": 1432647338000\n" + >> > > " },\n" + >> > > " {\n" + >> > > " \"id\": 377206,\n" + >> > > " \"accountId\": 362106,\n" + >> > > " \"name\": \"Aburame Shino\",\n" + >> > > " \"profileIconId\": 844,\n" + >> > > " \"level\": 30,\n" + >> > > " \"expPoints\": 84,\n" + >> > > " \"infPoints\": 354087,\n" + >> > > " \"revisionDate\": 1477666556000\n" + >> > > " },\n" + >> > > " {\n" + >> > > " \"id\": 5377433,\n" + >> > > " \"accountId\": 202697921,\n" + >> > > " \"name\": \"AcEcolton35\",\n" + >> > > " \"profileIconId\": 984,\n" + >> > > " \"level\": 25,\n" + >> > > " \"expPoints\": 751,\n" + >> > > " \"infPoints\": 30061,\n" + >> > > " \"revisionDate\": 1475503024000\n" + >> > > " },\n" + >> > > " {\n" + >> > > " \"id\": 2381404,\n" + >> > > " \"accountId\": 200333680,\n" + >> > > " \"name\": \"adafakaaa\",\n" + >> > > " \"profileIconId\": 663,\n" + >> > > " \"level\": 30,\n" + >> > > " \"expPoints\": 8,\n" + >> > > " \"infPoints\": 534204,\n" + >> > > " \"revisionDate\": 1480719827000\n" + >> > > " },\n" + >> > > " {\n" + >> > > " \"id\": 1281203,\n" + >> > > " \"accountId\": 1259342,\n" + >> > > " \"name\": \"AC Klondike\",\n" + >> > > " \"profileIconId\": 898,\n" + >> > > " \"level\": 30,\n" + >> > > " \"expPoints\": 27,\n" + >> > > " \"infPoints\": 191429,\n" + >> > > " \"revisionDate\": 1480294973000\n" + >> > > " },\n" + >> > > " {\n" + >> > > " \"id\": 13161471,\n" + >> > > " \"accountId\": 207847181,\n" + >> > > " \"name\": \"adar21\",\n" + >> > > " \"profileIconId\": 26,\n" + >> > > " \"level\": 10,\n" + >> > > " \"expPoints\": 143,\n" + >> > > " \"infPoints\": 3558,\n" + >> > > " \"revisionDate\": 1476529855000\n" + >> > > " },\n" + >> > > " {\n" + >> > > " \"id\": 5841915,\n" + >> > > " \"accountId\": 202998794,\n" + >> > > " \"name\": \"Achilles29\",\n" + >> > > " \"profileIconId\": 666,\n" + >> > > " \"level\": 30,\n" + >> > > " \"expPoints\": 41,\n" + >> > > " \"infPoints\": 219714,\n" + >> > > " \"revisionDate\": 1480777744000\n" + >> > > " },\n" + >> > > " {\n" + >> > > " \"id\": 2853062,\n" + >> > > " \"accountId\": 200726707,\n" + >> > > " \"name\": \"AbIanStarBebegim\",\n" + >> > > " \"profileIconId\": 909,\n" + >> > > " \"level\": 30,\n" + >> > > " \"expPoints\": 64,\n" + >> > > " \"infPoints\": 297580,\n" + >> > > " \"revisionDate\": 1480556859000\n" + >> > > " },\n" + >> > > " {\n" + >> > > " \"id\": 8323114,\n" + >> > > " \"accountId\": 205093515,\n" + >> > > " \"name\": \"Absuruk\",\n" + >> > > " \"profileIconId\": 6,\n" + >> > > " \"level\": 30,\n" + >> > > " \"expPoints\": 21,\n" + >> > > " \"infPoints\": 121086,\n" + >> > > " \"revisionDate\": 1480820801000\n" + >> > > " }\n" + >> > > "]" >> > > >> > > On Wed, Dec 7, 2016 at 7:01 AM, Hannes Walln?fer < >> hannes.wallnoefer at oracle.com> wrote: >> > > Hi Jesus, >> > > >> > > I?m trying to reproduce the problem, and just want to make sure I get >> the missing pieces right. >> > > >> > > You already showed us how you?re setting up the engine and the JS >> code you?re running. I assume the JSON code you?re parsing is a simple >> array of objects? And you?re just calling Invocable.invokeFunction on the >> ScriptEngine from multiple threads in parallel, right? >> > > >> > > Thanks, >> > > Hannes >> > > >> > > >> > > > Am 07.12.2016 um 00:03 schrieb Jesus Luzon : >> > > > >> > > > When we share one invocable across many threads and run >> invokeFunction it >> > > > happens, such as this: >> > > > >> > > > ExecutorService executor = Executors.newFixedThreadPool(50); >> > > >> >> > > >> Invocable invocable = generateInvocable(script); >> > > >> >> > > >> AtomicLong count = new AtomicLong(); >> > > >> >> > > >> for (int i = 0; i < 50; i++) { >> > > >> >> > > >> executor.submit(new Runnable() { >> > > >> >> > > >> @Override >> > > >> >> > > >> public void run() { >> > > >> >> > > >> try { >> > > >> >> > > >> while(true) { >> > > >> >> > > >> invocable.invokeFunction("tran >> sform", >> > > >>> something); >> > > >> >> > > >> count.incrementAndGet(); >> > > >> >> > > >> } >> > > >> >> > > >> } catch (NoSuchMethodException | >> ScriptException >> > > >>> e) { >> > > >> >> > > >> e.printStackTrace(); >> > > >> >> > > >> } >> > > >> >> > > >> } >> > > >> >> > > >> }); >> > > >> >> > > >> } >> > > >> >> > > >> >> > > > >> > > > >> > > > On Tue, Dec 6, 2016 at 2:59 PM, Jim Laskey (Oracle) < >> james.laskey at oracle.com >> > > >> wrote: >> > > > >> > > >> Intersting. The example you posted demonstrates this behaviour? >> If so >> > > >> I?ll file a bug and dig in. It sounds like an object is being >> reused >> > > >> across invocations and accumulating changes to the property map. >> > > >> >> > > >> ? Jim >> > > >> >> > > >> >> > > >> On Dec 6, 2016, at 5:12 PM, Jesus Luzon >> wrote: >> > > >> >> > > >> With more threads you are impacting the same 8 cores, so it will >> taper off >> > > >>> after 8 threads. If it?s a 2x4 core machine then I can see 4 >> being a >> > > >>> threshold depending on System performance. Transport: I meant if >> you were >> > > >>> using sockets to provide the script. >> > > >> >> > > >> This makes sense. This one's on me then. >> > > >> >> > > >> >> > > >>> So you are using the same invocable instance for all threads? If >> so, >> > > >>> then you are probably good to go. As far as leaks are concerned, >> not sure >> > > >>> how you would get leaks from Nashorn. The JSON object is written >> in Java, >> > > >>> and little JavaScript involved. >> > > >> >> > > >> >> > > >> >> > > >>> In your example, pull up Invocable invocable = >> generateInvocable(script); >> > > >>> out of the loop and use the same invocable for all threads. >> > > >> >> > > >> >> > > >> We were using one invocable across all threads and we were getting >> > > >> slowdowns on execution, high CPU Usage and memory leaks that led to >> > > >> OutOfMemory errors. I could trace the leak to >> > > >> >> > > >> jdk.nashorn.internal.objects.Global -> *objectSpill* Object[8] -> >> > > >> jdk.nashorn.internal.scripts.JO4 -> *arrayData* >> > > >> jdk.nashorn.internal.runtime.arrays.SparseArraysData -> >> *underlying* >> > > >> jdk.nashorn.internal.runtime.arrays.DeletedArrayFilter >> > > >> >> > > >> which just keeps growing forever. >> > > >> >> > > >> On Tue, Dec 6, 2016 at 6:30 AM, Jim Laskey (Oracle) < >> > > >> james.laskey at oracle.com> wrote: >> > > >> >> > > >>> >> > > >>> On Dec 6, 2016, at 9:56 AM, Jesus Luzon >> wrote: >> > > >>> >> > > >>> The cost of creating a new engine is significant. So share an >> engine >> > > >>>> across threads but use *eval >> > > >>>> > ScriptEngine.html#eval(java.lang.String,%20javax.script.ScriptContext)>* >> > > >>>> (String >> > > >>>> > > >> > > >>>> script, ScriptContext >> > > >>>> > ScriptContext.html> >> > > >>>> context) instead, separate context per execution. If your >> JavaScript >> > > >>>> code does not modify globals you can get away with using the >> same engine, >> > > >>>> same compiled script on each thread. >> > > >>> >> > > >>> >> > > >>> I guess there's a few things here I don't understand. One thing >> I'm >> > > >>> trying to do is sharing a CompiledScript (which is why I'm using >> > > >>> invocable). Also, what exactly does modify globals mean? All our >> filters do >> > > >>> the same thing, make a function that takes a JSON String, turns >> it into a >> > > >>> JSON, modifies it and then stringifies it back. No state is >> changed of >> > > >>> anything else but there are temporary vars created inside the >> scope of the >> > > >>> function. When we run this multithreaded, running invokeFunction >> slows down >> > > >>> significantly and we get crazy memory leaks. >> > > >>> >> > > >>> >> > > >>> So you are using the same invocable instance for all threads? If >> so, >> > > >>> then you are probably good to go. As far as leaks are concerned, >> not sure >> > > >>> how you would get leaks from Nashorn. The JSON object is written >> in Java, >> > > >>> and little JavaScript involved. >> > > >>> >> > > >>> >> > > >>> Of course there are many factors involved n performance. How >> many cores >> > > >>>> do you have on the test machine? How much memory in the >> process? What >> > > >>>> transport are you using between threads? That sort of thing. >> Other than >> > > >>>> constructing then engine and context Nashorn performance should >> scale. >> > > >>> >> > > >>> I'm using an 8 core machine to test with 2.5Gs of RAM allocated >> to the >> > > >>> process. Not sure what transports between threads means, but this >> is the >> > > >>> code I'm benchmarking with. Increasing the number of threads >> actually makes >> > > >>> it go faster until about 4 threads, then adding more threads >> takes the same >> > > >>> amount to get to 1000 and and after a certain point it is just >> slower to >> > > >>> get to 1000 counts. Some of our filters need to be able to run >> over 1000 >> > > >>> times a second (across all threads) and the fastest time I could >> actually >> > > >>> get with this was about 2.4 seconds for a 1000 counts. >> > > >>> >> > > >>>> ExecutorService executor = Executors.newFixedThreadPool(5 >> 0); >> > > >>>> >> > > >>>> AtomicLong count = new AtomicLong(); >> > > >>>> >> > > >>>> for (int i = 0; i < 50; i++) { >> > > >>>> >> > > >>>> executor.submit(new Runnable() { >> > > >>>> >> > > >>>> @Override >> > > >>>> >> > > >>>> public void run() { >> > > >>>> >> > > >>>> >> > > >>>>> try { >> > > >>>> >> > > >>>> Invocable invocable = >> > > >>>>> generateInvocable(script); >> > > >>>> >> > > >>>> while(true) { >> > > >>>> >> > > >>>> invocable.invokeFunction("tran >> sform", >> > > >>>>> something); >> > > >>>> >> > > >>>> count.incrementAndGet(); >> > > >>>> >> > > >>>> } >> > > >>>> >> > > >>>> } catch (NoSuchMethodException | >> ScriptException >> > > >>>>> e) { >> > > >>>> >> > > >>>> e.printStackTrace(); >> > > >>>> >> > > >>>> } >> > > >>>> >> > > >>>> } >> > > >>>> >> > > >>>> }); >> > > >>>> >> > > >>>> } >> > > >>>> >> > > >>>> long lastTimestamp = System.currentTimeMillis(); >> > > >>>> >> > > >>>> while(true) { >> > > >>>> >> > > >>>> >> > > >>>>> if (count.get() > 1000) { >> > > >>>> >> > > >>>> count.getAndAdd(-1000); >> > > >>>> >> > > >>>> System.out.println((System.currentTimeMillis() - >> > > >>>>> lastTimestamp)/1000.0); >> > > >>>> >> > > >>>> lastTimestamp = System.currentTimeMillis(); >> > > >>>> >> > > >>>> } >> > > >>>> >> > > >>>> } >> > > >>>> >> > > >>>> >> > > >>> With more threads you are impacting the same 8 cores, so it will >> taper >> > > >>> off after 8 threads. If it?s a 2x4 core machine then I can see 4 >> being a >> > > >>> threshold depending on System performance. Transport: I meant if >> you were >> > > >>> using sockets to provide the script. >> > > >>> >> > > >>> In your example, pull up Invocable invocable = >> generateInvocable(script); >> > > >>> out of the loop and use the same invocable for all threads. >> > > >>> >> > > >>> - Jim >> > > >>> >> > > >>> >> > > >>> >> > > >>> >> > > >>> On Tue, Dec 6, 2016 at 5:31 AM, Jim Laskey (Oracle) < >> > > >>> james.laskey at oracle.com> wrote: >> > > >>> >> > > >>>> >> > > >>>> On Dec 6, 2016, at 9:19 AM, Jesus Luzon >> wrote: >> > > >>>> >> > > >>>> Hey Jim, >> > > >>>> >> > > >>>> I looked at it and I will look into loadWithNewGlobal to see what >> > > >>>> exactly it does since it could be relevant. As for the rest, for >> my use >> > > >>>> case having threads in the JS would not help. We're using >> Nashorn to build >> > > >>>> JSON filters in a Dynamic Proxy Service and need any of the >> threads >> > > >>>> processing a request to be able to execute the script to filter. >> > > >>>> >> > > >>>> >> > > >>>> The cost of creating a new engine is significant. So share an >> engine >> > > >>>> across threads but use *eval >> > > >>>> > ScriptEngine.html#eval(java.lang.String,%20javax.script.ScriptContext)>* >> > > >>>> (String >> > > >>>> > > >> > > >>>> script, ScriptContext >> > > >>>> > ScriptContext.html> >> > > >>>> context) instead, separate context per execution. If your >> JavaScript >> > > >>>> code does not modify globals you can get away with using the >> same engine, >> > > >>>> same compiled script on each thread. >> > > >>>> >> > > >>>> >> > > >>>> Also, when you say a new engine per threads is the worst case >> what >> > > >>>> exactly do you mean? I would expect an initial cost of compiling >> the script >> > > >>>> on each thread and then each engine should be able to do its own >> thing, but >> > > >>>> what I'm seeing is that when running with more than 10 threads >> all my >> > > >>>> engines get slow at executing code, even though they are all >> completely >> > > >>>> separate from each other. >> > > >>>> >> > > >>>> >> > > >>>> Of course there are many factors involved n performance. How >> many cores >> > > >>>> do you have on the test machine? How much memory in the >> process? What >> > > >>>> transport are you using between threads? That sort of thing. >> Other than >> > > >>>> constructing then engine and context Nashorn performance should >> scale. >> > > >>>> >> > > >>>> >> > > >>>> On Tue, Dec 6, 2016 at 5:07 AM, Jim Laskey (Oracle) < >> > > >>>> james.laskey at oracle.com> wrote: >> > > >>>> >> > > >>>>> Jesus, >> > > >>>>> >> > > >>>>> Probably the most informative information is in this blog. >> > > >>>>> >> > > >>>>> https://blogs.oracle.com/nashorn/entry/nashorn_multi_threadi >> ng_and_mt >> > > >>>>> >> > > >>>>> This example uses Executors but threads would work as well. >> > > >>>>> >> > > >>>>> I did a talk that looked at different methods to max out >> multithreading >> > > >>>>> performance. A new engine per thread is the worst case. A new >> context per >> > > >>>>> thread does much better. A new global per thread is the best >> while >> > > >>>>> remaining thread safe. >> > > >>>>> >> > > >>>>> Cheers, >> > > >>>>> >> > > >>>>> ? Jim >> > > >>>>> >> > > >>>>> >> > > >>>>> >> > > >>>>> >> > > >>>>> >> > > >>>>> On Dec 6, 2016, at 8:45 AM, Jesus Luzon >> wrote: >> > > >>>>> >> > > >>>>> Hey folks, >> > > >>>>> >> > > >>>>> I've tried many different ways of using Nashorn multithreaded >> based on >> > > >>>>> what >> > > >>>>> I've found on the internet and I still can't get a single one >> to scale. >> > > >>>>> Even the most naive method of making many script engines with >> my script >> > > >>>>> tends to bottleneck itself when I have more than 10 threads >> invoking >> > > >>>>> functions. >> > > >>>>> >> > > >>>>> I'm using the following code to compile my script and >> > > >>>>> invocable.invokeFunction("transform", input) to execute: >> > > >>>>> >> > > >>>>> static Invocable generateInvocable(String script) throws >> > > >>>>> ScriptException { >> > > >>>>> ScriptEngineManager manager = new ScriptEngineManager(); >> > > >>>>> ScriptEngine engine = >> > > >>>>> manager.getEngineByName(JAVASCRIPT_ENGINE_NAME); >> > > >>>>> Compilable compilable = (Compilable) engine; >> > > >>>>> final CompiledScript compiled = >> compilable.compile(script); >> > > >>>>> compiled.eval(); >> > > >>>>> return (Invocable) engine; >> > > >>>>> } >> > > >>>>> >> > > >>>>> >> > > >>>>> >> > > >>>>> The script I'm compiling is: >> > > >>>>> >> > > >>>>> String script = "function transform(input) {" + >> > > >>>>> "var result = JSON.parse(input);" + >> > > >>>>> "response = {};\n" + >> > > >>>>> "for (var i = 0; i < result.length; i++) {\n" + >> > > >>>>> " var summoner = {};\n" + >> > > >>>>> " summoner.id = result[i].id;\n" + >> > > >>>>> " summoner.name = result[i].name;\n" + >> > > >>>>> " summoner.profileIconId = >> > > >>>>> result[i].profileIconId;\n" + >> > > >>>>> " summoner.revisionDate = >> result[i].revisionDate;\n" + >> > > >>>>> " summoner.summonerLevel = result[i].level;\n" >> + >> > > >>>>> " response[summoner.id] = summoner;\n" + >> > > >>>>> "}\n" + >> > > >>>>> "result = response;" + >> > > >>>>> "return JSON.stringify(result);" + >> > > >>>>> "};"; >> > > >>>>> >> > > >>>>> >> > > >>>>> >> > > >>>>> I've also tried other more scaleable ways to work with scripts >> > > >>>>> concurrently, but given that this is the most naive method where >> > > >>>>> everything >> > > >>>>> is brand new and I still get slowness calling them concurrently >> I fear >> > > >>>>> that >> > > >>>>> maybe I'm overlooking something extremely basic on my code. >> > > >>>>> >> > > >>>>> Thanks. >> > > >>>>> -Jesus Luzon >> > > >>>>> >> > > >>>>> >> > > >>>> >> > > >>> >> > > >>> >> > > >> >> > > >> >> > > >> > > >> > > >> > >> > >> > >> >> > From hannes.wallnoefer at oracle.com Mon Jan 9 22:57:03 2017 From: hannes.wallnoefer at oracle.com (=?utf-8?Q?Hannes_Walln=C3=B6fer?=) Date: Mon, 9 Jan 2017 23:57:03 +0100 Subject: Can't get Multithreaded Nashorn uses to Scale In-Reply-To: References: <31833CD9-8263-478E-9400-87D5D561C29A@oracle.com> Message-ID: <927BE131-BC1E-42F4-8165-B169BD96A0BF@oracle.com> The fix is in JDK 9 now. I will propose this to be backported this to 8u, which means it should appear in some 8u release soon, but I can?t make any promise about a specific release or date. Hannes > Am 09.01.2017 um 23:44 schrieb Jesus Luzon : > > Hey folks, > > Looked at the ticket and noticed it has been marked as fixed. woot! Thank you so much! > > My team has been asking me if I can find out the date this fix will get released. I noticed the version on there (version 9) states it has no release date yet. Is there any tentative date you all have for the net release this would be included in? Even a ballpark figure would be awesome. > > Thanks. > > On Fri, Dec 9, 2016 at 2:49 AM, Jesus Luzon wrote: > Wow I totally missed the var. Thanks for that! I actually had changed our code to use ThreadLocal ScriptObjectMirrors created from the CompiledScript with the following code: > > ScriptObjectMirror mirror = mirrorThreadLocal.get(); > if (mirror == null) { > Bindings bindings = compiledScript.getEngine().createBindings(); > compiledScript.eval(bindings); > mirror = (ScriptObjectMirror) bindings.get("transform"); > mirrorThreadLocal.set(mirror); > } > return (String) mirror.call(null, something); > > Given that we will always run standalone functions to filter data, is there one we should be using over the other? > > Lastly thanks for filing the bug. I'll keep track of it so I can make sure to upgrade when a fix comes out. > > On Fri, Dec 9, 2016 at 2:37 AM, Hannes Walln?fer wrote: > Jesus, > > I looked at this issue more in depth and there are two problems here, one on your side and one on ours: > > The problem with your code is that you left out the ?var? declaration of the ?response? variable in the third line of your function. This means that ?response? is allocated as a global variable outside the scope of the function. When you run this in parallel with multiple threads you actually access the same object from multiple threads, meaning your output will be corrupt. > > Because of things like this, it is actually a good idea to run JavaScript in strict mode (e.g. by using ?use strict? directive in your JavaScript code, or by creating the engine with -strict option). Another solution would be to use multiple engines or bindings, which should not have a big performance impact once the other problem is fixed. > > Which leads us to the problem on our side, which is performance of sparse arrays. As you have noticed, using something that is not a valid array index greatly improves performance, and that is because some array element assignment are implemented very inefficiently in Nashorn. I?ve filed a bug for this: > > https://bugs.openjdk.java.net/browse/JDK-8170977 > > Once this bug is fixed, using numeric keys should be roughly as fast as using non-numeric ones. > > Hannes > > > > Am 09.12.2016 um 04:47 schrieb Jesus Luzon : > > > > I came up with a workaround which is getting us through this but it definitely seems like this is a bug. The gist is I append an arbitrary string (we made it complex on our end to make it unlikely something else has this string inside) to the key and then remove all instances of said string on the JSON String resulting from calling stringify. We are leaving this for overnight testing but it showed promising results immediately. > > > > String script = "function transform(input) {" + > > "var result = JSON.parse(input);" + > > "response = {};\n" + > > "for (var i = 0; i < result.length; i++) {\n" + > > " var summoner = {};\n" + > > " summoner.id = result[i].id;\n" + > > " summoner.name = result[i].name;\n" + > > " summoner.profileIconId = result[i].profileIconId;\n" + > > " summoner.revisionDate = result[i].revisionDate;\n" + > > " summoner.summonerLevel = result[i].level;\n" + > > " response[\"someArbitraryString\" + summoner.id] = summoner;\n" + > > "}\n" + > > "var stringy = JSON.stringify(response);" + > > "result = stringy.replace(/someArbitraryString/g, \"\");" + > > "return result;" + > > "};"; > > > > On Thu, Dec 8, 2016 at 4:54 PM, Jesus Luzon wrote: > > It doesn't seem like changing to a string fixed it. We dug deeper and found a very interesting issue though. After running the invocable a few thousand times, when we put a breakpoint in ArrayData.computerIteratorKeys() and we found that it would stop at an execution from SparseArrayData with an underlying array of size 923392, stored length of 461672 (this is one of our IDs, the largest 6 digit one). Because of this we tried a run changing all the IDs in the array we pass in to number from 1-38 and this thing went blazing fast. When putting a break point in the same place, this array in SpareArrayData was now of size 39. We then changed an id in the array we take in to be 1337 and the size of the array in the SparseArrayData was 1338. > > > > I don't understand why or how to prevent but it's using this ID as an index for SpareArrayData underlying array. If someone can help me find a workaround for this I would be extremely grateful. > > > > On Thu, Dec 8, 2016 at 3:52 AM, Hannes Walln?fer wrote: > > Yes, this is very likely to be the cause of the problem. However, I do think we should be able to handle sparse array data better, so it?s quite possible that you exposed some weak spot in our implementation. I?ll have a look into what?s going on. > > > > Hannes > > > > > > > Am 08.12.2016 um 00:40 schrieb Jesus Luzon : > > > > > > Looks like the memory leak is due to the way we wrote our code and how javascript works. I was expecting the line response[summoner.id] = summoner; to build a map but it turns out that if you use a number as the "key", javscript automatically fills the indexes in the middle with null (Undefined type?). When these IDs are very large, it is creating huge arrays that take longer to garbage collect than the code executing. I am about to start testing this on our end to make sure we see the improvements we expect. > > > > > > Does this idea seem like it is reasonably possible? > > > > > > On Wed, Dec 7, 2016 at 11:23 AM, Jesus Luzon wrote: > > > Yes, it's an array of objects which I'll paste. And yes, I'm just calling invokeFunction from many many different threads. I'm also going to go back and take a look at all the heap dumps we have to re-confirm what I mentioned. > > > > > > "[\n" + > > > " {\n" + > > > " \"id\": 6011511,\n" + > > > " \"accountId\": 203192481,\n" + > > > " \"name\": \"Adam Pro Qarda?\",\n" + > > > " \"profileIconId\": 25,\n" + > > > " \"level\": 5,\n" + > > > " \"expPoints\": 83,\n" + > > > " \"infPoints\": 1475,\n" + > > > " \"revisionDate\": 1406631727000\n" + > > > " },\n" + > > > " {\n" + > > > " \"id\": 2810674,\n" + > > > " \"accountId\": 200706913,\n" + > > > " \"name\": \"ABZ Devrim\",\n" + > > > " \"profileIconId\": 663,\n" + > > > " \"level\": 13,\n" + > > > " \"expPoints\": 982,\n" + > > > " \"infPoints\": 10472,\n" + > > > " \"revisionDate\": 1450791227000\n" + > > > " },\n" + > > > " {\n" + > > > " \"id\": 5411195,\n" + > > > " \"accountId\": 202647689,\n" + > > > " \"name\": \"Ace HypcronN\",\n" + > > > " \"profileIconId\": 911,\n" + > > > " \"level\": 30,\n" + > > > " \"expPoints\": 73,\n" + > > > " \"infPoints\": 182445,\n" + > > > " \"revisionDate\": 1480781650000\n" + > > > " },\n" + > > > " {\n" + > > > " \"id\": 1363020,\n" + > > > " \"accountId\": 1357837,\n" + > > > " \"name\": \"AdanaLee\",\n" + > > > " \"profileIconId\": 502,\n" + > > > " \"level\": 30,\n" + > > > " \"expPoints\": 125,\n" + > > > " \"infPoints\": 719299,\n" + > > > " \"revisionDate\": 1480530778000\n" + > > > " },\n" + > > > " {\n" + > > > " \"id\": 8261198,\n" + > > > " \"accountId\": 205027096,\n" + > > > " \"name\": \"Achilehuz\",\n" + > > > " \"profileIconId\": 1381,\n" + > > > " \"level\": 30,\n" + > > > " \"expPoints\": 10,\n" + > > > " \"infPoints\": 158603,\n" + > > > " \"revisionDate\": 1480770307000\n" + > > > " },\n" + > > > " {\n" + > > > " \"id\": 12685857,\n" + > > > " \"accountId\": 207591166,\n" + > > > " \"name\": \"ac?mas?zpicc\",\n" + > > > " \"profileIconId\": 9,\n" + > > > " \"level\": 21,\n" + > > > " \"expPoints\": 840,\n" + > > > " \"infPoints\": 16659,\n" + > > > " \"revisionDate\": 1480515325000\n" + > > > " },\n" + > > > " {\n" + > > > " \"id\": 10860127,\n" + > > > " \"accountId\": 206507727,\n" + > > > " \"name\": \"AAngelFlyy\",\n" + > > > " \"profileIconId\": 1395,\n" + > > > " \"level\": 30,\n" + > > > " \"expPoints\": 10,\n" + > > > " \"infPoints\": 73111,\n" + > > > " \"revisionDate\": 1480787870000\n" + > > > " },\n" + > > > " {\n" + > > > " \"id\": 3292376,\n" + > > > " \"accountId\": 201048714,\n" + > > > " \"name\": \"ACAB1907\",\n" + > > > " \"profileIconId\": 20,\n" + > > > " \"level\": 6,\n" + > > > " \"expPoints\": 305,\n" + > > > " \"infPoints\": 2107,\n" + > > > " \"revisionDate\": 1402448089000\n" + > > > " },\n" + > > > " {\n" + > > > " \"id\": 461671,\n" + > > > " \"accountId\": 446571,\n" + > > > " \"name\": \"Acta Est Fabul?\",\n" + > > > " \"profileIconId\": 1435,\n" + > > > " \"level\": 30,\n" + > > > " \"expPoints\": 47,\n" + > > > " \"infPoints\": 644672,\n" + > > > " \"revisionDate\": 1480626505000\n" + > > > " },\n" + > > > " {\n" + > > > " \"id\": 394183,\n" + > > > " \"accountId\": 379083,\n" + > > > " \"name\": \"acekse4\",\n" + > > > " \"profileIconId\": 27,\n" + > > > " \"level\": 5,\n" + > > > " \"expPoints\": 223,\n" + > > > " \"infPoints\": 908,\n" + > > > " \"revisionDate\": 1348116544000\n" + > > > " },\n" + > > > " {\n" + > > > " \"id\": 5941247,\n" + > > > " \"accountId\": 203106300,\n" + > > > " \"name\": \"abdul7878\",\n" + > > > " \"profileIconId\": 26,\n" + > > > " \"level\": 3,\n" + > > > " \"expPoints\": 10,\n" + > > > " \"infPoints\": 401,\n" + > > > " \"revisionDate\": 1406029148000\n" + > > > " },\n" + > > > " {\n" + > > > " \"id\": 2467446,\n" + > > > " \"accountId\": 200459837,\n" + > > > " \"name\": \"ActionC\",\n" + > > > " \"profileIconId\": 986,\n" + > > > " \"level\": 30,\n" + > > > " \"expPoints\": 74,\n" + > > > " \"infPoints\": 401367,\n" + > > > " \"revisionDate\": 1480808608000\n" + > > > " },\n" + > > > " {\n" + > > > " \"id\": 9402979,\n" + > > > " \"accountId\": 205698832,\n" + > > > " \"name\": \"Ablenia \",\n" + > > > " \"profileIconId\": 1129,\n" + > > > " \"level\": 30,\n" + > > > " \"expPoints\": 19,\n" + > > > " \"infPoints\": 163518,\n" + > > > " \"revisionDate\": 1480687603000\n" + > > > " },\n" + > > > " {\n" + > > > " \"id\": 13187505,\n" + > > > " \"accountId\": 207898213,\n" + > > > " \"name\": \"aDaMiYiM\",\n" + > > > " \"profileIconId\": 1301,\n" + > > > " \"level\": 30,\n" + > > > " \"expPoints\": 116,\n" + > > > " \"infPoints\": 45214,\n" + > > > " \"revisionDate\": 1480793258000\n" + > > > " },\n" + > > > " {\n" + > > > " \"id\": 4141059,\n" + > > > " \"accountId\": 201688290,\n" + > > > " \"name\": \"Abimin?ar?\",\n" + > > > " \"profileIconId\": 898,\n" + > > > " \"level\": 30,\n" + > > > " \"expPoints\": 152,\n" + > > > " \"infPoints\": 752477,\n" + > > > " \"revisionDate\": 1480635961000\n" + > > > " },\n" + > > > " {\n" + > > > " \"id\": 5702134,\n" + > > > " \"accountId\": 202899395,\n" + > > > " \"name\": \"Above the Clouds\",\n" + > > > " \"profileIconId\": 684,\n" + > > > " \"level\": 30,\n" + > > > " \"expPoints\": 110,\n" + > > > " \"infPoints\": 288096,\n" + > > > " \"revisionDate\": 1471011372000\n" + > > > " },\n" + > > > " {\n" + > > > " \"id\": 5810740,\n" + > > > " \"accountId\": 202985228,\n" + > > > " \"name\": \"aBimm\",\n" + > > > " \"profileIconId\": 11,\n" + > > > " \"level\": 13,\n" + > > > " \"expPoints\": 1180,\n" + > > > " \"infPoints\": 10736,\n" + > > > " \"revisionDate\": 1409832684000\n" + > > > " },\n" + > > > " {\n" + > > > " \"id\": 5817751,\n" + > > > " \"accountId\": 203050678,\n" + > > > " \"name\": \"AD Glor?am\",\n" + > > > " \"profileIconId\": 982,\n" + > > > " \"level\": 30,\n" + > > > " \"expPoints\": 111,\n" + > > > " \"infPoints\": 304658,\n" + > > > " \"revisionDate\": 1480795250000\n" + > > > " },\n" + > > > " {\n" + > > > " \"id\": 9851802,\n" + > > > " \"accountId\": 206011054,\n" + > > > " \"name\": \"AdarAllame\",\n" + > > > " \"profileIconId\": 911,\n" + > > > " \"level\": 30,\n" + > > > " \"expPoints\": 48,\n" + > > > " \"infPoints\": 73763,\n" + > > > " \"revisionDate\": 1479422812000\n" + > > > " },\n" + > > > " {\n" + > > > " \"id\": 12735622,\n" + > > > " \"accountId\": 207587019,\n" + > > > " \"name\": \"absinthe666\",\n" + > > > " \"profileIconId\": 903,\n" + > > > " \"level\": 30,\n" + > > > " \"expPoints\": 83,\n" + > > > " \"infPoints\": 40302,\n" + > > > " \"revisionDate\": 1480782923000\n" + > > > " },\n" + > > > " {\n" + > > > " \"id\": 6371389,\n" + > > > " \"accountId\": 203416952,\n" + > > > " \"name\": \"adamsat?c?\",\n" + > > > " \"profileIconId\": 3,\n" + > > > " \"level\": 4,\n" + > > > " \"expPoints\": 17,\n" + > > > " \"infPoints\": 685,\n" + > > > " \"revisionDate\": 1409320171000\n" + > > > " },\n" + > > > " {\n" + > > > " \"id\": 7828139,\n" + > > > " \"accountId\": 204927980,\n" + > > > " \"name\": \"AbsoluteForce\",\n" + > > > " \"profileIconId\": 950,\n" + > > > " \"level\": 30,\n" + > > > " \"expPoints\": 139,\n" + > > > " \"infPoints\": 208789,\n" + > > > " \"revisionDate\": 1480804396000\n" + > > > " },\n" + > > > " {\n" + > > > " \"id\": 1373229,\n" + > > > " \"accountId\": 1358441,\n" + > > > " \"name\": \"AbsoluteDeath\",\n" + > > > " \"profileIconId\": 7,\n" + > > > " \"level\": 30,\n" + > > > " \"expPoints\": 34,\n" + > > > " \"infPoints\": 223655,\n" + > > > " \"revisionDate\": 1471867646000\n" + > > > " },\n" + > > > " {\n" + > > > " \"id\": 7694972,\n" + > > > " \"accountId\": 204803668,\n" + > > > " \"name\": \"ac pnp\",\n" + > > > " \"profileIconId\": 937,\n" + > > > " \"level\": 30,\n" + > > > " \"expPoints\": 161,\n" + > > > " \"infPoints\": 249681,\n" + > > > " \"revisionDate\": 1480801507000\n" + > > > " },\n" + > > > " {\n" + > > > " \"id\": 1373524,\n" + > > > " \"accountId\": 1350474,\n" + > > > " \"name\": \"Abd??\",\n" + > > > " \"profileIconId\": 1301,\n" + > > > " \"level\": 30,\n" + > > > " \"expPoints\": 103,\n" + > > > " \"infPoints\": 286803,\n" + > > > " \"revisionDate\": 1476621827000\n" + > > > " },\n" + > > > " {\n" + > > > " \"id\": 1650227,\n" + > > > " \"accountId\": 200000503,\n" + > > > " \"name\": \"AD Ambrosia\",\n" + > > > " \"profileIconId\": 1152,\n" + > > > " \"level\": 30,\n" + > > > " \"expPoints\": 139,\n" + > > > " \"infPoints\": 156333,\n" + > > > " \"revisionDate\": 1480805320000\n" + > > > " },\n" + > > > " {\n" + > > > " \"id\": 8331358,\n" + > > > " \"accountId\": 205073925,\n" + > > > " \"name\": \"acarmanyust2\",\n" + > > > " \"profileIconId\": 0,\n" + > > > " \"level\": 2,\n" + > > > " \"expPoints\": 43,\n" + > > > " \"infPoints\": 318,\n" + > > > " \"revisionDate\": 1423915139000\n" + > > > " },\n" + > > > " {\n" + > > > " \"id\": 1862106,\n" + > > > " \"accountId\": 200139838,\n" + > > > " \"name\": \"aboU\",\n" + > > > " \"profileIconId\": 1155,\n" + > > > " \"level\": 30,\n" + > > > " \"expPoints\": 0,\n" + > > > " \"infPoints\": 412616,\n" + > > > " \"revisionDate\": 1480771055000\n" + > > > " },\n" + > > > " {\n" + > > > " \"id\": 2362628,\n" + > > > " \"accountId\": 685649,\n" + > > > " \"name\": \"Ac?F?sT?k\",\n" + > > > " \"profileIconId\": 1074,\n" + > > > " \"level\": 30,\n" + > > > " \"expPoints\": 48,\n" + > > > " \"infPoints\": 233882,\n" + > > > " \"revisionDate\": 1480786233000\n" + > > > " },\n" + > > > " {\n" + > > > " \"id\": 4323909,\n" + > > > " \"accountId\": 201917672,\n" + > > > " \"name\": \"Addrenalin\",\n" + > > > " \"profileIconId\": 603,\n" + > > > " \"level\": 30,\n" + > > > " \"expPoints\": 55,\n" + > > > " \"infPoints\": 220605,\n" + > > > " \"revisionDate\": 1432647338000\n" + > > > " },\n" + > > > " {\n" + > > > " \"id\": 377206,\n" + > > > " \"accountId\": 362106,\n" + > > > " \"name\": \"Aburame Shino\",\n" + > > > " \"profileIconId\": 844,\n" + > > > " \"level\": 30,\n" + > > > " \"expPoints\": 84,\n" + > > > " \"infPoints\": 354087,\n" + > > > " \"revisionDate\": 1477666556000\n" + > > > " },\n" + > > > " {\n" + > > > " \"id\": 5377433,\n" + > > > " \"accountId\": 202697921,\n" + > > > " \"name\": \"AcEcolton35\",\n" + > > > " \"profileIconId\": 984,\n" + > > > " \"level\": 25,\n" + > > > " \"expPoints\": 751,\n" + > > > " \"infPoints\": 30061,\n" + > > > " \"revisionDate\": 1475503024000\n" + > > > " },\n" + > > > " {\n" + > > > " \"id\": 2381404,\n" + > > > " \"accountId\": 200333680,\n" + > > > " \"name\": \"adafakaaa\",\n" + > > > " \"profileIconId\": 663,\n" + > > > " \"level\": 30,\n" + > > > " \"expPoints\": 8,\n" + > > > " \"infPoints\": 534204,\n" + > > > " \"revisionDate\": 1480719827000\n" + > > > " },\n" + > > > " {\n" + > > > " \"id\": 1281203,\n" + > > > " \"accountId\": 1259342,\n" + > > > " \"name\": \"AC Klondike\",\n" + > > > " \"profileIconId\": 898,\n" + > > > " \"level\": 30,\n" + > > > " \"expPoints\": 27,\n" + > > > " \"infPoints\": 191429,\n" + > > > " \"revisionDate\": 1480294973000\n" + > > > " },\n" + > > > " {\n" + > > > " \"id\": 13161471,\n" + > > > " \"accountId\": 207847181,\n" + > > > " \"name\": \"adar21\",\n" + > > > " \"profileIconId\": 26,\n" + > > > " \"level\": 10,\n" + > > > " \"expPoints\": 143,\n" + > > > " \"infPoints\": 3558,\n" + > > > " \"revisionDate\": 1476529855000\n" + > > > " },\n" + > > > " {\n" + > > > " \"id\": 5841915,\n" + > > > " \"accountId\": 202998794,\n" + > > > " \"name\": \"Achilles29\",\n" + > > > " \"profileIconId\": 666,\n" + > > > " \"level\": 30,\n" + > > > " \"expPoints\": 41,\n" + > > > " \"infPoints\": 219714,\n" + > > > " \"revisionDate\": 1480777744000\n" + > > > " },\n" + > > > " {\n" + > > > " \"id\": 2853062,\n" + > > > " \"accountId\": 200726707,\n" + > > > " \"name\": \"AbIanStarBebegim\",\n" + > > > " \"profileIconId\": 909,\n" + > > > " \"level\": 30,\n" + > > > " \"expPoints\": 64,\n" + > > > " \"infPoints\": 297580,\n" + > > > " \"revisionDate\": 1480556859000\n" + > > > " },\n" + > > > " {\n" + > > > " \"id\": 8323114,\n" + > > > " \"accountId\": 205093515,\n" + > > > " \"name\": \"Absuruk\",\n" + > > > " \"profileIconId\": 6,\n" + > > > " \"level\": 30,\n" + > > > " \"expPoints\": 21,\n" + > > > " \"infPoints\": 121086,\n" + > > > " \"revisionDate\": 1480820801000\n" + > > > " }\n" + > > > "]" > > > > > > On Wed, Dec 7, 2016 at 7:01 AM, Hannes Walln?fer wrote: > > > Hi Jesus, > > > > > > I?m trying to reproduce the problem, and just want to make sure I get the missing pieces right. > > > > > > You already showed us how you?re setting up the engine and the JS code you?re running. I assume the JSON code you?re parsing is a simple array of objects? And you?re just calling Invocable.invokeFunction on the ScriptEngine from multiple threads in parallel, right? > > > > > > Thanks, > > > Hannes > > > > > > > > > > Am 07.12.2016 um 00:03 schrieb Jesus Luzon : > > > > > > > > When we share one invocable across many threads and run invokeFunction it > > > > happens, such as this: > > > > > > > > ExecutorService executor = Executors.newFixedThreadPool(50); > > > >> > > > >> Invocable invocable = generateInvocable(script); > > > >> > > > >> AtomicLong count = new AtomicLong(); > > > >> > > > >> for (int i = 0; i < 50; i++) { > > > >> > > > >> executor.submit(new Runnable() { > > > >> > > > >> @Override > > > >> > > > >> public void run() { > > > >> > > > >> try { > > > >> > > > >> while(true) { > > > >> > > > >> invocable.invokeFunction("transform", > > > >>> something); > > > >> > > > >> count.incrementAndGet(); > > > >> > > > >> } > > > >> > > > >> } catch (NoSuchMethodException | ScriptException > > > >>> e) { > > > >> > > > >> e.printStackTrace(); > > > >> > > > >> } > > > >> > > > >> } > > > >> > > > >> }); > > > >> > > > >> } > > > >> > > > >> > > > > > > > > > > > > On Tue, Dec 6, 2016 at 2:59 PM, Jim Laskey (Oracle) > > >> wrote: > > > > > > > >> Intersting. The example you posted demonstrates this behaviour? If so > > > >> I?ll file a bug and dig in. It sounds like an object is being reused > > > >> across invocations and accumulating changes to the property map. > > > >> > > > >> ? Jim > > > >> > > > >> > > > >> On Dec 6, 2016, at 5:12 PM, Jesus Luzon wrote: > > > >> > > > >> With more threads you are impacting the same 8 cores, so it will taper off > > > >>> after 8 threads. If it?s a 2x4 core machine then I can see 4 being a > > > >>> threshold depending on System performance. Transport: I meant if you were > > > >>> using sockets to provide the script. > > > >> > > > >> This makes sense. This one's on me then. > > > >> > > > >> > > > >>> So you are using the same invocable instance for all threads? If so, > > > >>> then you are probably good to go. As far as leaks are concerned, not sure > > > >>> how you would get leaks from Nashorn. The JSON object is written in Java, > > > >>> and little JavaScript involved. > > > >> > > > >> > > > >> > > > >>> In your example, pull up Invocable invocable = generateInvocable(script); > > > >>> out of the loop and use the same invocable for all threads. > > > >> > > > >> > > > >> We were using one invocable across all threads and we were getting > > > >> slowdowns on execution, high CPU Usage and memory leaks that led to > > > >> OutOfMemory errors. I could trace the leak to > > > >> > > > >> jdk.nashorn.internal.objects.Global -> *objectSpill* Object[8] -> > > > >> jdk.nashorn.internal.scripts.JO4 -> *arrayData* > > > >> jdk.nashorn.internal.runtime.arrays.SparseArraysData -> *underlying* > > > >> jdk.nashorn.internal.runtime.arrays.DeletedArrayFilter > > > >> > > > >> which just keeps growing forever. > > > >> > > > >> On Tue, Dec 6, 2016 at 6:30 AM, Jim Laskey (Oracle) < > > > >> james.laskey at oracle.com> wrote: > > > >> > > > >>> > > > >>> On Dec 6, 2016, at 9:56 AM, Jesus Luzon wrote: > > > >>> > > > >>> The cost of creating a new engine is significant. So share an engine > > > >>>> across threads but use *eval > > > >>>> * > > > >>>> (String > > > >>>> > > > >>>> script, ScriptContext > > > >>>> > > > >>>> context) instead, separate context per execution. If your JavaScript > > > >>>> code does not modify globals you can get away with using the same engine, > > > >>>> same compiled script on each thread. > > > >>> > > > >>> > > > >>> I guess there's a few things here I don't understand. One thing I'm > > > >>> trying to do is sharing a CompiledScript (which is why I'm using > > > >>> invocable). Also, what exactly does modify globals mean? All our filters do > > > >>> the same thing, make a function that takes a JSON String, turns it into a > > > >>> JSON, modifies it and then stringifies it back. No state is changed of > > > >>> anything else but there are temporary vars created inside the scope of the > > > >>> function. When we run this multithreaded, running invokeFunction slows down > > > >>> significantly and we get crazy memory leaks. > > > >>> > > > >>> > > > >>> So you are using the same invocable instance for all threads? If so, > > > >>> then you are probably good to go. As far as leaks are concerned, not sure > > > >>> how you would get leaks from Nashorn. The JSON object is written in Java, > > > >>> and little JavaScript involved. > > > >>> > > > >>> > > > >>> Of course there are many factors involved n performance. How many cores > > > >>>> do you have on the test machine? How much memory in the process? What > > > >>>> transport are you using between threads? That sort of thing. Other than > > > >>>> constructing then engine and context Nashorn performance should scale. > > > >>> > > > >>> I'm using an 8 core machine to test with 2.5Gs of RAM allocated to the > > > >>> process. Not sure what transports between threads means, but this is the > > > >>> code I'm benchmarking with. Increasing the number of threads actually makes > > > >>> it go faster until about 4 threads, then adding more threads takes the same > > > >>> amount to get to 1000 and and after a certain point it is just slower to > > > >>> get to 1000 counts. Some of our filters need to be able to run over 1000 > > > >>> times a second (across all threads) and the fastest time I could actually > > > >>> get with this was about 2.4 seconds for a 1000 counts. > > > >>> > > > >>>> ExecutorService executor = Executors.newFixedThreadPool(50); > > > >>>> > > > >>>> AtomicLong count = new AtomicLong(); > > > >>>> > > > >>>> for (int i = 0; i < 50; i++) { > > > >>>> > > > >>>> executor.submit(new Runnable() { > > > >>>> > > > >>>> @Override > > > >>>> > > > >>>> public void run() { > > > >>>> > > > >>>> > > > >>>>> try { > > > >>>> > > > >>>> Invocable invocable = > > > >>>>> generateInvocable(script); > > > >>>> > > > >>>> while(true) { > > > >>>> > > > >>>> invocable.invokeFunction("transform", > > > >>>>> something); > > > >>>> > > > >>>> count.incrementAndGet(); > > > >>>> > > > >>>> } > > > >>>> > > > >>>> } catch (NoSuchMethodException | ScriptException > > > >>>>> e) { > > > >>>> > > > >>>> e.printStackTrace(); > > > >>>> > > > >>>> } > > > >>>> > > > >>>> } > > > >>>> > > > >>>> }); > > > >>>> > > > >>>> } > > > >>>> > > > >>>> long lastTimestamp = System.currentTimeMillis(); > > > >>>> > > > >>>> while(true) { > > > >>>> > > > >>>> > > > >>>>> if (count.get() > 1000) { > > > >>>> > > > >>>> count.getAndAdd(-1000); > > > >>>> > > > >>>> System.out.println((System.currentTimeMillis() - > > > >>>>> lastTimestamp)/1000.0); > > > >>>> > > > >>>> lastTimestamp = System.currentTimeMillis(); > > > >>>> > > > >>>> } > > > >>>> > > > >>>> } > > > >>>> > > > >>>> > > > >>> With more threads you are impacting the same 8 cores, so it will taper > > > >>> off after 8 threads. If it?s a 2x4 core machine then I can see 4 being a > > > >>> threshold depending on System performance. Transport: I meant if you were > > > >>> using sockets to provide the script. > > > >>> > > > >>> In your example, pull up Invocable invocable = generateInvocable(script); > > > >>> out of the loop and use the same invocable for all threads. > > > >>> > > > >>> - Jim > > > >>> > > > >>> > > > >>> > > > >>> > > > >>> On Tue, Dec 6, 2016 at 5:31 AM, Jim Laskey (Oracle) < > > > >>> james.laskey at oracle.com> wrote: > > > >>> > > > >>>> > > > >>>> On Dec 6, 2016, at 9:19 AM, Jesus Luzon wrote: > > > >>>> > > > >>>> Hey Jim, > > > >>>> > > > >>>> I looked at it and I will look into loadWithNewGlobal to see what > > > >>>> exactly it does since it could be relevant. As for the rest, for my use > > > >>>> case having threads in the JS would not help. We're using Nashorn to build > > > >>>> JSON filters in a Dynamic Proxy Service and need any of the threads > > > >>>> processing a request to be able to execute the script to filter. > > > >>>> > > > >>>> > > > >>>> The cost of creating a new engine is significant. So share an engine > > > >>>> across threads but use *eval > > > >>>> * > > > >>>> (String > > > >>>> > > > >>>> script, ScriptContext > > > >>>> > > > >>>> context) instead, separate context per execution. If your JavaScript > > > >>>> code does not modify globals you can get away with using the same engine, > > > >>>> same compiled script on each thread. > > > >>>> > > > >>>> > > > >>>> Also, when you say a new engine per threads is the worst case what > > > >>>> exactly do you mean? I would expect an initial cost of compiling the script > > > >>>> on each thread and then each engine should be able to do its own thing, but > > > >>>> what I'm seeing is that when running with more than 10 threads all my > > > >>>> engines get slow at executing code, even though they are all completely > > > >>>> separate from each other. > > > >>>> > > > >>>> > > > >>>> Of course there are many factors involved n performance. How many cores > > > >>>> do you have on the test machine? How much memory in the process? What > > > >>>> transport are you using between threads? That sort of thing. Other than > > > >>>> constructing then engine and context Nashorn performance should scale. > > > >>>> > > > >>>> > > > >>>> On Tue, Dec 6, 2016 at 5:07 AM, Jim Laskey (Oracle) < > > > >>>> james.laskey at oracle.com> wrote: > > > >>>> > > > >>>>> Jesus, > > > >>>>> > > > >>>>> Probably the most informative information is in this blog. > > > >>>>> > > > >>>>> https://blogs.oracle.com/nashorn/entry/nashorn_multi_threading_and_mt > > > >>>>> > > > >>>>> This example uses Executors but threads would work as well. > > > >>>>> > > > >>>>> I did a talk that looked at different methods to max out multithreading > > > >>>>> performance. A new engine per thread is the worst case. A new context per > > > >>>>> thread does much better. A new global per thread is the best while > > > >>>>> remaining thread safe. > > > >>>>> > > > >>>>> Cheers, > > > >>>>> > > > >>>>> ? Jim > > > >>>>> > > > >>>>> > > > >>>>> > > > >>>>> > > > >>>>> > > > >>>>> On Dec 6, 2016, at 8:45 AM, Jesus Luzon wrote: > > > >>>>> > > > >>>>> Hey folks, > > > >>>>> > > > >>>>> I've tried many different ways of using Nashorn multithreaded based on > > > >>>>> what > > > >>>>> I've found on the internet and I still can't get a single one to scale. > > > >>>>> Even the most naive method of making many script engines with my script > > > >>>>> tends to bottleneck itself when I have more than 10 threads invoking > > > >>>>> functions. > > > >>>>> > > > >>>>> I'm using the following code to compile my script and > > > >>>>> invocable.invokeFunction("transform", input) to execute: > > > >>>>> > > > >>>>> static Invocable generateInvocable(String script) throws > > > >>>>> ScriptException { > > > >>>>> ScriptEngineManager manager = new ScriptEngineManager(); > > > >>>>> ScriptEngine engine = > > > >>>>> manager.getEngineByName(JAVASCRIPT_ENGINE_NAME); > > > >>>>> Compilable compilable = (Compilable) engine; > > > >>>>> final CompiledScript compiled = compilable.compile(script); > > > >>>>> compiled.eval(); > > > >>>>> return (Invocable) engine; > > > >>>>> } > > > >>>>> > > > >>>>> > > > >>>>> > > > >>>>> The script I'm compiling is: > > > >>>>> > > > >>>>> String script = "function transform(input) {" + > > > >>>>> "var result = JSON.parse(input);" + > > > >>>>> "response = {};\n" + > > > >>>>> "for (var i = 0; i < result.length; i++) {\n" + > > > >>>>> " var summoner = {};\n" + > > > >>>>> " summoner.id = result[i].id;\n" + > > > >>>>> " summoner.name = result[i].name;\n" + > > > >>>>> " summoner.profileIconId = > > > >>>>> result[i].profileIconId;\n" + > > > >>>>> " summoner.revisionDate = result[i].revisionDate;\n" + > > > >>>>> " summoner.summonerLevel = result[i].level;\n" + > > > >>>>> " response[summoner.id] = summoner;\n" + > > > >>>>> "}\n" + > > > >>>>> "result = response;" + > > > >>>>> "return JSON.stringify(result);" + > > > >>>>> "};"; > > > >>>>> > > > >>>>> > > > >>>>> > > > >>>>> I've also tried other more scaleable ways to work with scripts > > > >>>>> concurrently, but given that this is the most naive method where > > > >>>>> everything > > > >>>>> is brand new and I still get slowness calling them concurrently I fear > > > >>>>> that > > > >>>>> maybe I'm overlooking something extremely basic on my code. > > > >>>>> > > > >>>>> Thanks. > > > >>>>> -Jesus Luzon > > > >>>>> > > > >>>>> > > > >>>> > > > >>> > > > >>> > > > >> > > > >> > > > > > > > > > > > > > > > > > > From sundararajan.athijegannathan at oracle.com Tue Jan 10 08:45:28 2017 From: sundararajan.athijegannathan at oracle.com (Sundararajan Athijegannathan) Date: Tue, 10 Jan 2017 14:15:28 +0530 Subject: RFR 8172493: Nashorn FX example 3-4 using load for fx: scripts fails to run with latest jdk9 ea build Message-ID: <58749F28.3010406@oracle.com> Please review http://cr.openjdk.java.net/~sundar/8172493/webrev.00/ for https://bugs.openjdk.java.net/browse/JDK-8172493 PS. I've not added an automated test because of javafx dependency [and the tests need to be run on openjdk builds as well]. I manually tested the fix using --patch-module option to replace build's nashorn classes with those of nashorn repo with the fix. The test shows the javafx window with a button as expected. Thanks, -Sundar From hannes.wallnoefer at oracle.com Tue Jan 10 08:38:18 2017 From: hannes.wallnoefer at oracle.com (=?utf-8?Q?Hannes_Walln=C3=B6fer?=) Date: Tue, 10 Jan 2017 09:38:18 +0100 Subject: RFR 8172493: Nashorn FX example 3-4 using load for fx: scripts fails to run with latest jdk9 ea build In-Reply-To: <58749F28.3010406@oracle.com> References: <58749F28.3010406@oracle.com> Message-ID: <2884BB65-2EA0-4AFD-8E47-ACE22D5E87E3@oracle.com> +1 Hannes > Am 10.01.2017 um 09:45 schrieb Sundararajan Athijegannathan : > > Please review http://cr.openjdk.java.net/~sundar/8172493/webrev.00/ for https://bugs.openjdk.java.net/browse/JDK-8172493 > > PS. I've not added an automated test because of javafx dependency [and the tests need to be run on openjdk builds as well]. I manually tested the fix using --patch-module option to replace build's nashorn classes with those of nashorn repo with the fix. The test shows the javafx window with a button as expected. > > Thanks, > -Sundar From james.laskey at oracle.com Tue Jan 10 12:32:32 2017 From: james.laskey at oracle.com (Jim Laskey (Oracle)) Date: Tue, 10 Jan 2017 08:32:32 -0400 Subject: RFR 8172493: Nashorn FX example 3-4 using load for fx: scripts fails to run with latest jdk9 ea build In-Reply-To: <58749F28.3010406@oracle.com> References: <58749F28.3010406@oracle.com> Message-ID: <930CC909-24BF-4C78-AC21-390415A83D1C@oracle.com> +1 > On Jan 10, 2017, at 4:45 AM, Sundararajan Athijegannathan wrote: > > Please review http://cr.openjdk.java.net/~sundar/8172493/webrev.00/ for https://bugs.openjdk.java.net/browse/JDK-8172493 > > PS. I've not added an automated test because of javafx dependency [and the tests need to be run on openjdk builds as well]. I manually tested the fix using --patch-module option to replace build's nashorn classes with those of nashorn repo with the fix. The test shows the javafx window with a button as expected. > > Thanks, > -Sundar From hannes.wallnoefer at oracle.com Tue Jan 10 14:50:00 2017 From: hannes.wallnoefer at oracle.com (=?utf-8?Q?Hannes_Walln=C3=B6fer?=) Date: Tue, 10 Jan 2017 15:50:00 +0100 Subject: RFR: 8166187: Regression: NPE during reparse when using persistent code cache and optimistic types In-Reply-To: <6EADC1F8-634B-44F8-84CD-013A1170F298@oracle.com> References: <9B0F648B-71AE-432F-87BA-EB8647780427@oracle.com> <6EADC1F8-634B-44F8-84CD-013A1170F298@oracle.com> Message-ID: <460BDD44-A51F-451A-B4C4-47BCABCFF6C2@oracle.com> I just realized I used the wrong bug id for the second webrev linked below. Here?s the webrev again, with the correct id: http://cr.openjdk.java.net/~hannesw/8166187/webrev.01/ Hannes > Am 23.12.2016 um 12:20 schrieb Hannes Walln?fer : > > Thanks Attila, I had forgotten cached AST is not just a performance feature. > > I uploaded a new webrev. It pretty much follows your suggestions, except I used a slightly different approach to conditional serialization of cachedAst - I left the field transient and serialize it explicitly if it is an instance of SerializedAst, otherwise write out null. I also added a test case for split stored functions. > > http://cr.openjdk.java.net/~hannesw/8170977/webrev.01/ > > Hannes > > >> Am 22.12.2016 um 16:48 schrieb Attila Szegedi : >> >> Hm? cachedAst is essential for split functions; specifically if it contains a SerializedAst, then its "byte[] serializedAst" field is essential. If cachedAst is lost, we can reparse an unsplit function from source, but we can?t reparse fragments of split functions. >> >> I?d suggest instead of making cachedAst transient, we should: >> 1. make SerializedAst Serializable, and have SerializedAst.cachedAst within it transient (reference objects aren?t serializable, and we can afford to lose it anyway). >> 2. introduce RecompilableScriptFunctionData.writeObject and make sure that if serializedAst contains a reference (instead of a SerializedAst object) then we don?t attempt to serialize it ? write null instead (this can be accomplished by just setting serializedAst = null, and maybe re-setting it back to what it was after defaultWriteObject) >> 3. make sure there?s a null check on SerializedAst.cachedAst read in getCachedAst() (as now it can actually be null on deserialization, it was an invariant that it was never null before) >> >> Attila. >> >>> On 22 Dec 2016, at 16:18, Hannes Walln?fer wrote: >>> >>> Please review: >>> >>> Bug: https://bugs.openjdk.java.net/browse/JDK-8166187 >>> Webrev: http://cr.openjdk.java.net/~hannesw/8166187/webrev/ >>> >>> It was actually the combination of having a non-serialisable AST reference and not initialising the transient fields of nested functions that caused this error. >>> >>> Thanks, >>> Hannes >> > From james.laskey at oracle.com Tue Jan 10 15:00:18 2017 From: james.laskey at oracle.com (Jim Laskey (Oracle)) Date: Tue, 10 Jan 2017 11:00:18 -0400 Subject: RFR: 8166187: Regression: NPE during reparse when using persistent code cache and optimistic types In-Reply-To: <460BDD44-A51F-451A-B4C4-47BCABCFF6C2@oracle.com> References: <9B0F648B-71AE-432F-87BA-EB8647780427@oracle.com> <6EADC1F8-634B-44F8-84CD-013A1170F298@oracle.com> <460BDD44-A51F-451A-B4C4-47BCABCFF6C2@oracle.com> Message-ID: +1 > On Jan 10, 2017, at 10:50 AM, Hannes Walln?fer wrote: > > I just realized I used the wrong bug id for the second webrev linked below. Here?s the webrev again, with the correct id: > > http://cr.openjdk.java.net/~hannesw/8166187/webrev.01/ > > Hannes > >> Am 23.12.2016 um 12:20 schrieb Hannes Walln?fer : >> >> Thanks Attila, I had forgotten cached AST is not just a performance feature. >> >> I uploaded a new webrev. It pretty much follows your suggestions, except I used a slightly different approach to conditional serialization of cachedAst - I left the field transient and serialize it explicitly if it is an instance of SerializedAst, otherwise write out null. I also added a test case for split stored functions. >> >> http://cr.openjdk.java.net/~hannesw/8170977/webrev.01/ >> >> Hannes >> >> >>> Am 22.12.2016 um 16:48 schrieb Attila Szegedi : >>> >>> Hm? cachedAst is essential for split functions; specifically if it contains a SerializedAst, then its "byte[] serializedAst" field is essential. If cachedAst is lost, we can reparse an unsplit function from source, but we can?t reparse fragments of split functions. >>> >>> I?d suggest instead of making cachedAst transient, we should: >>> 1. make SerializedAst Serializable, and have SerializedAst.cachedAst within it transient (reference objects aren?t serializable, and we can afford to lose it anyway). >>> 2. introduce RecompilableScriptFunctionData.writeObject and make sure that if serializedAst contains a reference (instead of a SerializedAst object) then we don?t attempt to serialize it ? write null instead (this can be accomplished by just setting serializedAst = null, and maybe re-setting it back to what it was after defaultWriteObject) >>> 3. make sure there?s a null check on SerializedAst.cachedAst read in getCachedAst() (as now it can actually be null on deserialization, it was an invariant that it was never null before) >>> >>> Attila. >>> >>>> On 22 Dec 2016, at 16:18, Hannes Walln?fer wrote: >>>> >>>> Please review: >>>> >>>> Bug: https://bugs.openjdk.java.net/browse/JDK-8166187 >>>> Webrev: http://cr.openjdk.java.net/~hannesw/8166187/webrev/ >>>> >>>> It was actually the combination of having a non-serialisable AST reference and not initialising the transient fields of nested functions that caused this error. >>>> >>>> Thanks, >>>> Hannes >>> >> > From szegedia at gmail.com Tue Jan 10 15:04:15 2017 From: szegedia at gmail.com (Attila Szegedi) Date: Tue, 10 Jan 2017 16:04:15 +0100 Subject: RFR: 8166187: Regression: NPE during reparse when using persistent code cache and optimistic types In-Reply-To: <460BDD44-A51F-451A-B4C4-47BCABCFF6C2@oracle.com> References: <9B0F648B-71AE-432F-87BA-EB8647780427@oracle.com> <6EADC1F8-634B-44F8-84CD-013A1170F298@oracle.com> <460BDD44-A51F-451A-B4C4-47BCABCFF6C2@oracle.com> Message-ID: +1 > On 10 Jan 2017, at 15:50, Hannes Walln?fer wrote: > > I just realized I used the wrong bug id for the second webrev linked below. Here?s the webrev again, with the correct id: > > http://cr.openjdk.java.net/~hannesw/8166187/webrev.01/ > > Hannes > >> Am 23.12.2016 um 12:20 schrieb Hannes Walln?fer : >> >> Thanks Attila, I had forgotten cached AST is not just a performance feature. >> >> I uploaded a new webrev. It pretty much follows your suggestions, except I used a slightly different approach to conditional serialization of cachedAst - I left the field transient and serialize it explicitly if it is an instance of SerializedAst, otherwise write out null. I also added a test case for split stored functions. >> >> http://cr.openjdk.java.net/~hannesw/8170977/webrev.01/ >> >> Hannes >> >> >>> Am 22.12.2016 um 16:48 schrieb Attila Szegedi : >>> >>> Hm? cachedAst is essential for split functions; specifically if it contains a SerializedAst, then its "byte[] serializedAst" field is essential. If cachedAst is lost, we can reparse an unsplit function from source, but we can?t reparse fragments of split functions. >>> >>> I?d suggest instead of making cachedAst transient, we should: >>> 1. make SerializedAst Serializable, and have SerializedAst.cachedAst within it transient (reference objects aren?t serializable, and we can afford to lose it anyway). >>> 2. introduce RecompilableScriptFunctionData.writeObject and make sure that if serializedAst contains a reference (instead of a SerializedAst object) then we don?t attempt to serialize it ? write null instead (this can be accomplished by just setting serializedAst = null, and maybe re-setting it back to what it was after defaultWriteObject) >>> 3. make sure there?s a null check on SerializedAst.cachedAst read in getCachedAst() (as now it can actually be null on deserialization, it was an invariant that it was never null before) >>> >>> Attila. >>> >>>> On 22 Dec 2016, at 16:18, Hannes Walln?fer wrote: >>>> >>>> Please review: >>>> >>>> Bug: https://bugs.openjdk.java.net/browse/JDK-8166187 >>>> Webrev: http://cr.openjdk.java.net/~hannesw/8166187/webrev/ >>>> >>>> It was actually the combination of having a non-serialisable AST reference and not initialising the transient fields of nested functions that caused this error. >>>> >>>> Thanks, >>>> Hannes >>> >> > From hannes.wallnoefer at oracle.com Wed Jan 11 16:39:47 2017 From: hannes.wallnoefer at oracle.com (=?utf-8?Q?Hannes_Walln=C3=B6fer?=) Date: Wed, 11 Jan 2017 17:39:47 +0100 Subject: [8u-dev] Request for Approval: 8171219: Missing checks in sparse array shift() implementation Message-ID: <21A13103-D9CC-4908-A53D-A8495DFF6821@oracle.com> Please approve backport to 8u-dev: Bug: https://bugs.openjdk.java.net/browse/JDK-8171219 JDK9 Webrev: http://cr.openjdk.java.net/~hannesw/8171219/webrev/ JDK8u Webrev: http://cr.openjdk.java.net/~hannesw/8171219/webrev-8u/ Review thread: http://mail.openjdk.java.net/pipermail/nashorn-dev/2016-December/006737.html The patch applied cleanly to 8u except for SparseArrayData.java, where explicit boxing/unboxing of long values has been removed in JDK9. I preserved the boxing/unboxing in the backport to keep it consistent. Thanks, Hannes From james.laskey at oracle.com Wed Jan 11 16:45:28 2017 From: james.laskey at oracle.com (Jim Laskey (Oracle)) Date: Wed, 11 Jan 2017 12:45:28 -0400 Subject: [8u-dev] Request for Approval: 8171219: Missing checks in sparse array shift() implementation In-Reply-To: <21A13103-D9CC-4908-A53D-A8495DFF6821@oracle.com> References: <21A13103-D9CC-4908-A53D-A8495DFF6821@oracle.com> Message-ID: <4E71ECBF-D59E-4D6A-B308-98AD31E43B06@oracle.com> +1 > On Jan 11, 2017, at 12:39 PM, Hannes Walln?fer wrote: > > Please approve backport to 8u-dev: > > Bug: https://bugs.openjdk.java.net/browse/JDK-8171219 > JDK9 Webrev: http://cr.openjdk.java.net/~hannesw/8171219/webrev/ > JDK8u Webrev: http://cr.openjdk.java.net/~hannesw/8171219/webrev-8u/ > Review thread: http://mail.openjdk.java.net/pipermail/nashorn-dev/2016-December/006737.html > > The patch applied cleanly to 8u except for SparseArrayData.java, where explicit boxing/unboxing of long values has been removed in JDK9. I preserved the boxing/unboxing in the backport to keep it consistent. > > Thanks, > Hannes From rob.mckenna at oracle.com Wed Jan 11 16:47:54 2017 From: rob.mckenna at oracle.com (Rob McKenna) Date: Wed, 11 Jan 2017 16:47:54 +0000 Subject: [8u-dev] Request for Approval: 8171219: Missing checks in sparse array shift() implementation In-Reply-To: <4E71ECBF-D59E-4D6A-B308-98AD31E43B06@oracle.com> References: <21A13103-D9CC-4908-A53D-A8495DFF6821@oracle.com> <4E71ECBF-D59E-4D6A-B308-98AD31E43B06@oracle.com> Message-ID: <20170111164754.GB3721@tecra> Approved -Rob On 11/01/17 12:45, Jim Laskey (Oracle) wrote: > +1 > > > On Jan 11, 2017, at 12:39 PM, Hannes Walln?fer wrote: > > > > Please approve backport to 8u-dev: > > > > Bug: https://bugs.openjdk.java.net/browse/JDK-8171219 > > JDK9 Webrev: http://cr.openjdk.java.net/~hannesw/8171219/webrev/ > > JDK8u Webrev: http://cr.openjdk.java.net/~hannesw/8171219/webrev-8u/ > > Review thread: http://mail.openjdk.java.net/pipermail/nashorn-dev/2016-December/006737.html > > > > The patch applied cleanly to 8u except for SparseArrayData.java, where explicit boxing/unboxing of long values has been removed in JDK9. I preserved the boxing/unboxing in the backport to keep it consistent. > > > > Thanks, > > Hannes > From am at iit.de Wed Jan 11 17:39:52 2017 From: am at iit.de (Andreas Mueller) Date: Wed, 11 Jan 2017 18:39:52 +0100 Subject: binding issues Message-ID: <7DECE433-81F5-4578-A52B-561B9A039F9B@iit.de> Hi, it seems I have a problem understanding Nashorn?s bindings... I have multiple scripts, each independent of each other. They should run concurrently with their own context and engine scope bindings. This is created as follows for each script: ScriptEngineManager manager = new ScriptEngineManager(); ScriptEngine engine = manager.getEngineByName((String) entity.getProperty("script-language").getValue()); if (engine == null) throw new Exception("Engine for script-language '" + entity.getProperty("script-language").getValue() + "' not found!"); ScriptContext newContext = new SimpleScriptContext(); streamContext.engineScope = newContext.getBindings(ScriptContext.ENGINE_SCOPE); Internally we have a Java-based processor which calls Javascript functions (callbacks). It is always the same thread. It works fine when I start a script the first time. If I stop it (without stopping the JVM) and restart it (it runs through the code above) or if I run another script concurrently, I?m getting problems in so far that calls inside a Javascript callback to Java objects that set data don?t work. The data is not null on the Javascript callback but null inside the Java method. Here is an example callback: stream.create().memoryGroup("queues", "name").onCreate(function (memoryGroup, key) { stream.create().memory(key); print("Add:"+ key+"="+stream.memory(key)); }); The above ?stream.create().memory(key)? is a Java method that has a printout: AddMem: orderpos, mem=HeapMemory{name='orderpos?} But when I retrieve it with "stream.memory(key)? in the print statement of the Javascript function I?m getting: Add:orderpos=null For me this points to the bindings, e.g. a binding from a previous running instance of the script or something else. Can somebody provide some help? What do I need to do to have always a clean instance of a binding when I rerun a script without stopping the JVM? Thanks, Andreas -- Andreas Mueller IIT Software GmbH http://www.swiftmq.com IIT Software GmbH M?nsterstr. 111, 48145 M?nster, Germany Phone: +49 (0)2506 3049340 Managing Director: Andreas M?ller District Court: Amtsgericht M?nster, HRB 16294 VAT-No: DE199945912 This e-mail may contain confidential and/or privileged information. If you are not the intended recipient (or have received this e-mail in error) please notify the sender immediately and destroy this e-mail. Any unauthorized copying, disclosure or distribution of the material in this e-mail is strictly forbidden. From sundararajan.athijegannathan at oracle.com Thu Jan 12 04:23:57 2017 From: sundararajan.athijegannathan at oracle.com (Sundararajan Athijegannathan) Date: Thu, 12 Jan 2017 09:53:57 +0530 Subject: binding issues In-Reply-To: <7DECE433-81F5-4578-A52B-561B9A039F9B@iit.de> References: <7DECE433-81F5-4578-A52B-561B9A039F9B@iit.de> Message-ID: <587704DD.3070004@oracle.com> Will you please submit a bug with a compilable/runnable test case attached? Thanks, -Sundar On 11/01/17, 11:09 PM, Andreas Mueller wrote: > Hi, > > it seems I have a problem understanding Nashorn?s bindings... > > I have multiple scripts, each independent of each other. They should run concurrently with their own context and engine scope bindings. This is created as follows for each script: > > ScriptEngineManager manager = new ScriptEngineManager(); > ScriptEngine engine = manager.getEngineByName((String) entity.getProperty("script-language").getValue()); > if (engine == null) > throw new Exception("Engine for script-language '" + entity.getProperty("script-language").getValue() + "' not found!"); > ScriptContext newContext = new SimpleScriptContext(); > streamContext.engineScope = newContext.getBindings(ScriptContext.ENGINE_SCOPE); > > Internally we have a Java-based processor which calls Javascript functions (callbacks). It is always the same thread. > > It works fine when I start a script the first time. If I stop it (without stopping the JVM) and restart it (it runs through the code above) or if I run another script concurrently, I?m getting problems in so far that calls inside a Javascript callback to Java objects that set data don?t work. The data is not null on the Javascript callback but null inside the Java method. > > Here is an example callback: > > stream.create().memoryGroup("queues", "name").onCreate(function (memoryGroup, key) { > stream.create().memory(key); > print("Add:"+ key+"="+stream.memory(key)); > }); > > The above ?stream.create().memory(key)? is a Java method that has a printout: > > AddMem: orderpos, mem=HeapMemory{name='orderpos?} > > But when I retrieve it with "stream.memory(key)? in the print statement of the Javascript function I?m getting: > > Add:orderpos=null > > For me this points to the bindings, e.g. a binding from a previous running instance of the script or something else. Can somebody provide some help? What do I need to do to have always a clean instance of a binding when I rerun a script without stopping the JVM? > > Thanks, > Andreas > From am at iit.de Thu Jan 12 08:12:53 2017 From: am at iit.de (Andreas Mueller) Date: Thu, 12 Jan 2017 09:12:53 +0100 Subject: binding issues In-Reply-To: <587704DD.3070004@oracle.com> References: <7DECE433-81F5-4578-A52B-561B9A039F9B@iit.de> <587704DD.3070004@oracle.com> Message-ID: <5CAE16F9-6A66-442B-AB52-635DB8DE550A@iit.de> Will do. Can you tell me whether the engine is shared between scripts? Is there a way to use one engine per script and to start absolute clean (no caches, no refs from previous runs) just like when the JVM was started? Thanks, Andreas > Am 12.01.2017 um 05:23 schrieb Sundararajan Athijegannathan : > > Will you please submit a bug with a compilable/runnable test case attached? > > Thanks, > -Sundar > >> On 11/01/17, 11:09 PM, Andreas Mueller wrote: >> Hi, >> >> it seems I have a problem understanding Nashorn?s bindings... >> >> I have multiple scripts, each independent of each other. They should run concurrently with their own context and engine scope bindings. This is created as follows for each script: >> >> ScriptEngineManager manager = new ScriptEngineManager(); >> ScriptEngine engine = manager.getEngineByName((String) entity.getProperty("script-language").getValue()); >> if (engine == null) >> throw new Exception("Engine for script-language '" + entity.getProperty("script-language").getValue() + "' not found!"); >> ScriptContext newContext = new SimpleScriptContext(); >> streamContext.engineScope = newContext.getBindings(ScriptContext.ENGINE_SCOPE); >> >> Internally we have a Java-based processor which calls Javascript functions (callbacks). It is always the same thread. >> >> It works fine when I start a script the first time. If I stop it (without stopping the JVM) and restart it (it runs through the code above) or if I run another script concurrently, I?m getting problems in so far that calls inside a Javascript callback to Java objects that set data don?t work. The data is not null on the Javascript callback but null inside the Java method. >> >> Here is an example callback: >> >> stream.create().memoryGroup("queues", "name").onCreate(function (memoryGroup, key) { >> stream.create().memory(key); >> print("Add:"+ key+"="+stream.memory(key)); >> }); >> >> The above ?stream.create().memory(key)? is a Java method that has a printout: >> >> AddMem: orderpos, mem=HeapMemory{name='orderpos?} >> >> But when I retrieve it with "stream.memory(key)? in the print statement of the Javascript function I?m getting: >> >> Add:orderpos=null >> >> For me this points to the bindings, e.g. a binding from a previous running instance of the script or something else. Can somebody provide some help? What do I need to do to have always a clean instance of a binding when I rerun a script without stopping the JVM? >> >> Thanks, >> Andreas >> IIT Software GmbH M?nsterstr. 111, 48145 M?nster, Germany Phone: +49 (0)2506 3049340 Managing Director: Andreas M?ller District Court: Amtsgericht M?nster, HRB 16294 VAT-No: DE199945912 This e-mail may contain confidential and/or privileged information. If you are not the intended recipient (or have received this e-mail in error) please notify the sender immediately and destroy this e-mail. Any unauthorized copying, disclosure or distribution of the material in this e-mail is strictly forbidden. From sundararajan.athijegannathan at oracle.com Thu Jan 12 10:13:26 2017 From: sundararajan.athijegannathan at oracle.com (Sundararajan Athijegannathan) Date: Thu, 12 Jan 2017 15:43:26 +0530 Subject: binding issues In-Reply-To: <5CAE16F9-6A66-442B-AB52-635DB8DE550A@iit.de> References: <7DECE433-81F5-4578-A52B-561B9A039F9B@iit.de> <587704DD.3070004@oracle.com> <5CAE16F9-6A66-442B-AB52-635DB8DE550A@iit.de> Message-ID: <587756C6.6090304@oracle.com> Not sure what you mean by "engine is shared between scripts". Each separate Nashorn ScriptEngine instance is isolated. Nothing is shared across different script engine instances. There are no java level "statics" (i.e., process wide globals) that cut across engine instances. On the same engine, there is compiled code is shared (.class and Class objects in some cases) when possible. That should also not result in any issue (there may be bugs). Hope I addressed your questions, -Sundar On 12/01/17, 1:42 PM, Andreas Mueller wrote: > Will do. > > Can you tell me whether the engine is shared between scripts? Is there a way to use one engine per script and to start absolute clean (no caches, no refs from previous runs) just like when the JVM was started? > > Thanks, > Andreas > >> Am 12.01.2017 um 05:23 schrieb Sundararajan Athijegannathan: >> >> Will you please submit a bug with a compilable/runnable test case attached? >> >> Thanks, >> -Sundar >> >>> On 11/01/17, 11:09 PM, Andreas Mueller wrote: >>> Hi, >>> >>> it seems I have a problem understanding Nashorn?s bindings... >>> >>> I have multiple scripts, each independent of each other. They should run concurrently with their own context and engine scope bindings. This is created as follows for each script: >>> >>> ScriptEngineManager manager = new ScriptEngineManager(); >>> ScriptEngine engine = manager.getEngineByName((String) entity.getProperty("script-language").getValue()); >>> if (engine == null) >>> throw new Exception("Engine for script-language '" + entity.getProperty("script-language").getValue() + "' not found!"); >>> ScriptContext newContext = new SimpleScriptContext(); >>> streamContext.engineScope = newContext.getBindings(ScriptContext.ENGINE_SCOPE); >>> >>> Internally we have a Java-based processor which calls Javascript functions (callbacks). It is always the same thread. >>> >>> It works fine when I start a script the first time. If I stop it (without stopping the JVM) and restart it (it runs through the code above) or if I run another script concurrently, I?m getting problems in so far that calls inside a Javascript callback to Java objects that set data don?t work. The data is not null on the Javascript callback but null inside the Java method. >>> >>> Here is an example callback: >>> >>> stream.create().memoryGroup("queues", "name").onCreate(function (memoryGroup, key) { >>> stream.create().memory(key); >>> print("Add:"+ key+"="+stream.memory(key)); >>> }); >>> >>> The above ?stream.create().memory(key)? is a Java method that has a printout: >>> >>> AddMem: orderpos, mem=HeapMemory{name='orderpos?} >>> >>> But when I retrieve it with "stream.memory(key)? in the print statement of the Javascript function I?m getting: >>> >>> Add:orderpos=null >>> >>> For me this points to the bindings, e.g. a binding from a previous running instance of the script or something else. Can somebody provide some help? What do I need to do to have always a clean instance of a binding when I rerun a script without stopping the JVM? >>> >>> Thanks, >>> Andreas >>> > > > IIT Software GmbH > M?nsterstr. 111, 48145 M?nster, Germany > Phone: +49 (0)2506 3049340 > Managing Director: Andreas M?ller > District Court: Amtsgericht M?nster, HRB 16294 > VAT-No: DE199945912 > > This e-mail may contain confidential and/or privileged information. If you are not the intended recipient (or have received this e-mail in error) please notify the sender immediately and destroy this e-mail. Any unauthorized copying, disclosure or distribution of the material in this e-mail is strictly forbidden. > > From sundararajan.athijegannathan at oracle.com Thu Jan 12 10:15:35 2017 From: sundararajan.athijegannathan at oracle.com (Sundararajan Athijegannathan) Date: Thu, 12 Jan 2017 15:45:35 +0530 Subject: binding issues In-Reply-To: <587756C6.6090304@oracle.com> References: <7DECE433-81F5-4578-A52B-561B9A039F9B@iit.de> <587704DD.3070004@oracle.com> <5CAE16F9-6A66-442B-AB52-635DB8DE550A@iit.de> <587756C6.6090304@oracle.com> Message-ID: <58775747.6080206@oracle.com> If you face bugs due to sharing of compiled code within the same engine instance, please do report with a test case. -Sundar On 12/01/17, 3:43 PM, Sundararajan Athijegannathan wrote: > Not sure what you mean by "engine is shared between scripts". Each > separate Nashorn ScriptEngine instance is isolated. Nothing is shared > across different script engine instances. There are no java level > "statics" (i.e., process wide globals) that cut across engine > instances. On the same engine, there is compiled code is shared > (.class and Class objects in some cases) when possible. That should > also not result in any issue (there may be bugs). > > Hope I addressed your questions, > -Sundar > > On 12/01/17, 1:42 PM, Andreas Mueller wrote: >> Will do. >> >> Can you tell me whether the engine is shared between scripts? Is >> there a way to use one engine per script and to start absolute clean >> (no caches, no refs from previous runs) just like when the JVM was >> started? >> >> Thanks, >> Andreas >> >>> Am 12.01.2017 um 05:23 schrieb Sundararajan >>> Athijegannathan: >>> >>> Will you please submit a bug with a compilable/runnable test case >>> attached? >>> >>> Thanks, >>> -Sundar >>> >>>> On 11/01/17, 11:09 PM, Andreas Mueller wrote: >>>> Hi, >>>> >>>> it seems I have a problem understanding Nashorn?s bindings... >>>> >>>> I have multiple scripts, each independent of each other. They >>>> should run concurrently with their own context and engine scope >>>> bindings. This is created as follows for each script: >>>> >>>> ScriptEngineManager manager = new ScriptEngineManager(); >>>> ScriptEngine engine = manager.getEngineByName((String) >>>> entity.getProperty("script-language").getValue()); >>>> if (engine == null) >>>> throw new Exception("Engine for script-language '" + >>>> entity.getProperty("script-language").getValue() + "' not found!"); >>>> ScriptContext newContext = new SimpleScriptContext(); >>>> streamContext.engineScope = >>>> newContext.getBindings(ScriptContext.ENGINE_SCOPE); >>>> >>>> Internally we have a Java-based processor which calls Javascript >>>> functions (callbacks). It is always the same thread. >>>> >>>> It works fine when I start a script the first time. If I stop it >>>> (without stopping the JVM) and restart it (it runs through the code >>>> above) or if I run another script concurrently, I?m getting >>>> problems in so far that calls inside a Javascript callback to Java >>>> objects that set data don?t work. The data is not null on the >>>> Javascript callback but null inside the Java method. >>>> >>>> Here is an example callback: >>>> >>>> stream.create().memoryGroup("queues", "name").onCreate(function >>>> (memoryGroup, key) { >>>> stream.create().memory(key); >>>> print("Add:"+ key+"="+stream.memory(key)); >>>> }); >>>> >>>> The above ?stream.create().memory(key)? is a Java method that has a >>>> printout: >>>> >>>> AddMem: orderpos, mem=HeapMemory{name='orderpos?} >>>> >>>> But when I retrieve it with "stream.memory(key)? in the print >>>> statement of the Javascript function I?m getting: >>>> >>>> Add:orderpos=null >>>> >>>> For me this points to the bindings, e.g. a binding from a previous >>>> running instance of the script or something else. Can somebody >>>> provide some help? What do I need to do to have always a clean >>>> instance of a binding when I rerun a script without stopping the JVM? >>>> >>>> Thanks, >>>> Andreas >>>> >> >> >> IIT Software GmbH >> M?nsterstr. 111, 48145 M?nster, Germany >> Phone: +49 (0)2506 3049340 >> Managing Director: Andreas M?ller >> District Court: Amtsgericht M?nster, HRB 16294 >> VAT-No: DE199945912 >> >> This e-mail may contain confidential and/or privileged information. >> If you are not the intended recipient (or have received this e-mail >> in error) please notify the sender immediately and destroy this >> e-mail. Any unauthorized copying, disclosure or distribution of the >> material in this e-mail is strictly forbidden. >> >> From am at iit.de Thu Jan 12 11:32:15 2017 From: am at iit.de (Andreas Mueller) Date: Thu, 12 Jan 2017 12:32:15 +0100 Subject: binding issues In-Reply-To: <587756C6.6090304@oracle.com> References: <7DECE433-81F5-4578-A52B-561B9A039F9B@iit.de> <587704DD.3070004@oracle.com> <5CAE16F9-6A66-442B-AB52-635DB8DE550A@iit.de> <587756C6.6090304@oracle.com> Message-ID: <5B0F97AB-4800-4E6B-8B33-470685ACF91F@iit.de> I figured out what the problem is. Here is my Javascript callback function, simplified: stream.create().memoryGroup("queues", "name").onCreate(function (memoryGroup, key) { stream.create().memory(key); print("Add:"+ key+"="+stream.memory(key)); }); The ?stream? variable is set in the bindings before evaluating the script: ScriptContext newContext = new SimpleScriptContext(); streamContext.engineScope = newContext.getBindings(ScriptContext.ENGINE_SCOPE); streamContext.engineScope.put("stream", streamContext.stream); Now, the first statement in the function accesses: com.swiftmq.impl.streams.Stream at 47273fd1 But the second statement (print) has a different ?stream? instance: com.swiftmq.impl.streams.Stream at 6222f856 That?s why I?m not getting data set in the ?stream? because they are different instances. Seems like a binding issue. How can this happen? -- Andreas Mueller IIT Software GmbH http://www.swiftmq.com > On 12.01.2017, at 11:13, Sundararajan Athijegannathan wrote: > > Not sure what you mean by "engine is shared between scripts". Each separate Nashorn ScriptEngine instance is isolated. Nothing is shared across different script engine instances. There are no java level "statics" (i.e., process wide globals) that cut across engine instances. On the same engine, there is compiled code is shared (.class and Class objects in some cases) when possible. That should also not result in any issue (there may be bugs). > > Hope I addressed your questions, > -Sundar > > On 12/01/17, 1:42 PM, Andreas Mueller wrote: >> Will do. >> >> Can you tell me whether the engine is shared between scripts? Is there a way to use one engine per script and to start absolute clean (no caches, no refs from previous runs) just like when the JVM was started? >> >> Thanks, >> Andreas >> >>> Am 12.01.2017 um 05:23 schrieb Sundararajan Athijegannathan: >>> >>> Will you please submit a bug with a compilable/runnable test case attached? >>> >>> Thanks, >>> -Sundar >>> >>>> On 11/01/17, 11:09 PM, Andreas Mueller wrote: >>>> Hi, >>>> >>>> it seems I have a problem understanding Nashorn?s bindings... >>>> >>>> I have multiple scripts, each independent of each other. They should run concurrently with their own context and engine scope bindings. This is created as follows for each script: >>>> >>>> ScriptEngineManager manager = new ScriptEngineManager(); >>>> ScriptEngine engine = manager.getEngineByName((String) entity.getProperty("script-language").getValue()); >>>> if (engine == null) >>>> throw new Exception("Engine for script-language '" + entity.getProperty("script-language").getValue() + "' not found!"); >>>> ScriptContext newContext = new SimpleScriptContext(); >>>> streamContext.engineScope = newContext.getBindings(ScriptContext.ENGINE_SCOPE); >>>> >>>> Internally we have a Java-based processor which calls Javascript functions (callbacks). It is always the same thread. >>>> >>>> It works fine when I start a script the first time. If I stop it (without stopping the JVM) and restart it (it runs through the code above) or if I run another script concurrently, I?m getting problems in so far that calls inside a Javascript callback to Java objects that set data don?t work. The data is not null on the Javascript callback but null inside the Java method. >>>> >>>> Here is an example callback: >>>> >>>> stream.create().memoryGroup("queues", "name").onCreate(function (memoryGroup, key) { >>>> stream.create().memory(key); >>>> print("Add:"+ key+"="+stream.memory(key)); >>>> }); >>>> >>>> The above ?stream.create().memory(key)? is a Java method that has a printout: >>>> >>>> AddMem: orderpos, mem=HeapMemory{name='orderpos?} >>>> >>>> But when I retrieve it with "stream.memory(key)? in the print statement of the Javascript function I?m getting: >>>> >>>> Add:orderpos=null >>>> >>>> For me this points to the bindings, e.g. a binding from a previous running instance of the script or something else. Can somebody provide some help? What do I need to do to have always a clean instance of a binding when I rerun a script without stopping the JVM? >>>> >>>> Thanks, >>>> Andreas >>>> >> >> >> IIT Software GmbH >> M?nsterstr. 111, 48145 M?nster, Germany >> Phone: +49 (0)2506 3049340 >> Managing Director: Andreas M?ller >> District Court: Amtsgericht M?nster, HRB 16294 >> VAT-No: DE199945912 >> >> This e-mail may contain confidential and/or privileged information. If you are not the intended recipient (or have received this e-mail in error) please notify the sender immediately and destroy this e-mail. Any unauthorized copying, disclosure or distribution of the material in this e-mail is strictly forbidden. >> >> IIT Software GmbH M?nsterstr. 111, 48145 M?nster, Germany Phone: +49 (0)2506 3049340 Managing Director: Andreas M?ller District Court: Amtsgericht M?nster, HRB 16294 VAT-No: DE199945912 This e-mail may contain confidential and/or privileged information. If you are not the intended recipient (or have received this e-mail in error) please notify the sender immediately and destroy this e-mail. Any unauthorized copying, disclosure or distribution of the material in this e-mail is strictly forbidden. From sundararajan.athijegannathan at oracle.com Thu Jan 12 12:54:37 2017 From: sundararajan.athijegannathan at oracle.com (Sundararajan Athijegannathan) Date: Thu, 12 Jan 2017 18:24:37 +0530 Subject: binding issues In-Reply-To: <5B0F97AB-4800-4E6B-8B33-470685ACF91F@iit.de> References: <7DECE433-81F5-4578-A52B-561B9A039F9B@iit.de> <587704DD.3070004@oracle.com> <5CAE16F9-6A66-442B-AB52-635DB8DE550A@iit.de> <587756C6.6090304@oracle.com> <5B0F97AB-4800-4E6B-8B33-470685ACF91F@iit.de> Message-ID: <58777C8D.2080705@oracle.com> That does not give us much info. to debug the issue :( Please provide us with a simple test case that reproduces the issue mentioned. Thanks, -Sundar On 12/01/17, 5:02 PM, Andreas Mueller wrote: > I figured out what the problem is. Here is my Javascript callback > function, simplified: > > stream.create().memoryGroup("queues", "name").onCreate(function (memoryGroup, > key) { > stream.create().memory(key); > print("Add:"+ key+"="+stream.memory(key)); > }); > The ?stream? variable is set in the bindings before evaluating the script: > > ScriptContext newContext = new SimpleScriptContext(); > streamContext.engineScope = > newContext.getBindings(ScriptContext.ENGINE_SCOPE); > streamContext.engineScope.put("stream", streamContext.stream); > > Now, the first statement in the function accesses: > > com.swiftmq.impl.streams.Stream at 47273fd1 > > But the second statement (print) has a different ?stream? instance: > > com.swiftmq.impl.streams.Stream at 6222f856 > > That?s why I?m not getting data set in the ?stream? because they are > different instances. Seems like a binding issue. > > How can this happen? > > -- > Andreas Mueller > IIT Software GmbH > http://www.swiftmq.com > > > >> On 12.01.2017, at 11:13, Sundararajan Athijegannathan >> > > wrote: >> >> Not sure what you mean by "engine is shared between scripts". Each >> separate Nashorn ScriptEngine instance is isolated. Nothing is shared >> across different script engine instances. There are no java level >> "statics" (i.e., process wide globals) that cut across engine >> instances. On the same engine, there is compiled code is shared >> (.class and Class objects in some cases) when possible. That should >> also not result in any issue (there may be bugs). >> >> Hope I addressed your questions, >> -Sundar >> >> On 12/01/17, 1:42 PM, Andreas Mueller wrote: >>> Will do. >>> >>> Can you tell me whether the engine is shared between scripts? Is >>> there a way to use one engine per script and to start absolute clean >>> (no caches, no refs from previous runs) just like when the JVM was >>> started? >>> >>> Thanks, >>> Andreas >>> >>>> Am 12.01.2017 um 05:23 schrieb Sundararajan >>>> Athijegannathan>>> >: >>>> >>>> Will you please submit a bug with a compilable/runnable test case >>>> attached? >>>> >>>> Thanks, >>>> -Sundar >>>> >>>>> On 11/01/17, 11:09 PM, Andreas Mueller wrote: >>>>> Hi, >>>>> >>>>> it seems I have a problem understanding Nashorn?s bindings... >>>>> >>>>> I have multiple scripts, each independent of each other. They >>>>> should run concurrently with their own context and engine scope >>>>> bindings. This is created as follows for each script: >>>>> >>>>> ScriptEngineManager manager = new ScriptEngineManager(); >>>>> ScriptEngine engine = manager.getEngineByName((String) >>>>> entity.getProperty("script-language").getValue()); >>>>> if (engine == null) >>>>> throw new Exception("Engine for script-language '" + >>>>> entity.getProperty("script-language").getValue() + "' not found!"); >>>>> ScriptContext newContext = new SimpleScriptContext(); >>>>> streamContext.engineScope = >>>>> newContext.getBindings(ScriptContext.ENGINE_SCOPE); >>>>> >>>>> Internally we have a Java-based processor which calls Javascript >>>>> functions (callbacks). It is always the same thread. >>>>> >>>>> It works fine when I start a script the first time. If I stop it >>>>> (without stopping the JVM) and restart it (it runs through the >>>>> code above) or if I run another script concurrently, I?m getting >>>>> problems in so far that calls inside a Javascript callback to Java >>>>> objects that set data don?t work. The data is not null on the >>>>> Javascript callback but null inside the Java method. >>>>> >>>>> Here is an example callback: >>>>> >>>>> stream.create().memoryGroup("queues", "name").onCreate(function >>>>> (memoryGroup, key) { >>>>> stream.create().memory(key); >>>>> print("Add:"+ key+"="+stream.memory(key)); >>>>> }); >>>>> >>>>> The above ?stream.create().memory(key)? is a Java method that has >>>>> a printout: >>>>> >>>>> AddMem: orderpos, mem=HeapMemory{name='orderpos?} >>>>> >>>>> But when I retrieve it with "stream.memory(key)? in the print >>>>> statement of the Javascript function I?m getting: >>>>> >>>>> Add:orderpos=null >>>>> >>>>> For me this points to the bindings, e.g. a binding from a previous >>>>> running instance of the script or something else. Can somebody >>>>> provide some help? What do I need to do to have always a clean >>>>> instance of a binding when I rerun a script without stopping the JVM? >>>>> >>>>> Thanks, >>>>> Andreas >>>>> >>> >>> >>> IIT Software GmbH >>> M?nsterstr. 111, 48145 M?nster, Germany >>> Phone: +49 (0)2506 3049340 >>> Managing Director: Andreas M?ller >>> District Court: Amtsgericht M?nster, HRB 16294 >>> VAT-No: DE199945912 >>> >>> This e-mail may contain confidential and/or privileged information. >>> If you are not the intended recipient (or have received this e-mail >>> in error) please notify the sender immediately and destroy this >>> e-mail. Any unauthorized copying, disclosure or distribution of the >>> material in this e-mail is strictly forbidden. >>> >>> > > > > ------------------------------------------------------------------------ > IIT Software GmbH > M?nsterstr. 111, 48145 M?nster, Germany > Phone: +49 (0)2506 3049340 > Managing Director: Andreas M?ller > District Court: Amtsgericht M?nster, HRB 16294 > VAT-No: DE199945912 > > This e-mail may contain confidential and/or privileged information. If you are not the intended recipient (or have received this e-mail in error) please notify the sender immediately and destroy this e-mail. Any unauthorized copying, disclosure or distribution of the material in this e-mail is strictly forbidden. > From am at iit.de Thu Jan 12 14:31:51 2017 From: am at iit.de (Andreas Mueller) Date: Thu, 12 Jan 2017 15:31:51 +0100 Subject: binding issues In-Reply-To: <58777C8D.2080705@oracle.com> References: <7DECE433-81F5-4578-A52B-561B9A039F9B@iit.de> <587704DD.3070004@oracle.com> <5CAE16F9-6A66-442B-AB52-635DB8DE550A@iit.de> <587756C6.6090304@oracle.com> <5B0F97AB-4800-4E6B-8B33-470685ACF91F@iit.de> <58777C8D.2080705@oracle.com> Message-ID: <8EEFF7C0-D903-4C00-9E52-0D8CF61D2DAB@iit.de> So I wrote the test case! But I were not able to reproduce it - but found a bug on my side! Forgot to remove a listener somewhere which produced events on an old stream instance? I?m developing since decades but still need to realize that there is only a very little chance it is a JDK bug. It?s always my code! I need to pin that mantra on my office wall. ;-) So, thanks a lot for you help! -- Andreas Mueller IIT Software GmbH http://www.swiftmq.com > On 12.01.2017, at 13:54, Sundararajan Athijegannathan wrote: > > That does not give us much info. to debug the issue :( Please provide us with a simple test case that reproduces the issue mentioned. > > Thanks, > -Sundar > > On 12/01/17, 5:02 PM, Andreas Mueller wrote: >> I figured out what the problem is. Here is my Javascript callback function, simplified: >> >> stream.create().memoryGroup("queues", "name").onCreate(function (memoryGroup, key) { >> stream.create().memory(key); >> print("Add:"+ key+"="+stream.memory(key)); >> }); >> >> The ?stream? variable is set in the bindings before evaluating the script: >> >> ScriptContext newContext = new SimpleScriptContext(); >> streamContext.engineScope = newContext.getBindings(ScriptContext.ENGINE_SCOPE); >> streamContext.engineScope.put("stream", streamContext.stream); >> >> Now, the first statement in the function accesses: >> >> com.swiftmq.impl.streams.Stream at 47273fd1 >> >> But the second statement (print) has a different ?stream? instance: >> >> com.swiftmq.impl.streams.Stream at 6222f856 >> >> That?s why I?m not getting data set in the ?stream? because they are different instances. Seems like a binding issue. >> >> How can this happen? >> >> -- >> Andreas Mueller >> IIT Software GmbH >> http://www.swiftmq.com >> >> >> >>> On 12.01.2017, at 11:13, Sundararajan Athijegannathan wrote: >>> >>> Not sure what you mean by "engine is shared between scripts". Each separate Nashorn ScriptEngine instance is isolated. Nothing is shared across different script engine instances. There are no java level "statics" (i.e., process wide globals) that cut across engine instances. On the same engine, there is compiled code is shared (.class and Class objects in some cases) when possible. That should also not result in any issue (there may be bugs). >>> >>> Hope I addressed your questions, >>> -Sundar >>> >>> On 12/01/17, 1:42 PM, Andreas Mueller wrote: >>>> Will do. >>>> >>>> Can you tell me whether the engine is shared between scripts? Is there a way to use one engine per script and to start absolute clean (no caches, no refs from previous runs) just like when the JVM was started? >>>> >>>> Thanks, >>>> Andreas >>>> >>>>> Am 12.01.2017 um 05:23 schrieb Sundararajan Athijegannathan: >>>>> >>>>> Will you please submit a bug with a compilable/runnable test case attached? >>>>> >>>>> Thanks, >>>>> -Sundar >>>>> >>>>>> On 11/01/17, 11:09 PM, Andreas Mueller wrote: >>>>>> Hi, >>>>>> >>>>>> it seems I have a problem understanding Nashorn?s bindings... >>>>>> >>>>>> I have multiple scripts, each independent of each other. They should run concurrently with their own context and engine scope bindings. This is created as follows for each script: >>>>>> >>>>>> ScriptEngineManager manager = new ScriptEngineManager(); >>>>>> ScriptEngine engine = manager.getEngineByName((String) entity.getProperty("script-language").getValue()); >>>>>> if (engine == null) >>>>>> throw new Exception("Engine for script-language '" + entity.getProperty("script-language").getValue() + "' not found!"); >>>>>> ScriptContext newContext = new SimpleScriptContext(); >>>>>> streamContext.engineScope = newContext.getBindings(ScriptContext.ENGINE_SCOPE); >>>>>> >>>>>> Internally we have a Java-based processor which calls Javascript functions (callbacks). It is always the same thread. >>>>>> >>>>>> It works fine when I start a script the first time. If I stop it (without stopping the JVM) and restart it (it runs through the code above) or if I run another script concurrently, I?m getting problems in so far that calls inside a Javascript callback to Java objects that set data don?t work. The data is not null on the Javascript callback but null inside the Java method. >>>>>> >>>>>> Here is an example callback: >>>>>> >>>>>> stream.create().memoryGroup("queues", "name").onCreate(function (memoryGroup, key) { >>>>>> stream.create().memory(key); >>>>>> print("Add:"+ key+"="+stream.memory(key)); >>>>>> }); >>>>>> >>>>>> The above ?stream.create().memory(key)? is a Java method that has a printout: >>>>>> >>>>>> AddMem: orderpos, mem=HeapMemory{name='orderpos?} >>>>>> >>>>>> But when I retrieve it with "stream.memory(key)? in the print statement of the Javascript function I?m getting: >>>>>> >>>>>> Add:orderpos=null >>>>>> >>>>>> For me this points to the bindings, e.g. a binding from a previous running instance of the script or something else. Can somebody provide some help? What do I need to do to have always a clean instance of a binding when I rerun a script without stopping the JVM? >>>>>> >>>>>> Thanks, >>>>>> Andreas >>>>>> >>>> >>>> >>>> IIT Software GmbH >>>> M?nsterstr. 111, 48145 M?nster, Germany >>>> Phone: +49 (0)2506 3049340 >>>> Managing Director: Andreas M?ller >>>> District Court: Amtsgericht M?nster, HRB 16294 >>>> VAT-No: DE199945912 >>>> >>>> This e-mail may contain confidential and/or privileged information. If you are not the intended recipient (or have received this e-mail in error) please notify the sender immediately and destroy this e-mail. Any unauthorized copying, disclosure or distribution of the material in this e-mail is strictly forbidden. >>>> >>>> >> >> >> >> IIT Software GmbH >> M?nsterstr. 111, 48145 M?nster, Germany >> Phone: +49 (0)2506 3049340 >> Managing Director: Andreas M?ller >> District Court: Amtsgericht M?nster, HRB 16294 >> VAT-No: DE199945912 >> >> This e-mail may contain confidential and/or privileged information. If you are not the intended recipient (or have received this e-mail in error) please notify the sender immediately and destroy this e-mail. Any unauthorized copying, disclosure or distribution of the material in this e-mail is strictly forbidden. >> IIT Software GmbH M?nsterstr. 111, 48145 M?nster, Germany Phone: +49 (0)2506 3049340 Managing Director: Andreas M?ller District Court: Amtsgericht M?nster, HRB 16294 VAT-No: DE199945912 This e-mail may contain confidential and/or privileged information. If you are not the intended recipient (or have received this e-mail in error) please notify the sender immediately and destroy this e-mail. Any unauthorized copying, disclosure or distribution of the material in this e-mail is strictly forbidden. From sundararajan.athijegannathan at oracle.com Thu Jan 12 15:44:42 2017 From: sundararajan.athijegannathan at oracle.com (Sundararajan Athijegannathan) Date: Thu, 12 Jan 2017 21:14:42 +0530 Subject: binding issues In-Reply-To: <8EEFF7C0-D903-4C00-9E52-0D8CF61D2DAB@iit.de> References: <7DECE433-81F5-4578-A52B-561B9A039F9B@iit.de> <587704DD.3070004@oracle.com> <5CAE16F9-6A66-442B-AB52-635DB8DE550A@iit.de> <587756C6.6090304@oracle.com> <5B0F97AB-4800-4E6B-8B33-470685ACF91F@iit.de> <58777C8D.2080705@oracle.com> <8EEFF7C0-D903-4C00-9E52-0D8CF61D2DAB@iit.de> Message-ID: <5877A46A.7010203@oracle.com> Hi, Good to know that you've spotted the issue and fixed it! Thanks for informing us... -Sundar On 12/01/17, 8:01 PM, Andreas Mueller wrote: > So I wrote the test case! But I were not able to reproduce it - but > found a bug on my side! Forgot to remove a listener somewhere which > produced events on an old stream instance? > > I?m developing since decades but still need to realize that there is > only a very little chance it is a JDK bug. It?s always my code! I need > to pin that mantra on my office wall. ;-) > > So, thanks a lot for you help! > > -- > Andreas Mueller > IIT Software GmbH > http://www.swiftmq.com > > > >> On 12.01.2017, at 13:54, Sundararajan Athijegannathan >> > > wrote: >> >> That does not give us much info. to debug the issue :( Please provide >> us with a simple test case that reproduces the issue mentioned. >> >> Thanks, >> -Sundar >> >> On 12/01/17, 5:02 PM, Andreas Mueller wrote: >>> I figured out what the problem is. Here is my Javascript callback >>> function, simplified: >>> >>> stream.create().memoryGroup("queues", "name").onCreate(function >>> (memoryGroup, key) { >>> stream.create().memory(key); >>> print("Add:"+ key+"="+stream.memory(key)); >>> }); >>> >>> The ?stream? variable is set in the bindings before evaluating the >>> script: >>> >>> ScriptContext newContext = new SimpleScriptContext(); >>> streamContext.engineScope >>> = newContext.getBindings(ScriptContext.ENGINE_SCOPE); >>> streamContext.engineScope.put("stream", streamContext.stream); >>> >>> Now, the first statement in the function accesses: >>> >>> com.swiftmq.impl.streams.Stream at 47273fd1 >>> >>> But the second statement (print) has a different ?stream? instance: >>> >>> com.swiftmq.impl.streams.Stream at 6222f856 >>> >>> That?s why I?m not getting data set in the ?stream? because they are >>> different instances. Seems like a binding issue. >>> >>> How can this happen? >>> >>> -- >>> Andreas Mueller >>> IIT Software GmbH >>> http://www.swiftmq.com >>> >>> >>> >>>> On 12.01.2017, at 11:13, Sundararajan Athijegannathan >>>> wrote: >>>> >>>> Not sure what you mean by "engine is shared between scripts". Each >>>> separate Nashorn ScriptEngine instance is isolated. Nothing is >>>> shared across different script engine instances. There are no java >>>> level "statics" (i.e., process wide globals) that cut across engine >>>> instances. On the same engine, there is compiled code is shared >>>> (.class and Class objects in some cases) when possible. That should >>>> also not result in any issue (there may be bugs). >>>> >>>> Hope I addressed your questions, >>>> -Sundar >>>> >>>> On 12/01/17, 1:42 PM, Andreas Mueller wrote: >>>>> Will do. >>>>> >>>>> Can you tell me whether the engine is shared between scripts? Is >>>>> there a way to use one engine per script and to start absolute >>>>> clean (no caches, no refs from previous runs) just like when the >>>>> JVM was started? >>>>> >>>>> Thanks, >>>>> Andreas >>>>> >>>>>> Am 12.01.2017 um 05:23 schrieb Sundararajan >>>>>> Athijegannathan: >>>>>> >>>>>> Will you please submit a bug with a compilable/runnable test case >>>>>> attached? >>>>>> >>>>>> Thanks, >>>>>> -Sundar >>>>>> >>>>>>> On 11/01/17, 11:09 PM, Andreas Mueller wrote: >>>>>>> Hi, >>>>>>> >>>>>>> it seems I have a problem understanding Nashorn?s bindings... >>>>>>> >>>>>>> I have multiple scripts, each independent of each other. They >>>>>>> should run concurrently with their own context and engine scope >>>>>>> bindings. This is created as follows for each script: >>>>>>> >>>>>>> ScriptEngineManager manager = new ScriptEngineManager(); >>>>>>> ScriptEngine engine = >>>>>>> manager.getEngineByName((String) entity.getProperty("script-language").getValue()); >>>>>>> if (engine == null) >>>>>>> throw new Exception("Engine for script-language '" >>>>>>> + entity.getProperty("script-language").getValue() + "' not >>>>>>> found!"); >>>>>>> ScriptContext newContext = new SimpleScriptContext(); >>>>>>> streamContext.engineScope >>>>>>> = newContext.getBindings(ScriptContext.ENGINE_SCOPE); >>>>>>> >>>>>>> Internally we have a Java-based processor which calls Javascript >>>>>>> functions (callbacks). It is always the same thread. >>>>>>> >>>>>>> It works fine when I start a script the first time. If I stop it >>>>>>> (without stopping the JVM) and restart it (it runs through the >>>>>>> code above) or if I run another script concurrently, I?m getting >>>>>>> problems in so far that calls inside a Javascript callback to >>>>>>> Java objects that set data don?t work. The data is not null on >>>>>>> the Javascript callback but null inside the Java method. >>>>>>> >>>>>>> Here is an example callback: >>>>>>> >>>>>>> stream.create().memoryGroup("queues", "name").onCreate(function >>>>>>> (memoryGroup, key) { >>>>>>> stream.create().memory(key); >>>>>>> print("Add:"+ key+"="+stream.memory(key)); >>>>>>> }); >>>>>>> >>>>>>> The above ?stream.create().memory(key)? is a Java method that >>>>>>> has a printout: >>>>>>> >>>>>>> AddMem: orderpos, mem=HeapMemory{name='orderpos?} >>>>>>> >>>>>>> But when I retrieve it with "stream.memory(key)? in the print >>>>>>> statement of the Javascript function I?m getting: >>>>>>> >>>>>>> Add:orderpos=null >>>>>>> >>>>>>> For me this points to the bindings, e.g. a binding from a >>>>>>> previous running instance of the script or something else. Can >>>>>>> somebody provide some help? What do I need to do to have always >>>>>>> a clean instance of a binding when I rerun a script without >>>>>>> stopping the JVM? >>>>>>> >>>>>>> Thanks, >>>>>>> Andreas >>>>>>> >>>>> >>>>> >>>>> IIT Software GmbH >>>>> M?nsterstr. 111, 48145 M?nster, Germany >>>>> Phone: +49 (0)2506 3049340 >>>>> Managing Director: Andreas M?ller >>>>> District Court: Amtsgericht M?nster, HRB 16294 >>>>> VAT-No: DE199945912 >>>>> >>>>> This e-mail may contain confidential and/or >>>>> privileged information. If you are not the intended recipient (or >>>>> have received this e-mail in error) please notify >>>>> the sender immediately and destroy this e-mail. Any >>>>> unauthorized copying, disclosure or distribution of the material >>>>> in this e-mail is strictly forbidden. >>>>> >>>>> >>> >>> >>> >>> IIT Software GmbH >>> M?nsterstr. 111, 48145 M?nster, Germany >>> Phone: +49 (0)2506 3049340 >>> Managing Director: Andreas M?ller >>> District Court: Amtsgericht M?nster, HRB 16294 >>> VAT-No: DE199945912 >>> >>> This e-mail may contain confidential and/or privileged information. >>> If you are not the intended recipient (or have received this e-mail >>> in error) please notify the sender immediately and destroy this >>> e-mail. Any unauthorized copying, disclosure or distribution of the >>> material in this e-mail is strictly forbidden. >>> > > > > ------------------------------------------------------------------------ > IIT Software GmbH > M?nsterstr. 111, 48145 M?nster, Germany > Phone: +49 (0)2506 3049340 > Managing Director: Andreas M?ller > District Court: Amtsgericht M?nster, HRB 16294 > VAT-No: DE199945912 > > This e-mail may contain confidential and/or privileged information. If you are not the intended recipient (or have received this e-mail in error) please notify the sender immediately and destroy this e-mail. Any unauthorized copying, disclosure or distribution of the material in this e-mail is strictly forbidden. > From inigo at arima.eu Mon Jan 23 22:24:25 2017 From: inigo at arima.eu (=?UTF-8?Q?I=C3=B1igo_Telleria?=) Date: Mon, 23 Jan 2017 23:24:25 +0100 Subject: Mustache.js on Nashorn Message-ID: Hi, I'm trying to compare the performance of Mustache Java Implementation ( https://github.com/spullara/mustache.java) and Mustache JavaScript ( https://github.com/janl/mustache.js) on JVM. Developing a web application to compare them, https://github.com/wearearima/mustache-java-js-comparison , I've found an issue that I can't solve. I've got a Todo bean which is a Java class and I want to render it using a Mustache.js template. If the template receives a Todo object as a simple param, the value is printed correctly. For example this param works fine https://github.com/wearearima/mustache-java-js-comparison/blob/master/src/test/java/eu/arima/mustachecomparison/MustacheVersionTests.java#L88 However, when the template receive a Todo list, the values are empty. For example, this list is rendered with empty values: https://github.com/wearearima/mustache-java-js-comparison/blob/master/src/test/java/eu/arima/mustachecomparison/MustacheVersionTests.java#L89 I'm not sure if this issue is related to Nashorn engine or Mustache Javascript framework, because using different versions of Mustache (0.8.2 or 2.3.0) I've got different results. With the lowest version the template is rendered correctly but not with the highest. Any advice would be highly appreciated. Thanks in advance. I?igo Telleria From sundararajan.athijegannathan at oracle.com Tue Jan 24 08:56:55 2017 From: sundararajan.athijegannathan at oracle.com (Sundararajan Athijegannathan) Date: Tue, 24 Jan 2017 14:26:55 +0530 Subject: RFR 8173257: test/script/trusted/JDK-8021189.js and test/script/trusted/JDK-8021129.js fail in nashorn nightly Message-ID: <588716D7.9030601@oracle.com> Please review http://cr.openjdk.java.net/~sundar/8173257/webrev.00/ for https://bugs.openjdk.java.net/browse/JDK-8173257 Thanks, -Sundar From hannes.wallnoefer at oracle.com Tue Jan 24 08:50:21 2017 From: hannes.wallnoefer at oracle.com (=?utf-8?Q?Hannes_Walln=C3=B6fer?=) Date: Tue, 24 Jan 2017 09:50:21 +0100 Subject: RFR 8173257: test/script/trusted/JDK-8021189.js and test/script/trusted/JDK-8021129.js fail in nashorn nightly In-Reply-To: <588716D7.9030601@oracle.com> References: <588716D7.9030601@oracle.com> Message-ID: <08729DE3-34B3-4604-BB56-F4CB016AE5D3@oracle.com> +1 Hannes > Am 24.01.2017 um 09:56 schrieb Sundararajan Athijegannathan : > > Please review http://cr.openjdk.java.net/~sundar/8173257/webrev.00/ for https://bugs.openjdk.java.net/browse/JDK-8173257 > > Thanks, > -Sundar From james.laskey at oracle.com Tue Jan 24 12:23:44 2017 From: james.laskey at oracle.com (Jim Laskey (Oracle)) Date: Tue, 24 Jan 2017 08:23:44 -0400 Subject: RFR 8173257: test/script/trusted/JDK-8021189.js and test/script/trusted/JDK-8021129.js fail in nashorn nightly In-Reply-To: <588716D7.9030601@oracle.com> References: <588716D7.9030601@oracle.com> Message-ID: <5B728444-A8D4-4F14-A2A0-2CDA3B444918@oracle.com> +1 > On Jan 24, 2017, at 4:56 AM, Sundararajan Athijegannathan wrote: > > Please review http://cr.openjdk.java.net/~sundar/8173257/webrev.00/ for https://bugs.openjdk.java.net/browse/JDK-8173257 > > Thanks, > -Sundar From hannes.wallnoefer at oracle.com Tue Jan 24 14:31:30 2017 From: hannes.wallnoefer at oracle.com (=?utf-8?Q?Hannes_Walln=C3=B6fer?=) Date: Tue, 24 Jan 2017 15:31:30 +0100 Subject: RFR: 8166186: ClassCastException with arguments usage Message-ID: Please review: bug: https://bugs.openjdk.java.net/browse/JDK-8166186 webrev: http://cr.openjdk.java.net/~hannesw/8166186/webrev.00/ The problem was that guards for non-strict functions sometimes have a this-object parameter which also needs to be unpacked, inserted, or wrapped when called via Function.prototype.apply. This also includes a patch for types contributed by Ahmed Ashour. Thanks, Hannes From szegedia at gmail.com Tue Jan 24 15:52:37 2017 From: szegedia at gmail.com (Attila Szegedi) Date: Tue, 24 Jan 2017 16:52:37 +0100 Subject: RFR: 8166186: ClassCastException with arguments usage In-Reply-To: References: Message-ID: <6C3A6B07-2D2E-4738-8034-0E4453650202@gmail.com> +1 > On 24 Jan 2017, at 15:31, Hannes Walln?fer wrote: > > Please review: > > bug: https://bugs.openjdk.java.net/browse/JDK-8166186 > webrev: http://cr.openjdk.java.net/~hannesw/8166186/webrev.00/ > > The problem was that guards for non-strict functions sometimes have a this-object parameter which also needs to be unpacked, inserted, or wrapped when called via Function.prototype.apply. > > This also includes a patch for types contributed by Ahmed Ashour. > > Thanks, > Hannes From sundararajan.athijegannathan at oracle.com Wed Jan 25 03:20:51 2017 From: sundararajan.athijegannathan at oracle.com (Sundararajan Athijegannathan) Date: Wed, 25 Jan 2017 08:50:51 +0530 Subject: RFR: 8166186: ClassCastException with arguments usage In-Reply-To: <6C3A6B07-2D2E-4738-8034-0E4453650202@gmail.com> References: <6C3A6B07-2D2E-4738-8034-0E4453650202@gmail.com> Message-ID: <58881993.2030301@oracle.com> +1 -Sundar On 24/01/17, 9:22 PM, Attila Szegedi wrote: > +1 > >> On 24 Jan 2017, at 15:31, Hannes Walln?fer wrote: >> >> Please review: >> >> bug: https://bugs.openjdk.java.net/browse/JDK-8166186 >> webrev: http://cr.openjdk.java.net/~hannesw/8166186/webrev.00/ >> >> The problem was that guards for non-strict functions sometimes have a this-object parameter which also needs to be unpacked, inserted, or wrapped when called via Function.prototype.apply. >> >> This also includes a patch for types contributed by Ahmed Ashour. >> >> Thanks, >> Hannes From hannes.wallnoefer at oracle.com Wed Jan 25 08:57:16 2017 From: hannes.wallnoefer at oracle.com (=?utf-8?Q?Hannes_Walln=C3=B6fer?=) Date: Wed, 25 Jan 2017 09:57:16 +0100 Subject: [PATCH] typos In-Reply-To: <17d83339-58cb-2279-fb9d-fbdd16177e0c@yahoo.com> References: <17d83339-58cb-2279-fb9d-fbdd16177e0c@yahoo.com> Message-ID: Thanks Ahmed, I included your patch in my last commit. Hannes > Am 07.01.2017 um 02:39 schrieb Ahmed Ashour : > > Hi all, > > > Please find below a proposed patch, for some typos. > > > Thanks, > > Ahmed Ashour > > > diff --git a/README b/README > --- a/README > +++ b/README > @@ -18,7 +18,7 @@ > > http://mercurial.selenic.com/wiki/ForestExtension > > -and downlaoded using > +and downloaded using > > hg clone https://bitbucket.org/gxti/hgforest > > @@ -39,7 +39,7 @@ > - How to build? > > To build Nashorn, you need to install JDK 9. You may use the Nashorn > -forest build (recommended) or down load from java.net. You will need to > +forest build (recommended) or download from java.net. You will need to > set JAVA_HOME environmental variable to point to your JDK installation > directory. > > diff --git a/src/jdk.scripting.nashorn/share/classes/jdk/nashorn/api/linker/NashornLinkerExporter.java b/src/jdk.scripting.nashorn/share/classes/jdk/nashorn/api/linker/NashornLinkerExporter.java > --- a/src/jdk.scripting.nashorn/share/classes/jdk/nashorn/api/linker/NashornLinkerExporter.java > +++ b/src/jdk.scripting.nashorn/share/classes/jdk/nashorn/api/linker/NashornLinkerExporter.java > @@ -38,7 +38,7 @@ > > /** > * This linker exporter is a service provider that exports Nashorn Dynalink > - * linkers to external users. Other languague runtimes that use Dynalink > + * linkers to external users. Other language runtimes that use Dynalink > * can use the linkers exported by this provider to support tight integration > * of Nashorn objects. > */ > diff --git a/src/jdk.scripting.nashorn/share/classes/jdk/nashorn/internal/runtime/ScriptFunction.java b/src/jdk.scripting.nashorn/share/classes/jdk/nashorn/internal/runtime/ScriptFunction.java > --- a/src/jdk.scripting.nashorn/share/classes/jdk/nashorn/internal/runtime/ScriptFunction.java > +++ b/src/jdk.scripting.nashorn/share/classes/jdk/nashorn/internal/runtime/ScriptFunction.java > @@ -735,7 +735,7 @@ > /** > * Name getter - ECMA Function.name > * > - * @param self self refence > + * @param self self reference > * @return the name, or undefined if none > */ > public static Object G$name(final Object self) { > From hannes.wallnoefer at oracle.com Wed Jan 25 16:05:16 2017 From: hannes.wallnoefer at oracle.com (=?utf-8?Q?Hannes_Walln=C3=B6fer?=) Date: Wed, 25 Jan 2017 17:05:16 +0100 Subject: RFR: 8172006: Nashorn JavaScript engine fails to call @FunctionalInterface with a java.util.List argument Message-ID: <5B45327C-6BE2-46AA-AE20-78B078EA83E2@oracle.com> Please review: Bug: https://bugs.openjdk.java.net/browse/JDK-8172006 Webrev: http://cr.openjdk.java.net/~hannesw/8172006/webrev.00/ The final invocation of linkerServices.filterInternalObjects was redundant, and in fact caused the argument to be converted to ScripObjectMirror when the actual target type was java.util.List. As far as I can tell, linkerServices.filterInternalObjects is called elsewhere for all types of invocations. Existing tests pass, and I added a few more. Thanks, Hannes From szegedia at gmail.com Wed Jan 25 16:21:15 2017 From: szegedia at gmail.com (Attila Szegedi) Date: Wed, 25 Jan 2017 17:21:15 +0100 Subject: RFR: 8172006: Nashorn JavaScript engine fails to call @FunctionalInterface with a java.util.List argument In-Reply-To: <5B45327C-6BE2-46AA-AE20-78B078EA83E2@oracle.com> References: <5B45327C-6BE2-46AA-AE20-78B078EA83E2@oracle.com> Message-ID: Oh, great. I was just starting at this for a bit (after I saw you updated the JIRA), and was definitely starting to suspect the filterInternalObjects call in NashornBeansLinker. It still worries me that filtering would add a script object mirror wrapper ? the method handle?s parameter is typed as List, isn?t it? DefaultInternalObjectFilter should only operate on parameters declared as Object. Attila. > On 25 Jan 2017, at 17:05, Hannes Walln?fer wrote: > > Please review: > > Bug: https://bugs.openjdk.java.net/browse/JDK-8172006 > Webrev: http://cr.openjdk.java.net/~hannesw/8172006/webrev.00/ > > The final invocation of linkerServices.filterInternalObjects was redundant, and in fact caused the argument to be converted to ScripObjectMirror when the actual target type was java.util.List. As far as I can tell, linkerServices.filterInternalObjects is called elsewhere for all types of invocations. Existing tests pass, and I added a few more. > > Thanks, > Hannes From hannes.wallnoefer at oracle.com Wed Jan 25 16:32:23 2017 From: hannes.wallnoefer at oracle.com (=?utf-8?Q?Hannes_Walln=C3=B6fer?=) Date: Wed, 25 Jan 2017 17:32:23 +0100 Subject: RFR: 8172006: Nashorn JavaScript engine fails to call @FunctionalInterface with a java.util.List argument In-Reply-To: References: <5B45327C-6BE2-46AA-AE20-78B078EA83E2@oracle.com> Message-ID: The problem is that the first invocation of filtertInternalObjects (that happens closer to the target handle) changes the method handle?s parameter type from java.util.List to java.lang.Object, so the outer filtertInternalObjects invocation did not see the List target type. Hannes > Am 25.01.2017 um 17:21 schrieb Attila Szegedi : > > Oh, great. I was just starting at this for a bit (after I saw you updated the JIRA), and was definitely starting to suspect the filterInternalObjects call in NashornBeansLinker. It still worries me that filtering would add a script object mirror wrapper ? the method handle?s parameter is typed as List, isn?t it? DefaultInternalObjectFilter should only operate on parameters declared as Object. > > Attila. > >> On 25 Jan 2017, at 17:05, Hannes Walln?fer wrote: >> >> Please review: >> >> Bug: https://bugs.openjdk.java.net/browse/JDK-8172006 >> Webrev: http://cr.openjdk.java.net/~hannesw/8172006/webrev.00/ >> >> The final invocation of linkerServices.filterInternalObjects was redundant, and in fact caused the argument to be converted to ScripObjectMirror when the actual target type was java.util.List. As far as I can tell, linkerServices.filterInternalObjects is called elsewhere for all types of invocations. Existing tests pass, and I added a few more. >> >> Thanks, >> Hannes > From szegedia at gmail.com Wed Jan 25 16:39:16 2017 From: szegedia at gmail.com (Attila Szegedi) Date: Wed, 25 Jan 2017 17:39:16 +0100 Subject: RFR: 8172006: Nashorn JavaScript engine fails to call @FunctionalInterface with a java.util.List argument In-Reply-To: References: <5B45327C-6BE2-46AA-AE20-78B078EA83E2@oracle.com> Message-ID: <2AE91E6B-BE71-410E-BBEB-10088B8A1A75@gmail.com> Well, filterInternalObjects itself doesn?t change the method handle type. I guess what happens is that the delegate BeansLinker.getGuardedInvocation returned a handle that it already adapted to the call site type. But you?re right that the filterInternalObjects here was both redundant and harmful; BeanLinker calls it where necessary. +1. Glad you got to the bottom of this, it felt really scary how the original reproducer seemingly depended on the shape of not-yet-evaluated expressions (I completely forgot about shared scope?) Attila. > On 25 Jan 2017, at 17:32, Hannes Walln?fer wrote: > > The problem is that the first invocation of filtertInternalObjects (that happens closer to the target handle) changes the method handle?s parameter type from java.util.List to java.lang.Object, so the outer filtertInternalObjects invocation did not see the List target type. > > Hannes > >> Am 25.01.2017 um 17:21 schrieb Attila Szegedi : >> >> Oh, great. I was just starting at this for a bit (after I saw you updated the JIRA), and was definitely starting to suspect the filterInternalObjects call in NashornBeansLinker. It still worries me that filtering would add a script object mirror wrapper ? the method handle?s parameter is typed as List, isn?t it? DefaultInternalObjectFilter should only operate on parameters declared as Object. >> >> Attila. >> >>> On 25 Jan 2017, at 17:05, Hannes Walln?fer wrote: >>> >>> Please review: >>> >>> Bug: https://bugs.openjdk.java.net/browse/JDK-8172006 >>> Webrev: http://cr.openjdk.java.net/~hannesw/8172006/webrev.00/ >>> >>> The final invocation of linkerServices.filterInternalObjects was redundant, and in fact caused the argument to be converted to ScripObjectMirror when the actual target type was java.util.List. As far as I can tell, linkerServices.filterInternalObjects is called elsewhere for all types of invocations. Existing tests pass, and I added a few more. >>> >>> Thanks, >>> Hannes >> > From hannes.wallnoefer at oracle.com Wed Jan 25 16:45:43 2017 From: hannes.wallnoefer at oracle.com (=?utf-8?Q?Hannes_Walln=C3=B6fer?=) Date: Wed, 25 Jan 2017 17:45:43 +0100 Subject: RFR: 8172006: Nashorn JavaScript engine fails to call @FunctionalInterface with a java.util.List argument In-Reply-To: <2AE91E6B-BE71-410E-BBEB-10088B8A1A75@gmail.com> References: <5B45327C-6BE2-46AA-AE20-78B078EA83E2@oracle.com> <2AE91E6B-BE71-410E-BBEB-10088B8A1A75@gmail.com> Message-ID: > Am 25.01.2017 um 17:39 schrieb Attila Szegedi : > > Well, filterInternalObjects itself doesn?t change the method handle type. I guess what happens is that the delegate BeansLinker.getGuardedInvocation returned a handle that it already adapted to the call site type. But you?re right that the filterInternalObjects here was both redundant and harmful; BeanLinker calls it where necessary. > Yes, I realised that after I sent the message. I added a note to the issue as well: https://bugs.openjdk.java.net/browse/JDK-8172006?focusedCommentId=14044057&page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel#comment-14044057 Thanks a lot! Hannes > +1. > > Glad you got to the bottom of this, it felt really scary how the original reproducer seemingly depended on the shape of not-yet-evaluated expressions (I completely forgot about shared scope?) > > Attila. > >> On 25 Jan 2017, at 17:32, Hannes Walln?fer wrote: >> >> The problem is that the first invocation of filtertInternalObjects (that happens closer to the target handle) changes the method handle?s parameter type from java.util.List to java.lang.Object, so the outer filtertInternalObjects invocation did not see the List target type. >> >> Hannes >> >>> Am 25.01.2017 um 17:21 schrieb Attila Szegedi : >>> >>> Oh, great. I was just starting at this for a bit (after I saw you updated the JIRA), and was definitely starting to suspect the filterInternalObjects call in NashornBeansLinker. It still worries me that filtering would add a script object mirror wrapper ? the method handle?s parameter is typed as List, isn?t it? DefaultInternalObjectFilter should only operate on parameters declared as Object. >>> >>> Attila. >>> >>>> On 25 Jan 2017, at 17:05, Hannes Walln?fer wrote: >>>> >>>> Please review: >>>> >>>> Bug: https://bugs.openjdk.java.net/browse/JDK-8172006 >>>> Webrev: http://cr.openjdk.java.net/~hannesw/8172006/webrev.00/ >>>> >>>> The final invocation of linkerServices.filterInternalObjects was redundant, and in fact caused the argument to be converted to ScripObjectMirror when the actual target type was java.util.List. As far as I can tell, linkerServices.filterInternalObjects is called elsewhere for all types of invocations. Existing tests pass, and I added a few more. >>>> >>>> Thanks, >>>> Hannes >>> >> > From hannes.wallnoefer at oracle.com Thu Jan 26 09:29:45 2017 From: hannes.wallnoefer at oracle.com (=?utf-8?Q?Hannes_Walln=C3=B6fer?=) Date: Thu, 26 Jan 2017 10:29:45 +0100 Subject: Mustache.js on Nashorn In-Reply-To: References: Message-ID: Hi I?igo, I?ve looked at your project. The array of todo items is converted correctly, and access to the items in the array from JS works as expected. I guess you should have a look at what?s going on inside mustache.js. Hannes > Am 23.01.2017 um 23:24 schrieb I?igo Telleria : > > Hi, > > I'm trying to compare the performance of Mustache Java Implementation ( > https://github.com/spullara/mustache.java) and Mustache JavaScript ( > https://github.com/janl/mustache.js) on JVM. Developing a web application > to compare them, https://github.com/wearearima/mustache-java-js-comparison , > I've found an issue that I can't solve. > > I've got a Todo bean which is a Java class and I want to render it using a > Mustache.js template. If the template receives a Todo object as a simple > param, the value is printed correctly. For example this param works fine > https://github.com/wearearima/mustache-java-js-comparison/blob/master/src/test/java/eu/arima/mustachecomparison/MustacheVersionTests.java#L88 > > However, when the template receive a Todo list, the values are empty. For > example, this list is rendered with empty values: > https://github.com/wearearima/mustache-java-js-comparison/blob/master/src/test/java/eu/arima/mustachecomparison/MustacheVersionTests.java#L89 > > I'm not sure if this issue is related to Nashorn engine or Mustache > Javascript framework, because using different versions of Mustache (0.8.2 > or 2.3.0) I've got different results. With the lowest version the template > is rendered correctly but not with the highest. > > Any advice would be highly appreciated. > > Thanks in advance. > > I?igo Telleria From james.laskey at oracle.com Thu Jan 26 11:52:28 2017 From: james.laskey at oracle.com (Jim Laskey (Oracle)) Date: Thu, 26 Jan 2017 07:52:28 -0400 Subject: RFR: 8172006: Nashorn JavaScript engine fails to call @FunctionalInterface with a java.util.List argument In-Reply-To: References: <5B45327C-6BE2-46AA-AE20-78B078EA83E2@oracle.com> <2AE91E6B-BE71-410E-BBEB-10088B8A1A75@gmail.com> Message-ID: <9D394541-2A47-4B2B-87BD-776C017A6681@oracle.com> +1 > On Jan 25, 2017, at 12:45 PM, Hannes Walln?fer wrote: > > >> Am 25.01.2017 um 17:39 schrieb Attila Szegedi : >> >> Well, filterInternalObjects itself doesn?t change the method handle type. I guess what happens is that the delegate BeansLinker.getGuardedInvocation returned a handle that it already adapted to the call site type. But you?re right that the filterInternalObjects here was both redundant and harmful; BeanLinker calls it where necessary. >> > > Yes, I realised that after I sent the message. I added a note to the issue as well: > > https://bugs.openjdk.java.net/browse/JDK-8172006?focusedCommentId=14044057&page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel#comment-14044057 > > Thanks a lot! > > Hannes > >> +1. >> >> Glad you got to the bottom of this, it felt really scary how the original reproducer seemingly depended on the shape of not-yet-evaluated expressions (I completely forgot about shared scope?) >> >> Attila. >> >>> On 25 Jan 2017, at 17:32, Hannes Walln?fer wrote: >>> >>> The problem is that the first invocation of filtertInternalObjects (that happens closer to the target handle) changes the method handle?s parameter type from java.util.List to java.lang.Object, so the outer filtertInternalObjects invocation did not see the List target type. >>> >>> Hannes >>> >>>> Am 25.01.2017 um 17:21 schrieb Attila Szegedi : >>>> >>>> Oh, great. I was just starting at this for a bit (after I saw you updated the JIRA), and was definitely starting to suspect the filterInternalObjects call in NashornBeansLinker. It still worries me that filtering would add a script object mirror wrapper ? the method handle?s parameter is typed as List, isn?t it? DefaultInternalObjectFilter should only operate on parameters declared as Object. >>>> >>>> Attila. >>>> >>>>> On 25 Jan 2017, at 17:05, Hannes Walln?fer wrote: >>>>> >>>>> Please review: >>>>> >>>>> Bug: https://bugs.openjdk.java.net/browse/JDK-8172006 >>>>> Webrev: http://cr.openjdk.java.net/~hannesw/8172006/webrev.00/ >>>>> >>>>> The final invocation of linkerServices.filterInternalObjects was redundant, and in fact caused the argument to be converted to ScripObjectMirror when the actual target type was java.util.List. As far as I can tell, linkerServices.filterInternalObjects is called elsewhere for all types of invocations. Existing tests pass, and I added a few more. >>>>> >>>>> Thanks, >>>>> Hannes >>>> >>> >> > From hannes.wallnoefer at oracle.com Thu Jan 26 12:57:46 2017 From: hannes.wallnoefer at oracle.com (=?utf-8?Q?Hannes_Walln=C3=B6fer?=) Date: Thu, 26 Jan 2017 13:57:46 +0100 Subject: Supporting [[hasProperty]] on JavaBeans Message-ID: I noticed today that we don?t support the ?in? operator on JavaBeans. ScriptRuntime.IN(Object, Object) returns false if the second argument is a generic object (not a ScriptObject or JSObject). I was wondering if this is an oversight or intentional. If it is the former, how would we implement this? Is this the case for a non-standard Dynalink operation such as HAS? Hannes From szegedia at gmail.com Thu Jan 26 14:08:39 2017 From: szegedia at gmail.com (Attila Szegedi) Date: Thu, 26 Jan 2017 15:08:39 +0100 Subject: Supporting [[hasProperty]] on JavaBeans In-Reply-To: References: Message-ID: <2F9AC720-DA82-46F7-9522-F5A7308E1620@gmail.com> BeansLinker has a bunch of static methods like getReadableInstancePropertyNames etc. that could be used to implement special cases in ScriptRuntime.IN. A logic modelled after how NativeObject.bindProperties works should do (after all, ?in? on a bean should work equivalently to how it works on the result of Object.bindProperties({}, bean). To answer your operator question, a lot of INVOKESTATIC calls to RuntimeNode special methods could be eqiuvalently reworked to use INVOKEDYNAMIC with custom operations, although the benefit is unclear as long as all possible implementations reside within a single runtime (Nashorn). Expanding the set of standard operations would probably make more sense? My first candidate for a new standard operation is specifically DELETE (folks have asked for it here on the list), I just couldn?t find the time to make it happen for the JDK 9 initial release timeframe :-( Attila. > On 26 Jan 2017, at 13:57, Hannes Walln?fer wrote: > > I noticed today that we don?t support the ?in? operator on JavaBeans. ScriptRuntime.IN(Object, Object) returns false if the second argument is a generic object (not a ScriptObject or JSObject). > > I was wondering if this is an oversight or intentional. If it is the former, how would we implement this? Is this the case for a non-standard Dynalink operation such as HAS? > > Hannes From hannes.wallnoefer at oracle.com Fri Jan 27 09:50:39 2017 From: hannes.wallnoefer at oracle.com (=?utf-8?Q?Hannes_Walln=C3=B6fer?=) Date: Fri, 27 Jan 2017 10:50:39 +0100 Subject: Supporting [[hasProperty]] on JavaBeans In-Reply-To: <2F9AC720-DA82-46F7-9522-F5A7308E1620@gmail.com> References: <2F9AC720-DA82-46F7-9522-F5A7308E1620@gmail.com> Message-ID: <260112C1-6B18-4D97-AA3A-26443C91BB79@oracle.com> Am 26.01.2017 um 15:08 schrieb Attila Szegedi : > > BeansLinker has a bunch of static methods like getReadableInstancePropertyNames etc. that could be used to implement special cases in ScriptRuntime.IN. A logic modelled after how NativeObject.bindProperties works should do (after all, ?in? on a bean should work equivalently to how it works on the result of Object.bindProperties({}, bean). Thanks for that suggestion. I had skimmed over the static BeansLinker methods but had overseen that particular method, so it might be easier to implement than I had thought. > To answer your operator question, a lot of INVOKESTATIC calls to RuntimeNode special methods could be eqiuvalently reworked to use INVOKEDYNAMIC with custom operations, although the benefit is unclear as long as all possible implementations reside within a single runtime (Nashorn). Expanding the set of standard operations would probably make more sense? My first candidate for a new standard operation is specifically DELETE (folks have asked for it here on the list), I just couldn?t find the time to make it happen for the JDK 9 initial release timeframe :-( Yes, I know DELETE has been a candidate for a long time. Actually, HAS/CONTAINS and DELETE would make a nice pair as they?d complement our coverage for basic collection (map/set) functionality. It?s definitely too late for the initial JDK 9 release, but it could be a nice addition for 10. Hannes > Attila. > >> On 26 Jan 2017, at 13:57, Hannes Walln?fer wrote: >> >> I noticed today that we don?t support the ?in? operator on JavaBeans. ScriptRuntime.IN(Object, Object) returns false if the second argument is a generic object (not a ScriptObject or JSObject). >> >> I was wondering if this is an oversight or intentional. If it is the former, how would we implement this? Is this the case for a non-standard Dynalink operation such as HAS? >> >> Hannes > From hannes.wallnoefer at oracle.com Mon Jan 30 10:22:37 2017 From: hannes.wallnoefer at oracle.com (=?utf-8?Q?Hannes_Walln=C3=B6fer?=) Date: Mon, 30 Jan 2017 11:22:37 +0100 Subject: RFR: 8173480: in operator should work on java objects and classes Message-ID: <49CDA440-77E9-4701-939D-8D7D000D675E@oracle.com> Please review 8173480: in operator should work on java objects and classes. Bug: https://bugs.openjdk.java.net/browse/JDK-8173480 Webrev: http://cr.openjdk.java.net/~hannesw/8173480/webrev.00/nashorn.patch Thanks, Hannes From Joerg.Frantzius at aperto.com Mon Jan 30 10:28:14 2017 From: Joerg.Frantzius at aperto.com (=?utf-8?B?RnJhbnR6aXVzLCBKw7ZyZw==?=) Date: Mon, 30 Jan 2017 10:28:14 +0000 Subject: Function object cannot be called with different context Message-ID: <1D0FF04F-6178-47C1-BCC1-7B26C421D701@aperto.com> Hi, in my code, I get hold of a function object from some 3rd party Javascript code, and I need to execute that function within a new context, i.e. make new ENGINE_SCOPE bindings available to it. ScriptObjectMirror.call() unfortunately does not allow to define a context to execute in, so I tried to workaround by calling the function from a CompiledScript that in turn can be executed with a custom context: @Test public void testJsFunctionWithContext() throws ScriptException { ScriptEngine engine = new ScriptEngineManager().getEngineByName("JavaScript"); jdk.nashorn.api.scripting.ScriptObjectMirror jsFunction = (ScriptObjectMirror) engine.eval("function test() {return foo;}"); ScriptContext context = new SimpleScriptContext(); context.setAttribute("foo", "bar", ScriptContext.ENGINE_SCOPE); context.setAttribute("fn", jsFunction, ScriptContext.ENGINE_SCOPE); // does work: access context directly CompiledScript contextWrapper = ((Compilable) engine).compile("foo"); String result = (String) contextWrapper.eval(context); assertEquals("bar", result); // does not work: access context from within function ("foo" is not defined) contextWrapper = ((Compilable) engine).compile("fn()"); result = (String) contextWrapper.eval(context); assertEquals("bar", result); } Is there some mistake I made here, or is it simply not possible for a function object to access variables from a new context? If that?s really not possible, is there maybe a way of turning a function object into a CompiledScript object, which can then be evaluated with a new context? Thanks for any help, J?rg --- Dipl. Inf. J?rg von Frantzius, Technical Director E-Mail joerg.frantzius at aperto.com Phone +49 30 283921-318 Fax +49 30 283921-29 Aperto GmbH ? An IBM Company Chausseestra?e 5, D-10115 Berlin http://www.aperto.com http://www.facebook.com/aperto https://www.xing.com/companies/apertoag HRB 77049 B, AG Berlin Charlottenburg Gesch?ftsf?hrer: Dirk Buddensiek, Kai Gro?mann, Stephan Haagen, Daniel Simon From luisa_pace at it.ibm.com Mon Jan 30 10:58:40 2017 From: luisa_pace at it.ibm.com (Luisa Pace) Date: Mon, 30 Jan 2017 11:58:40 +0100 Subject: nashorn.jar is opensource? Message-ID: Hi, I am an IBM employee that work in legal team of Bluemix, the PaaS platform of IBM. This platform is based on CloudFoundry, an open source project and my goal is to analyze with some software tools the licenses of all CloudFoundry components and their dependencies to check if they can be included in Bluemix without legal issues. To do that, I need of the source of all the CloudFoundry components and their dependencies. In the case I'm managing now, Cloudfoundry (level 245) contains openjdk 1.8.0_101, that in turn contains nashorn.jar. But I was not able to find the source code of nashorn.jar . So, I've two questions: Could you please tell me if nashorn is an open source and in this case send me the link to its source code? What is the license of nashorn? Fell be free to ask me other details. Thanks a lot for your support. Best Regards/Cordiali saluti Luisa Pace ========================================================================================================================= Ci? che ? fuori ? anche dentro; e ci? che non ? dentro non ? da nessuna parte. Per questo viaggiare non serve. Se uno non ha niente dentro, non trover? mai niente fuori. ? inutile andare a cercare nel mondo quel che non si riesce a trovare dentro di s?. (Tiziano Terzani) ========================================================================================================================== Ing. Luisa Pace IBM Italy Bluemix Legal Project Manager Via Sciangai, 53 (B1 - 508) 00144 Roma Italy Tel. +39.06.5966.3795 Fax. +39.06.5966.3489 mob. +39.335.7368629 e-mail: luisa_pace at it.ibm.com IBM Italia S.p.A. Sede Legale: Circonvallazione Idroscalo - 20090 Segrate (MI) Cap. Soc. euro 347.256.998,80 C. F. e Reg. Imprese MI 01442240030 - Partita IVA 10914660153 Societ? con unico azionista Societ? soggetta all?attivit? di direzione e coordinamento di International Business Machines Corporation (Salvo che sia diversamente indicato sopra / Unless stated otherwise above) From james.laskey at oracle.com Mon Jan 30 13:31:04 2017 From: james.laskey at oracle.com (Jim Laskey (Oracle)) Date: Mon, 30 Jan 2017 09:31:04 -0400 Subject: nashorn.jar is opensource? In-Reply-To: References: Message-ID: <3002524C-92D3-4161-8070-2BFCC2DF45D1@oracle.com> Luisa, Hello. Response is inlined. Cheers, ? Jim > On Jan 30, 2017, at 6:58 AM, Luisa Pace wrote: > > Hi, > > I am an IBM employee that work in legal team of Bluemix, the PaaS platform > of IBM. This platform is based on CloudFoundry, an open source project > and my goal is to analyze with some software tools the licenses of all > CloudFoundry components and their dependencies to check if they can be > included in Bluemix without legal issues. > > To do that, I need of the source of all the CloudFoundry components and > their dependencies. > > In the case I'm managing now, Cloudfoundry (level 245) contains openjdk > 1.8.0_101, that in turn contains nashorn.jar. > > But I was not able to find the source code of nashorn.jar . > > So, I've two questions: > > Could you please tell me if nashorn is an open source and in this case > send me the link to its source code? http://hg.openjdk.java.net/jdk9/dev/ > What is the license of nashorn? GPL + ClassPath, the same as the Open JDK. > > Fell be free to ask me other details. > > Thanks a lot for your support. > > Best Regards/Cordiali saluti > Luisa Pace > > ========================================================================================================================= > > Ci? che ? fuori ? anche dentro; e ci? che non ? dentro non ? da nessuna > parte. Per questo viaggiare non serve. Se uno non ha niente dentro, non > trover? mai niente fuori. ? inutile andare a cercare nel mondo quel che > non si riesce a trovare dentro di s?. (Tiziano Terzani) > > ========================================================================================================================== > > > Ing. Luisa Pace > IBM Italy > Bluemix Legal Project Manager > Via Sciangai, 53 (B1 - 508) > 00144 Roma > Italy > Tel. +39.06.5966.3795 > Fax. +39.06.5966.3489 > mob. +39.335.7368629 > e-mail: luisa_pace at it.ibm.com > > IBM Italia S.p.A. > Sede Legale: Circonvallazione Idroscalo - 20090 Segrate (MI) > Cap. Soc. euro 347.256.998,80 > C. F. e Reg. Imprese MI 01442240030 - Partita IVA 10914660153 > Societ? con unico azionista > Societ? soggetta all?attivit? di direzione e coordinamento di > International Business Machines Corporation > > (Salvo che sia diversamente indicato sopra / Unless stated otherwise > above) From luisa_pace at it.ibm.com Mon Jan 30 14:28:52 2017 From: luisa_pace at it.ibm.com (Luisa Pace) Date: Mon, 30 Jan 2017 15:28:52 +0100 Subject: nashorn.jar is opensource? In-Reply-To: <3002524C-92D3-4161-8070-2BFCC2DF45D1@oracle.com> References: <3002524C-92D3-4161-8070-2BFCC2DF45D1@oracle.com> Message-ID: Hi Jim, thanks a lot for your quick answer. We've opened the link you provided me and downloaded the zip, but it seems to point to openjdk source code and not to nashorn source code only. Could you please specify what directory contains the nashorn code or send me the direct link to its source code? Thanks again. Best Regards/Cordiali saluti Luisa Pace ========================================================================================================================= Ci? che ? fuori ? anche dentro; e ci? che non ? dentro non ? da nessuna parte. Per questo viaggiare non serve. Se uno non ha niente dentro, non trover? mai niente fuori. ? inutile andare a cercare nel mondo quel che non si riesce a trovare dentro di s?. (Tiziano Terzani) ========================================================================================================================== Ing. Luisa Pace IBM Italy Bluemix Legal Project Manager Via Sciangai, 53 (B1 - 508) 00144 Roma Italy Tel. +39.06.5966.3795 Fax. +39.06.5966.3489 mob. +39.335.7368629 e-mail: luisa_pace at it.ibm.com From: "Jim Laskey (Oracle)" To: Luisa Pace/Italy/IBM at IBMIT Cc: nashorn-dev at openjdk.java.net Date: 30/01/2017 14.31 Subject: Re: nashorn.jar is opensource? Luisa, Hello. Response is inlined. Cheers, ? Jim > On Jan 30, 2017, at 6:58 AM, Luisa Pace wrote: > > Hi, > > I am an IBM employee that work in legal team of Bluemix, the PaaS platform > of IBM. This platform is based on CloudFoundry, an open source project > and my goal is to analyze with some software tools the licenses of all > CloudFoundry components and their dependencies to check if they can be > included in Bluemix without legal issues. > > To do that, I need of the source of all the CloudFoundry components and > their dependencies. > > In the case I'm managing now, Cloudfoundry (level 245) contains openjdk > 1.8.0_101, that in turn contains nashorn.jar. > > But I was not able to find the source code of nashorn.jar . > > So, I've two questions: > > Could you please tell me if nashorn is an open source and in this case > send me the link to its source code? http://hg.openjdk.java.net/jdk9/dev/ > What is the license of nashorn? GPL + ClassPath, the same as the Open JDK. > > Fell be free to ask me other details. > > Thanks a lot for your support. > > Best Regards/Cordiali saluti > Luisa Pace > > ========================================================================================================================= > > Ci? che ? fuori ? anche dentro; e ci? che non ? dentro non ? da nessuna > parte. Per questo viaggiare non serve. Se uno non ha niente dentro, non > trover? mai niente fuori. ? inutile andare a cercare nel mondo quel che > non si riesce a trovare dentro di s?. (Tiziano Terzani) > > ========================================================================================================================== > > > Ing. Luisa Pace > IBM Italy > Bluemix Legal Project Manager > Via Sciangai, 53 (B1 - 508) > 00144 Roma > Italy > Tel. +39.06.5966.3795 > Fax. +39.06.5966.3489 > mob. +39.335.7368629 > e-mail: luisa_pace at it.ibm.com > > IBM Italia S.p.A. > Sede Legale: Circonvallazione Idroscalo - 20090 Segrate (MI) > Cap. Soc. euro 347.256.998,80 > C. F. e Reg. Imprese MI 01442240030 - Partita IVA 10914660153 > Societ? con unico azionista > Societ? soggetta all?attivit? di direzione e coordinamento di > International Business Machines Corporation > > (Salvo che sia diversamente indicato sopra / Unless stated otherwise > above) IBM Italia S.p.A. Sede Legale: Circonvallazione Idroscalo - 20090 Segrate (MI) Cap. Soc. euro 347.256.998,80 C. F. e Reg. Imprese MI 01442240030 - Partita IVA 10914660153 Societ? con unico azionista Societ? soggetta all?attivit? di direzione e coordinamento di International Business Machines Corporation (Salvo che sia diversamente indicato sopra / Unless stated otherwise above) From michel.trudeau at oracle.com Mon Jan 30 15:18:46 2017 From: michel.trudeau at oracle.com (Michel Trudeau) Date: Mon, 30 Jan 2017 07:18:46 -0800 Subject: nashorn.jar is opensource? In-Reply-To: References: <3002524C-92D3-4161-8070-2BFCC2DF45D1@oracle.com> Message-ID: <588F5956.2050006@oracle.com> It's all under http://hg.openjdk.java.net/jdk9/jdk9/nashorn/ -- --Michel > Luisa Pace > January 30, 2017 at 6:28 AMvia Postbox > > Hi Jim, > thanks a lot for your quick answer. > > We've opened the link you provided me and downloaded the zip, but it seems > to point to openjdk source code and not to nashorn source code only. > > Could you please specify what directory contains the nashorn code or send > me the direct link to its source code? > > Thanks again. > > Best Regards/Cordiali saluti > Luisa Pace > > ========================================================================================================================= > > Ci? che ? fuori ? anche dentro; e ci? che non ? dentro non ? da nessuna > parte. Per questo viaggiare non serve. Se uno non ha niente dentro, non > trover? mai niente fuori. ? inutile andare a cercare nel mondo quel che > non si riesce a trovare dentro di s?. (Tiziano Terzani) > > ========================================================================================================================== > > > Ing. Luisa Pace > IBM Italy > Bluemix Legal Project Manager > Via Sciangai, 53 (B1 - 508) > 00144 Roma > Italy > Tel. +39.06.5966.3795 > Fax. +39.06.5966.3489 > mob. +39.335.7368629 > e-mail: luisa_pace at it.ibm.com > > > > > From: "Jim Laskey (Oracle)" > To: Luisa Pace/Italy/IBM at IBMIT > Cc: nashorn-dev at openjdk.java.net > Date: 30/01/2017 14.31 > Subject: Re: nashorn.jar is opensource? > > > > Luisa, > > Hello. Response is inlined. > > Cheers, > > ? Jim > >> On Jan 30, 2017, at 6:58 AM, Luisa Pace wrote: >> >> Hi, >> >> I am an IBM employee that work in legal team of Bluemix, the PaaS > platform >> of IBM. This platform is based on CloudFoundry, an open source project >> and my goal is to analyze with some software tools the licenses of all >> CloudFoundry components and their dependencies to check if they can be >> included in Bluemix without legal issues. >> >> To do that, I need of the source of all the CloudFoundry components and >> their dependencies. >> >> In the case I'm managing now, Cloudfoundry (level 245) contains openjdk >> 1.8.0_101, that in turn contains nashorn.jar. >> >> But I was not able to find the source code of nashorn.jar . >> >> So, I've two questions: >> >> Could you please tell me if nashorn is an open source and in this case >> send me the link to its source code? > > http://hg.openjdk.java.net/jdk9/dev/ > > >> What is the license of nashorn? > > GPL + ClassPath, the same as the Open JDK. > > >> Fell be free to ask me other details. >> >> Thanks a lot for your support. >> >> Best Regards/Cordiali saluti >> Luisa Pace >> >> > ========================================================================================================================= >> Ci? che ? fuori ? anche dentro; e ci? che non ? dentro non ? da nessuna >> parte. Per questo viaggiare non serve. Se uno non ha niente dentro, non >> trover? mai niente fuori. ? inutile andare a cercare nel mondo quel > che >> non si riesce a trovare dentro di s?. (Tiziano Terzani) >> >> > ========================================================================================================================== >> Ing. Luisa Pace >> IBM Italy >> Bluemix Legal Project Manager >> Via Sciangai, 53 (B1 - 508) >> 00144 Roma >> Italy >> Tel. +39.06.5966.3795 >> Fax. +39.06.5966.3489 >> mob. +39.335.7368629 >> e-mail: luisa_pace at it.ibm.com >> >> IBM Italia S.p.A. >> Sede Legale: Circonvallazione Idroscalo - 20090 Segrate (MI) >> Cap. Soc. euro 347.256.998,80 >> C. F. e Reg. Imprese MI 01442240030 - Partita IVA 10914660153 >> Societ? con unico azionista >> Societ? soggetta all?attivit? di direzione e coordinamento di >> International Business Machines Corporation >> >> (Salvo che sia diversamente indicato sopra / Unless stated otherwise >> above) > > > > > IBM Italia S.p.A. > Sede Legale: Circonvallazione Idroscalo - 20090 Segrate (MI) > Cap. Soc. euro 347.256.998,80 > C. F. e Reg. Imprese MI 01442240030 - Partita IVA 10914660153 > Societ? con unico azionista > Societ? soggetta all?attivit? di direzione e coordinamento di > International Business Machines Corporation > > (Salvo che sia diversamente indicato sopra / Unless stated otherwise > above) > Jim Laskey (Oracle) > January 30, 2017 at 5:31 AMvia Postbox > > Luisa, > > Hello. Response is inlined. > > Cheers, > > ? Jim > >> On Jan 30, 2017, at 6:58 AM, Luisa Pace wrote: >> >> Hi, >> >> I am an IBM employee that work in legal team of Bluemix, the PaaS platform >> of IBM. This platform is based on CloudFoundry, an open source project >> and my goal is to analyze with some software tools the licenses of all >> CloudFoundry components and their dependencies to check if they can be >> included in Bluemix without legal issues. >> >> To do that, I need of the source of all the CloudFoundry components and >> their dependencies. >> >> In the case I'm managing now, Cloudfoundry (level 245) contains openjdk >> 1.8.0_101, that in turn contains nashorn.jar. >> >> But I was not able to find the source code of nashorn.jar . >> >> So, I've two questions: >> >> Could you please tell me if nashorn is an open source and in this case >> send me the link to its source code? > > http://hg.openjdk.java.net/jdk9/dev/ > > >> What is the license of nashorn? > > GPL + ClassPath, the same as the Open JDK. > > >> Fell be free to ask me other details. >> >> Thanks a lot for your support. >> >> Best Regards/Cordiali saluti >> Luisa Pace >> >> ========================================================================================================================= >> >> Ci? che ? fuori ? anche dentro; e ci? che non ? dentro non ? da nessuna >> parte. Per questo viaggiare non serve. Se uno non ha niente dentro, non >> trover? mai niente fuori. ? inutile andare a cercare nel mondo quel che >> non si riesce a trovare dentro di s?. (Tiziano Terzani) >> >> ========================================================================================================================== >> >> >> Ing. Luisa Pace >> IBM Italy >> Bluemix Legal Project Manager >> Via Sciangai, 53 (B1 - 508) >> 00144 Roma >> Italy >> Tel. +39.06.5966.3795 >> Fax. +39.06.5966.3489 >> mob. +39.335.7368629 >> e-mail: luisa_pace at it.ibm.com >> >> IBM Italia S.p.A. >> Sede Legale: Circonvallazione Idroscalo - 20090 Segrate (MI) >> Cap. Soc. euro 347.256.998,80 >> C. F. e Reg. Imprese MI 01442240030 - Partita IVA 10914660153 >> Societ? con unico azionista >> Societ? soggetta all?attivit? di direzione e coordinamento di >> International Business Machines Corporation >> >> (Salvo che sia diversamente indicato sopra / Unless stated otherwise >> above) > > Luisa Pace > January 30, 2017 at 2:58 AMvia Postbox > > Hi, > > I am an IBM employee that work in legal team of Bluemix, the PaaS > platform > of IBM. This platform is based on CloudFoundry, an open source project > and my goal is to analyze with some software tools the licenses of all > CloudFoundry components and their dependencies to check if they can be > included in Bluemix without legal issues. > > To do that, I need of the source of all the CloudFoundry components and > their dependencies. > > In the case I'm managing now, Cloudfoundry (level 245) contains openjdk > 1.8.0_101, that in turn contains nashorn.jar. > > But I was not able to find the source code of nashorn.jar . > > So, I've two questions: > > Could you please tell me if nashorn is an open source and in this case > send me the link to its source code? > What is the license of nashorn? > > Fell be free to ask me other details. > > Thanks a lot for your support. > > Best Regards/Cordiali saluti > Luisa Pace > > ========================================================================================================================= > > Ci? che ? fuori ? anche dentro; e ci? che non ? dentro non ? da nessuna > parte. Per questo viaggiare non serve. Se uno non ha niente dentro, non > trover? mai niente fuori. ? inutile andare a cercare nel mondo quel che > non si riesce a trovare dentro di s?. (Tiziano Terzani) > > ========================================================================================================================== > > > Ing. Luisa Pace > IBM Italy > Bluemix Legal Project Manager > Via Sciangai, 53 (B1 - 508) > 00144 Roma > Italy > Tel. +39.06.5966.3795 > Fax. +39.06.5966.3489 > mob. +39.335.7368629 > e-mail: luisa_pace at it.ibm.com > > IBM Italia S.p.A. > Sede Legale: Circonvallazione Idroscalo - 20090 Segrate (MI) > Cap. Soc. euro 347.256.998,80 > C. F. e Reg. Imprese MI 01442240030 - Partita IVA 10914660153 > Societ? con unico azionista > Societ? soggetta all?attivit? di direzione e coordinamento di > International Business Machines Corporation > > (Salvo che sia diversamente indicato sopra / Unless stated otherwise > above) From luisa_pace at it.ibm.com Mon Jan 30 16:19:53 2017 From: luisa_pace at it.ibm.com (Luisa Pace) Date: Mon, 30 Jan 2017 17:19:53 +0100 Subject: nashorn.jar is opensource? In-Reply-To: <588F5956.2050006@oracle.com> References: <3002524C-92D3-4161-8070-2BFCC2DF45D1@oracle.com> <588F5956.2050006@oracle.com> Message-ID: Thanks a lot for your kindly and quick help! I've another questions on nashorn: is it a component of OpenJDK? I mean: is its source code part of OpenJDK source code or it's something "external" to it? Thanks again. Best Regards/Cordiali saluti Luisa Pace ========================================================================================================================= Ci? che ? fuori ? anche dentro; e ci? che non ? dentro non ? da nessuna parte. Per questo viaggiare non serve. Se uno non ha niente dentro, non trover? mai niente fuori. ? inutile andare a cercare nel mondo quel che non si riesce a trovare dentro di s?. (Tiziano Terzani) ========================================================================================================================== Ing. Luisa Pace IBM Italy Bluemix Legal Project Manager Via Sciangai, 53 (B1 - 508) 00144 Roma Italy Tel. +39.06.5966.3795 Fax. +39.06.5966.3489 mob. +39.335.7368629 e-mail: luisa_pace at it.ibm.com From: Michel Trudeau To: Luisa Pace/Italy/IBM at IBMIT Cc: "Jim Laskey (Oracle)" , nashorn-dev at openjdk.java.net, Salvatore D'Angelo/Italy/IBM at IBMIT Date: 30/01/2017 16.19 Subject: Re: nashorn.jar is opensource? It's all under http://hg.openjdk.java.net/jdk9/jdk9/nashorn/ -- --Michel Luisa Pace January 30, 2017 at 6:28 AM via Postbox Hi Jim, thanks a lot for your quick answer. We've opened the link you provided me and downloaded the zip, but it seems to point to openjdk source code and not to nashorn source code only. Could you please specify what directory contains the nashorn code or send me the direct link to its source code? Thanks again. Best Regards/Cordiali saluti Luisa Pace ========================================================================================================================= Ci? che ? fuori ? anche dentro; e ci? che non ? dentro non ? da nessuna parte. Per questo viaggiare non serve. Se uno non ha niente dentro, non trover? mai niente fuori. ? inutile andare a cercare nel mondo quel che non si riesce a trovare dentro di s?. (Tiziano Terzani) ========================================================================================================================== Ing. Luisa Pace IBM Italy Bluemix Legal Project Manager Via Sciangai, 53 (B1 - 508) 00144 Roma Italy Tel. +39.06.5966.3795 Fax. +39.06.5966.3489 mob. +39.335.7368629 e-mail: luisa_pace at it.ibm.com From: "Jim Laskey (Oracle)" To: Luisa Pace/Italy/IBM at IBMIT Cc: nashorn-dev at openjdk.java.net Date: 30/01/2017 14.31 Subject: Re: nashorn.jar is opensource? Luisa, Hello. Response is inlined. Cheers, ? Jim On Jan 30, 2017, at 6:58 AM, Luisa Pace wrote: Hi, I am an IBM employee that work in legal team of Bluemix, the PaaS platform of IBM. This platform is based on CloudFoundry, an open source project and my goal is to analyze with some software tools the licenses of all CloudFoundry components and their dependencies to check if they can be included in Bluemix without legal issues. To do that, I need of the source of all the CloudFoundry components and their dependencies. In the case I'm managing now, Cloudfoundry (level 245) contains openjdk 1.8.0_101, that in turn contains nashorn.jar. But I was not able to find the source code of nashorn.jar . So, I've two questions: Could you please tell me if nashorn is an open source and in this case send me the link to its source code? http://hg.openjdk.java.net/jdk9/dev/ What is the license of nashorn? GPL + ClassPath, the same as the Open JDK. Fell be free to ask me other details. Thanks a lot for your support. Best Regards/Cordiali saluti Luisa Pace ========================================================================================================================= Ci? che ? fuori ? anche dentro; e ci? che non ? dentro non ? da nessuna parte. Per questo viaggiare non serve. Se uno non ha niente dentro, non trover? mai niente fuori. ? inutile andare a cercare nel mondo quel che non si riesce a trovare dentro di s?. (Tiziano Terzani) ========================================================================================================================== Ing. Luisa Pace IBM Italy Bluemix Legal Project Manager Via Sciangai, 53 (B1 - 508) 00144 Roma Italy Tel. +39.06.5966.3795 Fax. +39.06.5966.3489 mob. +39.335.7368629 e-mail: luisa_pace at it.ibm.com IBM Italia S.p.A. Sede Legale: Circonvallazione Idroscalo - 20090 Segrate (MI) Cap. Soc. euro 347.256.998,80 C. F. e Reg. Imprese MI 01442240030 - Partita IVA 10914660153 Societ? con unico azionista Societ? soggetta all?attivit? di direzione e coordinamento di International Business Machines Corporation (Salvo che sia diversamente indicato sopra / Unless stated otherwise above) IBM Italia S.p.A. Sede Legale: Circonvallazione Idroscalo - 20090 Segrate (MI) Cap. Soc. euro 347.256.998,80 C. F. e Reg. Imprese MI 01442240030 - Partita IVA 10914660153 Societ? con unico azionista Societ? soggetta all?attivit? di direzione e coordinamento di International Business Machines Corporation (Salvo che sia diversamente indicato sopra / Unless stated otherwise above) Jim Laskey (Oracle) January 30, 2017 at 5:31 AM via Postbox Luisa, Hello. Response is inlined. Cheers, ? Jim On Jan 30, 2017, at 6:58 AM, Luisa Pace wrote: Hi, I am an IBM employee that work in legal team of Bluemix, the PaaS platform of IBM. This platform is based on CloudFoundry, an open source project and my goal is to analyze with some software tools the licenses of all CloudFoundry components and their dependencies to check if they can be included in Bluemix without legal issues. To do that, I need of the source of all the CloudFoundry components and their dependencies. In the case I'm managing now, Cloudfoundry (level 245) contains openjdk 1.8.0_101, that in turn contains nashorn.jar. But I was not able to find the source code of nashorn.jar . So, I've two questions: Could you please tell me if nashorn is an open source and in this case send me the link to its source code? http://hg.openjdk.java.net/jdk9/dev/ What is the license of nashorn? GPL + ClassPath, the same as the Open JDK. Fell be free to ask me other details. Thanks a lot for your support. Best Regards/Cordiali saluti Luisa Pace ========================================================================================================================= Ci? che ? fuori ? anche dentro; e ci? che non ? dentro non ? da nessuna parte. Per questo viaggiare non serve. Se uno non ha niente dentro, non trover? mai niente fuori. ? inutile andare a cercare nel mondo quel che non si riesce a trovare dentro di s?. (Tiziano Terzani) ========================================================================================================================== Ing. Luisa Pace IBM Italy Bluemix Legal Project Manager Via Sciangai, 53 (B1 - 508) 00144 Roma Italy Tel. +39.06.5966.3795 Fax. +39.06.5966.3489 mob. +39.335.7368629 e-mail: luisa_pace at it.ibm.com IBM Italia S.p.A. Sede Legale: Circonvallazione Idroscalo - 20090 Segrate (MI) Cap. Soc. euro 347.256.998,80 C. F. e Reg. Imprese MI 01442240030 - Partita IVA 10914660153 Societ? con unico azionista Societ? soggetta all?attivit? di direzione e coordinamento di International Business Machines Corporation (Salvo che sia diversamente indicato sopra / Unless stated otherwise above) Luisa Pace January 30, 2017 at 2:58 AM via Postbox Hi, I am an IBM employee that work in legal team of Bluemix, the PaaS platform of IBM. This platform is based on CloudFoundry, an open source project and my goal is to analyze with some software tools the licenses of all CloudFoundry components and their dependencies to check if they can be included in Bluemix without legal issues. To do that, I need of the source of all the CloudFoundry components and their dependencies. In the case I'm managing now, Cloudfoundry (level 245) contains openjdk 1.8.0_101, that in turn contains nashorn.jar. But I was not able to find the source code of nashorn.jar . So, I've two questions: Could you please tell me if nashorn is an open source and in this case send me the link to its source code? What is the license of nashorn? Fell be free to ask me other details. Thanks a lot for your support. Best Regards/Cordiali saluti Luisa Pace ========================================================================================================================= Ci? che ? fuori ? anche dentro; e ci? che non ? dentro non ? da nessuna parte. Per questo viaggiare non serve. Se uno non ha niente dentro, non trover? mai niente fuori. ? inutile andare a cercare nel mondo quel che non si riesce a trovare dentro di s?. (Tiziano Terzani) ========================================================================================================================== Ing. Luisa Pace IBM Italy Bluemix Legal Project Manager Via Sciangai, 53 (B1 - 508) 00144 Roma Italy Tel. +39.06.5966.3795 Fax. +39.06.5966.3489 mob. +39.335.7368629 e-mail: luisa_pace at it.ibm.com IBM Italia S.p.A. Sede Legale: Circonvallazione Idroscalo - 20090 Segrate (MI) Cap. Soc. euro 347.256.998,80 C. F. e Reg. Imprese MI 01442240030 - Partita IVA 10914660153 Societ? con unico azionista Societ? soggetta all?attivit? di direzione e coordinamento di International Business Machines Corporation (Salvo che sia diversamente indicato sopra / Unless stated otherwise above) IBM Italia S.p.A. Sede Legale: Circonvallazione Idroscalo - 20090 Segrate (MI) Cap. Soc. euro 347.256.998,80 C. F. e Reg. Imprese MI 01442240030 - Partita IVA 10914660153 Societ? con unico azionista Societ? soggetta all?attivit? di direzione e coordinamento di International Business Machines Corporation (Salvo che sia diversamente indicato sopra / Unless stated otherwise above) From michel.trudeau at oracle.com Mon Jan 30 16:20:44 2017 From: michel.trudeau at oracle.com (Michel Trudeau) Date: Mon, 30 Jan 2017 08:20:44 -0800 Subject: nashorn.jar is opensource? In-Reply-To: References: <3002524C-92D3-4161-8070-2BFCC2DF45D1@oracle.com> <588F5956.2050006@oracle.com> Message-ID: <588F67DC.7050105@oracle.com> Part of OpenJDK. -- --Michel > Luisa Pace > January 30, 2017 at 8:19 AMvia Postbox > > Thanks a lot for your kindly and quick help! > > I've another questions on nashorn: is it a component of OpenJDK? I > mean: is its source code part of OpenJDK source code or it's something > "external" to it? > > Thanks again. > > Best Regards/Cordiali saluti > Luisa Pace > > ========================================================================================================================= > > Ci? che ? fuori ? anche dentro; e ci? che non ? dentro non ? da > nessuna parte. Per questo viaggiare non serve. Se uno non ha niente > dentro, non trover? mai niente fuori. ? inutile andare a cercare nel > mondo quel che non si riesce a trovare dentro di s?. (Tiziano Terzani) > > ========================================================================================================================== > > > Ing. Luisa Pace > IBM Italy > Bluemix Legal Project Manager > Via Sciangai, 53 (B1 - 508) > 00144 Roma > Italy > Tel. +39.06.5966.3795 > Fax. +39.06.5966.3489 > mob. +39.335.7368629 > e-mail: luisa_pace at it.ibm.com > > > > > From: Michel Trudeau > To: Luisa Pace/Italy/IBM at IBMIT > Cc: "Jim Laskey (Oracle)" , > nashorn-dev at openjdk.java.net, Salvatore D'Angelo/Italy/IBM at IBMIT > Date: 30/01/2017 16.19 > Subject: Re: nashorn.jar is opensource? > ------------------------------------------------------------------------ > > > > It's all under _http://hg.openjdk.java.net/jdk9/jdk9/nashorn/_ > > -- > --Michel > > > > Luisa Pace > January 30, 2017 at 6:28 AMvia Postbox > > > Hi Jim, > thanks a lot for your quick answer. > > We've opened the link you provided me and downloaded the zip, but it > seems > to point to openjdk source code and not to nashorn source code only. > > Could you please specify what directory contains the nashorn code or send > me the direct link to its source code? > > Thanks again. > > Best Regards/Cordiali saluti > Luisa Pace > > ========================================================================================================================= > > Ci? che ? fuori ? anche dentro; e ci? che non ? dentro non ? da nessuna > parte. Per questo viaggiare non serve. Se uno non ha niente dentro, non > trover? mai niente fuori. ? inutile andare a cercare nel mondo quel che > non si riesce a trovare dentro di s?. (Tiziano Terzani) > > ========================================================================================================================== > > > Ing. Luisa Pace > IBM Italy > Bluemix Legal Project Manager > Via Sciangai, 53 (B1 - 508) > 00144 Roma > Italy > Tel. +39.06.5966.3795 > Fax. +39.06.5966.3489 > mob. +39.335.7368629 > e-mail: _luisa_pace at it.ibm.com_ > > > > > From: "Jim Laskey (Oracle)" __ > > To: Luisa Pace/Italy/IBM at IBMIT > Cc: _nashorn-dev at openjdk.java.net_ > Date: 30/01/2017 14.31 > Subject: Re: nashorn.jar is opensource? > > > > Luisa, > > Hello. Response is inlined. > > Cheers, > > ? Jim > > > On Jan 30, 2017, at 6:58 AM, Luisa Pace __ > wrote: > > Hi, > > I am an IBM employee that work in legal team of Bluemix, the PaaS > > platform > > of IBM. This platform is based on CloudFoundry, an open source project > and my goal is to analyze with some software tools the licenses of all > CloudFoundry components and their dependencies to check if they can be > included in Bluemix without legal issues. > > To do that, I need of the source of all the CloudFoundry components and > their dependencies. > > In the case I'm managing now, Cloudfoundry (level 245) contains openjdk > 1.8.0_101, that in turn contains nashorn.jar. > > But I was not able to find the source code of nashorn.jar . > > So, I've two questions: > > Could you please tell me if nashorn is an open source and in this case > send me the link to its source code? > > > _http://hg.openjdk.java.net/jdk9/dev/_ > > > > What is the license of nashorn? > > > GPL + ClassPath, the same as the Open JDK. > > > > Fell be free to ask me other details. > > Thanks a lot for your support. > > Best Regards/Cordiali saluti > Luisa Pace > > > > ========================================================================================================================= > > Ci? che ? fuori ? anche dentro; e ci? che non ? dentro non ? da nessuna > parte. Per questo viaggiare non serve. Se uno non ha niente dentro, non > trover? mai niente fuori. ? inutile andare a cercare nel mondo quel > > che > > non si riesce a trovare dentro di s?. (Tiziano Terzani) > > > > ========================================================================================================================== > > Ing. Luisa Pace > IBM Italy > Bluemix Legal Project Manager > Via Sciangai, 53 (B1 - 508) > 00144 Roma > Italy > Tel. +39.06.5966.3795 > Fax. +39.06.5966.3489 > mob. +39.335.7368629 > e-mail: _luisa_pace at it.ibm.com_ > > IBM Italia S.p.A. > Sede Legale: Circonvallazione Idroscalo - 20090 Segrate (MI) > Cap. Soc. euro 347.256.998,80 > C. F. e Reg. Imprese MI 01442240030 - Partita IVA 10914660153 > Societ? con unico azionista > Societ? soggetta all?attivit? di direzione e coordinamento di > International Business Machines Corporation > > (Salvo che sia diversamente indicato sopra / Unless stated otherwise > above) > > > > > > IBM Italia S.p.A. > Sede Legale: Circonvallazione Idroscalo - 20090 Segrate (MI) > Cap. Soc. euro 347.256.998,80 > C. F. e Reg. Imprese MI 01442240030 - Partita IVA 10914660153 > Societ? con unico azionista > Societ? soggetta all?attivit? di direzione e coordinamento di > International Business Machines Corporation > > (Salvo che sia diversamente indicato sopra / Unless stated otherwise > above) > > Jim Laskey (Oracle) > January 30, 2017 at 5:31 AMvia Postbox > > > Luisa, > > Hello. Response is inlined. > > Cheers, > > ? Jim > > > On Jan 30, 2017, at 6:58 AM, Luisa Pace __ > wrote: > > Hi, > > I am an IBM employee that work in legal team of Bluemix, the PaaS > platform > of IBM. This platform is based on CloudFoundry, an open source project > and my goal is to analyze with some software tools the licenses of all > CloudFoundry components and their dependencies to check if they can be > included in Bluemix without legal issues. > > To do that, I need of the source of all the CloudFoundry components and > their dependencies. > > In the case I'm managing now, Cloudfoundry (level 245) contains openjdk > 1.8.0_101, that in turn contains nashorn.jar. > > But I was not able to find the source code of nashorn.jar . > > So, I've two questions: > > Could you please tell me if nashorn is an open source and in this case > send me the link to its source code? > > > _http://hg.openjdk.java.net/jdk9/dev/_ > > > > What is the license of nashorn? > > > GPL + ClassPath, the same as the Open JDK. > > > > Fell be free to ask me other details. > > Thanks a lot for your support. > > Best Regards/Cordiali saluti > Luisa Pace > > ========================================================================================================================= > > Ci? che ? fuori ? anche dentro; e ci? che non ? dentro non ? da nessuna > parte. Per questo viaggiare non serve. Se uno non ha niente dentro, non > trover? mai niente fuori. ? inutile andare a cercare nel mondo quel che > non si riesce a trovare dentro di s?. (Tiziano Terzani) > > ========================================================================================================================== > > > Ing. Luisa Pace > IBM Italy > Bluemix Legal Project Manager > Via Sciangai, 53 (B1 - 508) > 00144 Roma > Italy > Tel. +39.06.5966.3795 > Fax. +39.06.5966.3489 > mob. +39.335.7368629 > e-mail: _luisa_pace at it.ibm.com_ > > IBM Italia S.p.A. > Sede Legale: Circonvallazione Idroscalo - 20090 Segrate (MI) > Cap. Soc. euro 347.256.998,80 > C. F. e Reg. Imprese MI 01442240030 - Partita IVA 10914660153 > Societ? con unico azionista > Societ? soggetta all?attivit? di direzione e coordinamento di > International Business Machines Corporation > > (Salvo che sia diversamente indicato sopra / Unless stated otherwise > above) > > > > Luisa Pace > January 30, 2017 at 2:58 AMvia Postbox > > > Hi, > > I am an IBM employee that work in legal team of Bluemix, the PaaS > platform > of IBM. This platform is based on CloudFoundry, an open source project > and my goal is to analyze with some software tools the licenses of all > CloudFoundry components and their dependencies to check if they can be > included in Bluemix without legal issues. > > To do that, I need of the source of all the CloudFoundry components and > their dependencies. > > In the case I'm managing now, Cloudfoundry (level 245) contains openjdk > 1.8.0_101, that in turn contains nashorn.jar. > > But I was not able to find the source code of nashorn.jar . > > So, I've two questions: > > Could you please tell me if nashorn is an open source and in this case > send me the link to its source code? > What is the license of nashorn? > > Fell be free to ask me other details. > > Thanks a lot for your support. > > Best Regards/Cordiali saluti > Luisa Pace > > ========================================================================================================================= > > Ci? che ? fuori ? anche dentro; e ci? che non ? dentro non ? da nessuna > parte. Per questo viaggiare non serve. Se uno non ha niente dentro, non > trover? mai niente fuori. ? inutile andare a cercare nel mondo quel che > non si riesce a trovare dentro di s?. (Tiziano Terzani) > > ========================================================================================================================== > > > Ing. Luisa Pace > IBM Italy > Bluemix Legal Project Manager > Via Sciangai, 53 (B1 - 508) > 00144 Roma > Italy > Tel. +39.06.5966.3795 > Fax. +39.06.5966.3489 > mob. +39.335.7368629 > e-mail: _luisa_pace at it.ibm.com_ > > IBM Italia S.p.A. > Sede Legale: Circonvallazione Idroscalo - 20090 Segrate (MI) > Cap. Soc. euro 347.256.998,80 > C. F. e Reg. Imprese MI 01442240030 - Partita IVA 10914660153 > Societ? con unico azionista > Societ? soggetta all?attivit? di direzione e coordinamento di > International Business Machines Corporation > > (Salvo che sia diversamente indicato sopra / Unless stated otherwise > above) > > > > IBM Italia S.p.A. > Sede Legale: Circonvallazione Idroscalo - 20090 Segrate (MI) > Cap. Soc. euro 347.256.998,80 > C. F. e Reg. Imprese MI 01442240030 - Partita IVA 10914660153 > Societ? con unico azionista > Societ? soggetta all?attivit? di direzione e coordinamento di > International Business Machines Corporation > > (Salvo che sia diversamente indicato sopra / Unless stated otherwise > above) > Michel Trudeau > January 30, 2017 at 7:18 AMvia Postbox > > It's all under http://hg.openjdk.java.net/jdk9/jdk9/nashorn/ > > > > > Luisa Pace > January 30, 2017 at 6:28 AMvia Postbox > > Hi Jim, > thanks a lot for your quick answer. > > We've opened the link you provided me and downloaded the zip, but it seems > to point to openjdk source code and not to nashorn source code only. > > Could you please specify what directory contains the nashorn code or send > me the direct link to its source code? > > Thanks again. > > Best Regards/Cordiali saluti > Luisa Pace > > ========================================================================================================================= > > Ci? che ? fuori ? anche dentro; e ci? che non ? dentro non ? da nessuna > parte. Per questo viaggiare non serve. Se uno non ha niente dentro, non > trover? mai niente fuori. ? inutile andare a cercare nel mondo quel che > non si riesce a trovare dentro di s?. (Tiziano Terzani) > > ========================================================================================================================== > > > Ing. Luisa Pace > IBM Italy > Bluemix Legal Project Manager > Via Sciangai, 53 (B1 - 508) > 00144 Roma > Italy > Tel. +39.06.5966.3795 > Fax. +39.06.5966.3489 > mob. +39.335.7368629 > e-mail: luisa_pace at it.ibm.com > > > > > From: "Jim Laskey (Oracle)" > To: Luisa Pace/Italy/IBM at IBMIT > Cc: nashorn-dev at openjdk.java.net > Date: 30/01/2017 14.31 > Subject: Re: nashorn.jar is opensource? > > > > Luisa, > > Hello. Response is inlined. > > Cheers, > > ? Jim > >> On Jan 30, 2017, at 6:58 AM, Luisa Pace wrote: >> >> Hi, >> >> I am an IBM employee that work in legal team of Bluemix, the PaaS > platform >> of IBM. This platform is based on CloudFoundry, an open source project >> and my goal is to analyze with some software tools the licenses of all >> CloudFoundry components and their dependencies to check if they can be >> included in Bluemix without legal issues. >> >> To do that, I need of the source of all the CloudFoundry components and >> their dependencies. >> >> In the case I'm managing now, Cloudfoundry (level 245) contains openjdk >> 1.8.0_101, that in turn contains nashorn.jar. >> >> But I was not able to find the source code of nashorn.jar . >> >> So, I've two questions: >> >> Could you please tell me if nashorn is an open source and in this case >> send me the link to its source code? > > http://hg.openjdk.java.net/jdk9/dev/ > > >> What is the license of nashorn? > > GPL + ClassPath, the same as the Open JDK. > > >> Fell be free to ask me other details. >> >> Thanks a lot for your support. >> >> Best Regards/Cordiali saluti >> Luisa Pace >> >> > ========================================================================================================================= >> Ci? che ? fuori ? anche dentro; e ci? che non ? dentro non ? da nessuna >> parte. Per questo viaggiare non serve. Se uno non ha niente dentro, non >> trover? mai niente fuori. ? inutile andare a cercare nel mondo quel > che >> non si riesce a trovare dentro di s?. (Tiziano Terzani) >> >> > ========================================================================================================================== >> Ing. Luisa Pace >> IBM Italy >> Bluemix Legal Project Manager >> Via Sciangai, 53 (B1 - 508) >> 00144 Roma >> Italy >> Tel. +39.06.5966.3795 >> Fax. +39.06.5966.3489 >> mob. +39.335.7368629 >> e-mail: luisa_pace at it.ibm.com >> >> IBM Italia S.p.A. >> Sede Legale: Circonvallazione Idroscalo - 20090 Segrate (MI) >> Cap. Soc. euro 347.256.998,80 >> C. F. e Reg. Imprese MI 01442240030 - Partita IVA 10914660153 >> Societ? con unico azionista >> Societ? soggetta all?attivit? di direzione e coordinamento di >> International Business Machines Corporation >> >> (Salvo che sia diversamente indicato sopra / Unless stated otherwise >> above) > > > > > IBM Italia S.p.A. > Sede Legale: Circonvallazione Idroscalo - 20090 Segrate (MI) > Cap. Soc. euro 347.256.998,80 > C. F. e Reg. Imprese MI 01442240030 - Partita IVA 10914660153 > Societ? con unico azionista > Societ? soggetta all?attivit? di direzione e coordinamento di > International Business Machines Corporation > > (Salvo che sia diversamente indicato sopra / Unless stated otherwise > above) > Jim Laskey (Oracle) > January 30, 2017 at 5:31 AMvia Postbox > > Luisa, > > Hello. Response is inlined. > > Cheers, > > ? Jim > >> On Jan 30, 2017, at 6:58 AM, Luisa Pace wrote: >> >> Hi, >> >> I am an IBM employee that work in legal team of Bluemix, the PaaS platform >> of IBM. This platform is based on CloudFoundry, an open source project >> and my goal is to analyze with some software tools the licenses of all >> CloudFoundry components and their dependencies to check if they can be >> included in Bluemix without legal issues. >> >> To do that, I need of the source of all the CloudFoundry components and >> their dependencies. >> >> In the case I'm managing now, Cloudfoundry (level 245) contains openjdk >> 1.8.0_101, that in turn contains nashorn.jar. >> >> But I was not able to find the source code of nashorn.jar . >> >> So, I've two questions: >> >> Could you please tell me if nashorn is an open source and in this case >> send me the link to its source code? > > http://hg.openjdk.java.net/jdk9/dev/ > > >> What is the license of nashorn? > > GPL + ClassPath, the same as the Open JDK. > > >> Fell be free to ask me other details. >> >> Thanks a lot for your support. >> >> Best Regards/Cordiali saluti >> Luisa Pace >> >> ========================================================================================================================= >> >> Ci? che ? fuori ? anche dentro; e ci? che non ? dentro non ? da nessuna >> parte. Per questo viaggiare non serve. Se uno non ha niente dentro, non >> trover? mai niente fuori. ? inutile andare a cercare nel mondo quel che >> non si riesce a trovare dentro di s?. (Tiziano Terzani) >> >> ========================================================================================================================== >> >> >> Ing. Luisa Pace >> IBM Italy >> Bluemix Legal Project Manager >> Via Sciangai, 53 (B1 - 508) >> 00144 Roma >> Italy >> Tel. +39.06.5966.3795 >> Fax. +39.06.5966.3489 >> mob. +39.335.7368629 >> e-mail: luisa_pace at it.ibm.com >> >> IBM Italia S.p.A. >> Sede Legale: Circonvallazione Idroscalo - 20090 Segrate (MI) >> Cap. Soc. euro 347.256.998,80 >> C. F. e Reg. Imprese MI 01442240030 - Partita IVA 10914660153 >> Societ? con unico azionista >> Societ? soggetta all?attivit? di direzione e coordinamento di >> International Business Machines Corporation >> >> (Salvo che sia diversamente indicato sopra / Unless stated otherwise >> above) > > Luisa Pace > January 30, 2017 at 2:58 AMvia Postbox > > Hi, > > I am an IBM employee that work in legal team of Bluemix, the PaaS > platform > of IBM. This platform is based on CloudFoundry, an open source project > and my goal is to analyze with some software tools the licenses of all > CloudFoundry components and their dependencies to check if they can be > included in Bluemix without legal issues. > > To do that, I need of the source of all the CloudFoundry components and > their dependencies. > > In the case I'm managing now, Cloudfoundry (level 245) contains openjdk > 1.8.0_101, that in turn contains nashorn.jar. > > But I was not able to find the source code of nashorn.jar . > > So, I've two questions: > > Could you please tell me if nashorn is an open source and in this case > send me the link to its source code? > What is the license of nashorn? > > Fell be free to ask me other details. > > Thanks a lot for your support. > > Best Regards/Cordiali saluti > Luisa Pace > > ========================================================================================================================= > > Ci? che ? fuori ? anche dentro; e ci? che non ? dentro non ? da nessuna > parte. Per questo viaggiare non serve. Se uno non ha niente dentro, non > trover? mai niente fuori. ? inutile andare a cercare nel mondo quel che > non si riesce a trovare dentro di s?. (Tiziano Terzani) > > ========================================================================================================================== > > > Ing. Luisa Pace > IBM Italy > Bluemix Legal Project Manager > Via Sciangai, 53 (B1 - 508) > 00144 Roma > Italy > Tel. +39.06.5966.3795 > Fax. +39.06.5966.3489 > mob. +39.335.7368629 > e-mail: luisa_pace at it.ibm.com > > IBM Italia S.p.A. > Sede Legale: Circonvallazione Idroscalo - 20090 Segrate (MI) > Cap. Soc. euro 347.256.998,80 > C. F. e Reg. Imprese MI 01442240030 - Partita IVA 10914660153 > Societ? con unico azionista > Societ? soggetta all?attivit? di direzione e coordinamento di > International Business Machines Corporation > > (Salvo che sia diversamente indicato sopra / Unless stated otherwise > above) From luisa_pace at it.ibm.com Mon Jan 30 16:29:59 2017 From: luisa_pace at it.ibm.com (Luisa Pace) Date: Mon, 30 Jan 2017 16:29:59 +0000 Subject: nashorn.jar is opensource? In-Reply-To: <588F67DC.7050105@oracle.com> References: <3002524C-92D3-4161-8070-2BFCC2DF45D1@oracle.com> <588F5956.2050006@oracle.com> <588F67DC.7050105@oracle.com> Message-ID: Great, thanks. Best Regards/Cordiali saluti Luisa Pace ========================================================================================================================= Ci? che ? fuori ? anche dentro; e ci? che non ? dentro non ? da nessuna parte. Per questo viaggiare non serve. Se uno non ha niente dentro, non trover? mai niente fuori. ? inutile andare a cercare nel mondo quel che non si riesce a trovare dentro di s?. (Tiziano Terzani) ========================================================================================================================== Ing. Luisa Pace IBM Italy Bluemix Legal Project Manager Via Sciangai, 53 (B1 - 508) 00144 Roma Italy Tel. +39.06.5966.3795 Fax. +39.06.5966.3489 mob. +39.335.7368629 e-mail: luisa_pace at it.ibm.com From: Michel Trudeau To: Luisa Pace/Italy/IBM at IBMIT Cc: "Jim Laskey (Oracle)" , nashorn-dev at openjdk.java.net, Salvatore D'Angelo/Italy/IBM at IBMIT Date: 30/01/2017 17.21 Subject: Re: nashorn.jar is opensource? Part of OpenJDK. -- --Michel Luisa Pace January 30, 2017 at 8:19 AM via Postbox Thanks a lot for your kindly and quick help! I've another questions on nashorn: is it a component of OpenJDK? I mean: is its source code part of OpenJDK source code or it's something "external" to it? Thanks again. Best Regards/Cordiali saluti Luisa Pace ========================================================================================================================= Ci? che ? fuori ? anche dentro; e ci? che non ? dentro non ? da nessuna parte. Per questo viaggiare non serve. Se uno non ha niente dentro, non trover? mai niente fuori. ? inutile andare a cercare nel mondo quel che non si riesce a trovare dentro di s?. (Tiziano Terzani) ========================================================================================================================== Ing. Luisa Pace IBM Italy Bluemix Legal Project Manager Via Sciangai, 53 (B1 - 508) 00144 Roma Italy Tel. +39.06.5966.3795 Fax. +39.06.5966.3489 mob. +39.335.7368629 e-mail: luisa_pace at it.ibm.com From: Michel Trudeau To: Luisa Pace/Italy/IBM at IBMIT Cc: "Jim Laskey (Oracle)" , nashorn-dev at openjdk.java.net, Salvatore D'Angelo/Italy/IBM at IBMIT Date: 30/01/2017 16.19 Subject: Re: nashorn.jar is opensource? It's all under http://hg.openjdk.java.net/jdk9/jdk9/nashorn/ -- --Michel Luisa Pace January 30, 2017 at 6:28 AM via Postbox Hi Jim, thanks a lot for your quick answer. We've opened the link you provided me and downloaded the zip, but it seems to point to openjdk source code and not to nashorn source code only. Could you please specify what directory contains the nashorn code or send me the direct link to its source code? Thanks again. Best Regards/Cordiali saluti Luisa Pace ========================================================================================================================= Ci? che ? fuori ? anche dentro; e ci? che non ? dentro non ? da nessuna parte. Per questo viaggiare non serve. Se uno non ha niente dentro, non trover? mai niente fuori. ? inutile andare a cercare nel mondo quel che non si riesce a trovare dentro di s?. (Tiziano Terzani) ========================================================================================================================== Ing. Luisa Pace IBM Italy Bluemix Legal Project Manager Via Sciangai, 53 (B1 - 508) 00144 Roma Italy Tel. +39.06.5966.3795 Fax. +39.06.5966.3489 mob. +39.335.7368629 e-mail: luisa_pace at it.ibm.com From: "Jim Laskey (Oracle)" To: Luisa Pace/Italy/IBM at IBMIT Cc: nashorn-dev at openjdk.java.net Date: 30/01/2017 14.31 Subject: Re: nashorn.jar is opensource? Luisa, Hello. Response is inlined. Cheers, ? Jim On Jan 30, 2017, at 6:58 AM, Luisa Pace wrote: Hi, I am an IBM employee that work in legal team of Bluemix, the PaaS platform of IBM. This platform is based on CloudFoundry, an open source project and my goal is to analyze with some software tools the licenses of all CloudFoundry components and their dependencies to check if they can be included in Bluemix without legal issues. To do that, I need of the source of all the CloudFoundry components and their dependencies. In the case I'm managing now, Cloudfoundry (level 245) contains openjdk 1.8.0_101, that in turn contains nashorn.jar. But I was not able to find the source code of nashorn.jar . So, I've two questions: Could you please tell me if nashorn is an open source and in this case send me the link to its source code? http://hg.openjdk.java.net/jdk9/dev/ What is the license of nashorn? GPL + ClassPath, the same as the Open JDK. Fell be free to ask me other details. Thanks a lot for your support. Best Regards/Cordiali saluti Luisa Pace ========================================================================================================================= Ci? che ? fuori ? anche dentro; e ci? che non ? dentro non ? da nessuna parte. Per questo viaggiare non serve. Se uno non ha niente dentro, non trover? mai niente fuori. ? inutile andare a cercare nel mondo quel che non si riesce a trovare dentro di s?. (Tiziano Terzani) ========================================================================================================================== Ing. Luisa Pace IBM Italy Bluemix Legal Project Manager Via Sciangai, 53 (B1 - 508) 00144 Roma Italy Tel. +39.06.5966.3795 Fax. +39.06.5966.3489 mob. +39.335.7368629 e-mail: luisa_pace at it.ibm.com IBM Italia S.p.A. Sede Legale: Circonvallazione Idroscalo - 20090 Segrate (MI) Cap. Soc. euro 347.256.998,80 C. F. e Reg. Imprese MI 01442240030 - Partita IVA 10914660153 Societ? con unico azionista Societ? soggetta all?attivit? di direzione e coordinamento di International Business Machines Corporation (Salvo che sia diversamente indicato sopra / Unless stated otherwise above) IBM Italia S.p.A. Sede Legale: Circonvallazione Idroscalo - 20090 Segrate (MI) Cap. Soc. euro 347.256.998,80 C. F. e Reg. Imprese MI 01442240030 - Partita IVA 10914660153 Societ? con unico azionista Societ? soggetta all?attivit? di direzione e coordinamento di International Business Machines Corporation (Salvo che sia diversamente indicato sopra / Unless stated otherwise above) Jim Laskey (Oracle) January 30, 2017 at 5:31 AM via Postbox Luisa, Hello. Response is inlined. Cheers, ? Jim On Jan 30, 2017, at 6:58 AM, Luisa Pace wrote: Hi, I am an IBM employee that work in legal team of Bluemix, the PaaS platform of IBM. This platform is based on CloudFoundry, an open source project and my goal is to analyze with some software tools the licenses of all CloudFoundry components and their dependencies to check if they can be included in Bluemix without legal issues. To do that, I need of the source of all the CloudFoundry components and their dependencies. In the case I'm managing now, Cloudfoundry (level 245) contains openjdk 1.8.0_101, that in turn contains nashorn.jar. But I was not able to find the source code of nashorn.jar . So, I've two questions: Could you please tell me if nashorn is an open source and in this case send me the link to its source code? http://hg.openjdk.java.net/jdk9/dev/ What is the license of nashorn? GPL + ClassPath, the same as the Open JDK. Fell be free to ask me other details. Thanks a lot for your support. Best Regards/Cordiali saluti Luisa Pace ========================================================================================================================= Ci? che ? fuori ? anche dentro; e ci? che non ? dentro non ? da nessuna parte. Per questo viaggiare non serve. Se uno non ha niente dentro, non trover? mai niente fuori. ? inutile andare a cercare nel mondo quel che non si riesce a trovare dentro di s?. (Tiziano Terzani) ========================================================================================================================== Ing. Luisa Pace IBM Italy Bluemix Legal Project Manager Via Sciangai, 53 (B1 - 508) 00144 Roma Italy Tel. +39.06.5966.3795 Fax. +39.06.5966.3489 mob. +39.335.7368629 e-mail: luisa_pace at it.ibm.com IBM Italia S.p.A. Sede Legale: Circonvallazione Idroscalo - 20090 Segrate (MI) Cap. Soc. euro 347.256.998,80 C. F. e Reg. Imprese MI 01442240030 - Partita IVA 10914660153 Societ? con unico azionista Societ? soggetta all?attivit? di direzione e coordinamento di International Business Machines Corporation (Salvo che sia diversamente indicato sopra / Unless stated otherwise above) Luisa Pace January 30, 2017 at 2:58 AM via Postbox Hi, I am an IBM employee that work in legal team of Bluemix, the PaaS platform of IBM. This platform is based on CloudFoundry, an open source project and my goal is to analyze with some software tools the licenses of all CloudFoundry components and their dependencies to check if they can be included in Bluemix without legal issues. To do that, I need of the source of all the CloudFoundry components and their dependencies. In the case I'm managing now, Cloudfoundry (level 245) contains openjdk 1.8.0_101, that in turn contains nashorn.jar. But I was not able to find the source code of nashorn.jar . So, I've two questions: Could you please tell me if nashorn is an open source and in this case send me the link to its source code? What is the license of nashorn? Fell be free to ask me other details. Thanks a lot for your support. Best Regards/Cordiali saluti Luisa Pace ========================================================================================================================= Ci? che ? fuori ? anche dentro; e ci? che non ? dentro non ? da nessuna parte. Per questo viaggiare non serve. Se uno non ha niente dentro, non trover? mai niente fuori. ? inutile andare a cercare nel mondo quel che non si riesce a trovare dentro di s?. (Tiziano Terzani) ========================================================================================================================== Ing. Luisa Pace IBM Italy Bluemix Legal Project Manager Via Sciangai, 53 (B1 - 508) 00144 Roma Italy Tel. +39.06.5966.3795 Fax. +39.06.5966.3489 mob. +39.335.7368629 e-mail: luisa_pace at it.ibm.com IBM Italia S.p.A. Sede Legale: Circonvallazione Idroscalo - 20090 Segrate (MI) Cap. Soc. euro 347.256.998,80 C. F. e Reg. Imprese MI 01442240030 - Partita IVA 10914660153 Societ? con unico azionista Societ? soggetta all?attivit? di direzione e coordinamento di International Business Machines Corporation (Salvo che sia diversamente indicato sopra / Unless stated otherwise above) IBM Italia S.p.A. Sede Legale: Circonvallazione Idroscalo - 20090 Segrate (MI) Cap. Soc. euro 347.256.998,80 C. F. e Reg. Imprese MI 01442240030 - Partita IVA 10914660153 Societ? con unico azionista Societ? soggetta all?attivit? di direzione e coordinamento di International Business Machines Corporation (Salvo che sia diversamente indicato sopra / Unless stated otherwise above) Michel Trudeau January 30, 2017 at 7:18 AM via Postbox It's all under http://hg.openjdk.java.net/jdk9/jdk9/nashorn/ Luisa Pace January 30, 2017 at 6:28 AM via Postbox Hi Jim, thanks a lot for your quick answer. We've opened the link you provided me and downloaded the zip, but it seems to point to openjdk source code and not to nashorn source code only. Could you please specify what directory contains the nashorn code or send me the direct link to its source code? Thanks again. Best Regards/Cordiali saluti Luisa Pace ========================================================================================================================= Ci? che ? fuori ? anche dentro; e ci? che non ? dentro non ? da nessuna parte. Per questo viaggiare non serve. Se uno non ha niente dentro, non trover? mai niente fuori. ? inutile andare a cercare nel mondo quel che non si riesce a trovare dentro di s?. (Tiziano Terzani) ========================================================================================================================== Ing. Luisa Pace IBM Italy Bluemix Legal Project Manager Via Sciangai, 53 (B1 - 508) 00144 Roma Italy Tel. +39.06.5966.3795 Fax. +39.06.5966.3489 mob. +39.335.7368629 e-mail: luisa_pace at it.ibm.com From: "Jim Laskey (Oracle)" To: Luisa Pace/Italy/IBM at IBMIT Cc: nashorn-dev at openjdk.java.net Date: 30/01/2017 14.31 Subject: Re: nashorn.jar is opensource? Luisa, Hello. Response is inlined. Cheers, ? Jim On Jan 30, 2017, at 6:58 AM, Luisa Pace wrote: Hi, I am an IBM employee that work in legal team of Bluemix, the PaaS platform of IBM. This platform is based on CloudFoundry, an open source project and my goal is to analyze with some software tools the licenses of all CloudFoundry components and their dependencies to check if they can be included in Bluemix without legal issues. To do that, I need of the source of all the CloudFoundry components and their dependencies. In the case I'm managing now, Cloudfoundry (level 245) contains openjdk 1.8.0_101, that in turn contains nashorn.jar. But I was not able to find the source code of nashorn.jar . So, I've two questions: Could you please tell me if nashorn is an open source and in this case send me the link to its source code? http://hg.openjdk.java.net/jdk9/dev/ What is the license of nashorn? GPL + ClassPath, the same as the Open JDK. Fell be free to ask me other details. Thanks a lot for your support. Best Regards/Cordiali saluti Luisa Pace ========================================================================================================================= Ci? che ? fuori ? anche dentro; e ci? che non ? dentro non ? da nessuna parte. Per questo viaggiare non serve. Se uno non ha niente dentro, non trover? mai niente fuori. ? inutile andare a cercare nel mondo quel che non si riesce a trovare dentro di s?. (Tiziano Terzani) ========================================================================================================================== Ing. Luisa Pace IBM Italy Bluemix Legal Project Manager Via Sciangai, 53 (B1 - 508) 00144 Roma Italy Tel. +39.06.5966.3795 Fax. +39.06.5966.3489 mob. +39.335.7368629 e-mail: luisa_pace at it.ibm.com IBM Italia S.p.A. Sede Legale: Circonvallazione Idroscalo - 20090 Segrate (MI) Cap. Soc. euro 347.256.998,80 C. F. e Reg. Imprese MI 01442240030 - Partita IVA 10914660153 Societ? con unico azionista Societ? soggetta all?attivit? di direzione e coordinamento di International Business Machines Corporation (Salvo che sia diversamente indicato sopra / Unless stated otherwise above) IBM Italia S.p.A. Sede Legale: Circonvallazione Idroscalo - 20090 Segrate (MI) Cap. Soc. euro 347.256.998,80 C. F. e Reg. Imprese MI 01442240030 - Partita IVA 10914660153 Societ? con unico azionista Societ? soggetta all?attivit? di direzione e coordinamento di International Business Machines Corporation (Salvo che sia diversamente indicato sopra / Unless stated otherwise above) Jim Laskey (Oracle) January 30, 2017 at 5:31 AM via Postbox Luisa, Hello. Response is inlined. Cheers, ? Jim On Jan 30, 2017, at 6:58 AM, Luisa Pace wrote: Hi, I am an IBM employee that work in legal team of Bluemix, the PaaS platform of IBM. This platform is based on CloudFoundry, an open source project and my goal is to analyze with some software tools the licenses of all CloudFoundry components and their dependencies to check if they can be included in Bluemix without legal issues. To do that, I need of the source of all the CloudFoundry components and their dependencies. In the case I'm managing now, Cloudfoundry (level 245) contains openjdk 1.8.0_101, that in turn contains nashorn.jar. But I was not able to find the source code of nashorn.jar . So, I've two questions: Could you please tell me if nashorn is an open source and in this case send me the link to its source code? http://hg.openjdk.java.net/jdk9/dev/ What is the license of nashorn? GPL + ClassPath, the same as the Open JDK. Fell be free to ask me other details. Thanks a lot for your support. Best Regards/Cordiali saluti Luisa Pace ========================================================================================================================= Ci? che ? fuori ? anche dentro; e ci? che non ? dentro non ? da nessuna parte. Per questo viaggiare non serve. Se uno non ha niente dentro, non trover? mai niente fuori. ? inutile andare a cercare nel mondo quel che non si riesce a trovare dentro di s?. (Tiziano Terzani) ========================================================================================================================== Ing. Luisa Pace IBM Italy Bluemix Legal Project Manager Via Sciangai, 53 (B1 - 508) 00144 Roma Italy Tel. +39.06.5966.3795 Fax. +39.06.5966.3489 mob. +39.335.7368629 e-mail: luisa_pace at it.ibm.com IBM Italia S.p.A. Sede Legale: Circonvallazione Idroscalo - 20090 Segrate (MI) Cap. Soc. euro 347.256.998,80 C. F. e Reg. Imprese MI 01442240030 - Partita IVA 10914660153 Societ? con unico azionista Societ? soggetta all?attivit? di direzione e coordinamento di International Business Machines Corporation (Salvo che sia diversamente indicato sopra / Unless stated otherwise above) Luisa Pace January 30, 2017 at 2:58 AM via Postbox Hi, I am an IBM employee that work in legal team of Bluemix, the PaaS platform of IBM. This platform is based on CloudFoundry, an open source project and my goal is to analyze with some software tools the licenses of all CloudFoundry components and their dependencies to check if they can be included in Bluemix without legal issues. To do that, I need of the source of all the CloudFoundry components and their dependencies. In the case I'm managing now, Cloudfoundry (level 245) contains openjdk 1.8.0_101, that in turn contains nashorn.jar. But I was not able to find the source code of nashorn.jar . So, I've two questions: Could you please tell me if nashorn is an open source and in this case send me the link to its source code? What is the license of nashorn? Fell be free to ask me other details. Thanks a lot for your support. Best Regards/Cordiali saluti Luisa Pace ========================================================================================================================= Ci? che ? fuori ? anche dentro; e ci? che non ? dentro non ? da nessuna parte. Per questo viaggiare non serve. Se uno non ha niente dentro, non trover? mai niente fuori. ? inutile andare a cercare nel mondo quel che non si riesce a trovare dentro di s?. (Tiziano Terzani) ========================================================================================================================== Ing. Luisa Pace IBM Italy Bluemix Legal Project Manager Via Sciangai, 53 (B1 - 508) 00144 Roma Italy Tel. +39.06.5966.3795 Fax. +39.06.5966.3489 mob. +39.335.7368629 e-mail: luisa_pace at it.ibm.com IBM Italia S.p.A. Sede Legale: Circonvallazione Idroscalo - 20090 Segrate (MI) Cap. Soc. euro 347.256.998,80 C. F. e Reg. Imprese MI 01442240030 - Partita IVA 10914660153 Societ? con unico azionista Societ? soggetta all?attivit? di direzione e coordinamento di International Business Machines Corporation (Salvo che sia diversamente indicato sopra / Unless stated otherwise above) IBM Italia S.p.A. Sede Legale: Circonvallazione Idroscalo - 20090 Segrate (MI) Cap. Soc. euro 347.256.998,80 C. F. e Reg. Imprese MI 01442240030 - Partita IVA 10914660153 Societ? con unico azionista Societ? soggetta all?attivit? di direzione e coordinamento di International Business Machines Corporation (Salvo che sia diversamente indicato sopra / Unless stated otherwise above) From hannes.wallnoefer at oracle.com Mon Jan 30 17:52:38 2017 From: hannes.wallnoefer at oracle.com (=?utf-8?Q?Hannes_Walln=C3=B6fer?=) Date: Mon, 30 Jan 2017 18:52:38 +0100 Subject: Function object cannot be called with different context In-Reply-To: <1D0FF04F-6178-47C1-BCC1-7B26C421D701@aperto.com> References: <1D0FF04F-6178-47C1-BCC1-7B26C421D701@aperto.com> Message-ID: There are a few problems with this code. The first is that a function declaration evaluates as undefined in Javascript, so your jsFunction variable is null. One way to work around this is to make the function an expression, e.g. by wrapping it in parentheses: engine.eval(?function test() { }?); // returns null but defines function ?test" engine.eval(?(function test() { })?); // returns the function but doesn?t define it in scope Another issue is that Nashorn cannot directly use the default Binding implementation used by SimpleScriptContext. You should create a native Nashorn global object using engine.createBindings() as described in http://docs.oracle.com/javase/8/docs/technotes/guides/scripting/prog_guide/api.html ScriptContext newContext = new SimpleScriptContext(); newContext.setBindings(engine.createBindings(), ScriptContext.ENGINE_SCOPE); Bindings engineScope = newContext.getBindings(ScriptContext.ENGINE_SCOPE); However, even with these issues fixed the problem remains that JavaScript functions are closures over the scope they were evaluated in. An evaluated function is always bound to the global object it was evaluated in. You can use the Compilable interface (as you did in your code) to create a compiled version of a script that will run with multiple globals: ScriptEngine engine = new ScriptEngineManager().getEngineByName("JavaScript"); CompiledScript compiledScript = ((Compilable) engine).compile("function test() {return foo;}; test();?); ScriptContext context = new SimpleScriptContext(); context.setBindings(engine.createBindings(), ScriptContext.ENGINE_SCOPE); context.setAttribute("foo", "bar", ScriptContext.ENGINE_SCOPE); Object result = compiledScript.eval(context); Hannes > Am 30.01.2017 um 11:28 schrieb Frantzius, J?rg : > > Hi, > > in my code, I get hold of a function object from some 3rd party Javascript code, and I need to execute that function within a new context, i.e. make new ENGINE_SCOPE bindings available to it. ScriptObjectMirror.call() unfortunately does not allow to define a context to execute in, so I tried to workaround by calling the function from a CompiledScript that in turn can be executed with a custom context: > > @Test > public void testJsFunctionWithContext() throws ScriptException { > ScriptEngine engine = new ScriptEngineManager().getEngineByName("JavaScript"); > jdk.nashorn.api.scripting.ScriptObjectMirror jsFunction = (ScriptObjectMirror) engine.eval("function test() {return foo;}"); > > ScriptContext context = new SimpleScriptContext(); > context.setAttribute("foo", "bar", ScriptContext.ENGINE_SCOPE); > context.setAttribute("fn", jsFunction, ScriptContext.ENGINE_SCOPE); > > // does work: access context directly > CompiledScript contextWrapper = ((Compilable) engine).compile("foo"); > String result = (String) contextWrapper.eval(context); > assertEquals("bar", result); > > // does not work: access context from within function ("foo" is not defined) > contextWrapper = ((Compilable) engine).compile("fn()"); > result = (String) contextWrapper.eval(context); > assertEquals("bar", result); > } > > Is there some mistake I made here, or is it simply not possible for a function object to access variables from a new context? > If that?s really not possible, is there maybe a way of turning a function object into a CompiledScript object, which can then be evaluated with a new context? > > Thanks for any help, > J?rg > > > > --- > > Dipl. Inf. J?rg von Frantzius, Technical Director > > E-Mail joerg.frantzius at aperto.com > > Phone +49 30 283921-318 > Fax +49 30 283921-29 > > Aperto GmbH ? An IBM Company > Chausseestra?e 5, D-10115 Berlin > http://www.aperto.com > http://www.facebook.com/aperto > https://www.xing.com/companies/apertoag > > HRB 77049 B, AG Berlin Charlottenburg > Gesch?ftsf?hrer: Dirk Buddensiek, Kai Gro?mann, Stephan Haagen, Daniel Simon > From james.laskey at oracle.com Mon Jan 30 18:47:43 2017 From: james.laskey at oracle.com (Jim Laskey (Oracle)) Date: Mon, 30 Jan 2017 14:47:43 -0400 Subject: RFR: 8173480: in operator should work on java objects and classes In-Reply-To: <49CDA440-77E9-4701-939D-8D7D000D675E@oracle.com> References: <49CDA440-77E9-4701-939D-8D7D000D675E@oracle.com> Message-ID: <0DCE8453-65D7-4E9A-B3DE-DFFFE3139656@oracle.com> +1 > On Jan 30, 2017, at 6:22 AM, Hannes Walln?fer wrote: > > Please review 8173480: in operator should work on java objects and classes. > > Bug: https://bugs.openjdk.java.net/browse/JDK-8173480 > Webrev: http://cr.openjdk.java.net/~hannesw/8173480/webrev.00/nashorn.patch > > Thanks, > Hannes > From sundararajan.athijegannathan at oracle.com Tue Jan 31 03:19:54 2017 From: sundararajan.athijegannathan at oracle.com (Sundararajan Athijegannathan) Date: Tue, 31 Jan 2017 08:49:54 +0530 Subject: RFR: 8173480: in operator should work on java objects and classes In-Reply-To: <49CDA440-77E9-4701-939D-8D7D000D675E@oracle.com> References: <49CDA440-77E9-4701-939D-8D7D000D675E@oracle.com> Message-ID: <5890025A.1090908@oracle.com> +1 On 30/01/17, 3:52 PM, Hannes Walln?fer wrote: > Please review 8173480: in operator should work on java objects and classes. > > Bug: https://bugs.openjdk.java.net/browse/JDK-8173480 > Webrev: http://cr.openjdk.java.net/~hannesw/8173480/webrev.00/nashorn.patch > > Thanks, > Hannes > From Joerg.Frantzius at aperto.com Tue Jan 31 10:39:56 2017 From: Joerg.Frantzius at aperto.com (=?utf-8?B?RnJhbnR6aXVzLCBKw7ZyZw==?=) Date: Tue, 31 Jan 2017 10:39:56 +0000 Subject: Function object cannot be called with different context In-Reply-To: References: <1D0FF04F-6178-47C1-BCC1-7B26C421D701@aperto.com> Message-ID: <026F752E-3FC0-437C-B49E-C32D584CEB71@aperto.com> Hi Hannes, thanks for the explanations! The Javascript function being a closure over the scope it was evaluated in is exactly what I did not understand yet. As the function object is dynamically created within some 3rd party Javascript that I cannot modify, I?m not able to create a CompiledScript instead. Just for some nit-picking, my test was able to call the function without placing it in parenthesis (the error message was '"foo" is not defined?, so execution did enter the function, even though it does not find ?foo? because that wasn't defined in its closure). So it seems that the function declaration does not evaluate to undefined, at least not when evaluating it using engine.eval() from Java. Thanks again, J?rg Am 30.01.2017 um 18:52 schrieb Hannes Walln?fer >: There are a few problems with this code. The first is that a function declaration evaluates as undefined in Javascript, so your jsFunction variable is null. One way to work around this is to make the function an expression, e.g. by wrapping it in parentheses: engine.eval(?function test() { }?); // returns null but defines function ?test" engine.eval(?(function test() { })?); // returns the function but doesn?t define it in scope Another issue is that Nashorn cannot directly use the default Binding implementation used by SimpleScriptContext. You should create a native Nashorn global object using engine.createBindings() as described in http://docs.oracle.com/javase/8/docs/technotes/guides/scripting/prog_guide/api.html ScriptContext newContext = new SimpleScriptContext(); newContext.setBindings(engine.createBindings(), ScriptContext.ENGINE_SCOPE); Bindings engineScope = newContext.getBindings(ScriptContext.ENGINE_SCOPE); However, even with these issues fixed the problem remains that JavaScript functions are closures over the scope they were evaluated in. An evaluated function is always bound to the global object it was evaluated in. You can use the Compilable interface (as you did in your code) to create a compiled version of a script that will run with multiple globals: ScriptEngine engine = new ScriptEngineManager().getEngineByName("JavaScript"); CompiledScript compiledScript = ((Compilable) engine).compile("function test() {return foo;}; test();?); ScriptContext context = new SimpleScriptContext(); context.setBindings(engine.createBindings(), ScriptContext.ENGINE_SCOPE); context.setAttribute("foo", "bar", ScriptContext.ENGINE_SCOPE); Object result = compiledScript.eval(context); Hannes Am 30.01.2017 um 11:28 schrieb Frantzius, J?rg >: Hi, in my code, I get hold of a function object from some 3rd party Javascript code, and I need to execute that function within a new context, i.e. make new ENGINE_SCOPE bindings available to it. ScriptObjectMirror.call() unfortunately does not allow to define a context to execute in, so I tried to workaround by calling the function from a CompiledScript that in turn can be executed with a custom context: @Test public void testJsFunctionWithContext() throws ScriptException { ScriptEngine engine = new ScriptEngineManager().getEngineByName("JavaScript"); jdk.nashorn.api.scripting.ScriptObjectMirror jsFunction = (ScriptObjectMirror) engine.eval("function test() {return foo;}"); ScriptContext context = new SimpleScriptContext(); context.setAttribute("foo", "bar", ScriptContext.ENGINE_SCOPE); context.setAttribute("fn", jsFunction, ScriptContext.ENGINE_SCOPE); // does work: access context directly CompiledScript contextWrapper = ((Compilable) engine).compile("foo"); String result = (String) contextWrapper.eval(context); assertEquals("bar", result); // does not work: access context from within function ("foo" is not defined) contextWrapper = ((Compilable) engine).compile("fn()"); result = (String) contextWrapper.eval(context); assertEquals("bar", result); } Is there some mistake I made here, or is it simply not possible for a function object to access variables from a new context? If that?s really not possible, is there maybe a way of turning a function object into a CompiledScript object, which can then be evaluated with a new context? Thanks for any help, J?rg --- Dipl. Inf. J?rg von Frantzius, Technical Director E-Mail joerg.frantzius at aperto.com Phone +49 30 283921-318 Fax +49 30 283921-29 Aperto GmbH ? An IBM Company Chausseestra?e 5, D-10115 Berlin http://www.aperto.com http://www.facebook.com/aperto https://www.xing.com/companies/apertoag HRB 77049 B, AG Berlin Charlottenburg Gesch?ftsf?hrer: Dirk Buddensiek, Kai Gro?mann, Stephan Haagen, Daniel Simon --- Dipl. Inf. J?rg von Frantzius, Technical Director E-Mail joerg.frantzius at aperto.com Phone +49 30 283921-318 Fax +49 30 283921-29 Aperto GmbH ? An IBM Company Chausseestra?e 5, D-10115 Berlin http://www.aperto.com http://www.facebook.com/aperto https://www.xing.com/companies/apertoag HRB 77049 B, AG Berlin Charlottenburg Gesch?ftsf?hrer: Dirk Buddensiek, Kai Gro?mann, Stephan Haagen, Daniel Simon From hannes.wallnoefer at oracle.com Tue Jan 31 11:12:01 2017 From: hannes.wallnoefer at oracle.com (=?utf-8?Q?Hannes_Walln=C3=B6fer?=) Date: Tue, 31 Jan 2017 12:12:01 +0100 Subject: Function object cannot be called with different context In-Reply-To: <026F752E-3FC0-437C-B49E-C32D584CEB71@aperto.com> References: <1D0FF04F-6178-47C1-BCC1-7B26C421D701@aperto.com> <026F752E-3FC0-437C-B49E-C32D584CEB71@aperto.com> Message-ID: <5D0D5968-B872-4964-971A-80A30BD692CB@oracle.com> Am 31.01.2017 um 11:39 schrieb Frantzius, J?rg : > > As the function object is dynamically created within some 3rd party Javascript that I cannot modify, I?m not able to create a CompiledScript instead. > Then your best bet is probably to evaluate the script containing the function for each ScriptContext you?re using it with. The Nashorn-Dev engine should cache the compiled script so it shouldn?t affect performance too much. > Just for some nit-picking, my test was able to call the function without placing it in parenthesis (the error message was '"foo" is not defined?, so execution did enter the function, even though it does not find ?foo? because that wasn't defined in its closure). So it seems that the function declaration does not evaluate to undefined, at least not when evaluating it using engine.eval() from Java. You?re right - that is a bug we fixed in JDK 9. For some reason it wasn?t back ported to 8u, maybe for compatibility reasons. https://bugs.openjdk.java.net/browse/JDK-8086052 Hannes From dalibor.topic at oracle.com Tue Jan 31 14:40:43 2017 From: dalibor.topic at oracle.com (dalibor topic) Date: Tue, 31 Jan 2017 15:40:43 +0100 Subject: nashorn.jar is opensource? In-Reply-To: <588F5956.2050006@oracle.com> References: <3002524C-92D3-4161-8070-2BFCC2DF45D1@oracle.com> <588F5956.2050006@oracle.com> Message-ID: Hi, From your initial query about "To do that, I need of the source of all the CloudFoundry components and their dependencies. In the case I'm managing now, Cloudfoundry (level 245) contains openjdk 1.8.0_101, that in turn contains nashorn.jar." I suspect that your query is really about the corresponding source code for a binary provided by CloudFoundry. Such third party provided binaries may or may not contain additional and/or different source code from the URL below. Please inquire with CloudFoundry directly to get the source code corresponding to the binary you are interested in, if I'm parsing your query correctly. On a more general note, the URL below is for Nashorn source code in JDK 9, rather than for source code of Nashorn in a 1.8.0_* release. The sources of Nashorn in JDK 8 Updates can be found in the Mercurial repository located at http://hg.openjdk.java.net/jdk8u/jdk8u/nashorn/ You can use Mercurial tags to locate source code corresponding to a specific build. Last but not least, the source code at the above URL may or may not contain third party works under different open source licenses. Please check the notices on individual files for details. cheers, dalibor topic On 30.01.2017 16:18, Michel Trudeau wrote: > It's all under http://hg.openjdk.java.net/jdk9/jdk9/nashorn/ > -- Dalibor Topic | Principal Product Manager Phone: +494089091214 | Mobile: +491737185961 ORACLE Deutschland B.V. & Co. KG | K?hneh?fe 5 | 22761 Hamburg ORACLE Deutschland B.V. & Co. KG Hauptverwaltung: Riesstr. 25, D-80992 M?nchen Registergericht: Amtsgericht M?nchen, HRA 95603 Komplement?rin: ORACLE Deutschland Verwaltung B.V. Hertogswetering 163/167, 3543 AS Utrecht, Niederlande Handelsregister der Handelskammer Midden-Niederlande, Nr. 30143697 Gesch?ftsf?hrer: Alexander van der Ven, Jan Schultheiss, Val Maher Oracle is committed to developing practices and products that help protect the environment From sari.attila at gravityrd.com Tue Jan 31 16:34:06 2017 From: sari.attila at gravityrd.com (Attila Sari) Date: Tue, 31 Jan 2017 17:34:06 +0100 Subject: raise ecmascript error from JSObject Message-ID: Hi all, Is it possible to throw ecmascript error from JSObject methods? (that can be catched later in the script, and will be enriched with filename and line number) Thanks, Attila Sari -- -- Attila SARI Software developer | Gravity R&D p: +36.1.799.5264 | skype: attila.sari86 | tw: @gravityrd From sundararajan.athijegannathan at oracle.com Tue Jan 31 17:03:29 2017 From: sundararajan.athijegannathan at oracle.com (Sundararajan Athijegannathan) Date: Tue, 31 Jan 2017 22:33:29 +0530 Subject: raise ecmascript error from JSObject In-Reply-To: References: Message-ID: <5890C361.3030900@oracle.com> Hope the following sample code helps you... -Sundar import javax.script.*; import jdk.nashorn.api.scripting.*; public class Main { private static JSObject errorCtr; public static void main(String[] args) throws Exception { ScriptEngine e = new ScriptEngineManager().getEngineByName("nashorn"); // save JS Error constructor which is used later to construct Error object errorCtr = (JSObject)e.eval("Error"); e.put("func", new MyFunc()); e.eval("try { func() } catch(e) { print(e); print(e.stack); } "); } public static class MyFunc extends AbstractJSObject { public boolean isFunction() { return true; } public Object call(Object self, Object... args) { // this is like "var e = new Error('myErrorMsg')" in JS code JSObject error = (JSObject)errorCtr.newObject("myErrorMsg"); // equivalent to "throw e;" throw (RuntimeException)error.getMember("nashornException"); } } } On 31/01/17, 10:04 PM, Attila Sari wrote: > Hi all, > > Is it possible to throw ecmascript error from JSObject methods? (that can > be catched later in the script, and will be enriched with filename and line > number) > > Thanks, > Attila Sari >