We're updating the issue view to help you get more done. 

Clojure master fails on JDK 11 EA builds due to overloaded toArray in gvec.clj

Description

The java.util.Collection interface has long had the methods:

1 2 Object[] toArray() <T> T[] toArray​(T[] a)

JDK 11 adds a new method with default impl:

1 default <T> T[] toArray​(IntFunction<T[]> generator)

For cases of a deftype implementing java.util.Collection, this makes existing implementations of the 1-arity toArray ambiguous. In Java, static typing means that existing implementors are not broken, but in our dynamic typing world, we now have ambiguity. *shakes fist at Java*

In Clojure itself, this comes up in gvec in the primitive vector implementation, which is done with deftype. This breaks the compilation of Clojure on JDK 11. This has also come up in some external projects that do the same thing (like core.rrbvector). See CRRBV-18.

Proposed: Add a type hint to disambiguate in JDK 11+.

This breaks our compilation of deftype implementation of java.util.Collection, which includes primitive vector in gvec, but also many external Clojure implementors.

Patch: clj-2374-2.patch

Environment

java version "11-ea" 2018-09-25
Java(TM) SE Runtime Environment 18.9 (build 11-ea+21)
Java HotSpot(TM) 64-Bit Server VM 18.9 (build 11-ea+21, mixed mode)
OS : Ubuntu

Status

Assignee

Unassigned

Reporter

Karthikeyan

Labels

Approval

Ok

Patch

Code

Fix versions

Priority

Critical