JDK-5087240 : (reflect) Constructor.getGenericParameterTypes for nested class w/ generics fail
  • Type: Bug
  • Component: core-libs
  • Sub-Component: java.lang:reflect
  • Affected Version: 6
  • Priority: P3
  • Status: Open
  • Resolution: Unresolved
  • OS: windows_xp
  • CPU: x86
  • Submitted: 2004-08-16
  • Updated: 2017-06-29
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.
Other
tbd_majorUnresolved
Related Reports
Duplicate :  
Relates :  
Relates :  
Relates :  
Description
Name: js151677			Date: 08/16/2004


FULL PRODUCT VERSION :
build 1.5.0-beta2-b51

ADDITIONAL OS VERSION INFORMATION :
Windows XP

A DESCRIPTION OF THE PROBLEM :
Constructor.getGenericParameterTypes for a nested class fail with a parameterized type.
The number of parameters is wrong (The first is missing).

STEPS TO FOLLOW TO REPRODUCE THE PROBLEM :
See code

EXPECTED VERSUS ACTUAL BEHAVIOR :
EXPECTED -
ConstructorBugTest$Nested(ConstructorBugTest,java.util.List,long)
        class ConstructorBugTest class java.lang.Class
        java.util.List<java.lang.String> class sun.reflect.generics.reflectiveObjects.ParameterizedTypeImpl
        long class java.lang.Class

ACTUAL -
ConstructorBugTest$Nested(ConstructorBugTest,java.util.List,long)
        java.util.List<java.lang.String> class sun.reflect.generics.reflectiveObjects.ParameterizedTypeImpl
        long class java.lang.Class


REPRODUCIBILITY :
This bug can be reproduced always.

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

---------- END SOURCE ----------
(Incident Review ID: 297027) 
======================================================================

Comments
One the synthetic and synthesized information is available in the platform from JDK-8004729, it will be possible to better address this bug.
08-12-2012

CONVERTED DATA BugTraq+ Release Management Values COMMIT TO FIX: mustang
19-08-2004

EVALUATION The root cause of this problem is a difference between the Java vm and language views of a inner class constructor. At the vm level, there is a synthetic parameter prepended to the argument list so the enclosing object reference can be passed down. When generic information is present, that information correctly represents the source view of the constructor. However, the existing getParameterTypes method models the vm view of the constructor. The proper fix is having getGenericParameterTypes always model the source semantics even when generic information is not present. This should be addressed in a future release. ###@###.### 2004-08-18
18-08-2004