----- Mail original ----- > De: "mandy chung" <mandy.ch...@oracle.com> > À: "Peter Levart" <peter.lev...@gmail.com>, "Xueming Shen" > <xueming.s...@oracle.com>, "core-libs-dev" > <core-libs-dev@openjdk.java.net> > Envoyé: Vendredi 29 Septembre 2017 22:34:52 > Objet: Re: RFR JDK-8185582, Update Zip implementation to use Cleaner, not > finalizers
> On 9/27/17 2:31 AM, Peter Levart wrote: >> >> Up to a point where 'this' is dereferenced to obtain the 'zsRef' value >> (line 261), the Deflater instance is reachable. But after that, even >> ensureOpen() may be inlined and 'this' is not needed any more. After >> that point, obtaining zsRef.address() and calling setDictionaly on the >> obtained address may be racing with Cleaner thread invoking >> ZStreamRef.run(): > What about making the native setDictionary method as an instance method > (currently it's a static method) so that this object remains strongly > reachable until the method returns? Mandy, unlike in C or C++, in Java a reference is garbage collected as soon as you do not need it anymore, so using an instance method will not change the issue here. one way to be sure that a referenced object is not garbage collected is to use http://docs.oracle.com/javase/9/docs/api/java/lang/ref/Reference.html#reachabilityFence-java.lang.Object- > > Mandy Rémi