JDK-6528714 : Introspector uses interface signature in property descriptor
  • Type: Bug
  • Component: client-libs
  • Sub-Component: java.beans
  • Affected Version: 6
  • Priority: P4
  • Status: Closed
  • Resolution: Fixed
  • OS: windows_xp
  • CPU: x86
  • Submitted: 2007-02-27
  • Updated: 2013-07-18
  • Resolved: 2011-03-08
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 Availabitlity Release.

To download the current JDK release, click here.
JDK 7
7 b15Fixed
Related Reports
Duplicate :  
Relates :  
Relates :  
Relates :  
Description
FULL PRODUCT VERSION :
java version "1.6.0"
Java(TM) SE Runtime Environment (build 1.6.0-b105)
Java HotSpot(TM) Client VM (build 1.6.0-b105, mixed mode, sharing)

ADDITIONAL OS VERSION INFORMATION :
Microsoft Windows XP [Version 5.1.2600]

A DESCRIPTION OF THE PROBLEM :
I have a generic interface that defines a getter method that uses the generic type.

When I Introspect a a class that implements this method, the Propertydescriptor for the method claims that the property type is Object when it should return the actual type declared in the class.



STEPS TO FOLLOW TO REPRODUCE THE PROBLEM :
Compile and run the test case:

javac NameBean.java
java NamedBean


EXPECTED VERSUS ACTUAL BEHAVIOR :
EXPECTED -
I expected to see:
Property class: class java.lang.Class
Property name: class java.lang.String

Which is what I get if I compile and run using :
java version "1.5.0_06"
Java(TM) 2 Runtime Environment, Standard Edition (build 1.5.0_06-b05)
Java HotSpot(TM) Client VM (build 1.5.0_06-b05, mixed mode, sharing)
ACTUAL -
What I get is:
Property class: class java.lang.Class
Property name: class java.lang.Object

I also get the same result when I run this with the latest build:
java version "1.6.0_01-ea"
Java(TM) SE Runtime Environment (build 1.6.0_01-ea-b03)
Java HotSpot(TM) Client VM (build 1.6.0_01-ea-b03, mixed mode)

REPRODUCIBILITY :
This bug can be reproduced always.

---------- BEGIN SOURCE ----------
Named.java:

public interface Named<T> {

  public T getName();

}

NamedBean.java:
import java.beans.*;

class NamedBean implements Named<String> {
  private String myName;

  public String getName() {
     return myName;
  }

  public void setName(String name) {
     myName = name;
  }

  public static void main(String[] args) throws Exception {
    BeanInfo bi = Introspector.getBeanInfo(NamedBean.class);
    for (PropertyDescriptor d: bi.getPropertyDescriptors()) {
      System.out.println("Property "+d.getName()+": "+d.getPropertyType());
    }
  }

}


---------- END SOURCE ----------

Comments
EVALUATION Java 5 allow to use narrow return types in subclasses. Special synthetic method is generated to support this feature. We should skip synthetic methods when determining the properties of the class.
2007-05-25