JDK-4168475 : beta4: Introspector doesn't let you override BeanInfo for core classes
  • Type: Bug
  • Component: client-libs
  • Sub-Component: java.beans
  • Affected Version: 1.2.0
  • Priority: P3
  • Status: Closed
  • Resolution: Fixed
  • OS: windows_nt
  • CPU: x86
  • Submitted: 1998-08-22
  • Updated: 1999-01-15
  • Resolved: 1999-01-15
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
1.2.0 1.2fcsFixed
Related Reports
Relates :  
Description
In JDK 1.2 beta4, it is not possible for a user to provide BeanInfo for
any of the core classes.  I have reported this as a bug using the bug
submission form, but I thought I would mail you about it as well, as I
very much hope that it will be fixed as soon as possible. The details of the
problem are as follows:

I would like to provide a BeanInfo for a core class, lets say
java.awt.Component, for example.  So I write a
my.beans.infos.ComponentBeanInfo class, and use the
Introspector.setBeanInfoSearchPath() method to put my.beans.infos on
the search path.  Example source code for this is provided below.  This
all works OK under 1.2beta3 and earlier, but under 1.2beta4 the
Introspector fails to find my BeanInfo. It does work if you use the
1.2Beta4 oldjava program. I believe the problem is due to the changes
in class loading in 1.2Beta4. What happens is that the Introspector
tries to get a classloader by using the getClassLoader() method, but
for the java.awt.Component class this returns null, because
java.awt.Component is a bootstrap class. Therefore the Introspector
uses Class.forName("my.beans.infos.ComponentBeanInfo") instead. This
fails because Class.forName() uses the  classloader of the class it is
called from, and java.beans.Introspector is a bootstrap class, and the
bootstrap classloader fails because my.beans.infos.ComponentBeanInfo is
not a bootstrap class.

Note that a similar problem occurs with property editors and the
PropertyEditorManager.

Here is some source code that shows the problem:

BeanInfoCheck.java:
import java.beans.*;

public class BeanInfoCheck {

    public static void main(String[] args) throws Exception {
        String[] beanInfoPath = {"my.beans.infos"};
        Introspector.setBeanInfoSearchPath(beanInfoPath);
        BeanInfo bi = Introspector.getBeanInfo(java.awt.Component.class);
        PropertyDescriptor[] pds = bi.getPropertyDescriptors();
        for (int j = 0; j < pds.length; j++) {
            System.out.println(pds[j].getName());
        }
    }

}

my.beans.infos.ComponentBeanInfo.java:
package my.beans.infos;

import java.beans.*;

public class ComponentBeanInfo extends SimpleBeanInfo {

    public PropertyDescriptor[] getPropertyDescriptors() {
        try {
            PropertyDescriptor name =
                new PropertyDescriptor("name", java.awt.Component.class);
            PropertyDescriptor[] rv = {name};
            return rv;
        } catch (IntrospectionException e) {
            throw new Error(e.toString());
        }
    }
}

Instructions:
Run "java BeanInfoCheck". It should just print out "name", but in fact
it prints out all the properties. It works correctly with oldjave or
previous JDKs.

[This came in on the java.beans alias]

graham.hamilton@Eng 1998-08-22

Comments
CONVERTED DATA BugTraq+ Release Management Values COMMIT TO FIX: generic FIXED IN: 1.2fcs INTEGRATED IN: 1.2fcs
14-06-2004

EVALUATION Yep, this is yet another side-effect of the classloader changes in beta4. We need to change Introspector.instantiate to also check the "system" class loader, similarly to what beans.instantiate already does. graham.hamilton@Eng 1998-08-22
22-08-1998