Uploaded image for project: 'JDK'
  1. JDK
  2. JDK-4045951

java.beans.Introspector doesn't load classes from beanInfoSearchPath

XMLWordPrintable

    • b01
    • sparc
    • solaris_2.5
    • Not verified



        Name: mgC56079 Date: 04/18/97



        java.beans.Introspector.getBeanInfo(beanClass) doesn't load classes from beanInfoSearchPath
        if there is custom classloader for beanClass.

        The bug is seen from the Introspector source code (findInformant method):
        it checks classloader only while loading class from the same package (line 216).
        But it uses default classloader while loading class from the beanInfoSearchPath (line 234).
        It should use bean's classloader in this case either (the check similar to one in line 216
        should be added).

        ===== Here is the part of source code (Introspector.java v1.62) =====
        211 private BeanInfo findInformant(Class beanClass) {
        212 String name = beanClass.getName() + "BeanInfo";
        213 try {
        214 ClassLoader cl = beanClass.getClassLoader();
        215 Class informantClass = null;
        216 if (cl == null) {
        217 // System default class loader.
        218 informantClass = Class.forName(name);
        219 } else {
        220 // Class has a specific class loader.
        221 informantClass = cl.loadClass(name);
        222 }
        223 return (java.beans.BeanInfo)informantClass.newInstance();
        224 } catch (Exception ex) {
        225 // Just drop through
        226 }
        227 // Now try looking for <searchPath>.fooBeanInfo
        228 while (name.indexOf('.') > 0) {
        229 name = name.substring(name.indexOf('.')+1);
        230 }
        231 for (int i = 0; i < searchPath.length; i++) {
        232 try {
        233 String fullName = searchPath[i] + "." + name;
        234 Class informantClass = Class.forName(fullName);
        235 return (java.beans.BeanInfo)informantClass.newInstance();
        236 } catch (Exception ex) {
        237 // Silently ignore any errors.
        238 }
        239 }
        240 return null;
        241 }


        ======================================================================

              ghamiltosunw Graham Hamilton (Inactive)
              mgorshen Mikhail Gorshenev (Inactive)
              Votes:
              0 Vote for this issue
              Watchers:
              0 Start watching this issue

                Created:
                Updated:
                Resolved:
                Imported:
                Indexed: