RFR: 8284855: Update needed to Cleaners added to jdk.crypto.cryptoki [v4]

Roger Riggs rriggs at openjdk.java.net
Fri Apr 15 15:28:54 UTC 2022


On Fri, 15 Apr 2022 15:04:20 GMT, Xue-Lei Andrew Fan <xuelei at openjdk.org> wrote:

>> This is an effort to fix a problem introduced in the fix for [JDK-8284368](https://bugs.openjdk.java.net/browse/JDK-8284368), which replaced the finalizers in jdk.crypto.cryptoki with Cleaners.  However, there is a problem with the code changes. The Runnables registered with Cleaner refer to the object being registered ('this'). Meaning, the Cleaner mechanism will keep the objects reachable, preventing them from being cleaned and collected.
>
> Xue-Lei Andrew Fan has updated the pull request incrementally with one additional commit since the last revision:
> 
>   more update on replace lambda

src/jdk.crypto.cryptoki/share/classes/sun/security/pkcs11/wrapper/PKCS11.java line 117:

> 115: 
> 116:     // Note: Please don't update this field other than the constructor.
> 117:     // Otherwise, the native data is not able to be collected.

If it is only set in the constructor, it can be 'final".

src/jdk.crypto.cryptoki/share/classes/sun/security/pkcs11/wrapper/PKCS11.java line 235:

> 233:      * and any subsequent calls to C_ methods will fail. This method is for
> 234:      * internal use only.  Please don't use this method other than finalization.
> 235:      *

Perhaps refer to the code in which the cleanup occurs.

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

PR: https://git.openjdk.java.net/jdk/pull/8248



More information about the security-dev mailing list