Commit 63d83744 by Mark Wielaard Committed by Michael Koch

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
parent e62e96e2
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> 2003-10-21 Sascha Brawer <brawer@dandelis.ch>
Fix for Classpath bug #6076. Fix for Classpath bug #6076.
......
/* java.beans.Introspector /* 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. This file is part of GNU Classpath.
...@@ -518,40 +518,54 @@ class ExplicitInfo ...@@ -518,40 +518,54 @@ class ExplicitInfo
static BeanInfo reallyFindExplicitBeanInfo(Class beanClass) static BeanInfo reallyFindExplicitBeanInfo(Class beanClass)
{ {
try ClassLoader beanClassLoader = beanClass.getClassLoader();
BeanInfo beanInfo;
beanInfo = getBeanInfo(beanClassLoader, beanClass.getName() + "BeanInfo");
if (beanInfo == null)
{ {
try String newName;
newName = ClassHelper.getTruncatedClassName(beanClass) + "BeanInfo";
for(int i = 0; i < Introspector.beanInfoSearchPath.length; i++)
{ {
return (BeanInfo)Class.forName(beanClass.getName()+"BeanInfo").newInstance(); if (Introspector.beanInfoSearchPath[i].equals(""))
beanInfo = getBeanInfo(beanClassLoader, newName);
else
beanInfo = getBeanInfo(beanClassLoader,
Introspector.beanInfoSearchPath[i] + "."
+ newName);
if (beanInfo != null)
return beanInfo;
} }
catch(ClassNotFoundException E)
{
} }
String newName = ClassHelper.getTruncatedClassName(beanClass) + "BeanInfo";
for(int i=0;i<Introspector.beanInfoSearchPath.length;i++) 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 try
{ {
if(Introspector.beanInfoSearchPath[i].equals("")) return (BeanInfo) Class.forName(infoName, true, cl).newInstance();
{
return (BeanInfo)Class.forName(newName).newInstance();
}
else
{
return (BeanInfo)Class.forName(Introspector.beanInfoSearchPath[i] + "." + newName).newInstance();
}
} }
catch(ClassNotFoundException E) catch (ClassNotFoundException cnfe)
{ {
return null;
} }
} catch (IllegalAccessException iae)
}
catch(IllegalAccessException E)
{ {
return null;
} }
catch(InstantiationException E) catch (InstantiationException ie)
{ {
}
return null; return null;
} }
}
} }
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment