diff options
author | Mark Wielaard <mark@klomp.org> | 2003-10-21 13:21:33 +0000 |
---|---|---|
committer | Michael Koch <mkoch@gcc.gnu.org> | 2003-10-21 13:21:33 +0000 |
commit | 63d8374488ca66d8349be60abe4659032a15125b (patch) | |
tree | 72dedae6e1c26f37d9435c4bb7cd31728552792e /libjava/java | |
parent | e62e96e2ae03a8aaf0dfb7b412bc20f687a5b399 (diff) | |
download | gcc-63d8374488ca66d8349be60abe4659032a15125b.zip gcc-63d8374488ca66d8349be60abe4659032a15125b.tar.gz gcc-63d8374488ca66d8349be60abe4659032a15125b.tar.bz2 |
Reported by M.Negovanovic
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.
From-SVN: r72749
Diffstat (limited to 'libjava/java')
-rw-r--r-- | libjava/java/beans/Introspector.java | 78 |
1 files changed, 46 insertions, 32 deletions
diff --git a/libjava/java/beans/Introspector.java b/libjava/java/beans/Introspector.java index ac9e367..b930b74 100644 --- a/libjava/java/beans/Introspector.java +++ b/libjava/java/beans/Introspector.java @@ -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; } + } |