<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8">
</head>
<body text="#000000" bgcolor="#FFFFFF">
<p>Hi Andreas,<br>
<br>
Looks like either:<br>
1. `interval` is not an int value (e.g. "3", 3.5, undefined, ...)<br>
2. TimerCallback is not an interface annotated with
@FunctionalInterface<br>
<br>
Possible workarounds:<br>
1. ensure interval is an integer value<br>
e.g.: seconds(interval | 0)<br>
2. onTimer({execute: function(timer){}})<br>
(where execute is the name of the interface method)<br>
or if possible, add @FunctionalInterface to the interface<br>
<br>
Note that our implicit conversions may be too conservative in some
cases. If you think there's a problem, let us know and we'll see
what we can do.<br>
<br>
- Andreas<br>
</p>
<br>
<div class="moz-cite-prefix">On 22.06.18 14:05, Andreas Mueller
wrote:<br>
</div>
<blockquote type="cite"
cite="mid:1FA7BABE-8883-4655-AE2C-9CA24AF7D80C@iit.de">Hi
Christian,
<div class=""><br class="">
</div>
<div class="">thanks. After adding the jars to the classpath, the
engine was available. </div>
<div class=""><br class="">
</div>
<div class="">However, I’m getting this while evaluating a script:</div>
<div class=""><br class="">
</div>
<div class="">javax.script.ScriptException:
org.graalvm.polyglot.PolyglotException: TypeError: INVOKE on
JavaObject[IntervalTimer{name='scheduler',
millis=0} (com.swiftmq.impl.streams.comp.timer.IntervalTimer)]
failed due to: UnsupportedTypeException<br class="">
<span class="Apple-tab-span" style="white-space:pre">        </span>at
com.oracle.truffle.js.scriptengine.GraalJSScriptEngine.eval(GraalJSScriptEngine.java:183)<br
class="">
<span class="Apple-tab-span" style="white-space:pre">        </span>at
com.oracle.truffle.js.scriptengine.GraalJSScriptEngine.eval(GraalJSScriptEngine.java:155)<br
class="">
<span class="Apple-tab-span" style="white-space:pre">        </span>at
com.swiftmq.impl.streams.StreamController.evalScript(Unknown
Source)<br class="">
<span class="Apple-tab-span" style="white-space:pre">        </span>at
com.swiftmq.impl.streams.StreamController.start(Unknown Source)<br
class="">
<br class="">
</div>
<div class="">The script does this:</div>
<div class=""><br class="">
</div>
<div class="">stream.create().timer("scheduler").interval().seconds(interval).onTimer(function
(timer) {<br class="">
...</div>
<div class="">}</div>
<div class=""><br class="">
</div>
<div class="">The Java class “IntervalTimer” has this “seconds”
and “onTimer" methods:</div>
<div class=""><br class="">
</div>
<div class="">public IntervalTimer seconds(int n) {<br class="">
millis += (long) n * 1000L;<br class="">
return this;<br class="">
}<br class="">
</div>
<div class=""><br class="">
</div>
<div class=""> @Override<br class="">
public Timer onTimer(TimerCallback callback) {<br class="">
this.callback = callback;<br class="">
return this;<br class="">
}<br class="">
<br class="">
</div>
<div class=""><br class="">
</div>
<div class="">Any hints?</div>
<div class=""><br class="">
</div>
<div class="">Thanks,</div>
<div class="">Andreas</div>
<div class=""><br class="">
<div class="">-- <br class="">
Andreas Mueller<br class="">
IIT Software GmbH<br class="">
<a
href="https://urldefense.proofpoint.com/v2/url?u=http-3A__www.swiftmq.com&d=DwMFaQ&c=RoP1YumCXCgaWHvlZYR8PZh8Bv7qIrMUB65eapI_JnE&r=CUkXBxBNT_D5N6HMJ5T9Z6rmvNKYsqupcbk72K0lcoQ&m=TP6vDFIvOwHIJubzP5a3mC1OLNpov_7VuXVjRKUILpY&s=9FM150Blv30fDT3EnnLT4BX13ZpAdhoPfJbyD5QbUwM&e="
class="" moz-do-not-send="true">http://www.swiftmq.com</a><br
class="">
<br class="">
<span><img apple-inline="yes"
id="CE513DC8-9F8B-491C-A567-8A6EE03FCA82"
apple-width="yes" apple-height="yes"
src="cid:part2.E9C5BC86.1607E6DB@oracle.com" class=""
width="452" height="100"></span><br class="">
</div>
<br class="">
<blockquote type="cite" class="">On 22 Jun 2018, at 09:48,
Christian Wirth <<a
href="mailto:christian.wirth@oracle.com" class=""
moz-do-not-send="true">christian.wirth@oracle.com</a>>
wrote:<br class="">
<br class="">
Hi Andreas,<br class="">
<br class="">
currently, we strongly endorse the use of GraalVM. That
guarantees that you use Graal JavaScript with Graal as
optimizing compiler.<br class="">
<br class="">
What you tried to achieve will work; note, however, that in
such a setup (on JDK 8) Graal is NOT used as optimzing
compiler (but HotSpot Server Compiler C2 is), thus
the performance of Graal JavaScript will likely be much worse
than it would be on GraalVM. <br class="">
<br class="">
Your commandline was probably missing
the $GRAALVM/jre/lib/boot/graaljs-scriptengine.jar file? I am
using a commandline like:<br class="">
<br class="">
GRAALVM=/path/to/GraalVM<br class="">
/path/to/jdk8/bin/java
-cp $GRAALVM/jre/languages/js/graaljs.jar:$GRAALVM/jre/lib/truffle/truffle-api.jar:$GRAALVM/jre/lib/boot/graal-sdk.jar:$GRAALVM/jre/lib/boot/graaljs-scriptengine.jar:$GRAALVM/jre/tools/regex/tregex.jar:. MyJavaApp<br
class="">
<br class="">
In MyJavaApp, you can start Graal JavaScript via ScriptEngine;
it registers under several names, including "graal.js". Again,
note that performance will be suboptimal this way; use GraalVM
for better results.<br class="">
<br class="">
For JDK 11 and beyond, you can execute Graal JavaScript with
Graal as optimizing compiler on a stock JVM already. We are
currently working on improved packaging/modularizing and
should be able to publish some documentation on that in the
coming weeks.<br class="">
<br class="">
Best,<br class="">
Christian Wirth<br class="">
Graal JavaScript team<br class="">
<br class="">
<br class="">
<br class="">
<br class="">
<blockquote type="cite" class="">From: Andreas Mueller <<a
href="mailto:am@iit.de" class="" moz-do-not-send="true">am@iit.de</a>><br
class="">
Subject: [graalvm-users] Migrate from Nashhorn JSR 223
Scripting Engine to Graal<br class="">
Date: 18 June 2018 at 15:05:22 CEST<br class="">
To: <a class="moz-txt-link-abbreviated" href="mailto:graalvm-users@oss.oracle.com">graalvm-users@oss.oracle.com</a><br class="">
<br class="">
Hi,<br class="">
<br class="">
I was cold hitted by the announcement that Nashorn might be
deprecated in future. Since we have a lot JS scripts
implemented that run on the JVM and interact with Java
very well, I need an alternative JSR 223 JavaScript engine.
So GraalVM comes to mind (and is suggested).<br class="">
<br class="">
GraalVM seems to me a JDK replacement rather than a
scripting engine. I downloaded it but didn’t find a jar file
(such as graaljs.jar) that contains the JSR 223 engine and
that I just add to the classpath of a legacy JDK 1.8.x and
then it is automatically available when I list the engines.<br
class="">
<br class="">
Can anybody tell me how I can achieve this?<br class="">
<br class="">
Thanks,<br class="">
Andreas<br class="">
<br class="">
-- <br class="">
Andreas Mueller<br class="">
IIT Software GmbH<br class="">
<a class="moz-txt-link-freetext" href="http://www.swiftmq.com">http://www.swiftmq.com</a><br class="">
<br class="">
<span id="cid:part4.1121624D.1730F500@oracle.com"><swiftmq_logo_positiv.png></span><br
class="">
<br class="">
<br class="">
<br class="">
IIT Software GmbH<br class="">
Falkenhorst 11, 48155 Münster, Germany<br class="">
Phone: +49 (0)251 39 72 99 00<br class="">
Managing Director: Andreas Müller<br class="">
District Court: Amtsgericht Münster, HRB 16294<br class="">
VAT-No: DE199945912<br class="">
<br class="">
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.<br class="">
_______________________________________________<br class="">
GraalVM-Users mailing list<br class="">
<a class="moz-txt-link-abbreviated" href="mailto:GraalVM-Users@oss.oracle.com">GraalVM-Users@oss.oracle.com</a><br class="">
<a class="moz-txt-link-freetext" href="https://oss.oracle.com/mailman/listinfo/graalvm-users">https://oss.oracle.com/mailman/listinfo/graalvm-users</a><br
class="">
</blockquote>
<br class="">
_______________________________________________<br class="">
GraalVM-Users mailing list<br class="">
<a href="mailto:GraalVM-Users@oss.oracle.com" class=""
moz-do-not-send="true">GraalVM-Users@oss.oracle.com</a><br
class="">
<a class="moz-txt-link-freetext" href="https://oss.oracle.com/mailman/listinfo/graalvm-users">https://oss.oracle.com/mailman/listinfo/graalvm-users</a><br
class="">
</blockquote>
<br class="">
</div>
<br>
<br>
<hr>
IIT Software GmbH<br>
Falkenhorst 11, 48155 Münster, Germany<br>
Phone: +49 (0)251 39 72 99 00<br>
Managing Director: Andreas Müller<br>
District Court: Amtsgericht Münster, HRB 16294<br>
VAT-No: DE199945912<br>
<br>
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.<br>
<!--'"--><br>
<fieldset class="mimeAttachmentHeader"></fieldset>
<br>
<pre wrap="">_______________________________________________
GraalVM-Users mailing list
<a class="moz-txt-link-abbreviated" href="mailto:GraalVM-Users@oss.oracle.com">GraalVM-Users@oss.oracle.com</a>
<a class="moz-txt-link-freetext" href="https://oss.oracle.com/mailman/listinfo/graalvm-users">https://oss.oracle.com/mailman/listinfo/graalvm-users</a></pre>
</blockquote>
<br>
</body>
</html>