<html><head><meta http-equiv="Content-Type" content="text/html; charset=utf-8"></head><body style="word-wrap: break-word; -webkit-nbsp-mode: space; line-break: after-white-space;">Hi,<div class=""><br class=""></div><div 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:</div><div class=""><br class=""></div><div 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&nbsp;java.lang.NumberFormatException], Method[public java.lang.Long(long)]], arguments: [1585059851090 (String)])</div><div class=""><br class=""></div><div 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.</div><div class=""><br class=""></div><div class="">My ScriptEngine with a mapping String -&gt; long is created as follows:</div><div class=""><br class=""></div><div class="">public class&nbsp;GraalSetup {<br class="">&nbsp; &nbsp;&nbsp;private static&nbsp;HostAccess getHostAccess() {<br class="">&nbsp; &nbsp; &nbsp; &nbsp; HostAccess.Builder builder = HostAccess.newBuilder(HostAccess.ALL);<br class="">&nbsp; &nbsp; &nbsp; &nbsp; builder.targetTypeMapping(String.class, Integer.class,&nbsp;null, (v) -&gt; Integer.parseInt(v));<br class="">&nbsp; &nbsp; &nbsp; &nbsp; builder.targetTypeMapping(String.class, Long.class,&nbsp;null, (v) -&gt; Long.parseLong(v));<br class="">&nbsp; &nbsp; &nbsp; &nbsp; builder.targetTypeMapping(String.class, Double.class,&nbsp;null, (v) -&gt; Double.parseDouble(v));<br class="">&nbsp; &nbsp; &nbsp; &nbsp; builder.targetTypeMapping(String.class, Float.class,&nbsp;null, (v) -&gt; Float.parseFloat(v));<br class="">&nbsp; &nbsp; &nbsp; &nbsp; builder.targetTypeMapping(Integer.class, Long.class,&nbsp;null, (v) -&gt; v.longValue());<br class="">&nbsp; &nbsp; &nbsp; &nbsp;&nbsp;return&nbsp;builder.build();<br class="">&nbsp; &nbsp; }</div><div class=""><br class="">&nbsp; &nbsp;&nbsp;public static&nbsp;ScriptEngine engine()&nbsp;throws&nbsp;Exception {<br class="">&nbsp; &nbsp; &nbsp; &nbsp;&nbsp;return&nbsp;GraalJSScriptEngine.create(null,Context.newBuilder("js").allowAllAccess(true).allowHostAccess(getHostAccess()));<br class="">&nbsp; &nbsp; }<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<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!JAZvy2BRpAt-fq5yTxPdkUbWUdQVGjXcIoEDS73fT4aCdVTUJNELDxHlzbNjh9yULvkOsA$" class="">http://www.swiftmq.com</a><br class=""><br class=""><span><img apple-inline="yes" id="5B456281-184A-4B70-A649-0CB9CD000B40" src="cid:A0309C4C-D818-48E8-A9CE-B43C74051926@multi.box" class=""></span></div><br class=""></div></body></html>