8066497: Update c.o.j.t.ByteCodeLoader to be able really reload given class

Reviewed-by: drchase, fzhinkin, iignatyev
This commit is contained in:
Pavel Chistyakov 2014-12-26 14:47:35 +03:00
parent f70b5b2e9c
commit 583d750b3d

View file

@ -37,6 +37,7 @@ import java.security.SecureClassLoader;
public class ByteCodeLoader extends SecureClassLoader {
private final String className;
private final byte[] byteCode;
private volatile Class<?> holder;
/**
* Creates a new {@code ByteCodeLoader} ready to load a class with the
@ -50,6 +51,21 @@ public class ByteCodeLoader extends SecureClassLoader {
this.byteCode = byteCode;
}
@Override
public Class<?> loadClass(String name) throws ClassNotFoundException {
if (!name.equals(className)) {
return super.loadClass(name);
}
if (holder == null) {
synchronized(this) {
if (holder == null) {
holder = findClass(name);
}
}
}
return holder;
}
@Override
protected Class<?> findClass(String name) throws ClassNotFoundException {
if (!name.equals(className)) {