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

Stuart Halloway made changes -
Field Original Value New Value
Summary Collection.toArray implementations to not conform to Java API docs Collection.toArray implementations do not conform to Java API docs
Stuart Halloway made changes -
Patch Code [ 10001 ]
Attachment 0895-to-array.patch [ 10738 ]
Stuart Halloway made changes -
Attachment 0895-to-array-take-2.patch [ 10739 ]
Cosmin Stejerean made changes -
Attachment 0895-to-array-take-3.patch [ 10740 ]
Cosmin Stejerean made changes -
Attachment 0895-to-array-tests.patch [ 10741 ]
Cosmin Stejerean made changes -
Patch Code [ 10001 ] Code and Test [ 10002 ]
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.
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.
Stuart Sierra made changes -
Approval Vetted [ 10003 ] Incomplete [ 10006 ]
Cosmin Stejerean made changes -
Attachment 0895-to-array-take-3.patch [ 10740 ]
Cosmin Stejerean made changes -
Attachment 0895-to-array-tests.patch [ 10741 ]
Cosmin Stejerean made changes -
Stuart Halloway made changes -
Approval Incomplete [ 10006 ] Screened [ 10004 ]
Attachment 0895-take-4.patch [ 10928 ]
Rich Hickey made changes -
Approval Screened [ 10004 ] Ok [ 10007 ]
Stuart Halloway made changes -
Attachment 0895-take-5.patch [ 10929 ]
Stuart Halloway made changes -
Resolution Completed [ 1 ]
Status Open [ 1 ] Resolved [ 5 ]
Stuart Halloway made changes -
Status Resolved [ 5 ] Closed [ 6 ]

People

Vote (1)
Watch (2)

Dates

  • Created:
    Updated:
    Resolved: