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

(reflect) Array needs public static clone() method

XMLWordPrintable

    • Icon: Enhancement Enhancement
    • Resolution: Unresolved
    • Icon: P5 P5
    • None
    • 1.4.0
    • core-libs



      Name: gm110360 Date: 12/18/2001


      FULL PRODUCT VERSION :
      java version "1.4.0-beta3"
      Java(TM) 2 Runtime Environment, Standard Edition (build
      1.4.0-beta3-b84)
      Java HotSpot(TM) Client VM (build 1.4.0-beta3-b84, mixed
      mode)

      FULL OPERATING SYSTEM VERSION :
      Microsoft Windows 2000 [Version 5.00.2195]

      ADDITIONAL OPERATING SYSTEMS :
      All


      A DESCRIPTION OF THE PROBLEM :
      java.lang.reflect.Array does not have a public method that
      allows you to clone arrays. The Java language
      specification says that all arrays implicitly support the
      Object.clone() method by logically overriding it to be
      public and so as to suppress CloneNotSupportedException.
      Consequently, when working with an unknown object, it would
      be nice if java.lang.reflect.Array could call the implicit
      clone() method.

      You cannot do this at the moment because when you have an
      unknown Object there is no way to get the compiler/runtime
      to recognize that the clone() method should be public.

      STEPS TO FOLLOW TO REPRODUCE THE PROBLEM :
      1. Create a new int[]. Assign it to a variable of type
      Object.
      2. Using that Object reference, try to invoke clone(). It
      won't work. Short of doing several instanceof checks,
      there is no way around this.

      This bug can be reproduced always.
      (Review ID: 137459)
      ======================================================================

            Unassigned Unassigned
            gmanwanisunw Girish Manwani (Inactive)
            Votes:
            0 Vote for this issue
            Watchers:
            0 Start watching this issue

              Created:
              Updated:
              Imported:
              Indexed: