JDK-5041784 : (reflect) generic signature methods needlessly return generic arrays
  • Type: Bug
  • Component: core-libs
  • Sub-Component: java.lang:reflect
  • Affected Version: 5.0
  • Priority: P3
  • Status: Closed
  • Resolution: Fixed
  • OS: generic,solaris_8,windows_xp
  • CPU: generic,x86
  • Submitted: 2004-05-04
  • Updated: 2012-09-28
  • Resolved: 2011-05-17
The Version table provides details related to the release that this issue/RFE will be addressed.

Unresolved : Release in which this issue/RFE will be addressed.
Resolved: Release in which this issue/RFE has been resolved.
Fixed : Release in which this issue/RFE has been fixed. The release containing this fix may be available for download as an Early Access Release or a General Availability Release.

To download the current JDK release, click here.
JDK 7
7 b36Fixed
Related Reports
Duplicate :  
Duplicate :  
Relates :  
Relates :  
Description
the generic reflection methods return type GenericArrayType in cases when they
could simply return an array class - that is, the element type is not generic.
I think it would be preferable in that case for them to return the non-generic
type.

Comments
EVALUATION Suggested fix has been applied to JDK 7.
27-08-2008

SUGGESTED FIX --- a/src/share/classes/sun/reflect/generics/factory/CoreReflectionFactory.java +++ b/src/share/classes/sun/reflect/generics/factory/CoreReflectionFactory.java @@ -25,6 +25,7 @@ package sun.reflect.generics.factory; +import java.lang.reflect.Array; import java.lang.reflect.Constructor; import java.lang.reflect.GenericDeclaration; import java.lang.reflect.Method; @@ -118,7 +119,10 @@ } public Type makeArrayType(Type componentType){ - return GenericArrayTypeImpl.make(componentType); + if (componentType instanceof Class<?>) + return Array.newInstance((Class<?>) componentType, 0).getClass(); + else + return GenericArrayTypeImpl.make(componentType); } public Type makeByte(){return byte.class;}
13-06-2008

CONVERTED DATA BugTraq+ Release Management Values COMMIT TO FIX: dragon
14-06-2004

EVALUATION The suggested change would be preferable but not crucial for Tiger. ###@###.### 2004-05-19
19-05-2004