JDK-5003398 : (reflect) getGenericParameterTypes() should return GenericArrayType
  • Type: Bug
  • Component: core-libs
  • Sub-Component: java.lang:reflect
  • Affected Version: 5.0
  • Priority: P4
  • Status: Closed
  • Resolution: Duplicate
  • OS: windows_xp
  • CPU: x86
  • Submitted: 2004-02-25
  • Updated: 2012-09-28
  • Resolved: 2004-06-02
Related Reports
Duplicate :  
Description

Name: rmT116609			Date: 02/25/2004


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

ADDITIONAL OS VERSION INFORMATION :
Windows XP

A DESCRIPTION OF THE PROBLEM :
getGenericParameterTypes() returns confusing values under certain conditions.

STEPS TO FOLLOW TO REPRODUCE THE PROBLEM :
javac -source 1.5 BugTest.java
java BugTest

EXPECTED VERSUS ACTUAL BEHAVIOR :
EXPECTED -
public BugTest(java.lang.String[],java.util.List)
        class [Ljava.lang.String;        sun.reflect.generics.reflectiveObjects.ParameterizedTypeImpl@530daa
public BugTest(java.lang.String[])
        class [Ljava.lang.String;

ACTUAL -
public BugTest(java.lang.String[],java.util.List)
        sun.reflect.generics.reflectiveObjects.GenericArrayTypeImpl@1729854
        sun.reflect.generics.reflectiveObjects.ParameterizedTypeImpl@6eb38a
public BugTest(java.lang.String[])
        class [Ljava.lang.String;


REPRODUCIBILITY :
This bug can be reproduced always.

---------- BEGIN SOURCE ----------
import java.lang.reflect.*;
import java.util.*;
public class BugTest<E> {
   public BugTest(String []args) {
   }
   public BugTest(String []args, List<E> list) {
   }
   public static void main(String... args){
      Class c = BugTest.class;
      Constructor[] constructors = c.getConstructors();
      for(Constructor cons : constructors){
         System.out.println(cons);
         Type[] types = cons.getGenericParameterTypes();
         for(Type t : types){
            System.out.println("\t" + t);
         }
      }
   }
}

---------- END SOURCE ----------
(Incident Review ID: 240296) 
======================================================================
###@###.### 2004-02-25

Comments
EVALUATION It is not clear to me what the bug submitter expects or wants. Marking the bug incomplete. ###@###.### 2004-02-25 If the complaint of this bug is that the toString information is uninformitive, that shortcoming has been addressed with the fix to 5015676. The output of BugTest is now public BugTest(java.lang.String[]) class [Ljava.lang.String; public BugTest(java.lang.String[],java.util.List) java.lang.String[] java.util.List<E> However, I believe the root complaint is that in the latter case a "generic" object is returned for the String array rather than the class object for String[]. That issue is a duplicate of 5041784 -- closing this bug accordingly. ###@###.### 2004-06-02
02-06-2004