Bug: no single overload found. Probably due to generic super interface

Jerven Tjalling Bolleman jerven.bolleman at sib.swiss
Tue Aug 8 14:47:14 UTC 2017


Hi All,

I have a class hierarchy like this in Java. I am not using the real 
hierarchy because it are large objects which hide the details. But the 
following Junit should demonstrate the issue.

package org.expasy.services.taxonomy.view;

import static org.junit.Assert.assertEquals;

import org.graalvm.polyglot.Context;
import org.graalvm.polyglot.Value;
import org.junit.Test;

public class GraalTest
{
	public interface Identity<T>{
		public T getId();
	}

	public interface SomeClassOfThingWithIdentity extends Identity<Integer>{
		public Integer getId();
	}

	public class ActualRealThingWithIdentity
		implements SomeClassOfThingWithIdentity {
		Integer id = 1;

		public Integer getId(){
			return id;
		};
	}
	
	@Test
	public void test(){
		final Value value = Context.create("js").eval("js", 
"function(example){return `${example.getId().toString()}`;}");
		String result = value.execute(new 
ActualRealThingWithIdentity()).asString();
		assertEquals("1", result);
	}
}

This fails with the following stacktrace

org.graalvm.polyglot.PolyglotException: 
java.lang.IllegalArgumentException: no single overload found 
(candidates: [Method[public java.lang.Integer 
org.expasy.services.taxonomy.view.GraalTest$ActualRealThingWithIdentity.getId()], 
Method[public java.lang.Object 
org.expasy.services.taxonomy.view.GraalTest$ActualRealThingWithIdentity.getId()]], 
arguments: [])
	at 
com.oracle.truffle.api.interop.java.ExecuteMethodNode.ambiguousOverloadsException(ExecuteMethodNode.java:441)
	at 
com.oracle.truffle.api.interop.java.ExecuteMethodNode.selectOverload(ExecuteMethodNode.java:270)
	at 
com.oracle.truffle.api.interop.java.ExecuteMethodNodeGen.executeAndSpecialize(ExecuteMethodNodeGen.java:179)
	at 
com.oracle.truffle.api.interop.java.ExecuteMethodNodeGen.execute(ExecuteMethodNodeGen.java:75)
	at 
com.oracle.truffle.api.interop.java.JavaObjectMessageResolution$InvokeNode.access(JavaObjectMessageResolution.java:94)
	at 
com.oracle.truffle.api.interop.java.JavaObjectMessageResolutionForeign$InvokeSubNode.accessWithTarget(JavaObjectMessageResolutionForeign.java:229)
	at 
com.oracle.truffle.api.interop.java.JavaObjectMessageResolutionForeignFactory$InvokeSubNodeGen.executeAndSpecialize(JavaObjectMessageResolutionForeignFactory.java:267)
	at 
com.oracle.truffle.api.interop.java.JavaObjectMessageResolutionForeignFactory$InvokeSubNodeGen.executeWithTarget(JavaObjectMessageResolutionForeignFactory.java:249)
	at 
com.oracle.truffle.api.interop.java.JavaObjectMessageResolutionForeign$InvokeSubNode$INVOKERootNode.execute(JavaObjectMessageResolutionForeign.java:247)
	at <js> :program$0(Unnamed:1:28-42)
	at org.graalvm.polyglot.Value.execute(Value.java:162)
	at org.expasy.services.taxonomy.view.GraalTest.test(GraalTest.java:31)
	at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
	at ....


Regards,
Jerven

On 08/08/2017 04:28 PM, Daniele Bonetta wrote:
> Hi Jerven,
> 
> there is no Graal.js-only list at the moment, so feel free to report any 
> issue on this list :)
> 
> Regards,
> 
> Daniele
> 
> 
> 
> On 08.08.2017 15:21, Jerven Tjalling Bolleman wrote:
>> Hi Daniele, All,
>>
>> Thanks, for the fast reply. Does anyone mind if I keep sending e-mails 
>> in this form to the graal-dev list or would you prefer I send these 
>> Graal.js java interop ones too a different list?
>>
>> I already have a few more ;)
>>
>> Regards,
>> Jerven
>>
>> On 08/08/2017 02:53 PM, Daniele Bonetta wrote:
>>> Hi Jerven,
>>>
>>> your code is correct, but does not work due to a bug in the Graal.js 
>>> interop support.
>>>
>>> We already have a fix for that bug, and the fix will be part of the 
>>> next monthly Graal VM release (v0.27).
>>>
>>>
>>> Thanks for your bug report!
>>>
>>> Regards,
>>>
>>> Daniele
>>>
>>>
>>>
>>> On 08.08.2017 11:54, Jerven Tjalling Bolleman wrote:
>>>> Hi All,
>>>>
>>>> Next question, How can I import a java.lang.Long into the js space 
>>>> inside the context. I am now working around it by passing it in as a 
>>>> parameter e.g.
>>>>
>>>> Value function = context.eval("js", "function(x,out){out.print(x)}");
>>>> function.execute(out, 1000_000_000_000L);
>>>>
>>>> Works
>>>>
>>>> However,
>>>>
>>>> context.exportSymbol("x",1000_000_000_000L);
>>>> context.exportSymbol("out", response.getOutoutStream());
>>>> Value function = context.eval("js", 
>>>> "x=Interop.import('x');out=Interop.import('out);out.print(x)");
>>>>
>>>> Does not with the following exception.
>>>>
>>>> java.lang.Long cannot be cast to 
>>>> com.oracle.truffle.api.interop.TruffleObject
>>>>
>>>> Regards,
>>>> Jerven
>>>>
>>>>
>>>>
>>>> On 08/07/2017 02:39 PM, Doug Simon wrote:
>>>>> We are currently working on extensive documentation for GraalVM but 
>>>>> it's not yet ready for release.
>>>>>
>>>>> You can find a draft of the embedding page at 
>>>>> https://urldefense.proofpoint.com/v2/url?u=https-3A__www.dropbox.com_s_ia4yoe2jh6viyzq_Embed-2520Languages-2520with-2520the-2520Graal-2520Polyglot-2520SDK.pdf-3Fdl-3D0&d=DwICaQ&c=RoP1YumCXCgaWHvlZYR8PQcxBKCX5YTpkKY057SbK10&r=W5Zo00VHyUAb3eyeSOfpd8vQ04i6XWgfLSLJcJECgxE&m=6PDu846uJ078h-SZRYjYKPBaGR1da2ltWJgHrzftIso&s=Cv0eEOI0tBRk2cYh61HPe4A00Xn4uUVm32MQgXGQSro&e= 
>>>>>
>>>>>
>>>>> Keep in mind that it's only a draft and may contain errors.
>>>>>
>>>>> -Doug
>>>>>
>>>>>> On 7 Aug 2017, at 12:49, Jerven Tjalling Bolleman 
>>>>>> <jerven.bolleman at sib.swiss> wrote:
>>>>>>
>>>>>> Dear Graal devs,
>>>>>>
>>>>>> Really love the work you are doing. I am just looking for some 
>>>>>> documentation.
>>>>>>
>>>>>> In the Graal OTN 0.26 release graalvm-0.26/examples/embed/README.md
>>>>>> file a location is mentioned where one should find graal embedding 
>>>>>> documentation.
>>>>>>
>>>>>> https://urldefense.proofpoint.com/v2/url?u=http-3A__www.graalvm.org_docs_embed_&d=DwICaQ&c=RoP1YumCXCgaWHvlZYR8PQcxBKCX5YTpkKY057SbK10&r=W5Zo00VHyUAb3eyeSOfpd8vQ04i6XWgfLSLJcJECgxE&m=6PDu846uJ078h-SZRYjYKPBaGR1da2ltWJgHrzftIso&s=X_S7O7VP-odaX11BVYCcKzjL8pLneZMoXl98Xzp-VmQ&e= 
>>>>>>
>>>>>> However, this does not resolve at this time.
>>>>>>
>>>>>> Otherwise, the example in that directory was exactly what I was 
>>>>>> looking for!
>>>>>>
>>>>>> I did want to know if it is already possible to run graal.js on a 
>>>>>> JDK9-EA? Without graal if need be? for example by copying the 
>>>>>> trufflejs.jar and truffle.jar to a JDK9 classpath?
>>>>>>
>>>>>> Regards,
>>>>>> Jerven
>>>>>> -- 
>>>>>> -------------------------------------------------------------------
>>>>>> Jerven Bolleman Jerven.Bolleman at sib.swiss
>>>>>> SIB Swiss Institute of Bioinformatics  Tel: +41 (0)22 379 58 85
>>>>>> CMU, rue Michel Servet 1               Fax: +41 (0)22 379 58 58
>>>>>> 1211 Geneve 4,
>>>>>> Switzerland     www.sib.swiss - www.uniprot.org
>>>>>> Follow us at 
>>>>>> https://urldefense.proofpoint.com/v2/url?u=https-3A__twitter.com_-23-21_uniprot&d=DwICaQ&c=RoP1YumCXCgaWHvlZYR8PQcxBKCX5YTpkKY057SbK10&r=W5Zo00VHyUAb3eyeSOfpd8vQ04i6XWgfLSLJcJECgxE&m=6PDu846uJ078h-SZRYjYKPBaGR1da2ltWJgHrzftIso&s=0kjMaBI9UJj3x8hoD0ePJJLhOMChklmfrE9b9kH0AKk&e= 
>>>>>> -------------------------------------------------------------------
>>>>>
>>>>
>>>
>>
> 

-- 
-------------------------------------------------------------------
Jerven Bolleman                        Jerven.Bolleman at sib.swiss
SIB Swiss Institute of Bioinformatics  Tel: +41 (0)22 379 58 85
CMU, rue Michel Servet 1               Fax: +41 (0)22 379 58 58
1211 Geneve 4,
Switzerland     www.sib.swiss - www.uniprot.org
Follow us at https://twitter.com/#!/uniprot
-------------------------------------------------------------------


More information about the graal-dev mailing list