mirror of https://github.com/apache/openjpa.git
OPENJPA-311
git-svn-id: https://svn.apache.org/repos/asf/openjpa/trunk@564688 13f79535-47bb-0310-9956-ffa450edef68
This commit is contained in:
parent
8ba0483bf7
commit
99ecf9564b
|
@ -50,12 +50,9 @@ public class GeneratedClasses {
|
||||||
if (l2 == null)
|
if (l2 == null)
|
||||||
return l1;
|
return l1;
|
||||||
|
|
||||||
for (ClassLoader p = (ClassLoader) AccessController.doPrivileged(
|
if(canLoad(l1, c2)) {
|
||||||
J2DoPrivHelper.getParentAction(l1)); p != null;
|
|
||||||
p = (ClassLoader) AccessController.doPrivileged(
|
|
||||||
J2DoPrivHelper.getParentAction(p)))
|
|
||||||
if (p == l2)
|
|
||||||
return l1;
|
return l1;
|
||||||
|
}
|
||||||
return l2;
|
return l2;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -74,4 +71,22 @@ public class GeneratedClasses {
|
||||||
throw new GeneralException(bc.getName()).setCause(t);
|
throw new GeneralException(bc.getName()).setCause(t);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Return true if the given loader will load the same version of a given
|
||||||
|
* class.
|
||||||
|
*
|
||||||
|
* @param loader Classloader to use.
|
||||||
|
* @param clazz Expected class.
|
||||||
|
* @return true if loader.load(clazz.getName()) == clazz. Otherwise false.
|
||||||
|
*/
|
||||||
|
private static boolean canLoad(ClassLoader loader, Class clazz) {
|
||||||
|
Class loaded = null;
|
||||||
|
try {
|
||||||
|
loaded = loader.loadClass(clazz.getName());
|
||||||
|
} catch (ClassNotFoundException e) {
|
||||||
|
// Rely on caller to handle return value = false.
|
||||||
|
}
|
||||||
|
return clazz == loaded;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue