JDK-6422403 : Bean introspection does not correctly calculate types of inherited properties
  • Type: Bug
  • Component: client-libs
  • Sub-Component: java.beans
  • Affected Version: 6,6u10,6u14,6u15
  • Priority: P3
  • Status: Closed
  • Resolution: Fixed
  • OS:
    generic,linux,windows_xp,windows_vista generic,linux,windows_xp,windows_vista
  • CPU: generic,x86
  • Submitted: 2006-05-05
  • Updated: 2011-07-26
  • 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 Availability Release.

To download the current JDK release, click here.
JDK 7
7 b15Fixed
Related Reports
Duplicate :  
Duplicate :  
Duplicate :  
Relates :  
Relates :  
Relates :  
Description
J2SE Version (please include all output from java -version flag):

  java version "1.6.0-beta2"
  Java(TM) SE Runtime Environment (build 1.6.0-beta2-b81)
  Java HotSpot(TM) Client VM (build 1.6.0-beta2-b81, mixed mode, sharing)

Does this problem occur on J2SE 1.4.x or 5.0.x ?  Yes / No (pick one)

  5 and 6

Bug Description:

  Bean introspection does not correctly calculate types of inherited properties that are typed as a 
  type parameter of a generic superclass.

Steps to Reproduce (be specific):


  Compile and run these files

Expected results
================
Bean Super
    Class class, R
    int count, RW
    Object reference, RW
Bean Sub2
    Class class, R
    int count, RW
    String reference, RW
Bean Sub
    Class class, R
    int count, RW
    Integer reference, RW

Actual results Mustang
======================
Bean Super
    Class class, R
    int count, RW
    Object reference, RW
Bean Sub2
    Class class, R
    int count, RW
    Object reference, RW
Bean Sub
    Class class, R
    int count, RW
    Object reference, RW


Impact
======

The incorrect typing normally has little impact because if you are using the introspector the 
methods are called reflectively, and you need to cast down to the correct type fromMethod.invoke()
anyway, so the error is not normally apparent. If you were using a gui tool to wire up beans, 
the tool could exhibit problems resulting from the incorrect types. YOu may also break type safety.

At work we are running 1.5.0_06 and Sub reported reference as Readonly,(presumably because the 
setter in Super was a different type. However I cannot reproduce this here at home on 1.5.0_03). 
That is how we first noticed it because JSF was reporting that our bean property was readonly and 
not letting us write to it. That occured on 2 different machines.

Comments
EVALUATION It is possible to fix it for beans that extend parametrized classes. For example, public class Abstract<T> { public T getProperty() {...} } public class Concrete extends Abstract<String> { // the property type is String }
06-06-2007

EVALUATION It is impossible to fix this bug because type information is not available at runtime. So the fix depends on the RFE 5098163.
15-05-2007

EVALUATION The following methods should be rewritten: PropertyDescriptor.findPropertyType(Method,Method) IndexedPropertyDescriptor.findIndexedPropertyType(Method,Method)
16-05-2006

EVALUATION Seems that JavaBeans implementation does not support Generics.
11-05-2006