From JS to Java objects?

Tal Liron tal.liron at threecrickets.com
Tue Oct 8 05:26:19 PDT 2013


Sorry about that, was trying to be succinct.

In detail: I'm creating Nashorn scripts programmatically from Java 
(using Context.compileScript and ScriptRuntime.apply), and receiving 
native results that need some massaging in order to be usable in Java. 
(Specifically I'm working on creating a Nashorn adapter for Scripturian.)

However, I mostly found the answers myself:

1. It's possible to call NativeJava.to (equivalent to Java.to in JavaScript)
2. More efficient is to test specifically for NativeArray results and 
wrap them in a ListAdapter, which makes them conform to the List 
interface. This is what NativeJava.to does internally.

On 10/08/2013 08:12 PM, Jim Laskey (Oracle) wrote:
> Please be more specific with an example.  I assume you want to extend a Java class or some such requirement,
>



More information about the nashorn-dev mailing list