graal-js - passing JS native object to Java - com.oracle.truffle.object.enterprise.b

Christian Humer christian.humer at gmail.com
Tue Jan 9 10:43:56 UTC 2018


Hi Adam,

If you are using latest GraalVM you can use the polyglot.Value type in any
Java signature. Graaljs will map the native js object automatically when
called from js.

As Andreas said we are improving javax.script compatibility atm such that
you can also do almost everything by just using core Java classes in the
Java signatures.

Hope this helps.

- Christian Humer



Adam McMahon <adam at cs.miami.edu> schrieb am Di., 9. Jan. 2018, 02:54:

> Hi,
>
> Here is the snippet of code I am working on.  It passes a native JS object
> to Java.  https://gist.github.com/AdamMcM/87bed21323aa5ff90ed020412f16eb02
>
> The org.graalvm.polyglot.Value class seems promising to be able to inspect
> natvie JS objects passed to Java, but I am not sure how to obtain a
> org.graalvm.polyglot.Value object from the native JS object passed to Java.
>
> >> We're currently reworking the value conversions so that
> language objects are always exposed as wrapper objects that Java code
> can work with, e.g. implementing java.util.Map (similar to
> ScriptObjectMirror).
>
> This sounds like it will work well.
>
> -Adam
>
>
> On Mon, Jan 8, 2018 at 4:59 PM, Thomas Wuerthinger <
> thomas.wuerthinger at oracle.com> wrote:
>
> > Hi Adam!
> >
> > The only class you should ever have to work with is in that context is
> > org.graalvm.polyglot.Value (see javadoc at http://graalvm.github.io/
> > graal/truffle/javadoc/index.html?org/graalvm/polyglot/Value.html). We are
> > not exposing implementation-internal classes but instead have this
> > language-agnostic Value interface abstraction. Can you share your code
> > snippet?
> >
> > Thanks, thomas
> >
> >
> > > On 08.01.2018, at 22:32, Adam McMahon <adam at cs.miami.edu> wrote:
> > >
> > > Hi,
> > >
> > > I am attempting to get a few nashorn projects working with graal.js.
> > Often
> > > we need to pass native JS objects back to Java.  In nashorn, this would
> > be
> > > passed back to Java as a jdk.nashorn.api.scripting.ScriptObjectMirror.
> > >
> > > Using Graal-js it seems to be passed back as a
> > > com.oracle.truffle.object.enterprise.b.  Is the actual name of this
> > class
> > > really just "b" (perhaps for "bindings")?
> > >
> > > Do you happen to have a link to javadoc for this class?  Or any other
> > info?
> > >
> > > Thanks,
> > >
> > > -Adam
> >
> >
>


More information about the graal-dev mailing list