RFR JDK-8185582, Update Zip implementation to use Cleaner, not finalizers
forax at univ-mlv.fr
forax at univ-mlv.fr
Fri Sep 29 21:03:56 UTC 2017
> De: "Peter Levart" <peter.levart at gmail.com>
> À: "Remi Forax" <forax at univ-mlv.fr>, "mandy chung" <mandy.chung at oracle.com>
> Cc: "Xueming Shen" <xueming.shen at oracle.com>, "core-libs-dev"
> <core-libs-dev at openjdk.java.net>
> Envoyé: Vendredi 29 Septembre 2017 22:56:26
> Objet: Re: RFR JDK-8185582, Update Zip implementation to use Cleaner, not
> Hi Remi,
> On 09/29/17 22:49, Remi Forax wrote:
>> ----- Mail original -----
>>> De: "mandy chung" [ mailto:mandy.chung at oracle.com | <mandy.chung at oracle.com> ]
>>> À: "Peter Levart" [ mailto:peter.levart at gmail.com | <peter.levart at gmail.com> ]
>>> , "Xueming Shen" [ mailto:xueming.shen at oracle.com | <xueming.shen at oracle.com> ]
>>> , "core-libs-dev" [ mailto:core-libs-dev at openjdk.java.net |
>>> <core-libs-dev at openjdk.java.net> ] Envoyé: Vendredi 29 Septembre 2017 22:34:52
>>> Objet: Re: RFR JDK-8185582, Update Zip implementation to use Cleaner, not
>>> 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
>>> 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?
>> 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.
> I might be wrong, but native instance method is an exception. It can't be
> inlined. The preparation for native method invocation makes sure 'this' is kept
> reachable because it can be dereferenced from the native code then and native
> code is out-of-bounds for JIT optimization.
I do not think that you are wrong now but this is a property (a side effect) of the current implementation, Panama and Metropolis may change that.
I think it's better to keep the reference available with a reachability fence.
> Regards, Peter
>> one way to be sure that a referenced object is not garbage collected is to use [
>> ] -
More information about the core-libs-dev