RFR JDK-8185582, Update Zip implementation to use Cleaner, not finalizers

Peter Levart peter.levart at gmail.com
Fri Sep 29 21:38:22 UTC 2017



On 09/29/17 23:23, Remi Forax wrote:
> ----- Mail original -----
>> De: "Peter Levart" <peter.levart at gmail.com>
>> À: "Roger Riggs" <Roger.Riggs at Oracle.com>, "core-libs-dev" <core-libs-dev at openjdk.java.net>
>> Envoyé: Vendredi 29 Septembre 2017 23:14:33
>> Objet: Re: RFR JDK-8185582, Update Zip implementation to use Cleaner, not finalizers
>> On 09/29/17 23:11, Peter Levart wrote:
>>> Hi Roger,
>>>
>>> On 09/29/17 22:55, Roger Riggs wrote:
>>>> fyi,
>>>>
>>>> The proposed[1]  changes to FileInputStream and FileOutputStream
>>>> remove the finalize method
>>>> exposing Object.finalize (throws Throwable) to subclasses.  We may
>>>> need retain
>>>> the finalize methods (with empty bodies) to mitigate source
>>>> compatibility.
>>> The problem is that empty finalize() method that throws anything other
>>> than Throwable will not compile.
>> Correction - it will compile (I was thinking about a method calling just
>> super.finalize() which is not empty, of course). Yes, this is the
>> solution to source compatibility.
>>
> Overriding finalize() will make the object not to be GCed as soon as it should.

I think the hotspot has an optimization and detects that finalize() has 
no bytecodes and treats the object as not needing finalization.

Regards, Peter

>>> Regards, Peter
>>>
> Rémi
>
>>>> Roger
>>>>
>>>>
>>>> [1]
>>>> http://mail.openjdk.java.net/pipermail/core-libs-dev/2017-September/049351.html
>>>>
>>>> On 9/29/2017 4:49 PM, Xueming Shen wrote:
>>>>> On 9/29/17, 1:18 PM, Peter Levart wrote:
>>>>>> Hi Sherman,
>>>>>>
>>>>>> I looked into ZipFile as promised.
>>>>>>
>>>>>> One thing I noticed is that FinalizeZipFile.java test fails
>>>>>> compilation:
>>>>>>
>>>>>> test/jdk/java/util/zip/ZipFile/FinalizeZipFile.java:49: error:
>>>>>> unreported exception Throwable; must be caught or declared to be
>>>>>> thrown
>>>>>>               super.finalize();
>>>>>>                             ^
>>>>>> (the overridden finalize() in InstrumentedZipFile should now
>>>>>> declare throws Throwable, since it overrides Object.finalize() and
>>>>>> not ZipFile.finalize() which is gone).
>>>>>>
>>>>>>
>>>>> Yes, it's the expected source incompatibility issue specified in the
>>>>> CSR request.
>>>>> I think I had it changed somewhere but obviously it's not in the
>>>>> webrev. Thanks
>>>>> for catching it. Yes, the test needs to update to be catch the
>>>>> throwable.
>>>>>
>>>>> Will return to the other comments later.
>>>>>
>>>>> Thanks!
>>>>> -sherman
>>>>>
>>>>>



More information about the core-libs-dev mailing list