-
Enhancement
-
Resolution: Won't Fix
-
P3
-
20
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 bugJDK-8295673 proposed to deprecate and remove this behavior since it is not specified in either the JVMS or JLS.
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
- relates to
-
JDK-8295673 Deprecate and disable legacy parallel class loading workaround for non-parallel-capable class loaders
- Resolved
-
JDK-8295278 Add parallel class loading tests
- Resolved
-
JDK-8298469 Obsolete legacy parallel class loading workaround for non-parallel-capable class loaders
- Resolved