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

Implement special unlocked parallel class loading handling in Java

XMLWordPrintable

    • Icon: Enhancement Enhancement
    • Resolution: Won't Fix
    • Icon: P3 P3
    • tbd
    • 20
    • hotspot

      There is special case class loading code in the JVM that detects whether another thread is loading a class from a non-parallel capable class loader and waits for that thread to complete. This is a long-standing behavior in the JVM to handle older class loading code that releases the ClassLoader object lock while loading. The result of this behavior is that unlocked class loading does not get a LinkageError: duplicate class definition.

      This code is implemented in the SystemDictionary double_lock_wait function and surrounding code, and uses internal information about object monitors to release the class loader lock in order to make the second thread wait for the first. This code can be moved to Java which can then simply wait on the lock with normal Object.wait call.

      The proposal is to move this wait to Java and have the JVM class loader call out to that function which will detect the class loading already in progress, and synchronize loading that class to not get LinkageError.

      Moving this to Java allows us to remove the code that notifies and reenters the class loader lock using details from our internal implementation.

      The linked bug JDK-8295673 proposed to deprecate and remove this behavior since it is not specified in either the JVMS or JLS.

            coleenp Coleen Phillimore
            coleenp Coleen Phillimore
            Votes:
            0 Vote for this issue
            Watchers:
            4 Start watching this issue

              Created:
              Updated:
              Resolved: