Going from Scheme list to Java array

Per Bothner per@bothner.com
Tue Jun 23 00:02:13 GMT 2020


On 6/22/20 9:26 AM, Duncan Mak via Kawa wrote:
> (define (into-array l ::java.util.List array-type)
>    (let* ((size  (length l))
>           (array ((primitive-array-new array-type) size)))
>      (l:toArray array)))
> 
> (display (into-array (list 1 2 3) <int>))
> 
> When I run this in Kawa 3.1.1, this is what I see:
> 
> foo.scm:4:5: warning - more than one possibly applicable method 'toArray'
> in java.util.List
>    candidate: Type java.lang.Object[] java.util.List.toArray(ClassType
> java.util.function.IntFunction<null>)
>    candidate: Type java.lang.Object[]
> java.util.List.toArray(java.lang.Object[])

Not sure what is going on here.  When I use Java 8, there is no problem.
When I use Java 14, I get the same error.  So it seems like something
got added (after Java got default interface methods).  However, I don't see
it in the documentation here:
https://docs.oracle.com/en/java/javase/14/docs/api/java.base/java/util/List.html
-- 
	--Per Bothner
per@bothner.com   http://per.bothner.com/


More information about the Kawa mailing list