mirror of
https://github.com/apache/openjpa.git
synced 2025-02-24 03:28:35 +00:00
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:
parent
65385662b0
commit
04bb066475
@ -79,8 +79,7 @@ public class InstrumentationFactory {
|
|||||||
* @return null if Instrumentation can not be obtained, or if any
|
* @return null if Instrumentation can not be obtained, or if any
|
||||||
* Exceptions are encountered.
|
* Exceptions are encountered.
|
||||||
*/
|
*/
|
||||||
public static synchronized Instrumentation
|
public static synchronized Instrumentation getInstrumentation(final Log log) {
|
||||||
getInstrumentation(final Log log) {
|
|
||||||
if (_inst != null || !_dynamicallyInstall)
|
if (_inst != null || !_dynamicallyInstall)
|
||||||
return _inst;
|
return _inst;
|
||||||
|
|
||||||
@ -90,6 +89,18 @@ public class InstrumentationFactory {
|
|||||||
|
|
||||||
AccessController.doPrivileged(new PrivilegedAction<Object>() {
|
AccessController.doPrivileged(new PrivilegedAction<Object>() {
|
||||||
public Object run() {
|
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.
|
// If we can't find the tools.jar, we can't load the agent.
|
||||||
File toolsJar = findToolsJar(log);
|
File toolsJar = findToolsJar(log);
|
||||||
if (toolsJar == null) {
|
if (toolsJar == null) {
|
||||||
|
Loading…
x
Reference in New Issue
Block a user