From szegedia at gmail.com Thu Jul 1 11:32:46 2021 From: szegedia at gmail.com (Attila Szegedi) Date: Thu, 1 Jul 2021 13:32:46 +0200 Subject: Nashorn 15.3 is out Message-ID: <55183ACD-EA7E-4027-B8C4-38EEC00284FD@gmail.com> Hey all, I just released Nashorn 15.3[0]. Check the change log[1] to easily see what?s new. The most notable change is that Nashorn now works with JDK 17. Attila. [0] https://search.maven.org/artifact/org.openjdk.nashorn/nashorn-core/15.3/jar [1] https://github.com/openjdk/nashorn/blob/main/CHANGELOG.md From Rony.Flatscher at wu.ac.at Thu Jul 1 12:15:19 2021 From: Rony.Flatscher at wu.ac.at (Rony G. Flatscher) Date: Thu, 1 Jul 2021 14:15:19 +0200 Subject: Nashorn 15.3 is out In-Reply-To: <55183ACD-EA7E-4027-B8C4-38EEC00284FD@gmail.com> References: <55183ACD-EA7E-4027-B8C4-38EEC00284FD@gmail.com> Message-ID: <12f47162-05fe-d466-a678-1e9330b63a9a@wu.ac.at> On 01.07.2021 13:32, Attila Szegedi wrote: > Hey all, > > I just released Nashorn 15.3[0]. Check the change log[1] to easily see what?s new. > > The most notable change is that Nashorn now works with JDK 17. > > Attila. > > [0] https://search.maven.org/artifact/org.openjdk.nashorn/nashorn-core/15.3/jar > [1] https://github.com/openjdk/nashorn/blob/main/CHANGELOG.md Cool, thank you very much!! ---rony From nashorn-dev at halloleo.hailmail.net Sun Jul 11 08:45:29 2021 From: nashorn-dev at halloleo.hailmail.net (leo) Date: Sun, 11 Jul 2021 18:45:29 +1000 Subject: How to read the content of a HTTP request via Nashorn Javascript? Message-ID: <30626CD8-C033-4BC5-B12C-DCB46D172489@halloleo.hailmail.net> I?m writing some JavaScript for Nashorn under Java 8. I try to read the content from a URL. So far I can create the (Java) URLConnection object in JavaScript via ``` var con = new java.net.URL(theUrl).openConnection() con.requestMethod = "GET" ``` But how can I do the `getInputStream` call which gets the content of the URL and put in a JavaScript string variable? *In Java I would read the content via a `BufferedReader`, but do I need to do this in JavaScript as well? Many thanks for any pointers! From lukas.stampf at bat.at Mon Jul 12 16:52:49 2021 From: lukas.stampf at bat.at (STAMPF Lukas) Date: Mon, 12 Jul 2021 16:52:49 +0000 Subject: JDK-8229011 update? Message-ID: Hello, A year ago I was asking for help with JDK-8229011 (https://mail.openjdk.java.net/pipermail/nashorn-dev/2020-July/007546.html) , but the bug ticket was deprioritized because Nashorn was to be removed soon. With the move to standalone, I thought I would give this another try. Unfortunatly the bug still exists in OpenJDK Nashorn 15.3 with Openjdk 11. Maybe somebody has some idea whats causing this. I would really like to get rid of our workaround that forces the same DynamicLinker into every Context via Reflection. Kind regards, Lukas From am at iit.de Tue Jul 13 13:33:29 2021 From: am at iit.de (=?UTF-8?Q?Andreas_Mueller?=) Date: Tue, 13 Jul 2021 13:33:29 +0000 Subject: Nashorn Standalone 15.3 engine returned is null References: <2B683FE2-07AB-4003-B15C-1A5CB2028ACB@iit.de> Message-ID: <0102017aa01292cd-2bd973e6-728e-475f-9def-988337c8ae80-000000@eu-west-1.amazonses.com> Hi, I?ve added Nashorn to Java 15 and it is properly displayed when listing the engines: 2021-07-13 15:14:30.233/sys$streams/INFORMATION/starting, available Scripting Engines: 2021-07-13 15:14:30.246/sys$streams/INFORMATION/name=OpenJDK Nashorn, version=15.3, language name=ECMAScript, language version=ECMA -?262?Edition?5.1, names=[nashorn, Nashorn, js, JS, JavaScript, javascript, ECMAScript, ecmascript] However, when I get the engine with name ?JavaScript? it returns null: 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!"); 2021-07-13 15:14:30.361/ERROR/Exception?occured:?java.lang.Exception: Engine for script-language?'JavaScript'?not found! Any ideas what the problem could be? Thanks, Andreas --? Andreas Mueller IIT Software GmbH http://www.swiftmq.com From szegedia at gmail.com Tue Jul 13 14:01:34 2021 From: szegedia at gmail.com (Attila Szegedi) Date: Tue, 13 Jul 2021 16:01:34 +0200 Subject: Nashorn Standalone 15.3 engine returned is null In-Reply-To: <0102017aa01292cd-2bd973e6-728e-475f-9def-988337c8ae80-000000@eu-west-1.amazonses.com> References: <2B683FE2-07AB-4003-B15C-1A5CB2028ACB@iit.de> <0102017aa01292cd-2bd973e6-728e-475f-9def-988337c8ae80-000000@eu-west-1.amazonses.com> Message-ID: <029AC7A2-C34B-4D07-A829-3FB630B86722@gmail.com> I?m honestly not sure. I have this very small test program: import javax.script.*; public class X { public static void main(String[] args) throws ScriptException { ScriptEngineManager factory = new ScriptEngineManager(); ScriptEngine engine = factory.getEngineByName("JavaScript"); engine.eval("function f() { print('Hello, World!'); } f()"); } } if I put it in a directory where I checked out Nashorn repo, and run ?ant jar? to build the JAR file and run: java --module-path build/nashorn/dist:build/nashorn/dependencies X.java It prints "Hello, World!? as expected, so it definitely find the engine under the name ?JavaScript". I can also run it with classpath instead of module path: java -cp build/nashorn/dist/nashorn.jar:build/nashorn/dependencies/asm-7.3.1.jar:build/nashorn/dependencies/asm-util-7.3.1.jar X.java and that works too. Do you have the dependencies (ASM) too? Attila. > On 2021. Jul 13., at 15:33, Andreas Mueller wrote: > > Hi, > > I?ve added Nashorn to Java 15 and it is properly displayed when listing the engines: > > 2021-07-13 15:14:30.233/sys$streams/INFORMATION/starting, available Scripting Engines: > 2021-07-13 15:14:30.246/sys$streams/INFORMATION/name=OpenJDK Nashorn, version=15.3, language name=ECMAScript, language version=ECMA - 262 Edition 5.1, names=[nashorn, Nashorn, js, JS, JavaScript, javascript, ECMAScript, ecmascript] > > However, when I get the engine with name ?JavaScript? it returns null: > > 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!"); > > 2021-07-13 15:14:30.361/ERROR/Exception occured: java.lang.Exception: Engine for script-language 'JavaScript' not found! > > Any ideas what the problem could be? > > Thanks, > Andreas > -- > Andreas Mueller > IIT Software GmbH > http://www.swiftmq.com > > From am at iit.de Thu Jul 15 08:59:55 2021 From: am at iit.de (=?UTF-8?Q?Andreas_Mueller?=) Date: Thu, 15 Jul 2021 08:59:55 +0000 Subject: Nashorn Standalone 15.3 engine returned is null In-Reply-To: <029AC7A2-C34B-4D07-A829-3FB630B86722@gmail.com> References: <2B683FE2-07AB-4003-B15C-1A5CB2028ACB@iit.de> <0102017aa01292cd-2bd973e6-728e-475f-9def-988337c8ae80-000000@eu-west-1.amazonses.com> <029AC7A2-C34B-4D07-A829-3FB630B86722@gmail.com> Message-ID: <0102017aa964d56f-5c1e8330-9b95-4eda-8e25-9f1153694661-000000@eu-west-1.amazonses.com> Hi Attila, thanks but didn?t work in my environment.? Tried every combination (using ?nashorn?, ?JavaScript? as name, using class path, using module path).? Fact is, it lists the Nashorn engine correctly: ScriptEngineManager manager =?new?ScriptEngineManager(); List factories = manager.getEngineFactories(); for?(int?i =?0;?i < factories.size();?i++) { ? ??ctx.logSwiftlet.logInformation(ctx.streamsSwiftlet.getName(),?"name="?+ factories.get(i).getEngineName() + ? ? ? ? ? ??", version="?+ factories.get(i).getEngineVersion() +?", language name="?+ factories.get(i).getLanguageName() + ? ? ? ? ? ??", language version="?+ factories.get(i).getLanguageVersion() + ? ? ? ? ? ??", names="?+ factories.get(i).getNames()); } 2021-07-15 10:51:37.948/sys$streams/INFORMATION/name=OpenJDK Nashorn, version=15.3, language name=ECMAScript, language version=ECMA -?262?Edition?5.1, names=[nashorn, Nashorn, js, JS, JavaScript, javascript, ECMAScript, ecmascript] But return null here: engine = manager.getEngineByName(?JavaScript?); I suspect it might have to do with class loaders as we use a dedicated class loader for every script: ScriptEngineManager manager =?new?ScriptEngineManager(); ClassLoader classLoader = createClassLoader(); streamContext.classLoader?= classLoader; Thread.currentThread().setContextClassLoader(classLoader); Thanks, Andreas --? Andreas Mueller IIT Software GmbH http://www.swiftmq.com On 13. Jul 2021, at 16:01, Attila Szegedi > wrote: I?m honestly not sure. I have this very small test program: import javax.script.*; public class X { ? ?public static void main(String[] args) throws ScriptException { ScriptEngineManager factory = new ScriptEngineManager();? ScriptEngine engine = factory.getEngineByName("JavaScript");? engine.eval("function f() { print('Hello, World!'); } f()"); ? ?} } if I put it in a directory where I checked out Nashorn repo, and run ?ant jar? to build the JAR file and run: java --module-path build/nashorn/dist:build/nashorn/dependencies X.java It prints "Hello, World!? as expected, so it definitely find the engine under the name ?JavaScript". I can also run it with classpath instead of module path: java -cp build/nashorn/dist/nashorn.jar:build/nashorn/dependencies/asm-7.3.1.jar:build/nashorn/dependencies/asm-util-7.3.1.jar X.java and that works too. Do you have the dependencies (ASM) too? Attila. On 2021. Jul 13., at 15:33, Andreas Mueller > wrote: Hi, I?ve added Nashorn to Java 15 and it is properly displayed when listing the engines: 2021-07-13 15:14:30.233/sys$streams/INFORMATION/starting, available Scripting Engines: 2021-07-13 15:14:30.246/sys$streams/INFORMATION/name=OpenJDK Nashorn, version=15.3, language name=ECMAScript, language version=ECMA -?262 Edition 5.1, names=[nashorn, Nashorn, js, JS, JavaScript, javascript, ECMAScript, ecmascript] However, when I get the engine with name ?JavaScript? it returns null: 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!"); 2021-07-13 15:14:30.361/ERROR/Exception occured: java.lang.Exception: Engine for script-language 'JavaScript' not found! Any ideas what the problem could be? Thanks, Andreas --? Andreas Mueller IIT Software GmbH http://www.swiftmq.com >? From am at iit.de Thu Jul 15 09:03:21 2021 From: am at iit.de (=?UTF-8?Q?Andreas_Mueller?=) Date: Thu, 15 Jul 2021 09:03:21 +0000 Subject: Nashorn Standalone 15.3 engine returned is null In-Reply-To: <029AC7A2-C34B-4D07-A829-3FB630B86722@gmail.com> References: <2B683FE2-07AB-4003-B15C-1A5CB2028ACB@iit.de> <0102017aa01292cd-2bd973e6-728e-475f-9def-988337c8ae80-000000@eu-west-1.amazonses.com> <029AC7A2-C34B-4D07-A829-3FB630B86722@gmail.com> <752BB597-2226-4A88-AC46-16AEBEFFA3FE@iit.de> Message-ID: <0102017aa967fa1d-b5aac2d4-8b62-43de-a977-196acd3bb822-000000@eu-west-1.amazonses.com> Here are the jar files I use: am at Mac-mini scripts % ll ../nashorn total 4968 -rwxr-xr-x ?1 am ?staff ? 121836 Jul 11 14:31 asm-7.3.1.jar -rwxr-xr-x ?1 am ?staff ? ?33446 Jul 11 14:31 asm-analysis-7.3.1.jar -rwxr-xr-x ?1 am ?staff ? ?71548 Jul 11 14:31 asm-commons-7.3.1.jar -rwxr-xr-x ?1 am ?staff ? ?52826 Jul 11 14:31 asm-tree-7.3.1.jar -rwxr-xr-x ?1 am ?staff ? ?84817 Jul 11 14:31 asm-util-7.3.1.jar -rwxr-xr-x ?1 am ?staff ?2167288 Jul 11 14:31 nashorn-core-15.3.jar This is my module path: --add-modules org.openjdk.nashorn --module-path ../nashorn --? Andreas Mueller IIT Software GmbH http://www.swiftmq.com From am at iit.de Thu Jul 15 10:49:13 2021 From: am at iit.de (=?UTF-8?Q?Andreas_Mueller?=) Date: Thu, 15 Jul 2021 10:49:13 +0000 Subject: Nashorn Standalone 15.3 engine returned is null In-Reply-To: References: <2B683FE2-07AB-4003-B15C-1A5CB2028ACB@iit.de> <0102017aa01292cd-2bd973e6-728e-475f-9def-988337c8ae80-000000@eu-west-1.amazonses.com> <029AC7A2-C34B-4D07-A829-3FB630B86722@gmail.com> <0851DE01-2C66-447E-9F5D-976DC392C8F0@iit.de> Message-ID: <0102017aa9c8e53a-af72d74b-cc95-4f28-91ed-ceb28311333c-000000@eu-west-1.amazonses.com> Tested it again with listing the engine right befor getByName: List factories = manager.getEngineFactories(); for?(int?i =?0;?i < factories.size();?i++) { ? ??ctx.logSwiftlet.logInformation(ctx.streamsSwiftlet.getName(),?"name="?+ factories.get(i).getEngineName() + ? ? ? ? ? ??", version="?+ factories.get(i).getEngineVersion() +?", language name="?+ factories.get(i).getLanguageName() + ? ? ? ? ? ??", language version="?+ factories.get(i).getLanguageVersion() + ? ? ? ? ? ??", names="?+ factories.get(i).getNames()); } engine = manager.getEngineByName((String)?entity.getProperty("script-language").getValue()); It is listed but returns null. This code is executed by a dedicated class loader. --? Andreas Mueller IIT Software GmbH http://www.swiftmq.com On 15. Jul 2021, at 10:59, Andreas Mueller > wrote: Hi Attila, thanks but didn?t work in my environment.? Tried every combination (using ?nashorn?, ?JavaScript? as name, using class path, using module path).? Fact is, it lists the Nashorn engine correctly: ScriptEngineManager manager = new ScriptEngineManager(); List factories = manager.getEngineFactories(); for (int i = 0; i < factories.size(); i++) { ? ? ctx.logSwiftlet.logInformation(ctx.streamsSwiftlet.getName(), "name=" + factories.get(i).getEngineName() + ? ? ? ? ? ? ", version=" + factories.get(i).getEngineVersion() + ", language name=" + factories.get(i).getLanguageName() + ? ? ? ? ? ? ", language version=" + factories.get(i).getLanguageVersion() + ? ? ? ? ? ? ", names=" + factories.get(i).getNames()); } 2021-07-15 10:51:37.948/sys$streams/INFORMATION/name=OpenJDK Nashorn, version=15.3, language name=ECMAScript, language version=ECMA -?262 Edition 5.1, names=[nashorn, Nashorn, js, JS, JavaScript, javascript, ECMAScript, ecmascript] But return null here: engine = manager.getEngineByName(?JavaScript?); I suspect it might have to do with class loaders as we use a dedicated class loader for every script: ScriptEngineManager manager = new ScriptEngineManager(); ClassLoader classLoader = createClassLoader(); streamContext.classLoader = classLoader; Thread.currentThread().setContextClassLoader(classLoader); Thanks, Andreas --? Andreas Mueller IIT Software GmbH http://www.swiftmq.com On 13. Jul 2021, at 16:01, Attila Szegedi wrote: I?m honestly not sure. I have this very small test program: import javax.script.*; public class X { ? ?public static void main(String[] args) throws ScriptException { ScriptEngineManager factory = new ScriptEngineManager();? ScriptEngine engine = factory.getEngineByName("JavaScript");? engine.eval("function f() { print('Hello, World!'); } f()"); ? ?} } if I put it in a directory where I checked out Nashorn repo, and run ?ant jar? to build the JAR file and run: java --module-path build/nashorn/dist:build/nashorn/dependencies X.java It prints "Hello, World!? as expected, so it definitely find the engine under the name ?JavaScript". I can also run it with classpath instead of module path: java -cp build/nashorn/dist/nashorn.jar:build/nashorn/dependencies/asm-7.3.1.jar:build/nashorn/dependencies/asm-util-7.3.1.jar X.java and that works too. Do you have the dependencies (ASM) too? Attila. On 2021. Jul 13., at 15:33, Andreas Mueller wrote: Hi, I?ve added Nashorn to Java 15 and it is properly displayed when listing the engines: 2021-07-13 15:14:30.233/sys$streams/INFORMATION/starting, available Scripting Engines: 2021-07-13 15:14:30.246/sys$streams/INFORMATION/name=OpenJDK Nashorn, version=15.3, language name=ECMAScript, language version=ECMA -?262 Edition 5.1, names=[nashorn, Nashorn, js, JS, JavaScript, javascript, ECMAScript, ecmascript] However, when I get the engine with name ?JavaScript? it returns null: 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!"); 2021-07-13 15:14:30.361/ERROR/Exception occured: java.lang.Exception: Engine for script-language 'JavaScript' not found! Any ideas what the problem could be? Thanks, Andreas --? Andreas Mueller IIT Software GmbH http://www.swiftmq.com?? From szegedia at gmail.com Thu Jul 15 20:11:13 2021 From: szegedia at gmail.com (Attila Szegedi) Date: Thu, 15 Jul 2021 22:11:13 +0200 Subject: Nashorn Standalone 15.3 engine returned is null In-Reply-To: <0102017aa9c8e53a-af72d74b-cc95-4f28-91ed-ceb28311333c-000000@eu-west-1.amazonses.com> References: <2B683FE2-07AB-4003-B15C-1A5CB2028ACB@iit.de> <0102017aa01292cd-2bd973e6-728e-475f-9def-988337c8ae80-000000@eu-west-1.amazonses.com> <029AC7A2-C34B-4D07-A829-3FB630B86722@gmail.com> <0851DE01-2C66-447E-9F5D-976DC392C8F0@iit.de> <0102017aa9c8e53a-af72d74b-cc95-4f28-91ed-ceb28311333c-000000@eu-west-1.amazonses.com> Message-ID: <73BE288E-0E05-4B06-A7B3-CAF6D675540B@gmail.com> Can you check if this is specific to 15.3, or does it also not work with e.g. 15.2? Attila. > On 2021. Jul 15., at 12:49, Andreas Mueller wrote: > > Tested it again with listing the engine right befor getByName: > > List factories = manager.getEngineFactories(); > for (int i = 0; i < factories.size(); i++) { > ctx.logSwiftlet.logInformation(ctx.streamsSwiftlet.getName(), "name=" + factories.get(i).getEngineName() + > ", version=" + factories.get(i).getEngineVersion() + ", language name=" + factories.get(i).getLanguageName() + > ", language version=" + factories.get(i).getLanguageVersion() + > ", names=" + factories.get(i).getNames()); > } > engine = manager.getEngineByName((String) entity.getProperty("script-language").getValue()); > > It is listed but returns null. This code is executed by a dedicated class loader. > > -- > Andreas Mueller > IIT Software GmbH > http://www.swiftmq.com > > > >> On 15. Jul 2021, at 10:59, Andreas Mueller > wrote: >> >> Hi Attila, >> >> thanks but didn?t work in my environment. >> >> Tried every combination (using ?nashorn?, ?JavaScript? as name, using class path, using module path). >> >> Fact is, it lists the Nashorn engine correctly: >> >> ScriptEngineManager manager = new ScriptEngineManager(); >> List factories = manager.getEngineFactories(); >> for (int i = 0; i < factories.size(); i++) { >> ctx.logSwiftlet.logInformation(ctx.streamsSwiftlet.getName(), "name=" + factories.get(i).getEngineName() + >> ", version=" + factories.get(i).getEngineVersion() + ", language name=" + factories.get(i).getLanguageName() + >> ", language version=" + factories.get(i).getLanguageVersion() + >> ", names=" + factories.get(i).getNames()); >> } >> >> 2021-07-15 10:51:37.948/sys$streams/INFORMATION/name=OpenJDK Nashorn, version=15.3, language name=ECMAScript, language version=ECMA - 262 Edition 5.1, names=[nashorn, Nashorn, js, JS, JavaScript, javascript, ECMAScript, ecmascript] >> >> But return null here: >> >> engine = manager.getEngineByName(?JavaScript?); >> >> I suspect it might have to do with class loaders as we use a dedicated class loader for every script: >> >> ScriptEngineManager manager = new ScriptEngineManager(); >> ClassLoader classLoader = createClassLoader(); >> streamContext.classLoader = classLoader; >> Thread.currentThread().setContextClassLoader(classLoader); >> >> Thanks, >> Andreas >> >> -- >> Andreas Mueller >> IIT Software GmbH >> http://www.swiftmq.com >> >> >> >>> On 13. Jul 2021, at 16:01, Attila Szegedi wrote: >>> >>> I?m honestly not sure. I have this very small test program: >>> >>> import javax.script.*; >>> >>> public class X { >>> public static void main(String[] args) throws ScriptException { >>> ScriptEngineManager factory = new ScriptEngineManager(); >>> ScriptEngine engine = factory.getEngineByName("JavaScript"); >>> engine.eval("function f() { print('Hello, World!'); } f()"); >>> } >>> } >>> >>> if I put it in a directory where I checked out Nashorn repo, and run ?ant jar? to build the JAR file and run: >>> >>> java --module-path build/nashorn/dist:build/nashorn/dependencies X.java >>> >>> It prints "Hello, World!? as expected, so it definitely find the engine under the name ?JavaScript". I can also run it with classpath instead of module path: >>> >>> java -cp build/nashorn/dist/nashorn.jar:build/nashorn/dependencies/asm-7.3.1.jar:build/nashorn/dependencies/asm-util-7.3.1.jar X.java >>> >>> and that works too. Do you have the dependencies (ASM) too? >>> >>> Attila. >>> >>>> On 2021. Jul 13., at 15:33, Andreas Mueller wrote: >>>> >>>> Hi, >>>> >>>> I?ve added Nashorn to Java 15 and it is properly displayed when listing the engines: >>>> >>>> 2021-07-13 15:14:30.233/sys$streams/INFORMATION/starting, available Scripting Engines: >>>> 2021-07-13 15:14:30.246/sys$streams/INFORMATION/name=OpenJDK Nashorn, version=15.3, language name=ECMAScript, language version=ECMA - 262 Edition 5.1, names=[nashorn, Nashorn, js, JS, JavaScript, javascript, ECMAScript, ecmascript] >>>> >>>> However, when I get the engine with name ?JavaScript? it returns null: >>>> >>>> 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!"); >>>> >>>> 2021-07-13 15:14:30.361/ERROR/Exception occured: java.lang.Exception: Engine for script-language 'JavaScript' not found! >>>> >>>> Any ideas what the problem could be? >>>> >>>> Thanks, >>>> Andreas >>>> -- >>>> Andreas Mueller >>>> IIT Software GmbH >>>> http://www.swiftmq.com >>>> >>>> >>> >> >