JDK-8258801 : Deprecate -XX:+AlwaysLockClassLoader
  • Type: CSR
  • Component: hotspot
  • Sub-Component: runtime
  • Priority: P3
  • Status: Closed
  • Resolution: Approved
  • Fix Versions: 17
  • Submitted: 2020-12-21
  • Updated: 2020-12-22
  • Resolved: 2020-12-22
Related Reports
CSR :  
Description
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")                                            \
                                                                                 

Comments
Moving to Approved.
22-12-2020

Fixed a minor typo.
21-12-2020

My understanding of this flag is that it should just treat a parallel capable classloader as not being parallel capable, thus using the legacy locking scheme. However, unless the code of the ClassLoader is aware of the fact it is no longer treated as parallel capable (which it isn't!) this flag would seem to be potentially very error prone. As a temporary transition mechanism this flag seems not completely unreasonable, but that time has long passed and this flag should have been deprecated and removed many releases ago.
21-12-2020

[~mchung] I noticed this option in my code reading today. I'm not really sure about this. What do you think?
21-12-2020