Summary
-------
Deprecate -XX:+AlwaysLockClassLoader option.
Problem
-------
This option was added when parallel capable class loading was added in JDK 7 to help users debug their parallel capable class loaders that might have bugs. Allowing general access to this functionality can cause deadlocks, so this shouldn't be an option for users. Nor is is useful for debugging parallel capable class loaders, since it may only hide their bugs.
This option is untested (and should be because it'll cause deadlocks) and should be deprecated in 17, obsoleted in 18 and removed in 19.
Solution
--------
Deprecate in JDK 17, make obsolete in 18 and remove in 19.
Specification
-------------
diff --git a/src/hotspot/share/runtime/arguments.cpp b/src/hotspot/share/runtime/arguments.cpp
index 5b262f6..e0b1ee9 100644
--- a/src/hotspot/share/runtime/arguments.cpp
+++ b/src/hotspot/share/runtime/arguments.cpp
@@ -521,6 +521,7 @@ static SpecialFlag const special_jvm_flags[] = {
{ "AllowRedefinitionToAddDeleteMethods", JDK_Version::jdk(13), JDK_Version::undefined(), JDK_Version::undefined() },
{ "FlightRecorder", JDK_Version::jdk(13), JDK_Version::undefined(), JDK_Version::undefined() },
{ "CriticalJNINatives", JDK_Version::jdk(16), JDK_Version::jdk(17), JDK_Version::jdk(18) },
+ { "AlwaysLockClassLoader", JDK_Version::jdk(17), JDK_Version::jdk(18), JDK_Version::jdk(19) },
{ "UseBiasedLocking", JDK_Version::jdk(15), JDK_Version::jdk(18), JDK_Version::jdk(19) },
{ "BiasedLockingStartupDelay", JDK_Version::jdk(15), JDK_Version::jdk(18), JDK_Version::jdk(19) },
{ "PrintBiasedLockingStatistics", JDK_Version::jdk(15), JDK_Version::jdk(18), JDK_Version::jdk(19) },
diff --git a/src/hotspot/share/runtime/globals.hpp b/src/hotspot/share/runtime/globals.hpp
index 0dd3f53..dc752a1 100644
--- a/src/hotspot/share/runtime/globals.hpp
+++ b/src/hotspot/share/runtime/globals.hpp
@@ -711,7 +711,7 @@ const intx ObjectAlignmentInBytes = 8;
"Dynamically resize system dictionaries as needed") \
\
product(bool, AlwaysLockClassLoader, false, \
- "Require the VM to acquire the class loader lock before calling " \
+ "(Deprecated) Require the VM to acquire the class loader lock before calling " \
"loadClass() even for class loaders registering " \
"as parallel capable") \