nashorn

How can I start coding with Oracle's Nashorn JS Engine and when will it replace Rhino in the OpenJDK?

拟墨画扇 提交于 2019-11-29 05:56:10
问题 I'm looking for a way to start playing around with Oracle's new Nashorn JavaScript Engine. I've DL'd the latest OpenJDK 8 (b65) and it appears that Rhino is still the only included script engine. Anyone know when (or in which build) Nashorn will replace Rhino in the OpenJDK? Or even better, where I can get a JDK with it included already? I know Netbeans has already written a debugger to use it, just not sure where they got the libraries/code to start writing it. Anyone have some links? Thanks

How to use graaljs ? Is there a place where to get a .jar file/files?

纵然是瞬间 提交于 2019-11-29 03:39:45
问题 I use Java 8 and I use the default JavaScript Engine (Nashorn). I would like to see how it compares with the 'highly hyped' GRAAL JS. See: https://github.com/graalvm/graaljs https://www.graalvm.org/ particularly because I hear they want to deprecate nashorn: http://openjdk.java.net/jeps/335 Does anybody know how to get access (easily) to graaljs ? I was hoping to find a pom.xml or a place where to download a jar file but not luck 回答1: At the moment there are no pre-built jars of Graal.js

Nashorn bug when calling overloaded method with varargs parameter

不问归期 提交于 2019-11-29 01:23:14
Assume the following API: package nashorn.test; public class API { public static void test(String string) { throw new RuntimeException("Don't call this"); } public static void test(Integer... args) { System.out.println("OK"); } } The following Nashorn JavaScript snippet will fail: var API = Java.type("nashorn.test.API"); API.test(1); The first method will be called instead of the second. Is this a bug in the Nashorn engine? For the record, this issue was previously reported on the jOOQ User Group , where method overloading and varargs are used heavily, and where this issue may cause a lot of

Switching from Rhino to Nashorn

被刻印的时光 ゝ 提交于 2019-11-28 18:16:00
I have a Java 7 project which makes a lot of use of Javascript for scripting various features. Until now I was using Rhino as script engine. I would now like to move to Java 8, which also means that I will replace Rhino by Nashorn. How compatible is Nashorn to Rhino? Can I use it as a drop-in replacement, or can I expect that some of my scripts will not work anymore and will need to be ported to the new engine? Are there any commonly-used features of Rhino which are not supported by Nashorn? One problem is that Nashorn can no longer by default import whole Java packages into the global scope

How to remove java apis from Nashorn-engine?

一世执手 提交于 2019-11-28 11:13:21
Is it possible to hide or remove java api's from nashorn-engine? So that it could only see or use "default" ECMAScript 262 Edition 5.1 with some especially exposed functions / variables? I would like to let my endusers create some specific logic for their own without worrying they could hack the whole system. Of course there might be some security holes in the nashorn engine etc. but that is the different topic. Edit: Sorry I forgot to mention that I am running nashorn inside my java application, so no commandline parameters can be used. Programmatically, you can also directly use the

Reuse Nashorn ScriptEngine in Servlet [duplicate]

本秂侑毒 提交于 2019-11-28 09:59:16
This question already has an answer here: Should I use a separate ScriptEngine and CompiledScript instances per each thread? 4 answers I want to execute a JavaScript within a servlet. Is it possible to reuse the same Scripting Engine across all servlet invocations? Servlet instances are shared by multiple threads. Does this require to create a new Scripting Engine per request? That would be a unacceptable performance penalty. As an example, is the following code save? public class MyServlet extends HttpServlet { private ScriptEngineManager factory; private ScriptEngine engine; @Override public

Can Nashorn startup slowness be overcome?

强颜欢笑 提交于 2019-11-27 23:54:09
问题 I've used Rhino for a scripting component inside graphics. In the project there are about 200 small scripts running independantly. Immediately when starting the application the scripts should be at full speed. Rhino's performance was sufficient, but since Oracle advices to migrate to Nashorn, i'm facing a dilema. Below a picture showing the load difference between Rhino and Nashorn at approximayely 15,000 invocations of the scripts. The Startup slowness of Nashorn is my biggest issue. Note,

Secure Nashorn JS Execution

♀尐吖头ヾ 提交于 2019-11-27 17:36:21
How can I securely execute some user supplied JS code using Java8 Nashorn? The script extends some computations for some servlet based reports. The app has many different (untrusted) users. The scripts should only be able to access a Java Object and those returned by the defined members. By default the scripts could instantiate any class using Class.forName() (using .getClass() of my supplied object). Is there any way to prohibit access to any java class not explicitly specified by me? I asked this question on the Nashorn mailing list a while back: Are there any recommendations for the best

Java 8 ScriptEngine across ClassLoaders

我们两清 提交于 2019-11-27 15:18:19
I need to execute some javascript code 'inside' different classloaders. If it is java, each task will run in separate class loader. Now I need this to be javascript. Do I need to create new instance of ScriptEngine in each classloader, or is it ok to share one across class loaders? From your question it is not clear why'd you look for such classloader isolation. So, I'm summarizing nashorn's classloader here - may be, you'll get what you're looking for. Nashorn and classloaders: Nashorn classes (jdk.nashorn.*) are loaded by Java extension class loader Generated script classes, adapters

Switching from Rhino to Nashorn

…衆ロ難τιáo~ 提交于 2019-11-27 11:10:01
问题 I have a Java 7 project which makes a lot of use of Javascript for scripting various features. Until now I was using Rhino as script engine. I would now like to move to Java 8, which also means that I will replace Rhino by Nashorn. How compatible is Nashorn to Rhino? Can I use it as a drop-in replacement, or can I expect that some of my scripts will not work anymore and will need to be ported to the new engine? Are there any commonly-used features of Rhino which are not supported by Nashorn?