JDK-4984912 : REGRESSION: Introspector loses PropertyDescriptors with no get- and set-Methods
  • Type: Bug
  • Component: client-libs
  • Sub-Component: java.beans
  • Affected Version: 1.4.0,1.4.2
  • Priority: P4
  • Status: Resolved
  • Resolution: Fixed
  • OS: generic,windows_xp
  • CPU: generic,x86
  • Submitted: 2004-01-28
  • Updated: 2006-04-13
  • Resolved: 2006-03-30
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 6
6 b78Fixed
Related Reports
Relates :  
Description
Name: gm110360			Date: 01/28/2004


FULL PRODUCT VERSION :
java version "1.4.1"
Java(TM) 2 Runtime Environment, Standard Edition (build 1.4.1-b21)
Java HotSpot(TM) Client VM (build 1.4.1-b21, mixed mode)

FULL OS VERSION :
Microsoft Windows XP [Version 5.1.2600]

A DESCRIPTION OF THE PROBLEM :
I wrote a BeanInfo class that returns one PropertyDesctiptor that has no get method and no set method. When I do a Introspector.getBeanInfo, I receive all PropertyDesctiptors except this one.

Since that has worked in JDK131, I compared both sourcefiles of Introspector.java, and I found in 141 a new private Method 'processPropertyDescriptors' which I think is the reason.

see my comment in the source code

REPRODUCIBILITY :
This bug can be reproduced always.

---------- BEGIN SOURCE ----------
import java.beans.*;

public class IntrospectorBug
{
    public static void main(String[] args)
    {
        try
        {
            BeanInfo bi = Introspector.getBeanInfo(IntrospectorBug.class);
            PropertyDescriptor[] pd = bi.getPropertyDescriptors();
            //pd should now contain all of my PropertyDescriptors, 'f' and 'x', but in fact it only contains 'f'.
            for (int i=0; i<pd.length; i++)
            {
                String n = pd[i].getName();
                System.out.println(n);
            }
        }
        catch (Exception e)
        {
            e.printStackTrace();
            System.exit(1);
        }
        System.exit(0);
    }

    private int f=0;
    public void setF(int P_f) { f = P_f; }
    public int getF() { return f; }
}

public class IntrospectorBugBeanInfo extends SimpleBeanInfo
{
    public PropertyDescriptor[] getPropertyDescriptors()
    {
        try
        {
            PropertyDescriptor fDes = new PropertyDescriptor("f", IntrospectorBug.class, "getF", "setF");
            PropertyDescriptor xDes = new PropertyDescriptor("x", IntrospectorBug.class, null, null);
            xDes.setValue("name", "value");
            return new PropertyDescriptor[] {fDes, xDes};
        }
        catch (IntrospectionException e)
        {
            e.printStackTrace();
            return null;
        }
    }
}

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

Release Regression From : 1.3.1
The above release value was the last known release where this 
bug was known to work. Since then there has been a regression.

(Incident Review ID: 182196) 
======================================================================

Comments
EVALUATION I think this feature is very useful for different modelling tools like Together Control Center. So we should fix this regression bug as soon as possible.
27-02-2006

EVALUATION I'm not sure what it means to have a PropertyDescriptor that describes a property that doesn't have read or write methods. It seems nonsensical to me and the Beans sepcification doesn't handle this situation. The specification of the PropertyDescriptor constuctor allows for a null setter or getter but doesn't take into accont that both may be null. Introspector.processPropertyDescriptors only considers PDs that have read or write methods. ###@###.### 2004-02-02 This is reproducible since 1.4, when processPropertyDescriptors() was added. ###@###.### 2004-02-19
02-02-2004