8066497: Update c.o.j.t.ByteCodeLoader to be able really reload given class
Reviewed-by: drchase, fzhinkin, iignatyev
--- a/hotspot/test/testlibrary/com/oracle/java/testlibrary/ByteCodeLoader.java Fri Dec 26 14:33:23 2014 +0300
+++ b/hotspot/test/testlibrary/com/oracle/java/testlibrary/ByteCodeLoader.java Fri Dec 26 14:47:35 2014 +0300
@@ -37,6 +37,7 @@
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
@@ -51,6 +52,21 @@
}
@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)) {
throw new ClassNotFoundException(name);