8374052: Use java/util/Calendar in ReplaceCriticalClasses.java test

Reviewed-by: iklam
This commit is contained in:
Coleen Phillimore 2025-12-19 17:45:14 +00:00
parent 821e9ff965
commit 23fc21a3e2

View File

@ -98,8 +98,7 @@ public class ReplaceCriticalClasses {
// Replace classes that are loaded after JVMTI_PHASE_PRIMORDIAL. It's OK to replace
// such
// classes even when CDS is enabled. Nothing bad should happen.
"-notshared java/util/Locale",
"-notshared sun/util/locale/BaseLocale",
"-notshared java/util/Calendar",
};
return tests;
}
@ -149,8 +148,8 @@ public class ReplaceCriticalClasses {
Class.forName(klassName.replace("/", ".")); // make sure it's a valid class
final String subgraphInit = "initialize_from_archived_subgraph " + subgraphKlass;
// We will pass an option like "-agentlib:SimpleClassFileLoadHook=java/util/Locale,XXX,XXX".
// The SimpleClassFileLoadHook agent would attempt to hook the java/util/Locale class
// We will pass an option like "-agentlib:SimpleClassFileLoadHook=java/util/Calendar,XXX,XXX".
// The SimpleClassFileLoadHook agent would attempt to hook the java/util/Calendar class
// but leave the class file bytes unchanged (it replaces all bytes "XXX" with "XXX", i.e.,
// a no-op). JVMTI doesn't check the class file bytes returned by the agent, so as long
// as the agent returns a buffer, it will not load the class from CDS, and will instead
@ -158,7 +157,7 @@ public class ReplaceCriticalClasses {
//
// Note that for safety we don't change the contents of the class file bytes. If in the
// future JVMTI starts checking the contents of the class file bytes, this test would need
// to be updated. (You'd see the test case with java/util/Locale staring to fail).
// to be updated. (You'd see the test case with java/util/Calendar staring to fail).
String agent = "-agentlib:SimpleClassFileLoadHook=" + early + klassName + ",XXX,XXX";
CDSOptions opts = (new CDSOptions())