From d4aeb92024d8a07503126bffefa7f859e9209aed Mon Sep 17 00:00:00 2001 From: Calvin Cheung Date: Fri, 1 Nov 2024 05:26:52 +0000 Subject: [PATCH] convert remaining getSystemClassLoader().loadClass() to Class.forName() --- .../jvmti/redefineClasses/OldClassAndRedefineClassApp.java | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/test/hotspot/jtreg/runtime/cds/appcds/jvmti/redefineClasses/OldClassAndRedefineClassApp.java b/test/hotspot/jtreg/runtime/cds/appcds/jvmti/redefineClasses/OldClassAndRedefineClassApp.java index 7f12329aac5af..0fcf540853754 100644 --- a/test/hotspot/jtreg/runtime/cds/appcds/jvmti/redefineClasses/OldClassAndRedefineClassApp.java +++ b/test/hotspot/jtreg/runtime/cds/appcds/jvmti/redefineClasses/OldClassAndRedefineClassApp.java @@ -28,15 +28,16 @@ public class OldClassAndRedefineClassApp { public static void main(String args[]) throws Throwable { + ClassLoader appClassLoader = ClassLoader.getSystemClassLoader(); System.out.println("Main: loading OldSuper"); // Load an old class (version 49), but not linking it. - Class.forName("OldSuper", false, ClassLoader.getSystemClassLoader()); + Class.forName("OldSuper", false, appClassLoader); // Redefine a class unrelated to the above old class. Instrumentation instrumentation = InstrumentationRegisterClassFileTransformer.getInstrumentation(); System.out.println("INFO: instrumentation = " + instrumentation); - Class c = ClassLoader.getSystemClassLoader().loadClass("Hello"); + Class c = Class.forName("Hello", false, appClassLoader); byte[] bytes = c.getClassLoader().getResourceAsStream(c.getName().replace('.', '/') + ".class").readAllBytes(); instrumentation.redefineClasses(new ClassDefinition(c, bytes));