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

(reflect) Typo for java.lang.reflect.Arrays.newInstance() method.

XMLWordPrintable

    • Icon: Bug Bug
    • Resolution: Not an Issue
    • Icon: P4 P4
    • 6
    • 1.4.0
    • core-libs

      Name: rmT116609 Date: 03/17/2002


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

      A DESCRIPTION OF THE PROBLEM :
      This typo is present in all versions of J2SE since reflection package is added.

      The documentation for following method has a example code. The declaration for the integer argument 'x' should have been just "int" rather than "int[]".

      int[] x = {length};
      Array.newInstance(componentType, x);

      The method accepts only integers. But the sample code given shows an integer array being passed to the method.

      There is another newInstance() method that accepts an integer array.

      STEPS TO FOLLOW TO REPRODUCE THE PROBLEM :
      1. Open Java Doc for java.lang.reflect.Array
      2. Check the java doc for newInstance(Class componentType, int length) method.

      http://java.sun.com/j2se/1.4/docs/api/java/lang/reflect/Array.html#newInstance(java.lang.Class, int)

      3. Read the method comment.


      (Review ID: 144278)
      ======================================================================

            darcy Joe Darcy
            rmandalasunw Ranjith Mandala (Inactive)
            Votes:
            0 Vote for this issue
            Watchers:
            0 Start watching this issue

              Created:
              Updated:
              Resolved:
              Imported:
              Indexed: