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

The clone method on arrays should be strongly typed

XMLWordPrintable

    • Icon: Bug Bug
    • Resolution: Fixed
    • Icon: P3 P3
    • 5.0
    • 1.3.0, 1.4.0
    • tools
    • b26
    • generic
    • generic

      As part of JSR-14 (generics), covariant returns were added to the language. The JSR-14 expert group therefore recommends that the clone method on arrays should return an object of the "correct" type, so than casting is no longer required to copy an array:

          int[] original = ...;
          int[] copy = original.clone();

            gafter Neal Gafter (Inactive)
            jjb Josh Bloch
            Votes:
            0 Vote for this issue
            Watchers:
            0 Start watching this issue

              Created:
              Updated:
              Resolved:
              Imported:
              Indexed: