Skip to content

Commit

Permalink
Fix classloader issue
Browse files Browse the repository at this point in the history
  • Loading branch information
jim-krueger committed Oct 2, 2024
1 parent 4e457ea commit 486a4f2
Show file tree
Hide file tree
Showing 3 changed files with 54 additions and 31 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -208,25 +208,29 @@ protected Object createProxy() {
final SecurityManager sm = System.getSecurityManager();
if (sm == null) {
// liberty change - use this classloader
// clazzLoader = delegate == null ? rawType.getClassLoader() : delegate.getClass().getClassLoader();
clazzLoader = delegate == null ? rawType.getClassLoader() : delegate.getClass().getClassLoader();
// The class loader may be null for primitives, void or the type was loaded from the bootstrap class loader.
// In such cases we should use the TCCL.
//if (clazzLoader == null) {
// clazzLoader = Thread.currentThread().getContextClassLoader();
//}
clazzLoader = this.getClass().getClassLoader();
if (clazzLoader == null) {
clazzLoader = Thread.currentThread().getContextClassLoader();
}
if (clazzLoader == null) {
clazzLoader = this.getClass().getClassLoader();
}
} else {
clazzLoader = AccessController.doPrivileged(new PrivilegedAction<ClassLoader>() {
@Override
public ClassLoader run() {
//ClassLoader result = delegate == null ? rawType.getClassLoader() : delegate.getClass().getClassLoader();
ClassLoader result = delegate == null ? rawType.getClassLoader() : delegate.getClass().getClassLoader();
// The class loader may be null for primitives, void or the type was loaded from the bootstrap class loader.
// In such cases we should use the TCCL.
//if (result == null) {
//result = Thread.currentThread().getContextClassLoader();
//}
//return result;
return this.getClass().getClassLoader(); //liberty change
if (result == null) {
result = Thread.currentThread().getContextClassLoader();
}
if (result == null) {
result = this.getClass().getClassLoader(); //liberty change
}
return result;
}
});
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -208,25 +208,29 @@ protected Object createProxy() {
final SecurityManager sm = System.getSecurityManager();
if (sm == null) {
// liberty change - use this classloader
// clazzLoader = delegate == null ? rawType.getClassLoader() : delegate.getClass().getClassLoader();
clazzLoader = delegate == null ? rawType.getClassLoader() : delegate.getClass().getClassLoader();
// The class loader may be null for primitives, void or the type was loaded from the bootstrap class loader.
// In such cases we should use the TCCL.
//if (clazzLoader == null) {
// clazzLoader = Thread.currentThread().getContextClassLoader();
//}
clazzLoader = this.getClass().getClassLoader();
if (clazzLoader == null) {
clazzLoader = Thread.currentThread().getContextClassLoader();
}
if (clazzLoader == null) {
clazzLoader = this.getClass().getClassLoader();
}
} else {
clazzLoader = AccessController.doPrivileged(new PrivilegedAction<ClassLoader>() {
@Override
public ClassLoader run() {
//ClassLoader result = delegate == null ? rawType.getClassLoader() : delegate.getClass().getClassLoader();
ClassLoader result = delegate == null ? rawType.getClassLoader() : delegate.getClass().getClassLoader();
// The class loader may be null for primitives, void or the type was loaded from the bootstrap class loader.
// In such cases we should use the TCCL.
//if (result == null) {
//result = Thread.currentThread().getContextClassLoader();
//}
//return result;
return this.getClass().getClassLoader(); //liberty change
if (result == null) {
result = Thread.currentThread().getContextClassLoader();
}
if (result == null) {
result = this.getClass().getClassLoader(); //liberty change
}
return result;
}
});
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -225,16 +225,31 @@ protected Object createProxy()
final SecurityManager sm = System.getSecurityManager();
if (sm == null) {
// liberty change - use this classloader
//clazzLoader = delegate == null ? rawType.getClassLoader() : delegate.getClass().getClassLoader();
clazzLoader = this.getClass().getClassLoader();
clazzLoader = delegate == null ? rawType.getClassLoader() : delegate.getClass().getClassLoader();
// The class loader may be null for primitives, void or the type was loaded from the bootstrap class loader.
// In such cases we should use the TCCL.
if (clazzLoader == null) {
clazzLoader = Thread.currentThread().getContextClassLoader();
}
if (clazzLoader == null) {
clazzLoader = this.getClass().getClassLoader();
}
} else {
clazzLoader = AccessController.doPrivileged(new PrivilegedAction<ClassLoader>() {
@Override
public ClassLoader run() {
//return delegate == null ? rawType.getClassLoader() : delegate.getClass().getClassLoader();
return this.getClass().getClassLoader(); //liberty change
}
});
clazzLoader = AccessController.doPrivileged(new PrivilegedAction<ClassLoader>() {
@Override
public ClassLoader run() {
ClassLoader result = delegate == null ? rawType.getClassLoader() : delegate.getClass().getClassLoader();
// The class loader may be null for primitives, void or the type was loaded from the bootstrap class loader.
// In such cases we should use the TCCL.
if (result == null) {
result = Thread.currentThread().getContextClassLoader();
}
if (result == null) {
result = this.getClass().getClassLoader(); //liberty change
}
return result;
}
});
}
return Proxy.newProxyInstance(clazzLoader, intfs, new GenericDelegatingProxy());
}
Expand Down

0 comments on commit 486a4f2

Please sign in to comment.