The change proposed in this PR improves the behavior of the JDK JNDI/LDAP provider when running in a virtual thread. Currently, when an LDAP operation is performed from a virtual thread context a pinned carrier thread is detected:
Thread[#29,ForkJoinPool-1-worker-1,5,CarrierThreads] java.naming/com.sun.jndi.ldap.Connection.read reply(Connection.java:444) <== monitors:1 java.naming/com.sun.jndi.ldap.LdapClient.ldapBind(LdapClient.java:369) <== monitors:1 java.naming/com.sun.jndi.ldap.LdapClient.authenticate(LdapClient.java:196) <== monitors:1 java.naming/com.sun.jndi.ldap.LdapCtx.connect(LdapCtx.java:2896) <== monitors:1 To fix that monitor usages are replaced with `j.u.c` locks. All synchronized blocks/methods have been replaced with locks even if it is only guarding memory access - the motivation behind such a decision was to avoid an analysis of scenarios where a mix of monitors and `j.u.c` locks is used. There are three types of mechanical changes done in this PR: 1. Classes with `synchronized` blocks or `synchronized` methods have been updated to include a new `ReentrantLock` field. These new fields are used to replace `synchronized` blocks/methods. 1. classes that use notify/wait on object monitor have been updated to use `ReentrantLock.Condition`s signal/await. 1. if one class `synchronized` on an instance of another class - the `ReentrantLock` added in item (1) was made a package-protected to give access to another class. With the proposed changes pinned carrier threads are no longer detected during execution of LDAP operations. Testing: `jdk-tier1` to `jdk-tier3`, other `jndi/ldap` regression and JCK naming tests show no failures. ------------- Commit messages: - revert incorrect changes in LdapCtx.addNamingListener, formatting and (c) updates - draft version Changes: https://git.openjdk.org/jdk/pull/15526/files Webrev: https://webrevs.openjdk.org/?repo=jdk&pr=15526&range=00 Issue: https://bugs.openjdk.org/browse/JDK-8277954 Stats: 970 lines in 11 files changed: 394 ins; 101 del; 475 mod Patch: https://git.openjdk.org/jdk/pull/15526.diff Fetch: git fetch https://git.openjdk.org/jdk.git pull/15526/head:pull/15526 PR: https://git.openjdk.org/jdk/pull/15526