RFR: 8283660: Convert com/sun/jndi/ldap/AbstractLdapNamingEnumeration.java finalizer to Cleaner [v8]

Peter Levart plevart at openjdk.org
Sat Jul 30 11:47:13 UTC 2022


On Wed, 1 Jun 2022 21:40:43 GMT, Roger Riggs <rriggs at openjdk.org> wrote:

> I don't think there is any benefit to the `try{} finally {fence}`. The reachabilityFence has no executable code. Its only purpose is to keep the reference in scope alive.

...reachability fence has no code, but puting it into finally block makes the compiler see it on all possible exit paths from the try block (any possible exceptions, returns, etc.) so the argument 'this' is protected from being GC-ed until every possible code in try block is finished.

> Ditto, the try/finally is unnecessary.

I think it is necessary for reachability fence since try block has many exit paths and accesses state cleaned up by Cleaner. Memory fence OTOH is not needed.

> Ditto try/finally is unnecessary.

Perhaps, because there may be only one exit path. But style-wise it is still better to play safe for any possible future changes to this part of code. Memory fence is not needed though as explained above.

-------------

PR: https://git.openjdk.org/jdk/pull/8311


More information about the core-libs-dev mailing list