<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->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="">-- <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 <<a href="mailto:christian.wirth@oracle.com" class="">christian.wirth@oracle.com</a>> wrote:<br class=""><br class="">Hi Andreas,<br class=""><br class="">From the error message, I assume you are calling `var Long = Java.type('java.lang.Long'); new Long('1585059851090')`.<br class=""><br class="">In that case, as you use targetTypeMapping String=>Long, it seems we fail to give precedence to the base (unmapped) type, String in this case. We identify that it is ambigous whether to call the `Long(String)` or the `Long(long)` (using targetTypeMapping) constructor, and thus you get the error. <br class=""><br class="">I would think this is an error on our side. Commenting out the String->Long targetTypeMapping resolved the problem (and calls the `Long(String)` constructor). But I'll have to check with our 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 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 GraalVM 20.0.0. I’m getting this exception while instantiating a java.lang.Long object from JS code:<br class=""><br class="">TypeError: instantiate on JavaClass[java.lang.Long] failed due to: Multiple applicable overloads found for method name java.lang.Long (candidates: [Method[public java.lang.Long(java.lang.String) throws java.lang.NumberFormatException], Method[public java.lang.Long(long)]], arguments: [1585059851090 (String)])<br class=""><br class="">The argument I pass is a String and there is a Long constructor for this so I don’t understand why this is thrown.<br class=""><br class="">My ScriptEngine with a mapping String -> long is created as follows:<br class=""><br class="">public class GraalSetup {<br class=""> private static HostAccess getHostAccess() {<br class=""> HostAccess.Builder builder = HostAccess.newBuilder(HostAccess.ALL);<br class=""> builder.targetTypeMapping(String.class, Integer.class, null, (v) -> Integer.parseInt(v));<br class=""> builder.targetTypeMapping(String.class, Long.class, null, (v) -> Long.parseLong(v));<br class=""> builder.targetTypeMapping(String.class, Double.class, null, (v) -> Double.parseDouble(v));<br class=""> builder.targetTypeMapping(String.class, Float.class, null, (v) -> Float.parseFloat(v));<br class=""> builder.targetTypeMapping(Integer.class, Long.class, null, (v) -> v.longValue());<br class=""> return builder.build();<br class=""> }<br class=""><br class=""> public static ScriptEngine engine() throws Exception {<br class=""> return GraalJSScriptEngine.create(null,Context.newBuilder("js").allowAllAccess(true).allowHostAccess(getHostAccess()));<br class=""> }<br class="">}<br class=""><br class="">Any hints?<br class=""><br class="">Thanks,<br class="">Andreas<br class="">-- <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"><swiftmq_logo_positiv.png></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>