classpath-patches
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

[cp-patches] FYI: Introspector fixes


From: Robert Schuster
Subject: [cp-patches] FYI: Introspector fixes
Date: Thu, 28 Apr 2005 21:03:26 +0200
User-agent: Mozilla/5.0 (X11; U; Linux i686; de-AT; rv:1.7.7) Gecko/20050427

-----BEGIN PGP SIGNED MESSAGE-----
Hash: SHA1

Hi,
this fixes
https://savannah.gnu.org/bugs/index.php?func=detailitem&item_id=12624
and some related problems:

Introspector.flushCaches() now really flushes all intermediate data.

If explicit BeanDescriptors are given, they will be used directly
without making copies that (and this was another problem) forgot to copy
all the properties of BeanDescriptor's superclass FeatureDescriptor.

Mauve tests will come later. :)

ChangeLog:

2005-04-28  Robert Schuster  <address@hidden>

    * java/beans/Introspector: Fixed bug #12624, BeanDescriptors
    will now be set correctly.
    (flushCaches): Now flushes all cached intermediate data.

cu
Robert
-----BEGIN PGP SIGNATURE-----
Version: GnuPG v1.4.1 (GNU/Linux)
Comment: Using GnuPG with Mozilla - http://enigmail.mozdev.org

iD8DBQFCcTN+G9cfwmwwEtoRAqVoAJ9afFP3qyzmHB/E3kb9ceu8MwyFUgCfQPo7
ECFGGCkjpQDUn4FO1Za+Dso=
=YzcK
-----END PGP SIGNATURE-----
Index: java/beans/Introspector.java
===================================================================
RCS file: /cvsroot/classpath/classpath/java/beans/Introspector.java,v
retrieving revision 1.18
diff -u -r1.18 Introspector.java
--- java/beans/Introspector.java        30 Sep 2004 14:50:51 -0000      1.18
+++ java/beans/Introspector.java        28 Apr 2005 18:45:42 -0000
@@ -220,6 +220,12 @@
   public static void flushCaches()
   {
     beanInfoCache.clear();
+
+       // Clears all the intermediate ExplicitInfo instances which
+       // have been created.
+       // This makes sure we have to retrieve stuff like BeanDescriptors
+       // again. (Remember that FeatureDescriptor can be modified by the user.)
+       ExplicitInfo.flushCaches();
   }
 
   /**
@@ -252,8 +258,8 @@
   public static BeanInfo getBeanInfo(Class beanClass, Class stopClass) 
     throws IntrospectionException 
   {
-    ExplicitInfo explicit = new ExplicitInfo(beanClass,stopClass);
-    
+    ExplicitInfo explicit = new ExplicitInfo(beanClass, stopClass);
+
     IntrospectionIncubator ii = new IntrospectionIncubator();
     ii.setPropertyStopClass(explicit.propertyStopClass);
     ii.setEventStopClass(explicit.eventStopClass);
@@ -303,15 +309,17 @@
          }
       }
     
-    if(explicit.explicitBeanDescriptor != null) 
-      {
-       currentInfo.setBeanDescriptor(new 
BeanDescriptor(beanClass,explicit.explicitBeanDescriptor.getCustomizerClass()));
-      } 
-    else 
-      {
-       currentInfo.setBeanDescriptor(new BeanDescriptor(beanClass,null));
-      }
-    
+       // Sets the info's BeanDescriptor to the one we extracted from the
+       // explicit BeanInfo instance(s) if they contained one. Otherwise we
+       // create the BeanDescriptor from scratch.
+       // Note: We do not create a copy the retrieved BeanDescriptor which 
will allow
+       // the user to modify the instance while it is cached. However this is 
how
+       // the RI does it.
+       currentInfo.setBeanDescriptor(
+               (explicit.explicitBeanDescriptor == null ? 
+                       new BeanDescriptor(beanClass, null) :
+                       explicit.explicitBeanDescriptor));
+
     currentInfo.setAdditionalBeanInfo(explicit.explicitBeanInfo);
     currentInfo.setIcons(explicit.im);
     
@@ -388,7 +396,7 @@
        return null;
       }
   }
-  
+
   static BeanInfo copyBeanInfo(BeanInfo b) 
   {
     java.awt.Image[] icons = new java.awt.Image[4];
@@ -396,13 +404,15 @@
       {
        icons[i-1] = b.getIcon(i);
       }
+
     return new ExplicitBeanInfo(b.getBeanDescriptor(),
                                b.getAdditionalBeanInfo(),
                                b.getPropertyDescriptors(),
                                b.getDefaultPropertyIndex(),
                                b.getEventSetDescriptors(),
                                b.getDefaultEventIndex(),
-                               b.getMethodDescriptors(),icons);
+                               b.getMethodDescriptors(),
+                               icons);
   }
 }
 
@@ -423,22 +433,31 @@
   Class propertyStopClass;
   Class eventStopClass;
   Class methodStopClass;
-  
+
+  static Hashtable explicitBeanInfos = new Hashtable();
+  static Vector emptyBeanInfos = new Vector();
+
   ExplicitInfo(Class beanClass, Class stopClass) 
   {
     while(beanClass != null && !beanClass.equals(stopClass)) 
       {
+
        BeanInfo explicit = findExplicitBeanInfo(beanClass);
+       
+
        if(explicit != null) 
          {
+
            if(explicitBeanDescriptor == null) 
              {
                explicitBeanDescriptor = explicit.getBeanDescriptor();
              }
+
            if(explicitBeanInfo == null) 
              {
                explicitBeanInfo = explicit.getAdditionalBeanInfo();
              }
+
            if(explicitPropertyDescriptors == null) 
              {
                if(explicit.getPropertyDescriptors() != null) 
@@ -448,6 +467,7 @@
                    propertyStopClass = beanClass;
                  }
              }
+
            if(explicitEventSetDescriptors == null) 
              {
                if(explicit.getEventSetDescriptors() != null) 
@@ -457,6 +477,7 @@
                    eventStopClass = beanClass;
                  }
              }
+
            if(explicitMethodDescriptors == null) 
              {
                if(explicit.getMethodDescriptors() != null) 
@@ -465,6 +486,7 @@
                    methodStopClass = beanClass;
                  }
              }
+
            if(im[0] == null && im[1] == null 
               && im[2] == null && im[3] == null) 
              {
@@ -476,22 +498,30 @@
          }
        beanClass = beanClass.getSuperclass();
       }
+
     if(propertyStopClass == null) 
       {
        propertyStopClass = stopClass;
       }
+
     if(eventStopClass == null) 
       {
        eventStopClass = stopClass;
       }
+
     if(methodStopClass == null) 
       {
        methodStopClass = stopClass;
       }
   }
   
-  static Hashtable explicitBeanInfos = new Hashtable();
-  static Vector emptyBeanInfos = new Vector();
+  /** Throws away all cached data and makes sure we re-instantiate things
+    * like BeanDescriptors again.
+    */
+  static void flushCaches() {
+       explicitBeanInfos.clear();
+       emptyBeanInfos.clear();
+  }
   
   static BeanInfo findExplicitBeanInfo(Class beanClass) 
   {
@@ -539,9 +569,13 @@
                                     Introspector.beanInfoSearchPath[i] + "."
                                     + newName);
 
-           if (beanInfo != null)
+               // Returns the beanInfo if it exists and the described class 
matches
+               // the one we searched.
+           if (beanInfo != null && beanInfo.getBeanDescriptor() != null &&
+                       beanInfo.getBeanDescriptor().getBeanClass() == 
beanClass)
+
              return beanInfo;
-         } 
+         }
       }
 
     return beanInfo;

reply via email to

[Prev in Thread] Current Thread [Next in Thread]