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

Introspector finds incorrect BeanInfo Introspector finds incorrect BeanInfo

XMLWordPrintable

    • Icon: Bug Bug
    • Resolution: Duplicate
    • Icon: P3 P3
    • None
    • 1.4.0_01
    • client-libs
    • None
    • x86
    • windows_2000

      java version "1.4.0"
      Java(TM) 2 Runtime Environment, Standard Edition (build 1.4.0-b92)
      Java HotSpot(TM) Client VM (build 1.4.0-b92, mixed mode)
      Windows 2000 version 5.0 running on x86


      There is a clash between BeanInfos for two classes of the
      same name in different packages (namely java.awt.TextArea
      and org.apache.taglibs.input.TextArea) when placing the
      BeanInfo into yet another package (namely
      org.netbeans.modules.form.beaninfo.awt.TextAreaBeanInfo),
      specified in the BeanInfo seach path. This by itself it
      expected, since the way the JavaBeans spec is written,
      Introspector has no way to figure out whether
      TextAreaBeanInfo is BeanInfo for java.awt.TextArea or
      org.apache.taglibs.input.TextArea.

      However, if the BeanInfo specifies a BeanDescriptor:

          public BeanDescriptor getBeanDescriptor() {
      return new BeanDescriptor(java.awt.TextArea.class);
          }

      then Introspector can figure out that this BeanInfo is
      BeanInfo for java.awt.TextArea, and not for
      org.apache.taglibs.input.TextArea.

      The way it currently works, when looking for BeanInfo for
      org.apache.taglibs.input.TextArea, Introspector finds this
      class. The awkward thing is that

      Introspector.getBeanInfo
      (org.apache.taglibs.input.TextArea.class).getBeanDescriptor
      ().getBeanClass()

      returns java.awt.TextArea.class. I believe the correct
      behavior in the case that bi.getBeanDescriptor
      ().getBeanClass() returns non-null, should be that this
      beaninfo is only found for this one bean class, and not for
      other classes of the same name in different packages.


      To reproduce:
      1. Create two classes p1.Clazz and p2.Clazz with the same
      name in different packages

      2. Create a BeanInfo p3.ClazzBeanInfo which extends
      SimpleBeanInfo, and its getBeanDescriptor() method returns
      new BeanDescriptor(p1.Cl.class)

      3. Put package p3 into Introspector's BeanInfo search path

      4. Try

      BeanInfo bi = Introspector.getBeanInfo(p2.Clazz.class);

      Introspector will find p3.ClazzBeanInfo.

      5. Try

      Class c = bi.getBeanDescriptor().getBeanClass();

      The returned class will be p1.Clazz



      The following invariant should hold:

      Introspector.getBeanInfo(clazz).getBeanDescriptor
      ().getBeanClass()

      returns either null or clazz.

            mdavidsosunw Mark Davidson (Inactive)
            pjiricka Petr Jiřička
            Votes:
            0 Vote for this issue
            Watchers:
            0 Start watching this issue

              Created:
              Updated:
              Resolved:
              Imported:
              Indexed: