<html><body style="word-wrap: break-word; -webkit-nbsp-mode: space; line-break: after-white-space;">Hi Christian,<div class=""><br class=""></div><div class="">thanks. Yes, that would solve this but would cause another one when I call a method that is unique. For that case I need this String-&gt;Long conversion. Nashorn is very relaxed on this matter…</div><div class=""><br class=""></div><div class="">Problem is really to migrate a huge number of JS scripts that you can’t touch because they run on customer site. So the only option is to make GraalVM fully compatible.</div><div class=""><br class=""></div><div class="">The best would be to have a predefined Nashorn mapping that is automatically set once you get into Nashorn compatibility mode.</div><div class=""><br class=""></div><div class="">Thanks,</div><div class="">Andreas</div><div class=""><br class=""><div class="">--&nbsp;<br class="">Andreas Mueller<br class="">IIT Software GmbH<br class=""><a href="https://urldefense.com/v3/__http://www.swiftmq.com__;!!GqivPVa7Brio!KwXcC9xGHGwJdjX6eGvunWgsx0m8Ju27PKChsklscVhiFS4rfxl2TQqee194Q-VRp17U1Q$" class="">http://www.swiftmq.com</a><br class=""><br class=""><span><img apple-inline="yes" id="9602EDB6-4DEE-4DDD-BF4A-9037BABAF7CF" src="cid:A0309C4C-D818-48E8-A9CE-B43C74051926@multi.box" class=""></span><br class=""></div><br class=""><blockquote type="cite" class="">On 24. Mar 2020, at 17:57, Christian Wirth &lt;<a href="mailto:christian.wirth@oracle.com" class="">christian.wirth@oracle.com</a>&gt; wrote:<br class=""><br class="">Hi Andreas,<br class=""><br class="">From the error message, I assume you are calling &nbsp;`var Long =&nbsp;Java.type('java.lang.Long'); new Long('1585059851090')`.<br class=""><br class="">In that case, as you use targetTypeMapping String=&gt;Long, it&nbsp;seems we fail to give precedence to the base (unmapped) type,&nbsp;String in this case. We identify that it is ambigous&nbsp;whether to&nbsp;call the `Long(String)` or the `Long(long)` (using&nbsp;targetTypeMapping) constructor, and thus you get the error.&nbsp;<br class=""><br class="">I would think this is an error on our side. Commenting out the&nbsp;String-&gt;Long targetTypeMapping resolved the problem (and calls&nbsp;the `Long(String)` constructor). But I'll have to&nbsp;check with our&nbsp;expert on that matter.<br class=""><br class="">Best,<br class="">Christian Wirth<br class=""><br class=""><br class=""><br class=""><br class=""><br class="">Am 24.03.2020 um 15:45 schrieb Andreas&nbsp;Mueller:<br class=""><blockquote type="cite" cite="mid:010201710d015b0c-5dde35b6-42fb-487b-b34f-970f0c6b2fe5-000000@eu-west-1.amazonses.com" class="">Hi,<br class=""><br class="">I’m testing existing Nashorn JS scripts running on&nbsp;GraalVM 20.0.0. I’m getting this exception while instantiating a&nbsp;java.lang.Long object from JS code:<br class=""><br class="">TypeError: instantiate on JavaClass[java.lang.Long]&nbsp;failed due to: Multiple applicable overloads found for method&nbsp;name java.lang.Long (candidates: [Method[public&nbsp;java.lang.Long(java.lang.String)&nbsp;throws java.lang.NumberFormatException], Method[public&nbsp;java.lang.Long(long)]], arguments: [1585059851090 (String)])<br class=""><br class="">The argument I pass is a String and there is a Long&nbsp;constructor for this so I don’t understand why this is thrown.<br class=""><br class="">My ScriptEngine with a mapping String -&gt; long is&nbsp;created as follows:<br class=""><br class="">public class GraalSetup {<br class="">&nbsp; &nbsp; private static HostAccess getHostAccess() {<br class="">&nbsp; &nbsp; &nbsp; &nbsp; HostAccess.Builder builder =&nbsp;HostAccess.newBuilder(HostAccess.ALL);<br class="">&nbsp; &nbsp; &nbsp; &nbsp; builder.targetTypeMapping(String.class,&nbsp;Integer.class, null, (v) -&gt; Integer.parseInt(v));<br class="">&nbsp; &nbsp; &nbsp; &nbsp; builder.targetTypeMapping(String.class,&nbsp;Long.class, null, (v) -&gt; Long.parseLong(v));<br class="">&nbsp; &nbsp; &nbsp; &nbsp; builder.targetTypeMapping(String.class,&nbsp;Double.class, null, (v) -&gt; Double.parseDouble(v));<br class="">&nbsp; &nbsp; &nbsp; &nbsp; builder.targetTypeMapping(String.class,&nbsp;Float.class, null, (v) -&gt; Float.parseFloat(v));<br class="">&nbsp; &nbsp; &nbsp; &nbsp; builder.targetTypeMapping(Integer.class,&nbsp;Long.class, null, (v) -&gt; v.longValue());<br class="">&nbsp; &nbsp; &nbsp; &nbsp; return builder.build();<br class="">&nbsp; &nbsp; }<br class=""><br class="">&nbsp; &nbsp; public static ScriptEngine engine() throws Exception {<br class="">&nbsp; &nbsp; &nbsp;&nbsp;&nbsp; return GraalJSScriptEngine.create(null,Context.newBuilder("js").allowAllAccess(true).allowHostAccess(getHostAccess()));<br class="">&nbsp; &nbsp; }<br class="">}<br class=""><br class="">Any hints?<br class=""><br class="">Thanks,<br class="">Andreas<br class="">--&nbsp;<br class="">Andreas Mueller<br class="">IIT Software GmbH<br class=""><a href="https://urldefense.com/v3/__http://www.swiftmq.com__;!!GqivPVa7Brio!KwXcC9xGHGwJdjX6eGvunWgsx0m8Ju27PKChsklscVhiFS4rfxl2TQqee194Q-VRp17U1Q$" class="">http://www.swiftmq.com</a><br class=""><br class=""><span id="cid:part2.D33D6074.F31DE9CC@oracle.com">&lt;swiftmq_logo_positiv.png&gt;</span><br class=""><br class=""><br class=""><br class=""><div class="">_______________________________________________</div><div class="">GraalVM-Users mailing list</div><br class="Apple-interchange-newline">GraalVM-Users@oss.oracle.com<br class="">https://oss.oracle.com/mailman/listinfo/graalvm-users<br class=""></blockquote>_______________________________________________<br class="">GraalVM-Users mailing list<br class=""><a href="mailto:GraalVM-Users@oss.oracle.com" class="">GraalVM-Users@oss.oracle.com</a><br class="">https://oss.oracle.com/mailman/listinfo/graalvm-users<br class=""></blockquote><br class=""></div></body></html>