Uploaded image for project: 'JDK'
  1. JDK
  2. JDK-8258801

Deprecate -XX:+AlwaysLockClassLoader

XMLWordPrintable

    • Icon: CSR CSR
    • Resolution: Approved
    • Icon: P3 P3
    • 17
    • hotspot
    • None
    • behavioral
    • low
    • Hide
      I ran into a bug with OpenJPA (?) in my google searching:
      https://issues.apache.org/jira/browse/OPENJPA-2399

      The error was a duplicate class definition because of their broken parallel capable class loader. Why don't they just not make it a parallel capable class loader?

      We also have this option documented for general troubleshooting in:
      https://docs.oracle.com/javase/7/docs/technotes/guides/lang/cl-mt.html
      which seems a bit broadly suggested.

      If I'm reading the code right, using this option can also cause deadlocks in our application class loader so troubleshooting may encounter unexpected deadlocks. This option seems like not a good idea.
      Show
      I ran into a bug with OpenJPA (?) in my google searching: https://issues.apache.org/jira/browse/OPENJPA-2399 The error was a duplicate class definition because of their broken parallel capable class loader. Why don't they just not make it a parallel capable class loader? We also have this option documented for general troubleshooting in: https://docs.oracle.com/javase/7/docs/technotes/guides/lang/cl-mt.html which seems a bit broadly suggested. If I'm reading the code right, using this option can also cause deadlocks in our application class loader so troubleshooting may encounter unexpected deadlocks. This option seems like not a good idea.
    • add/remove/modify command line option
    • Implementation

      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")                                            \

            coleenp Coleen Phillimore
            coleenp Coleen Phillimore
            David Holmes
            Votes:
            0 Vote for this issue
            Watchers:
            5 Start watching this issue

              Created:
              Updated:
              Resolved: