# HG changeset patch # User dholmes # Date 1571106003 14400 # Node ID 97974e906efb771c72f9dfa25342b5107a9a57b4 # Parent 45a085445a8c9c7a4c0df52f884d30c1aa769029 8232182: RedefineNestmateAttr/TestNestmateAttr.java failes due to ObjectCollectedException Reviewed-by: phh, sspitsyn diff -r 45a085445a8c -r 97974e906efb test/jdk/com/sun/jdi/RedefineNestmateAttr/TestNestmateAttr.java --- a/test/jdk/com/sun/jdi/RedefineNestmateAttr/TestNestmateAttr.java Fri Oct 11 16:52:18 2019 +0800 +++ b/test/jdk/com/sun/jdi/RedefineNestmateAttr/TestNestmateAttr.java Mon Oct 14 22:20:03 2019 -0400 @@ -151,9 +151,13 @@ reference. */ class Target { + + static Class topLevelHostA; // Prevent unloading of the class + // We have to load all of the variants of the classes that we will // attempt to redefine. This requires some in-memory compilation // and use of additional classloaders. + public static void main(String[] args) throws Throwable { String origin = args[0]; System.out.println("Target: Testing original Host class from " + origin); @@ -178,7 +182,7 @@ String hostA = "public class " + name + " {}"; byte[] bytes = InMemoryJavaCompiler.compile(name, hostA); // And we have to load this into a new classloader - Class topLevelHostA = ByteCodeLoader.load(name, bytes); + topLevelHostA = ByteCodeLoader.load(name, bytes); // The loaded class has not been linked (as per ClassLoader.resolveClass) // and so will be filtered out by VirtualMachine.allClasses(). There are // a number of ways to force linking - this is the simplest.