United StatesChange Country, Oracle Worldwide Web Sites Communities I am a... I want to...
Bug ID: JDK-6422403 Bean introspection does not correctly calculate types of inherited properties
JDK-6422403 : Bean introspection does not correctly calculate types of inherited properties

Details
Type:
Bug
Submit Date:
2006-05-05
Status:
Closed
Updated Date:
2011-07-26
Project Name:
JDK
Resolved Date:
2011-03-08
Component:
client-libs
OS:
windows_vista,linux,generic,windows_xp
Sub-Component:
java.beans
CPU:
x86,generic
Priority:
P3
Resolution:
Fixed
Affected Versions:
6,6u10,6u14,6u15
Fixed Versions:

Related Reports
Duplicate:
Duplicate:
Duplicate:
Relates:
Relates:
Relates:

Sub Tasks

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

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

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

It is impossible to fix this bug because
type information is not available at runtime.
So the fix depends on the RFE 5098163.
                                     
2007-05-15
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
    }
                                     
2007-06-06



Hardware and Software, Engineered to Work Together