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 Jul 22, 2024
1 parent 8e82f78 commit 44a3ae9
Show file tree
Hide file tree
Showing 3 changed files with 40 additions and 29 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -208,25 +208,25 @@ 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();
//}
if (clazzLoader == null) {
clazzLoader = Thread.currentThread().getContextClassLoader();
}
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();
}
return result;
//return this.getClass().getClassLoader(); //liberty change
}
});
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -208,25 +208,25 @@ 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();
//}
if (clazzLoader == null) {
clazzLoader = Thread.currentThread().getContextClassLoader();
}
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();
}
return result;
//return this.getClass().getClassLoader(); //liberty change
}
});
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -225,16 +225,27 @@ 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();
}
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();
}
return result;
//return this.getClass().getClassLoader(); //liberty change
}
});
}
return Proxy.newProxyInstance(clazzLoader, intfs, new GenericDelegatingProxy());
}
Expand Down

0 comments on commit 44a3ae9

Please sign in to comment.