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

mandy chung mandy.chung at oracle.com
Fri Sep 29 20:58:27 UTC 2017

On 9/27/17 4:41 PM, Xueming Shen wrote:
> Thanks Mandy!
> I removed the ln#657-#663, and updated the @apiNote in deflter, inflater
> and zipfile accordingly, mainly combined your comment and the approach
> for the fis/fo. they are "simpler" and straightforward now, at least 
> for me.
> https://bugs.openjdk.java.net/browse/JDK-8187485
> http://cr.openjdk.java.net/~sherman/8185582/webrev
> ||

76 * specified to call the {@code end} method to close the {@code 
deflater} and s/deflater/Deflater

80 * The recommended cleanup for compressor is to explicitly call {@code 
81 * method when it is no longer in use. Existing subclasses of {@code 
82 * that override {@code end} and require {@code end} to be invoked 
when the
83 * instance is unreachable should explicitly override {@link 
84 * and call {@code end}.

I suggest not to recommend "explicitly override Object.finalize" (in 
fact, we should discourage it) and the overridden end method should be 
called explicitly.  This was what I suggested in the previous mail:||

|* It is strongly recommended to explicitly call {@code end} to ||* discard any unprocessed input promptly to free up resources |* when 
|||the compressor |is no longer in use.| ||Same comment applies to Inflater. 75 * specified to call the {@code end} 
method to close the {@code inflater} and |


FinalizeZipFile.zip (I have mentioned this in the other mail):

I suggest to update InstrumentedZipFile to migrate away from the 
finalizer.   I can override the close method instead of the finalize 
method.   It can test explicitly calling close (that's what the test is 
currently doing) and try-with-resource.

  130                 throw new RuntimeException("'ZipFile.Source.zfile' is not accesible");



More information about the core-libs-dev mailing list