OPENJPA-1410 Disable loading of dynamic enhancement agent if OpenJPA is not loaded with the system classloader.

git-svn-id: https://svn.apache.org/repos/asf/openjpa/trunk@924395 13f79535-47bb-0310-9956-ffa450edef68
This commit is contained in:
Jeremy Bauer 2010-03-17 17:58:40 +00:00
parent 65385662b0
commit 04bb066475

View File

@ -79,8 +79,7 @@ public class InstrumentationFactory {
* @return null if Instrumentation can not be obtained, or if any
* Exceptions are encountered.
*/
public static synchronized Instrumentation
getInstrumentation(final Log log) {
public static synchronized Instrumentation getInstrumentation(final Log log) {
if (_inst != null || !_dynamicallyInstall)
return _inst;
@ -90,6 +89,18 @@ public class InstrumentationFactory {
AccessController.doPrivileged(new PrivilegedAction<Object>() {
public Object run() {
// Dynamic agent enhancement should only occur when the OpenJPA library is
// loaded using the system class loader. Otherwise, the OpenJPA
// library may get loaded by separate, disjunct loaders, leading to linkage issues.
try {
if (!InstrumentationFactory.class.getClassLoader().equals(
ClassLoader.getSystemClassLoader())) {
return null;
}
} catch (Throwable t) {
return null;
}
// If we can't find the tools.jar, we can't load the agent.
File toolsJar = findToolsJar(log);
if (toolsJar == null) {