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
This commit is contained in:
Mark Wielaard 2003-10-21 13:21:33 +00:00 committed by Michael Koch
parent e62e96e2ae
commit 63d8374488
2 changed files with 55 additions and 34 deletions

View 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.

View 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
{
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)
{
}
catch(InstantiationException E)
ClassLoader beanClassLoader = beanClass.getClassLoader();
BeanInfo beanInfo;
beanInfo = getBeanInfo(beanClassLoader, beanClass.getName() + "BeanInfo");
if (beanInfo == null)
{
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 null;
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
{
return (BeanInfo) Class.forName(infoName, true, cl).newInstance();
}
catch (ClassNotFoundException cnfe)
{
return null;
}
catch (IllegalAccessException iae)
{
return null;
}
catch (InstantiationException ie)
{
return null;
}
}
}