Merge in a fix from the tck-jaxp-1_2_0 branch:

Under some JDK's (notably both Sun and IBM 1.4.0), getClassLoader(), when invoked
on the JAXP or SAX classes, it returns null.  This means that
the fallback mechanism in these APIs may not work correctly:  in
particular, when an attempt to invoke an unknown Parser/XMLReader
implementation is made in SAX, a NullPointerException rather than the correct
ClassNotFoundException results.  This patch fixes this problem,
by using Class.forName() in the event that the bootstrap
classloader is not returned in this particular situation.


git-svn-id: https://svn.apache.org/repos/asf/xml/commons/trunk@226239 13f79535-47bb-0310-9956-ffa450edef68
This commit is contained in:
mrglavas 2005-06-17 19:50:14 +00:00
parent ea4dcf269c
commit 01c6c51764
2 changed files with 12 additions and 2 deletions

View File

@ -105,7 +105,12 @@ class FactoryFinder {
if (doFallback) { if (doFallback) {
// Fall back to current classloader // Fall back to current classloader
cl = FactoryFinder.class.getClassLoader(); cl = FactoryFinder.class.getClassLoader();
providerClass = cl.loadClass(className); if (cl != null) {
providerClass = cl.loadClass(className);
}
else {
providerClass = Class.forName(className);
}
} else { } else {
throw x; throw x;
} }

View File

@ -105,7 +105,12 @@ class FactoryFinder {
if (doFallback) { if (doFallback) {
// Fall back to current classloader // Fall back to current classloader
cl = FactoryFinder.class.getClassLoader(); cl = FactoryFinder.class.getClassLoader();
providerClass = cl.loadClass(className); if (cl != null) {
providerClass = cl.loadClass(className);
}
else {
providerClass = Class.forName(className);
}
} else { } else {
throw x; throw x;
} }