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

(reflect) GenericArrayType javadoc: component type can be another GenericArrayType

XMLWordPrintable

    • Icon: Bug Bug
    • Resolution: Duplicate
    • Icon: P4 P4
    • None
    • 6
    • core-libs

      FULL PRODUCT VERSION :
      java version "1.6.0_18"
      OpenJDK Runtime Environment (IcedTea6 1.8) (fedora-41.b18.fc13-x86_64)
      OpenJDK 64-Bit Server VM (build 14.0-b16, mixed mode)


      ADDITIONAL OS VERSION INFORMATION :
      Linux mattlaptop2.local 2.6.33.6-147.2.4.fc13.x86_64 #1 SMP Fri Jul 23 17:14:44 UTC 2010 x86_64 x86_64 x86_64 GNU/Linux

      A DESCRIPTION OF THE PROBLEM :
      The java.lang.reflect.GenericArrayType javadoc states, "{@code GenericArrayType} represents an array type whose component type is either a parameterized type or a type variable." This is incorrect: the component type can also be another GenericArrayType.

      STEPS TO FOLLOW TO REPRODUCE THE PROBLEM :
      1. Run the test case, and observe that a GenericArrayType can have another GenericArrayType as component type.
      2. Read the java.lang.reflect.GenericArrayType javadoc comment.

      EXPECTED VERSUS ACTUAL BEHAVIOR :
      EXPECTED -
      The documentation lists GenericArrayType as a possible kind of component type.
      ACTUAL -
      The documentation does not list GenericArrayType as a possible kind of component type.

      REPRODUCIBILITY :
      This bug can be reproduced always.

      ---------- BEGIN SOURCE ----------
      import java.lang.reflect.Field;
      import java.lang.reflect.GenericArrayType;

      class Generic2DArray<T> {

        T[][] arr;

        public static void main(String[] args) {
          try {
            Field arrField = Generic2DArray.class.getDeclaredField("arr");
            GenericArrayType type = (GenericArrayType) arrField.getGenericType();
            /* The javadoc for GenericArrayType fails to mention that the component
             * type can be another GenericArrayType. */
            GenericArrayType etype = (GenericArrayType) type.getGenericComponentType();
            System.out.println(etype);
          } catch (NoSuchFieldException ex) {
            throw new AssertionError(ex);
          }
        }
      }
      ---------- END SOURCE ----------

            Unassigned Unassigned
            webbuggrp Webbug Group
            Votes:
            0 Vote for this issue
            Watchers:
            1 Start watching this issue

              Created:
              Updated:
              Resolved:
              Imported:
              Indexed: