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


  • Type: Defect Defect
  • Status: Closed Closed
  • Priority: Critical Critical
  • Resolution: Completed
  • Affects Version/s: None
  • Fix Version/s: Release 1.10
  • Component/s: None
  • Labels:
  • 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
  • Patch:
  • Approval:


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

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

JDK 11 adds a new method with default impl:

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

  1. clj-2374.patch
    21/Sep/18 8:33 AM
    1 kB
    Alex Miller
  2. clj-2374-2.patch
    01/Oct/18 9:30 AM
    1.0 kB
    Alex Miller



Vote (2)
Watch (3)


  • Created: