mirror of
https://github.com/openjdk/jdk.git
synced 2025-09-22 20:14:43 +02:00
8066497: Update c.o.j.t.ByteCodeLoader to be able really reload given class
Reviewed-by: drchase, fzhinkin, iignatyev
This commit is contained in:
parent
f70b5b2e9c
commit
583d750b3d
1 changed files with 16 additions and 0 deletions
|
@ -37,6 +37,7 @@ import java.security.SecureClassLoader;
|
||||||
public class ByteCodeLoader extends SecureClassLoader {
|
public class ByteCodeLoader extends SecureClassLoader {
|
||||||
private final String className;
|
private final String className;
|
||||||
private final byte[] byteCode;
|
private final byte[] byteCode;
|
||||||
|
private volatile Class<?> holder;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Creates a new {@code ByteCodeLoader} ready to load a class with the
|
* Creates a new {@code ByteCodeLoader} ready to load a class with the
|
||||||
|
@ -50,6 +51,21 @@ public class ByteCodeLoader extends SecureClassLoader {
|
||||||
this.byteCode = byteCode;
|
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
|
@Override
|
||||||
protected Class<?> findClass(String name) throws ClassNotFoundException {
|
protected Class<?> findClass(String name) throws ClassNotFoundException {
|
||||||
if (!name.equals(className)) {
|
if (!name.equals(className)) {
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue