RFR: 8283660: Convert com/sun/jndi/ldap/AbstractLdapNamingEnumeration.java finalizer to Cleaner [v16]
Peter Levart
plevart at openjdk.org
Mon Aug 1 07:09:23 UTC 2022
On Fri, 22 Jul 2022 20:51:59 GMT, Brent Christian <bchristi at openjdk.org> wrote:
>> Please review this change to replace the finalizer in `AbstractLdapNamingEnumeration` with a Cleaner.
>>
>> The pieces of state required for cleanup (`LdapCtx homeCtx`, `LdapResult res`, and `LdapClient enumClnt`) are moved to a static inner class . From there, the change is fairly mechanical.
>>
>> Details of note:
>> 1. Some operations need to change the state values (the update() method is probably the most interesting).
>> 2. Subclasses need to access `homeCtx`; I added a `homeCtx()` method to read `homeCtx` from the superclass's `state`.
>>
>> The test case is based on a copy of `com/sun/jndi/ldap/blits/AddTests/AddNewEntry.java`. A more minimal test case might be possible, but this was done for expediency.
>>
>> The test only confirms that the new Cleaner use does not keep the object reachable. It only tests `LdapSearchEnumeration` (not `LdapNamingEnumeration` or `LdapBindingEnumeration`, though all are subclasses of `AbstractLdapNamingEnumeration`).
>>
>> Thanks.
>
> Brent Christian has updated the pull request incrementally with one additional commit since the last revision:
>
> remove some more tabs
...while waiting for a GC expert to confirm that writes, in program order preceding a call to reachability fence, are visibile to GC thread that discovers a phantom reachable referent, here is an example which illustrates that some writes at least "must" be visible for GC to function properly:
var ar = new Object[1];
var e = new Object();
ar[0] = e;
Reference.reachabilityFence(e);
// GC kicks-in at this point
var e2 = ar[0];
// use e2
A write to an array slot ar[0] must be visible to a GC thread when it searches for root(s) after the mutator thread's call to reachability fence. If it was not, it could miss that fact that object 'e' is still reachable. So GC must do something so that at least writes to reference variables are visible. If it does not distinguish reference writes from primitive writes, then it does the same for all writes.
-------------
PR: https://git.openjdk.org/jdk/pull/8311
More information about the core-libs-dev
mailing list