2003-10-21 Mark Wielaard <mark@klomp.org>
authormkoch <mkoch@138bc75d-0d04-0410-961f-82ee72b054a4>
Tue, 21 Oct 2003 13:21:33 +0000 (13:21 +0000)
committermkoch <mkoch@138bc75d-0d04-0410-961f-82ee72b054a4>
Tue, 21 Oct 2003 13:21:33 +0000 (13:21 +0000)
Reported by M.Negovanovic
* java/beans/Introspector.java (getBeanInfo(ClassLoader, String)): New
method.
(reallyFindExplicitBeanInfo): Use new getBeanInfo() method.

git-svn-id: svn+ssh://gcc.gnu.org/svn/gcc/trunk@72749 138bc75d-0d04-0410-961f-82ee72b054a4

libjava/ChangeLog
libjava/java/beans/Introspector.java

index 4946230..67dc182 100644 (file)
@@ -1,3 +1,10 @@
+2003-10-21  Mark Wielaard  <mark@klomp.org>
+
+       Reported by M.Negovanovic
+       * java/beans/Introspector.java (getBeanInfo(ClassLoader, String)): New
+       method.
+       (reallyFindExplicitBeanInfo): Use new getBeanInfo() method.
+
 2003-10-21  Sascha Brawer  <brawer@dandelis.ch>
 
        Fix for Classpath bug #6076.
index ac9e367..b930b74 100644 (file)
@@ -1,5 +1,5 @@
 /* java.beans.Introspector
-   Copyright (C) 1998, 2002 Free Software Foundation, Inc.
+   Copyright (C) 1998, 2002, 2003 Free Software Foundation, Inc.
 
 This file is part of GNU Classpath.
 
@@ -518,40 +518,54 @@ class ExplicitInfo
   
   static BeanInfo reallyFindExplicitBeanInfo(Class beanClass) 
   {
-    try 
+    ClassLoader beanClassLoader = beanClass.getClassLoader();
+    BeanInfo beanInfo;
+
+    beanInfo = getBeanInfo(beanClassLoader, beanClass.getName() + "BeanInfo");
+    if (beanInfo == null)
       {
-      try 
-       {
-         return (BeanInfo)Class.forName(beanClass.getName()+"BeanInfo").newInstance();
-       } 
-      catch(ClassNotFoundException E) 
-       {
-       }
-      String newName = ClassHelper.getTruncatedClassName(beanClass) + "BeanInfo";
-      for(int i=0;i<Introspector.beanInfoSearchPath.length;i++) 
-       {
-         try 
-           {
-             if(Introspector.beanInfoSearchPath[i].equals("")) 
-               {
-                 return (BeanInfo)Class.forName(newName).newInstance();
-               } 
-             else 
-               {
-                 return (BeanInfo)Class.forName(Introspector.beanInfoSearchPath[i] + "." + newName).newInstance();
-               }
-           } 
-         catch(ClassNotFoundException E) 
-           {
-           }
-       }
-      } 
-    catch(IllegalAccessException E) 
+       String newName;
+       newName = ClassHelper.getTruncatedClassName(beanClass) + "BeanInfo";
+
+       for(int i = 0; i < Introspector.beanInfoSearchPath.length; i++) 
+         {
+           if (Introspector.beanInfoSearchPath[i].equals("")) 
+             beanInfo = getBeanInfo(beanClassLoader, newName);
+           else 
+             beanInfo = getBeanInfo(beanClassLoader,
+                                    Introspector.beanInfoSearchPath[i] + "."
+                                    + newName);
+
+           if (beanInfo != null)
+             return beanInfo;
+         } 
+      }
+
+    return beanInfo;
+  }
+
+  /**
+   * Returns an instance of the given class name when it can be loaded
+   * through the given class loader, or null otherwise.
+   */
+  private static BeanInfo getBeanInfo(ClassLoader cl, String infoName)
+  {
+    try
       {
-      } 
-    catch(InstantiationException E) 
+       return (BeanInfo) Class.forName(infoName, true, cl).newInstance();
+      }
+    catch (ClassNotFoundException cnfe)
       {
+       return null;
+      }
+    catch (IllegalAccessException iae)
+      {
+       return null;
+      }
+    catch (InstantiationException ie)
+      {
+       return null;
       }
-    return null;
   }
+  
 }