Uploaded image for project: 'JDK'
  1. JDK
  2. JDK-5103030

(coll spec) Doc comment out of sync with generified Collection.toArray()

XMLWordPrintable

      Name: js151677 Date: 09/15/2004


      FULL PRODUCT VERSION :
      1.5.0-rc

      ADDITIONAL OS VERSION INFORMATION :
      5.1.2600

      A DESCRIPTION OF THE PROBLEM :
      In java.util.collection.java, the doc comment for the generified "toArray" method (the one with T[] as the argument type) has not been updated to reflect the "generification" of this method. In particular, in the example in the comment:

      String[] x = (String[]) v.toArray(new String[0]);

      An upcast is used that is not required with the new generified method. Since generics are new and this is a doc comment (destined for the online docs) I assert that fixing this comment should be done to ensure timely uptake of genric code by the community.


      STEPS TO FOLLOW TO REPRODUCE THE PROBLEM :
      Open source file. View doc comment.

      EXPECTED VERSUS ACTUAL BEHAVIOR :
      EXPECTED -
      The doc comment should read:

      String[] x = v.toArray(new String[0]);

      i.e. without the upcast.

      REPRODUCIBILITY :
      This bug can be reproduced always.
      (Incident Review ID: 310836)
      ======================================================================

            martin Martin Buchholz
            jssunw Jitender S (Inactive)
            Votes:
            0 Vote for this issue
            Watchers:
            0 Start watching this issue

              Created:
              Updated:
              Resolved:
              Imported:
              Indexed: