Clojure

Collection.toArray implementations do not conform to Java API docs

Details

  • Type: Defect Defect
  • Status: Closed Closed
  • Priority: Major Major
  • Resolution: Completed
  • Affects Version/s: None
  • Fix Version/s: None
  • Component/s: None
  • Labels:
    None
  • Patch:
    Code and Test
  • Approval:
    Ok

Description

Per http://docs.oracle.com/javase/6/docs/api/index.html?java/util/Collections.html, Collection.toArray(T []) implements must allocate an array of type T[], not Object[]. This will cause type-casty code to break. Not often a problem in Clojure, but e.g. it makes Clojure defrecords unprintable from the JRuby console.

There is also a chance to DRY up some common code, as the six places that have this problem should all call an RT helper.

This also fixes toArray(T[]) for PersistentQueue when the passed array has the same length as the queue.

  1. 0001-CLJ-895.-Use-RT.seqToPassedArray-to-implement-Collec.patch
    03/Feb/12 6:52 PM
    6 kB
    Cosmin Stejerean
  2. 0895-take-4.patch
    19/Feb/12 6:48 PM
    6 kB
    Stuart Halloway
  3. 0895-take-5.patch
    19/Feb/12 7:17 PM
    6 kB
    Stuart Halloway
  4. 0895-to-array.patch
    10/Dec/11 5:35 PM
    7 kB
    Stuart Halloway
  5. 0895-to-array-take-2.patch
    11/Dec/11 6:53 AM
    7 kB
    Stuart Halloway

Activity

People

Vote (1)
Watch (2)

Dates

  • Created:
    Updated:
    Resolved: