Uploaded image for project: 'JDK'
  1. JDK
  2. JDK-8187485

Update Zip implementation to use Cleaner, not finalizers

    Details

    • Type: CSR
    • Status: Closed
    • Priority: P3
    • Resolution: Approved
    • Fix Version/s: None
    • Component/s: core-libs
    • Labels:
    • Subcomponent:
    • Compatibility Kind:
      behavioral
    • Compatibility Risk:
      low
    • Compatibility Risk Description:
      Hide
      The change to clarify in spec that there is no guarantee the close/end will be called directly by `finalize()` should have a negligible effect. The recommended use to free resources is to call close/end. If not close/end-ed explicitly, the resources will be released when the ZipFile/Inflater/Deflater becomes unreachable.
      Show
      The change to clarify in spec that there is no guarantee the close/end will be called directly by `finalize()` should have a negligible effect. The recommended use to free resources is to call close/end. If not close/end-ed explicitly, the resources will be released when the ZipFile/Inflater/Deflater becomes unreachable.
    • Interface Kind:
      Java API
    • Scope:
      SE

      Description

      Summary

      To replace the finalizer mechanism with java.lang.ref.Cleaner to close the object java.util.zip.ZipFile/Inflater/Deflater, and cleanup/release its underlying native resources when the object is no longer reachable.

      Problem

      The finalization mechanism has a history of usage and performnace issues, it is desirable the j.u.zip implementation to migrate away from its use of finalizer to the newly introduced java.lang.ref.Cleaner.

      Solution

      1) To mark the overridden finalize() method of ZipFile/Deflater/Inflater class as "@Deprecated(, forRemoval=true)" and implement it with an empty body (to leverage the VM feature that vm does not put an object into the finalization process if its finalize() has an empty-body-ed implementation). The new implementation uses Cleaner to do the resource cleanup when the object has become unreachable, with the exception when the ZipFile/Inflater/Deflater has been subclassed and its corresponding close()/end() method has been overridden. In this case, the finalization mechanism is used to do the cleanup, and for behavioral compatibility, the corresponding close()/end() in subclass method will be called when the ZipFile/Inflater/Deflater object is unreachable.

      2) To update the specification of the end() method (for both Deflater and Inflater) to remove the requirement that the end() "will be called by the finalizer() automatically".

      3) To add additional @apiNote in class spec and @implSpec in finalize() method spec to clarify (a) the recommended approach to cleanup the resource after use, and (b) there is no guarantee that the close()/end() method will be called directly by finalize(), though the method in subclass will be called after the object is unreachable, via an implementation specific mechanism, for behavioral compatibility.

      http://cr.openjdk.java.net/~sherman/8185582/webrev

      Specification

      src/java.base/share/classes/java/util/zip/Deflater.java

      [adding class spec]

      + * @apiNote
      + * To release resources used by this {@code Deflater}, the {@link #end()} method
      + * should be called explicitly. Subclasses are responsible for the cleanup of resources
      + * acquired by the subclass. Subclasses that override {@link #finalize()} in order
      + * to perform cleanup should be modified to use alternative cleanup mechanisms such
      + * as {@link java.lang.ref.Cleaner} and remove the overriding {@code finalize} method.
      + *
      + * @implSpec
      + * If this {@code Deflater} has been subclassed and the {@code end} method has been
      + * overridden, the {@code end} method will be called by the finalization when the
      + * deflater is unreachable. But the subclasses should not depend on this specific
      + * implementation; the finalization is not reliable and the {@code finalize} method
      + * is deprecated to be removed.
      + *

      [updating end() spec]

           /**
            * Closes the compressor and discards any unprocessed input.
      +     *
            * This method should be called when the compressor is no longer
      -     * being used, but will also be called automatically by the
      -     * finalize() method. Once this method is called, the behavior
      -     * of the Deflater object is undefined.
      +     * being used. Once this method is called, the behavior of the
      +     * Deflater object is undefined.
      +     *
            */
           public void end() {...}

      [updating finalize() spec]

           /**
            * Closes the compressor when garbage is collected.
            *
      -     * @deprecated The {@code finalize} method has been deprecated.
      -     *     Subclasses that override {@code finalize} in order to perform cleanup
      -     *     should be modified to use alternative cleanup mechanisms and
      -     *     to remove the overriding {@code finalize} method.
      -     *     When overriding the {@code finalize} method, its implementation must explicitly
      -     *     ensure that {@code super.finalize()} is invoked as described in {@link Object#finalize}.
      -     *     See the specification for {@link Object#finalize()} for further
      -     *     information about migration options.
      -     */
      -    @Deprecated(since="9")
      -    protected void finalize() {
      -        end();
      -    }
      +     * @deprecated The {@code finalize} method has been deprecated and will be
      +     *     removed. It is implemented as a no-op. Subclasses that override
      +     *     {@code finalize} in order to perform cleanup should be modified to use
      +     *     alternative cleanup mechanisms and to remove the overriding {@code finalize}
      +     *     method. The recommended cleanup for compressor is to explicitly call
      +     *     {@code end} method when it is no longer in use. If the {@code end} is
      +     *     not invoked explicitly the resource of the compressor will be released
      +     *     when the instance becomes unreachable.
      +     */
      +    @Deprecated(since="9", forRemoval=true)
      +    protected void finalize() {}

      src/java.base/share/classes/java/util/zip/Inflater.java

      [adding class spec]

      + * @apiNote
      + * To release resources used by this {@code Inflater}, the {@link #end()} method
      + * should be called explicitly. Subclasses are responsible for the cleanup of resources
      + * acquired by the subclass. Subclasses that override {@link #finalize()} in order
      + * to perform cleanup should be modified to use alternative cleanup mechanisms such
      + * as {@link java.lang.ref.Cleaner} and remove the overriding {@code finalize} method.
      + *
      + * @implSpec
      + * If this {@code Inflater} has been subclassed and the {@code end} method has been
      + * overridden, the {@code end} method will be called by the finalization when the
      + * inflater is unreachable. But the subclasses should not depend on this specific
      + * implementation; the finalization is not reliable and the {@code finalize} method
      + * is deprecated to be removed.
      + *

      [updating end() spec]

           /**
            * Closes the decompressor and discards any unprocessed input.
      +     *
            * This method should be called when the decompressor is no longer
      -     * being used, but will also be called automatically by the finalize()
      -     * method. Once this method is called, the behavior of the Inflater
      -     * object is undefined.
      +     * being used. Once this method is called, the behavior of the
      +     * Inflater object is undefined.
      +     *
            */
           public void end() {

      [updating finalize() spec]

            /**
            * Closes the decompressor when garbage is collected.
            *
      -     * @deprecated The {@code finalize} method has been deprecated.
      -     *     Subclasses that override {@code finalize} in order to perform cleanup
      -     *     should be modified to use alternative cleanup mechanisms and
      -     *     to remove the overriding {@code finalize} method.
      -     *     When overriding the {@code finalize} method, its implementation must explicitly
      -     *     ensure that {@code super.finalize()} is invoked as described in {@link Object#finalize}.
      -     *     See the specification for {@link Object#finalize()} for further
      -     *     information about migration options.
      -     */
      -    @Deprecated(since="9")
      -    protected void finalize() {
      -        end();
      -    }
      +     * @implSpec
      +     * If this {@code Inflater} has been subclassed and the {@code end} method
      +     * has been overridden, the {@code end} method will be called when the
      +     * inflater is unreachable.
      +     *
      +     * @deprecated The {@code finalize} method has been deprecated and will be
      +     *     removed. It is implemented as a no-op. Subclasses that override
      +     *     {@code finalize} in order to perform cleanup should be modified to use
      +     *     alternative cleanup mechanisms and remove the overriding {@code finalize}
      +     *     method. The recommended cleanup for compressor is to explicitly call
      +     *     {@code end} method when it is no longer in use. If the {@code end} is
      +     *     not invoked explicitly the resource of the compressor will be released
      +     *     when the instance becomes unreachable, 
      +     */
      +    @Deprecated(since="9", forRemoval=true)
      +    protected void finalize() {}

      src/java.base/share/classes/java/util/zip/ZipFile.java

      [adding class spec]

      + * @apiNote
      + * To release resources used by this {@code ZipFile}, the {@link #close()} method
      + * should be called explicitly or by try-with-resources. Subclasses are responsible
      + * for the cleanup of resources acquired by the subclass. Subclasses that override
      + * {@link #finalize()} in order to perform cleanup should be modified to use alternative
      + * cleanup mechanisms such as {@link java.lang.ref.Cleaner} and remove the overriding
      + * {@code finalize} method.
      + *
      + * @implSpec
      + * If this {@code ZipFile} has been subclassed and the {@code close} method has
      + * been overridden, the {@code close} method will be called by the finalization
      + * when {@code ZipFile} is unreachable. But the subclasses should not depend on
      + * this specific implementation; the finalization is not reliable and the
      + * {@code finalize} method is deprecated to be removed.
      + *

      [updating finalize() spec]

           /**
            * Ensures that the system resources held by this ZipFile object are
            * released when there are no more references to it.
            *
      -     * <p>
      -     * Since the time when GC would invoke this method is undetermined,
      -     * it is strongly recommended that applications invoke the {@code close}
      -     * method as soon they have finished accessing this {@code ZipFile}.
      -     * This will prevent holding up system resources for an undetermined
      -     * length of time.
      -     *
      -     * @deprecated The {@code finalize} method has been deprecated.
      -     *     Subclasses that override {@code finalize} in order to perform cleanup
      -     *     should be modified to use alternative cleanup mechanisms and
      -     *     to remove the overriding {@code finalize} method.
      -     *     When overriding the {@code finalize} method, its implementation must explicitly
      -     *     ensure that {@code super.finalize()} is invoked as described in {@link Object#finalize}.
      -     *     See the specification for {@link Object#finalize()} for further
      -     *     information about migration options.
      +     * @deprecated The {@code finalize} method has been deprecated and will be
      +     *     removed. It is implemented as a no-op. Subclasses that override
      +     *     {@code finalize} in order to perform cleanup should be modified to
      +     *     use alternative cleanup mechanisms and to remove the overriding
      +     *     {@code finalize} method. The recommended cleanup for ZipFile object
      +     *     is to explicitly invoke {@code close} method when it is no longer in
      +     *     use, or use try-with-resources. If the {@code close} is not invoked
      +     *     explicitly the resources held by this object will be released when
      +     *     the instance becomes unreachable.
      +     *
            * @throws IOException if an I/O error has occurred
      -     * @see    java.util.zip.ZipFile#close()
            */
      -    @Deprecated(since="9")
      -    protected void finalize() throws IOException {}

        Issue Links

          Activity

          sherman Xueming Shen created issue -
          sherman Xueming Shen made changes -
          Field Original Value New Value
          Link This issue csr of JDK-8185582 [ JDK-8185582 ]
          sherman Xueming Shen made changes -
          Description
          Summary
          -------

          A concise description of the proposed change. The description should
          be one to two sentences long and written to be reusable in documents
          aggregating changes for a release.

          Problem
          -------

          A brief description of the problem, optionally including the
          motivation for developing a solution.

          Solution
          --------

          An overview of the solution. Alternative solutions may be discussed;
          links to rationale documents or review threads welcome to provide
          additional background to reviewers.

          Specification
          -------------

          The detailed changes. Acceptable normative formats include inline
          patches, attached webrevs, and attached specdiffs. The names of
          attached files are recommended to include a bug id. References to
          external webservers, such as http://cr.openjdk.java.net/, can be
          provided as informative supplements for the convenience of reviewers,
          but must be accompanied by a normative form of the specification
          directly associated with the CSR issue to satisfy archival purposes.

          Summary
          -------

          A concise description of the proposed change. The description should
          be one to two sentences long and written to be reusable in documents
          aggregating changes for a release.

          Problem
          -------

          A brief description of the problem, optionally including the
          motivation for developing a solution.

          Solution
          --------

          An overview of the solution. Alternative solutions may be discussed;
          links to rationale documents or review threads welcome to provide
          additional background to reviewers.

          Specification
          -------------

          src/java.base/share/classes/java/util/zip/Deflater.java

          + * <p>
          + * @apiNote
          + * Earlier versions of this class overrides {@link Object#finalize} to invokes
          + * {@code end} to close the compressor and release all resources when the instance
          + * becomes unreachable and therefor finalized. The {@code finalize} method has been
          + * removed in this version. The {@link java.lang.ref.Cleaner} is used to close the
          + * compressor when the instance becomes phantom-reachable, if the {@code end} is not
          + * invoked explicitly.
          + * <p>
          + *

          src/java.base/share/classes/java/util/zip/Inflater.java

          + * <p>
          + * @apiNote
          + * Earlier versions of this class overrides {@link Object#finalize} to invokes
          + * {@code end} to close the decompressor and release all resources when the instance
          + * becomes unreachable and therefor finalized. The {@code finalize} method has been
          + * removed in this version. The {@link java.lang.ref.Cleaner} is used to close the
          + * decompressor when the instance becomes phantom-reachable, if the {@code end} is
          + * not invoked explicitly.
          + * <p>

          src/java.base/share/classes/java/util/zip/ZipFile.java

          + * <p>
          + * @apiNote
          + * Earlier versions of this class overrides {@link Object#finalize} to invokes
          + * {@code close} to close the ZipFile object and release all system resources held
          + * by it when the instance becomes unreachable and therefor finalized. The
          + * {@code finalize} method has been removed in this version.
          + * The {@link java.lang.ref.Cleaner} is used to close the object when the instance
          + * becomes phantom-reachable, if the {@code close} is not invoked explicitly.
          + * <p>
          + * Since the time when Cleaner would clean this object is undetermined, it is
          + * strongly recommended that applications invoke the {@code close} method as soon
          + * they have finished accessing this {@code ZipFile}. This will prevent holding up
          + * system resources for an undetermined length of time.
          + * <p>
          + *
          sherman Xueming Shen made changes -
          Description Summary
          -------

          A concise description of the proposed change. The description should
          be one to two sentences long and written to be reusable in documents
          aggregating changes for a release.

          Problem
          -------

          A brief description of the problem, optionally including the
          motivation for developing a solution.

          Solution
          --------

          An overview of the solution. Alternative solutions may be discussed;
          links to rationale documents or review threads welcome to provide
          additional background to reviewers.

          Specification
          -------------

          src/java.base/share/classes/java/util/zip/Deflater.java

          + * <p>
          + * @apiNote
          + * Earlier versions of this class overrides {@link Object#finalize} to invokes
          + * {@code end} to close the compressor and release all resources when the instance
          + * becomes unreachable and therefor finalized. The {@code finalize} method has been
          + * removed in this version. The {@link java.lang.ref.Cleaner} is used to close the
          + * compressor when the instance becomes phantom-reachable, if the {@code end} is not
          + * invoked explicitly.
          + * <p>
          + *

          src/java.base/share/classes/java/util/zip/Inflater.java

          + * <p>
          + * @apiNote
          + * Earlier versions of this class overrides {@link Object#finalize} to invokes
          + * {@code end} to close the decompressor and release all resources when the instance
          + * becomes unreachable and therefor finalized. The {@code finalize} method has been
          + * removed in this version. The {@link java.lang.ref.Cleaner} is used to close the
          + * decompressor when the instance becomes phantom-reachable, if the {@code end} is
          + * not invoked explicitly.
          + * <p>

          src/java.base/share/classes/java/util/zip/ZipFile.java

          + * <p>
          + * @apiNote
          + * Earlier versions of this class overrides {@link Object#finalize} to invokes
          + * {@code close} to close the ZipFile object and release all system resources held
          + * by it when the instance becomes unreachable and therefor finalized. The
          + * {@code finalize} method has been removed in this version.
          + * The {@link java.lang.ref.Cleaner} is used to close the object when the instance
          + * becomes phantom-reachable, if the {@code close} is not invoked explicitly.
          + * <p>
          + * Since the time when Cleaner would clean this object is undetermined, it is
          + * strongly recommended that applications invoke the {@code close} method as soon
          + * they have finished accessing this {@code ZipFile}. This will prevent holding up
          + * system resources for an undetermined length of time.
          + * <p>
          + *
          Summary
          -------

          A concise description of the proposed change. The description should
          be one to two sentences long and written to be reusable in documents
          aggregating changes for a release.

          Problem
          -------

          A brief description of the problem, optionally including the
          motivation for developing a solution.

          Solution
          --------

          An overview of the solution. Alternative solutions may be discussed;
          links to rationale documents or review threads welcome to provide
          additional background to reviewers.

          Specification
          -------------

          src/java.base/share/classes/java/util/zip/Deflater.java

           * <p>
           * @apiNote
           * Earlier versions of this class overrides {@link Object#finalize} to invokes
           * {@code end} to close the compressor and release all resources when the instance
           * becomes unreachable and therefor finalized. The {@code finalize} method has been
           * removed in this version. The {@link java.lang.ref.Cleaner} is used to close the
           * compressor when the instance becomes phantom-reachable, if the {@code end} is not
           * invoked explicitly.
           * <p>
           *

          src/java.base/share/classes/java/util/zip/Inflater.java

          + * <p>
           * @apiNote
           * Earlier versions of this class overrides {@link Object#finalize} to invokes
           * {@code end} to close the decompressor and release all resources when the instance
           * becomes unreachable and therefor finalized. The {@code finalize} method has been
           * removed in this version. The {@link java.lang.ref.Cleaner} is used to close the
           * decompressor when the instance becomes phantom-reachable, if the {@code end} is
           * not invoked explicitly.
           * <p>

          src/java.base/share/classes/java/util/zip/ZipFile.java

           * <p>
           * @apiNote
           * Earlier versions of this class overrides {@link Object#finalize} to invokes
           * {@code close} to close the ZipFile object and release all system resources held
           * by it when the instance becomes unreachable and therefor finalized. The
           * {@code finalize} method has been removed in this version.
           * The {@link java.lang.ref.Cleaner} is used to close the object when the instance
           * becomes phantom-reachable, if the {@code close} is not invoked explicitly.
           * <p>
           * Since the time when Cleaner would clean this object is undetermined, it is
           * strongly recommended that applications invoke the {@code close} method as soon
           * they have finished accessing this {@code ZipFile}. This will prevent holding up
           * system resources for an undetermined length of time.
           * <p>
           *
          sherman Xueming Shen made changes -
          Description Summary
          -------

          A concise description of the proposed change. The description should
          be one to two sentences long and written to be reusable in documents
          aggregating changes for a release.

          Problem
          -------

          A brief description of the problem, optionally including the
          motivation for developing a solution.

          Solution
          --------

          An overview of the solution. Alternative solutions may be discussed;
          links to rationale documents or review threads welcome to provide
          additional background to reviewers.

          Specification
          -------------

          src/java.base/share/classes/java/util/zip/Deflater.java

           * <p>
           * @apiNote
           * Earlier versions of this class overrides {@link Object#finalize} to invokes
           * {@code end} to close the compressor and release all resources when the instance
           * becomes unreachable and therefor finalized. The {@code finalize} method has been
           * removed in this version. The {@link java.lang.ref.Cleaner} is used to close the
           * compressor when the instance becomes phantom-reachable, if the {@code end} is not
           * invoked explicitly.
           * <p>
           *

          src/java.base/share/classes/java/util/zip/Inflater.java

          + * <p>
           * @apiNote
           * Earlier versions of this class overrides {@link Object#finalize} to invokes
           * {@code end} to close the decompressor and release all resources when the instance
           * becomes unreachable and therefor finalized. The {@code finalize} method has been
           * removed in this version. The {@link java.lang.ref.Cleaner} is used to close the
           * decompressor when the instance becomes phantom-reachable, if the {@code end} is
           * not invoked explicitly.
           * <p>

          src/java.base/share/classes/java/util/zip/ZipFile.java

           * <p>
           * @apiNote
           * Earlier versions of this class overrides {@link Object#finalize} to invokes
           * {@code close} to close the ZipFile object and release all system resources held
           * by it when the instance becomes unreachable and therefor finalized. The
           * {@code finalize} method has been removed in this version.
           * The {@link java.lang.ref.Cleaner} is used to close the object when the instance
           * becomes phantom-reachable, if the {@code close} is not invoked explicitly.
           * <p>
           * Since the time when Cleaner would clean this object is undetermined, it is
           * strongly recommended that applications invoke the {@code close} method as soon
           * they have finished accessing this {@code ZipFile}. This will prevent holding up
           * system resources for an undetermined length of time.
           * <p>
           *
          Summary
          -------

          To use java.lang.ref.Cleaner to close the object and cleanup/release the underlying native resources when object is no longer reachable for java.util.zip.ZipFile/Inflater/Deflater.

          Problem
          -------

          A brief description of the problem, optionally including the
          motivation for developing a solution.

          Solution
          --------

          An overview of the solution. Alternative solutions may be discussed;
          links to rationale documents or review threads welcome to provide
          additional background to reviewers.

          Specification
          -------------

          src/java.base/share/classes/java/util/zip/Deflater.java

           * <p>
           * @apiNote
           * Earlier versions of this class overrides {@link Object#finalize} to invokes
           * {@code end} to close the compressor and release all resources when the instance
           * becomes unreachable and therefor finalized. The {@code finalize} method has been
           * removed in this version. The {@link java.lang.ref.Cleaner} is used to close the
           * compressor when the instance becomes phantom-reachable, if the {@code end} is not
           * invoked explicitly.
           * <p>
           *

          src/java.base/share/classes/java/util/zip/Inflater.java

           * <p>
           * @apiNote
           * Earlier versions of this class overrides {@link Object#finalize} to invokes
           * {@code end} to close the decompressor and release all resources when the instance
           * becomes unreachable and therefor finalized. The {@code finalize} method has been
           * removed in this version. The {@link java.lang.ref.Cleaner} is used to close the
           * decompressor when the instance becomes phantom-reachable, if the {@code end} is
           * not invoked explicitly.
           * <p>

          src/java.base/share/classes/java/util/zip/ZipFile.java

           * <p>
           * @apiNote
           * Earlier versions of this class overrides {@link Object#finalize} to invokes
           * {@code close} to close the ZipFile object and release all system resources held
           * by it when the instance becomes unreachable and therefor finalized. The
           * {@code finalize} method has been removed in this version.
           * The {@link java.lang.ref.Cleaner} is used to close the object when the instance
           * becomes phantom-reachable, if the {@code close} is not invoked explicitly.
           * <p>
           * Since the time when Cleaner would clean this object is undetermined, it is
           * strongly recommended that applications invoke the {@code close} method as soon
           * they have finished accessing this {@code ZipFile}. This will prevent holding up
           * system resources for an undetermined length of time.
           * <p>
           *
          sherman Xueming Shen made changes -
          Description Summary
          -------

          To use java.lang.ref.Cleaner to close the object and cleanup/release the underlying native resources when object is no longer reachable for java.util.zip.ZipFile/Inflater/Deflater.

          Problem
          -------

          A brief description of the problem, optionally including the
          motivation for developing a solution.

          Solution
          --------

          An overview of the solution. Alternative solutions may be discussed;
          links to rationale documents or review threads welcome to provide
          additional background to reviewers.

          Specification
          -------------

          src/java.base/share/classes/java/util/zip/Deflater.java

           * <p>
           * @apiNote
           * Earlier versions of this class overrides {@link Object#finalize} to invokes
           * {@code end} to close the compressor and release all resources when the instance
           * becomes unreachable and therefor finalized. The {@code finalize} method has been
           * removed in this version. The {@link java.lang.ref.Cleaner} is used to close the
           * compressor when the instance becomes phantom-reachable, if the {@code end} is not
           * invoked explicitly.
           * <p>
           *

          src/java.base/share/classes/java/util/zip/Inflater.java

           * <p>
           * @apiNote
           * Earlier versions of this class overrides {@link Object#finalize} to invokes
           * {@code end} to close the decompressor and release all resources when the instance
           * becomes unreachable and therefor finalized. The {@code finalize} method has been
           * removed in this version. The {@link java.lang.ref.Cleaner} is used to close the
           * decompressor when the instance becomes phantom-reachable, if the {@code end} is
           * not invoked explicitly.
           * <p>

          src/java.base/share/classes/java/util/zip/ZipFile.java

           * <p>
           * @apiNote
           * Earlier versions of this class overrides {@link Object#finalize} to invokes
           * {@code close} to close the ZipFile object and release all system resources held
           * by it when the instance becomes unreachable and therefor finalized. The
           * {@code finalize} method has been removed in this version.
           * The {@link java.lang.ref.Cleaner} is used to close the object when the instance
           * becomes phantom-reachable, if the {@code close} is not invoked explicitly.
           * <p>
           * Since the time when Cleaner would clean this object is undetermined, it is
           * strongly recommended that applications invoke the {@code close} method as soon
           * they have finished accessing this {@code ZipFile}. This will prevent holding up
           * system resources for an undetermined length of time.
           * <p>
           *
          Summary
          -------

          To replace the finalizer mechanism with java.lang.ref.Cleaner to close the object java.util.zip.ZipFile/Inflater/Deflater, and cleanup/release its underlying native resources when the object is no longer reachable.

          Problem
          -------

          The finalization mechanism has a history of usage and performnace issues, it is desirable the j.u.zip implementation to migrate away from its use of finalizer to the newly intorduced java.lang.ref.Cleaner.

          Solution
          --------

          To remove the overriden finalize() methods from Deflater, Inflater and ZipFile, and use Cleaner to do the resource cleanup when the object has become unreachable.

          To update the specification of the end() method (for both Deflater and Inflater) to remove the requirement that the end() "will be called by the finalizer() automately".

          To add additional @apiNote in class javadoc for Deflater, Inflater and ZipFile to describe the spec and behavioral change.

          http://cr.openjdk.java.net/~sherman/8185582/webrev

          Specification
          -------------

          src/java.base/share/classes/java/util/zip/Deflater.java

          [adding]

          + * <p>
          + * @apiNote
          + * Earlier versions of this class overrides {@link Object#finalize} to invokes
          + * {@code end} to close the compressor and release all resources when the instance
          + * becomes unreachable and therefor finalized. The {@code finalize} method has been
          + * removed in this version. The {@link java.lang.ref.Cleaner} is used to close the
          + * compressor when the instance becomes phantom-reachable, if the {@code end} is not
          + * invoked explicitly.
          + * <p>
          + *

          [updating]
               /**
                * Closes the compressor and discards any unprocessed input.
                * This method should be called when the compressor is no longer
          - * being used, but will also be called automatically by the
          - * finalize() method. Once this method is called, the behavior
          - * of the Deflater object is undefined.
          + * being used. Once this method is called, the behavior of the
          + * Deflater object is undefined.
                */
               public void end() {

          [removing]

          - /**
          - * Closes the compressor when garbage is collected.
          - *
          - * @deprecated The {@code finalize} method has been deprecated.
          - * Subclasses that override {@code finalize} in order to perform cleanup
          - * should be modified to use alternative cleanup mechanisms and
          - * to remove the overriding {@code finalize} method.
          - * When overriding the {@code finalize} method, its implementation must explicitly
          - * ensure that {@code super.finalize()} is invoked as described in {@link Object#finalize}.
          - * See the specification for {@link Object#finalize()} for further
          - * information about migration options.
          - */
          - @Deprecated(since="9")
          - protected void finalize() {
          - end();
          - }

          src/java.base/share/classes/java/util/zip/Inflater.java

          [adding]

          + * <p>
          + * @apiNote
          + * Earlier versions of this class overrides {@link Object#finalize} to invokes
          + * {@code end} to close the decompressor and release all resources when the instance
          + * becomes unreachable and therefor finalized. The {@code finalize} method has been
          + * removed in this version. The {@link java.lang.ref.Cleaner} is used to close the
          + * decompressor when the instance becomes phantom-reachable, if the {@code end} is
          + * not invoked explicitly.
          + * <p>

          [updating]

               /**
                * Closes the decompressor and discards any unprocessed input.
                * This method should be called when the decompressor is no longer
          - * being used, but will also be called automatically by the finalize()
          - * method. Once this method is called, the behavior of the Inflater
          - * object is undefined.
          + * being used. Once this method is called, the behavior of the
          + * Inflater object is undefined.
                */
               public void end() {

          [removing]

          - /**
          - * Closes the decompressor when garbage is collected.
          - *
          - * @deprecated The {@code finalize} method has been deprecated.
          - * Subclasses that override {@code finalize} in order to perform cleanup
          - * should be modified to use alternative cleanup mechanisms and
          - * to remove the overriding {@code finalize} method.
          - * When overriding the {@code finalize} method, its implementation must explicitly
          - * ensure that {@code super.finalize()} is invoked as described in {@link Object#finalize}.
          - * See the specification for {@link Object#finalize()} for further
          - * information about migration options.
          - */
          - @Deprecated(since="9")
          - protected void finalize() {
          - end();
          - }

          src/java.base/share/classes/java/util/zip/ZipFile.java

          [adding]

          + * <p>
          + * @apiNote
          + * Earlier versions of this class overrides {@link Object#finalize} to invokes
          + * {@code close} to close the ZipFile object and release all system resources held
          + * by it when the instance becomes unreachable and therefor finalized. The
          + * {@code finalize} method has been removed in this version.
          + * The {@link java.lang.ref.Cleaner} is used to close the object when the instance
          + * becomes phantom-reachable, if the {@code close} is not invoked explicitly.
          + * <p>
          + * Since the time when Cleaner would clean this object is undetermined, it is
          + * strongly recommended that applications invoke the {@code close} method as soon
          + * they have finished accessing this {@code ZipFile}. This will prevent holding up
          + * system resources for an undetermined length of time.
          + * <p>
          + *


          [removing]

          - /**
          - * Ensures that the system resources held by this ZipFile object are
          - * released when there are no more references to it.
          - * <p>
          - * Since the time when GC would invoke this method is undetermined,
          - * it is strongly recommended that applications invoke the {@code close}
          - * method as soon they have finished accessing this {@code ZipFile}.
          - * This will prevent holding up system resources for an undetermined
          - * length of time.
          - *
          - * @deprecated The {@code finalize} method has been deprecated.
          - * Subclasses that override {@code finalize} in order to perform cleanup
          - * should be modified to use alternative cleanup mechanisms and
          - * to remove the overriding {@code finalize} method.
          - * When overriding the {@code finalize} method, its implementation must explicitly
          - * ensure that {@code super.finalize()} is invoked as described in {@link Object#finalize}.
          - * See the specification for {@link Object#finalize()} for further
          - * information about migration options.
          - * @throws IOException if an I/O error has occurred
          - * @see java.util.zip.ZipFile#close()
          - */
          - @Deprecated(since="9")
          - protected void finalize() throws IOException {
          sherman Xueming Shen made changes -
          Description Summary
          -------

          To replace the finalizer mechanism with java.lang.ref.Cleaner to close the object java.util.zip.ZipFile/Inflater/Deflater, and cleanup/release its underlying native resources when the object is no longer reachable.

          Problem
          -------

          The finalization mechanism has a history of usage and performnace issues, it is desirable the j.u.zip implementation to migrate away from its use of finalizer to the newly intorduced java.lang.ref.Cleaner.

          Solution
          --------

          To remove the overriden finalize() methods from Deflater, Inflater and ZipFile, and use Cleaner to do the resource cleanup when the object has become unreachable.

          To update the specification of the end() method (for both Deflater and Inflater) to remove the requirement that the end() "will be called by the finalizer() automately".

          To add additional @apiNote in class javadoc for Deflater, Inflater and ZipFile to describe the spec and behavioral change.

          http://cr.openjdk.java.net/~sherman/8185582/webrev

          Specification
          -------------

          src/java.base/share/classes/java/util/zip/Deflater.java

          [adding]

          + * <p>
          + * @apiNote
          + * Earlier versions of this class overrides {@link Object#finalize} to invokes
          + * {@code end} to close the compressor and release all resources when the instance
          + * becomes unreachable and therefor finalized. The {@code finalize} method has been
          + * removed in this version. The {@link java.lang.ref.Cleaner} is used to close the
          + * compressor when the instance becomes phantom-reachable, if the {@code end} is not
          + * invoked explicitly.
          + * <p>
          + *

          [updating]
               /**
                * Closes the compressor and discards any unprocessed input.
                * This method should be called when the compressor is no longer
          - * being used, but will also be called automatically by the
          - * finalize() method. Once this method is called, the behavior
          - * of the Deflater object is undefined.
          + * being used. Once this method is called, the behavior of the
          + * Deflater object is undefined.
                */
               public void end() {

          [removing]

          - /**
          - * Closes the compressor when garbage is collected.
          - *
          - * @deprecated The {@code finalize} method has been deprecated.
          - * Subclasses that override {@code finalize} in order to perform cleanup
          - * should be modified to use alternative cleanup mechanisms and
          - * to remove the overriding {@code finalize} method.
          - * When overriding the {@code finalize} method, its implementation must explicitly
          - * ensure that {@code super.finalize()} is invoked as described in {@link Object#finalize}.
          - * See the specification for {@link Object#finalize()} for further
          - * information about migration options.
          - */
          - @Deprecated(since="9")
          - protected void finalize() {
          - end();
          - }

          src/java.base/share/classes/java/util/zip/Inflater.java

          [adding]

          + * <p>
          + * @apiNote
          + * Earlier versions of this class overrides {@link Object#finalize} to invokes
          + * {@code end} to close the decompressor and release all resources when the instance
          + * becomes unreachable and therefor finalized. The {@code finalize} method has been
          + * removed in this version. The {@link java.lang.ref.Cleaner} is used to close the
          + * decompressor when the instance becomes phantom-reachable, if the {@code end} is
          + * not invoked explicitly.
          + * <p>

          [updating]

               /**
                * Closes the decompressor and discards any unprocessed input.
                * This method should be called when the decompressor is no longer
          - * being used, but will also be called automatically by the finalize()
          - * method. Once this method is called, the behavior of the Inflater
          - * object is undefined.
          + * being used. Once this method is called, the behavior of the
          + * Inflater object is undefined.
                */
               public void end() {

          [removing]

          - /**
          - * Closes the decompressor when garbage is collected.
          - *
          - * @deprecated The {@code finalize} method has been deprecated.
          - * Subclasses that override {@code finalize} in order to perform cleanup
          - * should be modified to use alternative cleanup mechanisms and
          - * to remove the overriding {@code finalize} method.
          - * When overriding the {@code finalize} method, its implementation must explicitly
          - * ensure that {@code super.finalize()} is invoked as described in {@link Object#finalize}.
          - * See the specification for {@link Object#finalize()} for further
          - * information about migration options.
          - */
          - @Deprecated(since="9")
          - protected void finalize() {
          - end();
          - }

          src/java.base/share/classes/java/util/zip/ZipFile.java

          [adding]

          + * <p>
          + * @apiNote
          + * Earlier versions of this class overrides {@link Object#finalize} to invokes
          + * {@code close} to close the ZipFile object and release all system resources held
          + * by it when the instance becomes unreachable and therefor finalized. The
          + * {@code finalize} method has been removed in this version.
          + * The {@link java.lang.ref.Cleaner} is used to close the object when the instance
          + * becomes phantom-reachable, if the {@code close} is not invoked explicitly.
          + * <p>
          + * Since the time when Cleaner would clean this object is undetermined, it is
          + * strongly recommended that applications invoke the {@code close} method as soon
          + * they have finished accessing this {@code ZipFile}. This will prevent holding up
          + * system resources for an undetermined length of time.
          + * <p>
          + *


          [removing]

          - /**
          - * Ensures that the system resources held by this ZipFile object are
          - * released when there are no more references to it.
          - * <p>
          - * Since the time when GC would invoke this method is undetermined,
          - * it is strongly recommended that applications invoke the {@code close}
          - * method as soon they have finished accessing this {@code ZipFile}.
          - * This will prevent holding up system resources for an undetermined
          - * length of time.
          - *
          - * @deprecated The {@code finalize} method has been deprecated.
          - * Subclasses that override {@code finalize} in order to perform cleanup
          - * should be modified to use alternative cleanup mechanisms and
          - * to remove the overriding {@code finalize} method.
          - * When overriding the {@code finalize} method, its implementation must explicitly
          - * ensure that {@code super.finalize()} is invoked as described in {@link Object#finalize}.
          - * See the specification for {@link Object#finalize()} for further
          - * information about migration options.
          - * @throws IOException if an I/O error has occurred
          - * @see java.util.zip.ZipFile#close()
          - */
          - @Deprecated(since="9")
          - protected void finalize() throws IOException {
          Summary
          -------

          To replace the finalizer mechanism with java.lang.ref.Cleaner to close the object java.util.zip.ZipFile/Inflater/Deflater, and cleanup/release its underlying native resources when the object is no longer reachable.

          Problem
          -------

          The finalization mechanism has a history of usage and performnace issues, it is desirable the j.u.zip implementation to migrate away from its use of finalizer to the newly intorduced java.lang.ref.Cleaner.

          Solution
          --------

          To remove the overriden finalize() methods from Deflater, Inflater and ZipFile, and use Cleaner to do the resource cleanup when the object has become unreachable.

          To update the specification of the end() method (for both Deflater and Inflater) to remove the requirement that the end() "will be called by the finalizer() automately".

          To add additional @apiNote in class javadoc for Deflater, Inflater and ZipFile to describe the spec and behavioral change.

          http://cr.openjdk.java.net/~sherman/8185582/webrev

          Specification
          -------------

          src/java.base/share/classes/java/util/zip/Deflater.java

          [adding]

          + * <p>
          + * @apiNote
          + * Earlier versions of this class overrides {@link Object#finalize} to invokes
          + * {@code end} to close the compressor and release all resources when the instance
          + * becomes unreachable and therefor finalized. The {@code finalize} method has been
          + * removed in this version. The {@link java.lang.ref.Cleaner} is used to close the
          + * compressor when the instance becomes phantom-reachable, if the {@code end} is not
          + * invoked explicitly.
          + * <p>
          + *

          [updating]

                * Closes the compressor and discards any unprocessed input.
                * This method should be called when the compressor is no longer
          - * being used, but will also be called automatically by the
          - * finalize() method. Once this method is called, the behavior
          - * of the Deflater object is undefined.
          + * being used. Once this method is called, the behavior of the
          + * Deflater object is undefined.
                */
               public void end() {

          [removing]

          - /**
          - * Closes the compressor when garbage is collected.
          - *
          - * @deprecated The {@code finalize} method has been deprecated.
          - * Subclasses that override {@code finalize} in order to perform cleanup
          - * should be modified to use alternative cleanup mechanisms and
          - * to remove the overriding {@code finalize} method.
          - * When overriding the {@code finalize} method, its implementation must explicitly
          - * ensure that {@code super.finalize()} is invoked as described in {@link Object#finalize}.
          - * See the specification for {@link Object#finalize()} for further
          - * information about migration options.
          - */
          - @Deprecated(since="9")
          - protected void finalize() {
          - end();
          - }

          src/java.base/share/classes/java/util/zip/Inflater.java

          [adding]

          + * <p>
          + * @apiNote
          + * Earlier versions of this class overrides {@link Object#finalize} to invokes
          + * {@code end} to close the decompressor and release all resources when the instance
          + * becomes unreachable and therefor finalized. The {@code finalize} method has been
          + * removed in this version. The {@link java.lang.ref.Cleaner} is used to close the
          + * decompressor when the instance becomes phantom-reachable, if the {@code end} is
          + * not invoked explicitly.
          + * <p>

          [updating]

                * Closes the decompressor and discards any unprocessed input.
                * This method should be called when the decompressor is no longer
          - * being used, but will also be called automatically by the finalize()
          - * method. Once this method is called, the behavior of the Inflater
          - * object is undefined.
          + * being used. Once this method is called, the behavior of the
          + * Inflater object is undefined.
                */
               public void end() {

          [removing]

          - /**
          - * Closes the decompressor when garbage is collected.
          - *
          - * @deprecated The {@code finalize} method has been deprecated.
          - * Subclasses that override {@code finalize} in order to perform cleanup
          - * should be modified to use alternative cleanup mechanisms and
          - * to remove the overriding {@code finalize} method.
          - * When overriding the {@code finalize} method, its implementation must explicitly
          - * ensure that {@code super.finalize()} is invoked as described in {@link Object#finalize}.
          - * See the specification for {@link Object#finalize()} for further
          - * information about migration options.
          - */
          - @Deprecated(since="9")
          - protected void finalize() {
          - end();
          - }

          src/java.base/share/classes/java/util/zip/ZipFile.java

          [adding]

          + * <p>
          + * @apiNote
          + * Earlier versions of this class overrides {@link Object#finalize} to invokes
          + * {@code close} to close the ZipFile object and release all system resources held
          + * by it when the instance becomes unreachable and therefor finalized. The
          + * {@code finalize} method has been removed in this version.
          + * The {@link java.lang.ref.Cleaner} is used to close the object when the instance
          + * becomes phantom-reachable, if the {@code close} is not invoked explicitly.
          + * <p>
          + * Since the time when Cleaner would clean this object is undetermined, it is
          + * strongly recommended that applications invoke the {@code close} method as soon
          + * they have finished accessing this {@code ZipFile}. This will prevent holding up
          + * system resources for an undetermined length of time.
          + * <p>
          + *


          [removing]

          - /**
          - * Ensures that the system resources held by this ZipFile object are
          - * released when there are no more references to it.
          - * <p>
          - * Since the time when GC would invoke this method is undetermined,
          - * it is strongly recommended that applications invoke the {@code close}
          - * method as soon they have finished accessing this {@code ZipFile}.
          - * This will prevent holding up system resources for an undetermined
          - * length of time.
          - *
          - * @deprecated The {@code finalize} method has been deprecated.
          - * Subclasses that override {@code finalize} in order to perform cleanup
          - * should be modified to use alternative cleanup mechanisms and
          - * to remove the overriding {@code finalize} method.
          - * When overriding the {@code finalize} method, its implementation must explicitly
          - * ensure that {@code super.finalize()} is invoked as described in {@link Object#finalize}.
          - * See the specification for {@link Object#finalize()} for further
          - * information about migration options.
          - * @throws IOException if an I/O error has occurred
          - * @see java.util.zip.ZipFile#close()
          - */
          - @Deprecated(since="9")
          - protected void finalize() throws IOException {
          sherman Xueming Shen made changes -
          Description Summary
          -------

          To replace the finalizer mechanism with java.lang.ref.Cleaner to close the object java.util.zip.ZipFile/Inflater/Deflater, and cleanup/release its underlying native resources when the object is no longer reachable.

          Problem
          -------

          The finalization mechanism has a history of usage and performnace issues, it is desirable the j.u.zip implementation to migrate away from its use of finalizer to the newly intorduced java.lang.ref.Cleaner.

          Solution
          --------

          To remove the overriden finalize() methods from Deflater, Inflater and ZipFile, and use Cleaner to do the resource cleanup when the object has become unreachable.

          To update the specification of the end() method (for both Deflater and Inflater) to remove the requirement that the end() "will be called by the finalizer() automately".

          To add additional @apiNote in class javadoc for Deflater, Inflater and ZipFile to describe the spec and behavioral change.

          http://cr.openjdk.java.net/~sherman/8185582/webrev

          Specification
          -------------

          src/java.base/share/classes/java/util/zip/Deflater.java

          [adding]

          + * <p>
          + * @apiNote
          + * Earlier versions of this class overrides {@link Object#finalize} to invokes
          + * {@code end} to close the compressor and release all resources when the instance
          + * becomes unreachable and therefor finalized. The {@code finalize} method has been
          + * removed in this version. The {@link java.lang.ref.Cleaner} is used to close the
          + * compressor when the instance becomes phantom-reachable, if the {@code end} is not
          + * invoked explicitly.
          + * <p>
          + *

          [updating]

                * Closes the compressor and discards any unprocessed input.
                * This method should be called when the compressor is no longer
          - * being used, but will also be called automatically by the
          - * finalize() method. Once this method is called, the behavior
          - * of the Deflater object is undefined.
          + * being used. Once this method is called, the behavior of the
          + * Deflater object is undefined.
                */
               public void end() {

          [removing]

          - /**
          - * Closes the compressor when garbage is collected.
          - *
          - * @deprecated The {@code finalize} method has been deprecated.
          - * Subclasses that override {@code finalize} in order to perform cleanup
          - * should be modified to use alternative cleanup mechanisms and
          - * to remove the overriding {@code finalize} method.
          - * When overriding the {@code finalize} method, its implementation must explicitly
          - * ensure that {@code super.finalize()} is invoked as described in {@link Object#finalize}.
          - * See the specification for {@link Object#finalize()} for further
          - * information about migration options.
          - */
          - @Deprecated(since="9")
          - protected void finalize() {
          - end();
          - }

          src/java.base/share/classes/java/util/zip/Inflater.java

          [adding]

          + * <p>
          + * @apiNote
          + * Earlier versions of this class overrides {@link Object#finalize} to invokes
          + * {@code end} to close the decompressor and release all resources when the instance
          + * becomes unreachable and therefor finalized. The {@code finalize} method has been
          + * removed in this version. The {@link java.lang.ref.Cleaner} is used to close the
          + * decompressor when the instance becomes phantom-reachable, if the {@code end} is
          + * not invoked explicitly.
          + * <p>

          [updating]

                * Closes the decompressor and discards any unprocessed input.
                * This method should be called when the decompressor is no longer
          - * being used, but will also be called automatically by the finalize()
          - * method. Once this method is called, the behavior of the Inflater
          - * object is undefined.
          + * being used. Once this method is called, the behavior of the
          + * Inflater object is undefined.
                */
               public void end() {

          [removing]

          - /**
          - * Closes the decompressor when garbage is collected.
          - *
          - * @deprecated The {@code finalize} method has been deprecated.
          - * Subclasses that override {@code finalize} in order to perform cleanup
          - * should be modified to use alternative cleanup mechanisms and
          - * to remove the overriding {@code finalize} method.
          - * When overriding the {@code finalize} method, its implementation must explicitly
          - * ensure that {@code super.finalize()} is invoked as described in {@link Object#finalize}.
          - * See the specification for {@link Object#finalize()} for further
          - * information about migration options.
          - */
          - @Deprecated(since="9")
          - protected void finalize() {
          - end();
          - }

          src/java.base/share/classes/java/util/zip/ZipFile.java

          [adding]

          + * <p>
          + * @apiNote
          + * Earlier versions of this class overrides {@link Object#finalize} to invokes
          + * {@code close} to close the ZipFile object and release all system resources held
          + * by it when the instance becomes unreachable and therefor finalized. The
          + * {@code finalize} method has been removed in this version.
          + * The {@link java.lang.ref.Cleaner} is used to close the object when the instance
          + * becomes phantom-reachable, if the {@code close} is not invoked explicitly.
          + * <p>
          + * Since the time when Cleaner would clean this object is undetermined, it is
          + * strongly recommended that applications invoke the {@code close} method as soon
          + * they have finished accessing this {@code ZipFile}. This will prevent holding up
          + * system resources for an undetermined length of time.
          + * <p>
          + *


          [removing]

          - /**
          - * Ensures that the system resources held by this ZipFile object are
          - * released when there are no more references to it.
          - * <p>
          - * Since the time when GC would invoke this method is undetermined,
          - * it is strongly recommended that applications invoke the {@code close}
          - * method as soon they have finished accessing this {@code ZipFile}.
          - * This will prevent holding up system resources for an undetermined
          - * length of time.
          - *
          - * @deprecated The {@code finalize} method has been deprecated.
          - * Subclasses that override {@code finalize} in order to perform cleanup
          - * should be modified to use alternative cleanup mechanisms and
          - * to remove the overriding {@code finalize} method.
          - * When overriding the {@code finalize} method, its implementation must explicitly
          - * ensure that {@code super.finalize()} is invoked as described in {@link Object#finalize}.
          - * See the specification for {@link Object#finalize()} for further
          - * information about migration options.
          - * @throws IOException if an I/O error has occurred
          - * @see java.util.zip.ZipFile#close()
          - */
          - @Deprecated(since="9")
          - protected void finalize() throws IOException {
          Summary
          -------

          To replace the finalizer mechanism with java.lang.ref.Cleaner to close the object java.util.zip.ZipFile/Inflater/Deflater, and cleanup/release its underlying native resources when the object is no longer reachable.

          Problem
          -------

          The finalization mechanism has a history of usage and performnace issues, it is desirable the j.u.zip implementation to migrate away from its use of finalizer to the newly intorduced java.lang.ref.Cleaner.

          Solution
          --------

          To remove the overriden finalize() methods from Deflater, Inflater and ZipFile, and use Cleaner to do the resource cleanup when the object has become unreachable.

          To update the specification of the end() method (for both Deflater and Inflater) to remove the requirement that the end() "will be called by the finalizer() automately".

          To add additional @apiNote in class javadoc for Deflater, Inflater and ZipFile to describe the spec and behavioral change.

          http://cr.openjdk.java.net/~sherman/8185582/webrev

          Specification
          -------------

          > Blockquote

          src/java.base/share/classes/java/util/zip/Deflater.java

          [adding]

          + * <p>
          + * @apiNote
          + * Earlier versions of this class overrides {@link Object#finalize} to invokes
          + * {@code end} to close the compressor and release all resources when the instance
          + * becomes unreachable and therefor finalized. The {@code finalize} method has been
          + * removed in this version. The {@link java.lang.ref.Cleaner} is used to close the
          + * compressor when the instance becomes phantom-reachable, if the {@code end} is not
          + * invoked explicitly.
          + * <p>
          + *

          [updating]

               /**
                * Closes the compressor and discards any unprocessed input.
                * This method should be called when the compressor is no longer
          - * being used, but will also be called automatically by the
          - * finalize() method. Once this method is called, the behavior
          - * of the Deflater object is undefined.
          + * being used. Once this method is called, the behavior of the
          + * Deflater object is undefined.
                */
               public void end() {

          [removing]

          - /**
          - * Closes the compressor when garbage is collected.
          - *
          - * @deprecated The {@code finalize} method has been deprecated.
          - * Subclasses that override {@code finalize} in order to perform cleanup
          - * should be modified to use alternative cleanup mechanisms and
          - * to remove the overriding {@code finalize} method.
          - * When overriding the {@code finalize} method, its implementation must explicitly
          - * ensure that {@code super.finalize()} is invoked as described in {@link Object#finalize}.
          - * See the specification for {@link Object#finalize()} for further
          - * information about migration options.
          - */
          - @Deprecated(since="9")
          - protected void finalize() {
          - end();
          - }

          src/java.base/share/classes/java/util/zip/Inflater.java

          [adding]

          + * <p>
          + * @apiNote
          + * Earlier versions of this class overrides {@link Object#finalize} to invokes
          + * {@code end} to close the decompressor and release all resources when the instance
          + * becomes unreachable and therefor finalized. The {@code finalize} method has been
          + * removed in this version. The {@link java.lang.ref.Cleaner} is used to close the
          + * decompressor when the instance becomes phantom-reachable, if the {@code end} is
          + * not invoked explicitly.
          + * <p>

          [updating]

              /**
                * Closes the decompressor and discards any unprocessed input.
                * This method should be called when the decompressor is no longer
          - * being used, but will also be called automatically by the finalize()
          - * method. Once this method is called, the behavior of the Inflater
          - * object is undefined.
          + * being used. Once this method is called, the behavior of the
          + * Inflater object is undefined.
                */
               public void end() {

          [removing]

          - /**
          - * Closes the decompressor when garbage is collected.
          - *
          - * @deprecated The {@code finalize} method has been deprecated.
          - * Subclasses that override {@code finalize} in order to perform cleanup
          - * should be modified to use alternative cleanup mechanisms and
          - * to remove the overriding {@code finalize} method.
          - * When overriding the {@code finalize} method, its implementation must explicitly
          - * ensure that {@code super.finalize()} is invoked as described in {@link Object#finalize}.
          - * See the specification for {@link Object#finalize()} for further
          - * information about migration options.
          - */
          - @Deprecated(since="9")
          - protected void finalize() {
          - end();
          - }

          src/java.base/share/classes/java/util/zip/ZipFile.java

          [adding]

          + * <p>
          + * @apiNote
          + * Earlier versions of this class overrides {@link Object#finalize} to invokes
          + * {@code close} to close the ZipFile object and release all system resources held
          + * by it when the instance becomes unreachable and therefor finalized. The
          + * {@code finalize} method has been removed in this version.
          + * The {@link java.lang.ref.Cleaner} is used to close the object when the instance
          + * becomes phantom-reachable, if the {@code close} is not invoked explicitly.
          + * <p>
          + * Since the time when Cleaner would clean this object is undetermined, it is
          + * strongly recommended that applications invoke the {@code close} method as soon
          + * they have finished accessing this {@code ZipFile}. This will prevent holding up
          + * system resources for an undetermined length of time.
          + * <p>
          + *


          [removing]

          - /**
          - * Ensures that the system resources held by this ZipFile object are
          - * released when there are no more references to it.
          - * <p>
          - * Since the time when GC would invoke this method is undetermined,
          - * it is strongly recommended that applications invoke the {@code close}
          - * method as soon they have finished accessing this {@code ZipFile}.
          - * This will prevent holding up system resources for an undetermined
          - * length of time.
          - *
          - * @deprecated The {@code finalize} method has been deprecated.
          - * Subclasses that override {@code finalize} in order to perform cleanup
          - * should be modified to use alternative cleanup mechanisms and
          - * to remove the overriding {@code finalize} method.
          - * When overriding the {@code finalize} method, its implementation must explicitly
          - * ensure that {@code super.finalize()} is invoked as described in {@link Object#finalize}.
          - * See the specification for {@link Object#finalize()} for further
          - * information about migration options.
          - * @throws IOException if an I/O error has occurred
          - * @see java.util.zip.ZipFile#close()
          - */
          - @Deprecated(since="9")
          - protected void finalize() throws IOException {
          sherman Xueming Shen made changes -
          Description Summary
          -------

          To replace the finalizer mechanism with java.lang.ref.Cleaner to close the object java.util.zip.ZipFile/Inflater/Deflater, and cleanup/release its underlying native resources when the object is no longer reachable.

          Problem
          -------

          The finalization mechanism has a history of usage and performnace issues, it is desirable the j.u.zip implementation to migrate away from its use of finalizer to the newly intorduced java.lang.ref.Cleaner.

          Solution
          --------

          To remove the overriden finalize() methods from Deflater, Inflater and ZipFile, and use Cleaner to do the resource cleanup when the object has become unreachable.

          To update the specification of the end() method (for both Deflater and Inflater) to remove the requirement that the end() "will be called by the finalizer() automately".

          To add additional @apiNote in class javadoc for Deflater, Inflater and ZipFile to describe the spec and behavioral change.

          http://cr.openjdk.java.net/~sherman/8185582/webrev

          Specification
          -------------

          > Blockquote

          src/java.base/share/classes/java/util/zip/Deflater.java

          [adding]

          + * <p>
          + * @apiNote
          + * Earlier versions of this class overrides {@link Object#finalize} to invokes
          + * {@code end} to close the compressor and release all resources when the instance
          + * becomes unreachable and therefor finalized. The {@code finalize} method has been
          + * removed in this version. The {@link java.lang.ref.Cleaner} is used to close the
          + * compressor when the instance becomes phantom-reachable, if the {@code end} is not
          + * invoked explicitly.
          + * <p>
          + *

          [updating]

               /**
                * Closes the compressor and discards any unprocessed input.
                * This method should be called when the compressor is no longer
          - * being used, but will also be called automatically by the
          - * finalize() method. Once this method is called, the behavior
          - * of the Deflater object is undefined.
          + * being used. Once this method is called, the behavior of the
          + * Deflater object is undefined.
                */
               public void end() {

          [removing]

          - /**
          - * Closes the compressor when garbage is collected.
          - *
          - * @deprecated The {@code finalize} method has been deprecated.
          - * Subclasses that override {@code finalize} in order to perform cleanup
          - * should be modified to use alternative cleanup mechanisms and
          - * to remove the overriding {@code finalize} method.
          - * When overriding the {@code finalize} method, its implementation must explicitly
          - * ensure that {@code super.finalize()} is invoked as described in {@link Object#finalize}.
          - * See the specification for {@link Object#finalize()} for further
          - * information about migration options.
          - */
          - @Deprecated(since="9")
          - protected void finalize() {
          - end();
          - }

          src/java.base/share/classes/java/util/zip/Inflater.java

          [adding]

          + * <p>
          + * @apiNote
          + * Earlier versions of this class overrides {@link Object#finalize} to invokes
          + * {@code end} to close the decompressor and release all resources when the instance
          + * becomes unreachable and therefor finalized. The {@code finalize} method has been
          + * removed in this version. The {@link java.lang.ref.Cleaner} is used to close the
          + * decompressor when the instance becomes phantom-reachable, if the {@code end} is
          + * not invoked explicitly.
          + * <p>

          [updating]

              /**
                * Closes the decompressor and discards any unprocessed input.
                * This method should be called when the decompressor is no longer
          - * being used, but will also be called automatically by the finalize()
          - * method. Once this method is called, the behavior of the Inflater
          - * object is undefined.
          + * being used. Once this method is called, the behavior of the
          + * Inflater object is undefined.
                */
               public void end() {

          [removing]

          - /**
          - * Closes the decompressor when garbage is collected.
          - *
          - * @deprecated The {@code finalize} method has been deprecated.
          - * Subclasses that override {@code finalize} in order to perform cleanup
          - * should be modified to use alternative cleanup mechanisms and
          - * to remove the overriding {@code finalize} method.
          - * When overriding the {@code finalize} method, its implementation must explicitly
          - * ensure that {@code super.finalize()} is invoked as described in {@link Object#finalize}.
          - * See the specification for {@link Object#finalize()} for further
          - * information about migration options.
          - */
          - @Deprecated(since="9")
          - protected void finalize() {
          - end();
          - }

          src/java.base/share/classes/java/util/zip/ZipFile.java

          [adding]

          + * <p>
          + * @apiNote
          + * Earlier versions of this class overrides {@link Object#finalize} to invokes
          + * {@code close} to close the ZipFile object and release all system resources held
          + * by it when the instance becomes unreachable and therefor finalized. The
          + * {@code finalize} method has been removed in this version.
          + * The {@link java.lang.ref.Cleaner} is used to close the object when the instance
          + * becomes phantom-reachable, if the {@code close} is not invoked explicitly.
          + * <p>
          + * Since the time when Cleaner would clean this object is undetermined, it is
          + * strongly recommended that applications invoke the {@code close} method as soon
          + * they have finished accessing this {@code ZipFile}. This will prevent holding up
          + * system resources for an undetermined length of time.
          + * <p>
          + *


          [removing]

          - /**
          - * Ensures that the system resources held by this ZipFile object are
          - * released when there are no more references to it.
          - * <p>
          - * Since the time when GC would invoke this method is undetermined,
          - * it is strongly recommended that applications invoke the {@code close}
          - * method as soon they have finished accessing this {@code ZipFile}.
          - * This will prevent holding up system resources for an undetermined
          - * length of time.
          - *
          - * @deprecated The {@code finalize} method has been deprecated.
          - * Subclasses that override {@code finalize} in order to perform cleanup
          - * should be modified to use alternative cleanup mechanisms and
          - * to remove the overriding {@code finalize} method.
          - * When overriding the {@code finalize} method, its implementation must explicitly
          - * ensure that {@code super.finalize()} is invoked as described in {@link Object#finalize}.
          - * See the specification for {@link Object#finalize()} for further
          - * information about migration options.
          - * @throws IOException if an I/O error has occurred
          - * @see java.util.zip.ZipFile#close()
          - */
          - @Deprecated(since="9")
          - protected void finalize() throws IOException {
          Summary
          -------

          To replace the finalizer mechanism with java.lang.ref.Cleaner to close the object java.util.zip.ZipFile/Inflater/Deflater, and cleanup/release its underlying native resources when the object is no longer reachable.

          Problem
          -------

          The finalization mechanism has a history of usage and performnace issues, it is desirable the j.u.zip implementation to migrate away from its use of finalizer to the newly intorduced java.lang.ref.Cleaner.

          Solution
          --------

          To remove the overriden finalize() methods from Deflater, Inflater and ZipFile, and use Cleaner to do the resource cleanup when the object has become unreachable.

          To update the specification of the end() method (for both Deflater and Inflater) to remove the requirement that the end() "will be called by the finalizer() automately".

          To add additional @apiNote in class javadoc for Deflater, Inflater and ZipFile to describe the spec and behavioral change.

          http://cr.openjdk.java.net/~sherman/8185582/webrev

          Specification
          -------------

          src/java.base/share/classes/java/util/zip/Deflater.java

          [adding]

          + * <p>
          + * @apiNote
          + * Earlier versions of this class overrides {@link Object#finalize} to invokes
          + * {@code end} to close the compressor and release all resources when the instance
          + * becomes unreachable and therefor finalized. The {@code finalize} method has been
          + * removed in this version. The {@link java.lang.ref.Cleaner} is used to close the
          + * compressor when the instance becomes phantom-reachable, if the {@code end} is not
          + * invoked explicitly.
          + * <p>
          + *

          [updating]

               /**
                * Closes the compressor and discards any unprocessed input.
                * This method should be called when the compressor is no longer
          - * being used, but will also be called automatically by the
          - * finalize() method. Once this method is called, the behavior
          - * of the Deflater object is undefined.
          + * being used. Once this method is called, the behavior of the
          + * Deflater object is undefined.
                */
               public void end() {

          [removing]

          - /**
          - * Closes the compressor when garbage is collected.
          - *
          - * @deprecated The {@code finalize} method has been deprecated.
          - * Subclasses that override {@code finalize} in order to perform cleanup
          - * should be modified to use alternative cleanup mechanisms and
          - * to remove the overriding {@code finalize} method.
          - * When overriding the {@code finalize} method, its implementation must explicitly
          - * ensure that {@code super.finalize()} is invoked as described in {@link Object#finalize}.
          - * See the specification for {@link Object#finalize()} for further
          - * information about migration options.
          - */
          - @Deprecated(since="9")
          - protected void finalize() {
          - end();
          - }

          src/java.base/share/classes/java/util/zip/Inflater.java

          [adding]

          + * <p>
          + * @apiNote
          + * Earlier versions of this class overrides {@link Object#finalize} to invokes
          + * {@code end} to close the decompressor and release all resources when the instance
          + * becomes unreachable and therefor finalized. The {@code finalize} method has been
          + * removed in this version. The {@link java.lang.ref.Cleaner} is used to close the
          + * decompressor when the instance becomes phantom-reachable, if the {@code end} is
          + * not invoked explicitly.
          + * <p>

          [updating]

              /**
                * Closes the decompressor and discards any unprocessed input.
                * This method should be called when the decompressor is no longer
          - * being used, but will also be called automatically by the finalize()
          - * method. Once this method is called, the behavior of the Inflater
          - * object is undefined.
          + * being used. Once this method is called, the behavior of the
          + * Inflater object is undefined.
                */
               public void end() {

          [removing]

          - /**
          - * Closes the decompressor when garbage is collected.
          - *
          - * @deprecated The {@code finalize} method has been deprecated.
          - * Subclasses that override {@code finalize} in order to perform cleanup
          - * should be modified to use alternative cleanup mechanisms and
          - * to remove the overriding {@code finalize} method.
          - * When overriding the {@code finalize} method, its implementation must explicitly
          - * ensure that {@code super.finalize()} is invoked as described in {@link Object#finalize}.
          - * See the specification for {@link Object#finalize()} for further
          - * information about migration options.
          - */
          - @Deprecated(since="9")
          - protected void finalize() {
          - end();
          - }

          src/java.base/share/classes/java/util/zip/ZipFile.java

          [adding]

          + * <p>
          + * @apiNote
          + * Earlier versions of this class overrides {@link Object#finalize} to invokes
          + * {@code close} to close the ZipFile object and release all system resources held
          + * by it when the instance becomes unreachable and therefor finalized. The
          + * {@code finalize} method has been removed in this version.
          + * The {@link java.lang.ref.Cleaner} is used to close the object when the instance
          + * becomes phantom-reachable, if the {@code close} is not invoked explicitly.
          + * <p>
          + * Since the time when Cleaner would clean this object is undetermined, it is
          + * strongly recommended that applications invoke the {@code close} method as soon
          + * they have finished accessing this {@code ZipFile}. This will prevent holding up
          + * system resources for an undetermined length of time.
          + * <p>
          + *


          [removing]

          - /**
          - * Ensures that the system resources held by this ZipFile object are
          - * released when there are no more references to it.
          - * <p>
          - * Since the time when GC would invoke this method is undetermined,
          - * it is strongly recommended that applications invoke the {@code close}
          - * method as soon they have finished accessing this {@code ZipFile}.
          - * This will prevent holding up system resources for an undetermined
          - * length of time.
          - *
          - * @deprecated The {@code finalize} method has been deprecated.
          - * Subclasses that override {@code finalize} in order to perform cleanup
          - * should be modified to use alternative cleanup mechanisms and
          - * to remove the overriding {@code finalize} method.
          - * When overriding the {@code finalize} method, its implementation must explicitly
          - * ensure that {@code super.finalize()} is invoked as described in {@link Object#finalize}.
          - * See the specification for {@link Object#finalize()} for further
          - * information about migration options.
          - * @throws IOException if an I/O error has occurred
          - * @see java.util.zip.ZipFile#close()
          - */
          - @Deprecated(since="9")
          - protected void finalize() throws IOException {
          sherman Xueming Shen made changes -
          Description Summary
          -------

          To replace the finalizer mechanism with java.lang.ref.Cleaner to close the object java.util.zip.ZipFile/Inflater/Deflater, and cleanup/release its underlying native resources when the object is no longer reachable.

          Problem
          -------

          The finalization mechanism has a history of usage and performnace issues, it is desirable the j.u.zip implementation to migrate away from its use of finalizer to the newly intorduced java.lang.ref.Cleaner.

          Solution
          --------

          To remove the overriden finalize() methods from Deflater, Inflater and ZipFile, and use Cleaner to do the resource cleanup when the object has become unreachable.

          To update the specification of the end() method (for both Deflater and Inflater) to remove the requirement that the end() "will be called by the finalizer() automately".

          To add additional @apiNote in class javadoc for Deflater, Inflater and ZipFile to describe the spec and behavioral change.

          http://cr.openjdk.java.net/~sherman/8185582/webrev

          Specification
          -------------

          src/java.base/share/classes/java/util/zip/Deflater.java

          [adding]

          + * <p>
          + * @apiNote
          + * Earlier versions of this class overrides {@link Object#finalize} to invokes
          + * {@code end} to close the compressor and release all resources when the instance
          + * becomes unreachable and therefor finalized. The {@code finalize} method has been
          + * removed in this version. The {@link java.lang.ref.Cleaner} is used to close the
          + * compressor when the instance becomes phantom-reachable, if the {@code end} is not
          + * invoked explicitly.
          + * <p>
          + *

          [updating]

               /**
                * Closes the compressor and discards any unprocessed input.
                * This method should be called when the compressor is no longer
          - * being used, but will also be called automatically by the
          - * finalize() method. Once this method is called, the behavior
          - * of the Deflater object is undefined.
          + * being used. Once this method is called, the behavior of the
          + * Deflater object is undefined.
                */
               public void end() {

          [removing]

          - /**
          - * Closes the compressor when garbage is collected.
          - *
          - * @deprecated The {@code finalize} method has been deprecated.
          - * Subclasses that override {@code finalize} in order to perform cleanup
          - * should be modified to use alternative cleanup mechanisms and
          - * to remove the overriding {@code finalize} method.
          - * When overriding the {@code finalize} method, its implementation must explicitly
          - * ensure that {@code super.finalize()} is invoked as described in {@link Object#finalize}.
          - * See the specification for {@link Object#finalize()} for further
          - * information about migration options.
          - */
          - @Deprecated(since="9")
          - protected void finalize() {
          - end();
          - }

          src/java.base/share/classes/java/util/zip/Inflater.java

          [adding]

          + * <p>
          + * @apiNote
          + * Earlier versions of this class overrides {@link Object#finalize} to invokes
          + * {@code end} to close the decompressor and release all resources when the instance
          + * becomes unreachable and therefor finalized. The {@code finalize} method has been
          + * removed in this version. The {@link java.lang.ref.Cleaner} is used to close the
          + * decompressor when the instance becomes phantom-reachable, if the {@code end} is
          + * not invoked explicitly.
          + * <p>

          [updating]

              /**
                * Closes the decompressor and discards any unprocessed input.
                * This method should be called when the decompressor is no longer
          - * being used, but will also be called automatically by the finalize()
          - * method. Once this method is called, the behavior of the Inflater
          - * object is undefined.
          + * being used. Once this method is called, the behavior of the
          + * Inflater object is undefined.
                */
               public void end() {

          [removing]

          - /**
          - * Closes the decompressor when garbage is collected.
          - *
          - * @deprecated The {@code finalize} method has been deprecated.
          - * Subclasses that override {@code finalize} in order to perform cleanup
          - * should be modified to use alternative cleanup mechanisms and
          - * to remove the overriding {@code finalize} method.
          - * When overriding the {@code finalize} method, its implementation must explicitly
          - * ensure that {@code super.finalize()} is invoked as described in {@link Object#finalize}.
          - * See the specification for {@link Object#finalize()} for further
          - * information about migration options.
          - */
          - @Deprecated(since="9")
          - protected void finalize() {
          - end();
          - }

          src/java.base/share/classes/java/util/zip/ZipFile.java

          [adding]

          + * <p>
          + * @apiNote
          + * Earlier versions of this class overrides {@link Object#finalize} to invokes
          + * {@code close} to close the ZipFile object and release all system resources held
          + * by it when the instance becomes unreachable and therefor finalized. The
          + * {@code finalize} method has been removed in this version.
          + * The {@link java.lang.ref.Cleaner} is used to close the object when the instance
          + * becomes phantom-reachable, if the {@code close} is not invoked explicitly.
          + * <p>
          + * Since the time when Cleaner would clean this object is undetermined, it is
          + * strongly recommended that applications invoke the {@code close} method as soon
          + * they have finished accessing this {@code ZipFile}. This will prevent holding up
          + * system resources for an undetermined length of time.
          + * <p>
          + *


          [removing]

          - /**
          - * Ensures that the system resources held by this ZipFile object are
          - * released when there are no more references to it.
          - * <p>
          - * Since the time when GC would invoke this method is undetermined,
          - * it is strongly recommended that applications invoke the {@code close}
          - * method as soon they have finished accessing this {@code ZipFile}.
          - * This will prevent holding up system resources for an undetermined
          - * length of time.
          - *
          - * @deprecated The {@code finalize} method has been deprecated.
          - * Subclasses that override {@code finalize} in order to perform cleanup
          - * should be modified to use alternative cleanup mechanisms and
          - * to remove the overriding {@code finalize} method.
          - * When overriding the {@code finalize} method, its implementation must explicitly
          - * ensure that {@code super.finalize()} is invoked as described in {@link Object#finalize}.
          - * See the specification for {@link Object#finalize()} for further
          - * information about migration options.
          - * @throws IOException if an I/O error has occurred
          - * @see java.util.zip.ZipFile#close()
          - */
          - @Deprecated(since="9")
          - protected void finalize() throws IOException {
          Summary
          -------

          To replace the finalizer mechanism with java.lang.ref.Cleaner to close the object java.util.zip.ZipFile/Inflater/Deflater, and cleanup/release its underlying native resources when the object is no longer reachable.

          Problem
          -------

          The finalization mechanism has a history of usage and performnace issues, it is desirable the j.u.zip implementation to migrate away from its use of finalizer to the newly intorduced java.lang.ref.Cleaner.

          Solution
          --------

          To remove the overriden finalize() methods from Deflater, Inflater and ZipFile, and use Cleaner to do the resource cleanup when the object has become unreachable.

          To update the specification of the end() method (for both Deflater and Inflater) to remove the requirement that the end() "will be called by the finalizer() automately".

          To add additional @apiNote in class javadoc for Deflater, Inflater and ZipFile to describe the spec and behavioral change.

          http://cr.openjdk.java.net/~sherman/8185582/webrev

          Specification
          -------------

          src/java.base/share/classes/java/util/zip/Deflater.java

          [adding]

           * <p>
           * @apiNote
           * Earlier versions of this class overrides {@link Object#finalize} to invokes
           * {@code end} to close the compressor and release all resources when the instance
           * becomes unreachable and therefor finalized. The {@code finalize} method has been
           * removed in this version. The {@link java.lang.ref.Cleaner} is used to close the
           * compressor when the instance becomes phantom-reachable, if the {@code end} is not
           * invoked explicitly.
           * <p>
           *

          [updating]

               /**
                * Closes the compressor and discards any unprocessed input.
                * This method should be called when the compressor is no longer
                * being used. Once this method is called, the behavior of the
                * Deflater object is undefined.
                */
               public void end() {

          [removing]

          - /**
          - * Closes the compressor when garbage is collected.
          - *
          - * @deprecated The {@code finalize} method has been deprecated.
          - * Subclasses that override {@code finalize} in order to perform cleanup
          - * should be modified to use alternative cleanup mechanisms and
          - * to remove the overriding {@code finalize} method.
          - * When overriding the {@code finalize} method, its implementation must explicitly
          - * ensure that {@code super.finalize()} is invoked as described in {@link Object#finalize}.
          - * See the specification for {@link Object#finalize()} for further
          - * information about migration options.
          - */
          - @Deprecated(since="9")
          - protected void finalize() {
          - end();
          - }

          src/java.base/share/classes/java/util/zip/Inflater.java

          [adding]

          + * <p>
          + * @apiNote
          + * Earlier versions of this class overrides {@link Object#finalize} to invokes
          + * {@code end} to close the decompressor and release all resources when the instance
          + * becomes unreachable and therefor finalized. The {@code finalize} method has been
          + * removed in this version. The {@link java.lang.ref.Cleaner} is used to close the
          + * decompressor when the instance becomes phantom-reachable, if the {@code end} is
          + * not invoked explicitly.
          + * <p>

          [updating]

              /**
                * Closes the decompressor and discards any unprocessed input.
                * This method should be called when the decompressor is no longer
          - * being used, but will also be called automatically by the finalize()
          - * method. Once this method is called, the behavior of the Inflater
          - * object is undefined.
          + * being used. Once this method is called, the behavior of the
          + * Inflater object is undefined.
                */
               public void end() {

          [removing]

          - /**
          - * Closes the decompressor when garbage is collected.
          - *
          - * @deprecated The {@code finalize} method has been deprecated.
          - * Subclasses that override {@code finalize} in order to perform cleanup
          - * should be modified to use alternative cleanup mechanisms and
          - * to remove the overriding {@code finalize} method.
          - * When overriding the {@code finalize} method, its implementation must explicitly
          - * ensure that {@code super.finalize()} is invoked as described in {@link Object#finalize}.
          - * See the specification for {@link Object#finalize()} for further
          - * information about migration options.
          - */
          - @Deprecated(since="9")
          - protected void finalize() {
          - end();
          - }

          src/java.base/share/classes/java/util/zip/ZipFile.java

          [adding]

          + * <p>
          + * @apiNote
          + * Earlier versions of this class overrides {@link Object#finalize} to invokes
          + * {@code close} to close the ZipFile object and release all system resources held
          + * by it when the instance becomes unreachable and therefor finalized. The
          + * {@code finalize} method has been removed in this version.
          + * The {@link java.lang.ref.Cleaner} is used to close the object when the instance
          + * becomes phantom-reachable, if the {@code close} is not invoked explicitly.
          + * <p>
          + * Since the time when Cleaner would clean this object is undetermined, it is
          + * strongly recommended that applications invoke the {@code close} method as soon
          + * they have finished accessing this {@code ZipFile}. This will prevent holding up
          + * system resources for an undetermined length of time.
          + * <p>
          + *


          [removing]

          - /**
          - * Ensures that the system resources held by this ZipFile object are
          - * released when there are no more references to it.
          - * <p>
          - * Since the time when GC would invoke this method is undetermined,
          - * it is strongly recommended that applications invoke the {@code close}
          - * method as soon they have finished accessing this {@code ZipFile}.
          - * This will prevent holding up system resources for an undetermined
          - * length of time.
          - *
          - * @deprecated The {@code finalize} method has been deprecated.
          - * Subclasses that override {@code finalize} in order to perform cleanup
          - * should be modified to use alternative cleanup mechanisms and
          - * to remove the overriding {@code finalize} method.
          - * When overriding the {@code finalize} method, its implementation must explicitly
          - * ensure that {@code super.finalize()} is invoked as described in {@link Object#finalize}.
          - * See the specification for {@link Object#finalize()} for further
          - * information about migration options.
          - * @throws IOException if an I/O error has occurred
          - * @see java.util.zip.ZipFile#close()
          - */
          - @Deprecated(since="9")
          - protected void finalize() throws IOException {
          sherman Xueming Shen made changes -
          Description Summary
          -------

          To replace the finalizer mechanism with java.lang.ref.Cleaner to close the object java.util.zip.ZipFile/Inflater/Deflater, and cleanup/release its underlying native resources when the object is no longer reachable.

          Problem
          -------

          The finalization mechanism has a history of usage and performnace issues, it is desirable the j.u.zip implementation to migrate away from its use of finalizer to the newly intorduced java.lang.ref.Cleaner.

          Solution
          --------

          To remove the overriden finalize() methods from Deflater, Inflater and ZipFile, and use Cleaner to do the resource cleanup when the object has become unreachable.

          To update the specification of the end() method (for both Deflater and Inflater) to remove the requirement that the end() "will be called by the finalizer() automately".

          To add additional @apiNote in class javadoc for Deflater, Inflater and ZipFile to describe the spec and behavioral change.

          http://cr.openjdk.java.net/~sherman/8185582/webrev

          Specification
          -------------

          src/java.base/share/classes/java/util/zip/Deflater.java

          [adding]

           * <p>
           * @apiNote
           * Earlier versions of this class overrides {@link Object#finalize} to invokes
           * {@code end} to close the compressor and release all resources when the instance
           * becomes unreachable and therefor finalized. The {@code finalize} method has been
           * removed in this version. The {@link java.lang.ref.Cleaner} is used to close the
           * compressor when the instance becomes phantom-reachable, if the {@code end} is not
           * invoked explicitly.
           * <p>
           *

          [updating]

               /**
                * Closes the compressor and discards any unprocessed input.
                * This method should be called when the compressor is no longer
                * being used. Once this method is called, the behavior of the
                * Deflater object is undefined.
                */
               public void end() {

          [removing]

          - /**
          - * Closes the compressor when garbage is collected.
          - *
          - * @deprecated The {@code finalize} method has been deprecated.
          - * Subclasses that override {@code finalize} in order to perform cleanup
          - * should be modified to use alternative cleanup mechanisms and
          - * to remove the overriding {@code finalize} method.
          - * When overriding the {@code finalize} method, its implementation must explicitly
          - * ensure that {@code super.finalize()} is invoked as described in {@link Object#finalize}.
          - * See the specification for {@link Object#finalize()} for further
          - * information about migration options.
          - */
          - @Deprecated(since="9")
          - protected void finalize() {
          - end();
          - }

          src/java.base/share/classes/java/util/zip/Inflater.java

          [adding]

          + * <p>
          + * @apiNote
          + * Earlier versions of this class overrides {@link Object#finalize} to invokes
          + * {@code end} to close the decompressor and release all resources when the instance
          + * becomes unreachable and therefor finalized. The {@code finalize} method has been
          + * removed in this version. The {@link java.lang.ref.Cleaner} is used to close the
          + * decompressor when the instance becomes phantom-reachable, if the {@code end} is
          + * not invoked explicitly.
          + * <p>

          [updating]

              /**
                * Closes the decompressor and discards any unprocessed input.
                * This method should be called when the decompressor is no longer
          - * being used, but will also be called automatically by the finalize()
          - * method. Once this method is called, the behavior of the Inflater
          - * object is undefined.
          + * being used. Once this method is called, the behavior of the
          + * Inflater object is undefined.
                */
               public void end() {

          [removing]

          - /**
          - * Closes the decompressor when garbage is collected.
          - *
          - * @deprecated The {@code finalize} method has been deprecated.
          - * Subclasses that override {@code finalize} in order to perform cleanup
          - * should be modified to use alternative cleanup mechanisms and
          - * to remove the overriding {@code finalize} method.
          - * When overriding the {@code finalize} method, its implementation must explicitly
          - * ensure that {@code super.finalize()} is invoked as described in {@link Object#finalize}.
          - * See the specification for {@link Object#finalize()} for further
          - * information about migration options.
          - */
          - @Deprecated(since="9")
          - protected void finalize() {
          - end();
          - }

          src/java.base/share/classes/java/util/zip/ZipFile.java

          [adding]

          + * <p>
          + * @apiNote
          + * Earlier versions of this class overrides {@link Object#finalize} to invokes
          + * {@code close} to close the ZipFile object and release all system resources held
          + * by it when the instance becomes unreachable and therefor finalized. The
          + * {@code finalize} method has been removed in this version.
          + * The {@link java.lang.ref.Cleaner} is used to close the object when the instance
          + * becomes phantom-reachable, if the {@code close} is not invoked explicitly.
          + * <p>
          + * Since the time when Cleaner would clean this object is undetermined, it is
          + * strongly recommended that applications invoke the {@code close} method as soon
          + * they have finished accessing this {@code ZipFile}. This will prevent holding up
          + * system resources for an undetermined length of time.
          + * <p>
          + *


          [removing]

          - /**
          - * Ensures that the system resources held by this ZipFile object are
          - * released when there are no more references to it.
          - * <p>
          - * Since the time when GC would invoke this method is undetermined,
          - * it is strongly recommended that applications invoke the {@code close}
          - * method as soon they have finished accessing this {@code ZipFile}.
          - * This will prevent holding up system resources for an undetermined
          - * length of time.
          - *
          - * @deprecated The {@code finalize} method has been deprecated.
          - * Subclasses that override {@code finalize} in order to perform cleanup
          - * should be modified to use alternative cleanup mechanisms and
          - * to remove the overriding {@code finalize} method.
          - * When overriding the {@code finalize} method, its implementation must explicitly
          - * ensure that {@code super.finalize()} is invoked as described in {@link Object#finalize}.
          - * See the specification for {@link Object#finalize()} for further
          - * information about migration options.
          - * @throws IOException if an I/O error has occurred
          - * @see java.util.zip.ZipFile#close()
          - */
          - @Deprecated(since="9")
          - protected void finalize() throws IOException {
          Summary
          -------

          To replace the finalizer mechanism with java.lang.ref.Cleaner to close the object java.util.zip.ZipFile/Inflater/Deflater, and cleanup/release its underlying native resources when the object is no longer reachable.

          Problem
          -------

          The finalization mechanism has a history of usage and performnace issues, it is desirable the j.u.zip implementation to migrate away from its use of finalizer to the newly intorduced java.lang.ref.Cleaner.

          Solution
          --------

          To remove the overriden finalize() methods from Deflater, Inflater and ZipFile, and use Cleaner to do the resource cleanup when the object has become unreachable.

          To update the specification of the end() method (for both Deflater and Inflater) to remove the requirement that the end() "will be called by the finalizer() automately".

          To add additional @apiNote in class javadoc for Deflater, Inflater and ZipFile to describe the spec and behavioral change.

          http://cr.openjdk.java.net/~sherman/8185582/webrev

          Specification
          -------------

          src/java.base/share/classes/java/util/zip/Deflater.java

          [adding]

          + * <p>
          + * @apiNote
          + * Earlier versions of this class overrides {@link Object#finalize} to invokes
          + * {@code end} to close the compressor and release all resources when the instance
          + * becomes unreachable and therefor finalized. The {@code finalize} method has been
          + * removed in this version. The {@link java.lang.ref.Cleaner} is used to close the
          + * compressor when the instance becomes phantom-reachable, if the {@code end} is not
          + * invoked explicitly.
          + * <p>
          + *

          [updating, the updated version]

               /**
                * Closes the compressor and discards any unprocessed input.
                * This method should be called when the compressor is no longer
                * being used. Once this method is called, the behavior of the
                * Deflater object is undefined.
                */
               public void end() {

          [removing]

          - /**
          - * Closes the compressor when garbage is collected.
          - *
          - * @deprecated The {@code finalize} method has been deprecated.
          - * Subclasses that override {@code finalize} in order to perform cleanup
          - * should be modified to use alternative cleanup mechanisms and
          - * to remove the overriding {@code finalize} method.
          - * When overriding the {@code finalize} method, its implementation must explicitly
          - * ensure that {@code super.finalize()} is invoked as described in {@link Object#finalize}.
          - * See the specification for {@link Object#finalize()} for further
          - * information about migration options.
          - */
          - @Deprecated(since="9")
          - protected void finalize() {
          - end();
          - }

          src/java.base/share/classes/java/util/zip/Inflater.java

          [adding]

          + * <p>
          + * @apiNote
          + * Earlier versions of this class overrides {@link Object#finalize} to invokes
          + * {@code end} to close the decompressor and release all resources when the instance
          + * becomes unreachable and therefor finalized. The {@code finalize} method has been
          + * removed in this version. The {@link java.lang.ref.Cleaner} is used to close the
          + * decompressor when the instance becomes phantom-reachable, if the {@code end} is
          + * not invoked explicitly.
          + * <p>

          [updating, the updated version]

              /**
                * Closes the decompressor and discards any unprocessed input.
                * This method should be called when the decompressor is no longer
                * being used. Once this method is called, the behavior of the
                * Inflater object is undefined.
                */
               public void end() {

          [removing]

          - /**
          - * Closes the decompressor when garbage is collected.
          - *
          - * @deprecated The {@code finalize} method has been deprecated.
          - * Subclasses that override {@code finalize} in order to perform cleanup
          - * should be modified to use alternative cleanup mechanisms and
          - * to remove the overriding {@code finalize} method.
          - * When overriding the {@code finalize} method, its implementation must explicitly
          - * ensure that {@code super.finalize()} is invoked as described in {@link Object#finalize}.
          - * See the specification for {@link Object#finalize()} for further
          - * information about migration options.
          - */
          - @Deprecated(since="9")
          - protected void finalize() {
          - end();
          - }

          src/java.base/share/classes/java/util/zip/ZipFile.java

          [adding]

          + * <p>
          + * @apiNote
          + * Earlier versions of this class overrides {@link Object#finalize} to invokes
          + * {@code close} to close the ZipFile object and release all system resources held
          + * by it when the instance becomes unreachable and therefor finalized. The
          + * {@code finalize} method has been removed in this version.
          + * The {@link java.lang.ref.Cleaner} is used to close the object when the instance
          + * becomes phantom-reachable, if the {@code close} is not invoked explicitly.
          + * <p>
          + * Since the time when Cleaner would clean this object is undetermined, it is
          + * strongly recommended that applications invoke the {@code close} method as soon
          + * they have finished accessing this {@code ZipFile}. This will prevent holding up
          + * system resources for an undetermined length of time.
          + * <p>
          + *


          [removing]

          - /**
          - * Ensures that the system resources held by this ZipFile object are
          - * released when there are no more references to it.
          - * <p>
          - * Since the time when GC would invoke this method is undetermined,
          - * it is strongly recommended that applications invoke the {@code close}
          - * method as soon they have finished accessing this {@code ZipFile}.
          - * This will prevent holding up system resources for an undetermined
          - * length of time.
          - *
          - * @deprecated The {@code finalize} method has been deprecated.
          - * Subclasses that override {@code finalize} in order to perform cleanup
          - * should be modified to use alternative cleanup mechanisms and
          - * to remove the overriding {@code finalize} method.
          - * When overriding the {@code finalize} method, its implementation must explicitly
          - * ensure that {@code super.finalize()} is invoked as described in {@link Object#finalize}.
          - * See the specification for {@link Object#finalize()} for further
          - * information about migration options.
          - * @throws IOException if an I/O error has occurred
          - * @see java.util.zip.ZipFile#close()
          - */
          - @Deprecated(since="9")
          - protected void finalize() throws IOException {
          sherman Xueming Shen made changes -
          Compatibility Risk medium [ 19603 ]
          Compatibility Risk Description Both Deflater and Inflater's end() method have the specification wordings as "... will also be called automatically by the finalize() method"

           public void end() {
               ...
               end(addr);
               ...
           }

          And for the ZipFile, even the specification is not specified that its inflater() method will call close(), its implementation currently does ju\
          st that.

          protected void finalize() throws IOException {
              close();
          }

          Give that there are two kinds of "incompatible risk" caused by the proposed changes

          (1) Behavioral incompatibility

          It's possilbe that there are existing subclasses (of Deflater, Inflater and ZipFile) over there that has the dependency on the existing behavio\
          r, in which the "end()/close()" method is being invoked during finalization. Those subclasses might override the "end()/close() with some addit\
          onal implementation logic with the expection that these additioanl logic will be executed when the object is being gc-ed. With this change, it \
          no longer happen.

          (2) Source incomatiblity

          Inflater/Deflater.finalize() does not throw any exception
          ZipFile.finalize() only throws IOException.

          With the removal() of finalize() from Deflater, Inflater and ZipFile, any existing subclass (of these 3 classes) that overrides finalize() mig\
          ht not be compiled anymore as now their overriding finalize() needs to catch the "Throwable" from Object.finalize().

          It is believed that the compatibility risk should be low but marked as medium because it is uncertain how existing applications depend on these\
           behaviors.
          sherman Xueming Shen made changes -
          Compatibility Risk Description Both Deflater and Inflater's end() method have the specification wordings as "... will also be called automatically by the finalize() method"

           public void end() {
               ...
               end(addr);
               ...
           }

          And for the ZipFile, even the specification is not specified that its inflater() method will call close(), its implementation currently does ju\
          st that.

          protected void finalize() throws IOException {
              close();
          }

          Give that there are two kinds of "incompatible risk" caused by the proposed changes

          (1) Behavioral incompatibility

          It's possilbe that there are existing subclasses (of Deflater, Inflater and ZipFile) over there that has the dependency on the existing behavio\
          r, in which the "end()/close()" method is being invoked during finalization. Those subclasses might override the "end()/close() with some addit\
          onal implementation logic with the expection that these additioanl logic will be executed when the object is being gc-ed. With this change, it \
          no longer happen.

          (2) Source incomatiblity

          Inflater/Deflater.finalize() does not throw any exception
          ZipFile.finalize() only throws IOException.

          With the removal() of finalize() from Deflater, Inflater and ZipFile, any existing subclass (of these 3 classes) that overrides finalize() mig\
          ht not be compiled anymore as now their overriding finalize() needs to catch the "Throwable" from Object.finalize().

          It is believed that the compatibility risk should be low but marked as medium because it is uncertain how existing applications depend on these\
           behaviors.
          Both Deflater and Inflater's end() method have the specification wordings as "... will also be called automatically by the finalize() method"

           public void end() {
               ...
               end(addr);
               ...
           }

          And for the ZipFile, even the specification is not specified that its inflater() method will call close(), its implementation currently does just that.

          protected void finalize() throws IOException {
              close();
          }

          Give that there are two kinds of "incompatible risk" caused by the proposed changes

          (1) Behavioral incompatibility

          It's possilbe that there are existing subclasses (of Deflater, Inflater and ZipFile) over there that has the dependency on the existing behavior, in which the "end()/close()" method is being invoked during finalization. Those subclasses might override the "end()/close() with some additional implementation logic with the expection that these additioanl logic will be executed when the object is being gc-ed. With this change, it no longer happens.

          (2) Source incomatiblity

          Inflater/Deflater.finalize() does not throw any exception
          ZipFile.finalize() only throws IOException.

          With the removal() of finalize() from Deflater, Inflater and ZipFile, any existing subclass (of these 3 classes) that overrides finalize() might not be compiled anymore as now their overriding finalize() needs to catch the "Throwable" from Object.finalize().

          It is believed that the compatibility risk should be low but marked as medium because it is uncertain how existing applications depend on these behaviors.
          rriggs Roger Riggs made changes -
          Compatibility Risk Description Both Deflater and Inflater's end() method have the specification wordings as "... will also be called automatically by the finalize() method"

           public void end() {
               ...
               end(addr);
               ...
           }

          And for the ZipFile, even the specification is not specified that its inflater() method will call close(), its implementation currently does just that.

          protected void finalize() throws IOException {
              close();
          }

          Give that there are two kinds of "incompatible risk" caused by the proposed changes

          (1) Behavioral incompatibility

          It's possilbe that there are existing subclasses (of Deflater, Inflater and ZipFile) over there that has the dependency on the existing behavior, in which the "end()/close()" method is being invoked during finalization. Those subclasses might override the "end()/close() with some additional implementation logic with the expection that these additioanl logic will be executed when the object is being gc-ed. With this change, it no longer happens.

          (2) Source incomatiblity

          Inflater/Deflater.finalize() does not throw any exception
          ZipFile.finalize() only throws IOException.

          With the removal() of finalize() from Deflater, Inflater and ZipFile, any existing subclass (of these 3 classes) that overrides finalize() might not be compiled anymore as now their overriding finalize() needs to catch the "Throwable" from Object.finalize().

          It is believed that the compatibility risk should be low but marked as medium because it is uncertain how existing applications depend on these behaviors.
          Both Deflater and Inflater's end() method have the specification wordings as "... will also be called automatically by the finalize() method"

           public void end() {
               ...
               end(addr);
               ...
           }

          And for the ZipFile, even the specification is not specified that its inflater() method will call close(), its implementation currently does just that.

          protected void finalize() throws IOException {
              close();
          }

          Give that there are two kinds of "incompatible risk" caused by the proposed changes

          (1) Behavioral incompatibility

          It's possilbe that there are existing subclasses (of Deflater, Inflater and ZipFile) over there that has the dependency on the existing behavior, in which the "end()/close()" method is being invoked during finalization. Those subclasses might override the "end()/close() with some additional implementation logic with the expection that these additioanl logic will be executed when the object is being gc-ed. With this change, it no longer happens.

          (2) Source incompatiblity

          Inflater/Deflater.finalize() does not throw any exception
          ZipFile.finalize() only throws IOException.

          With the removal() of finalize() from Deflater, Inflater and ZipFile, any existing subclass (of these 3 classes) that overrides finalize() might not be compiled anymore as now their overriding finalize() needs to catch the "Throwable" from Object.finalize().

          It is believed that the compatibility risk should be low but marked as medium because it is uncertain how existing applications depend on these behaviors.
          rriggs Roger Riggs made changes -
          Description Summary
          -------

          To replace the finalizer mechanism with java.lang.ref.Cleaner to close the object java.util.zip.ZipFile/Inflater/Deflater, and cleanup/release its underlying native resources when the object is no longer reachable.

          Problem
          -------

          The finalization mechanism has a history of usage and performnace issues, it is desirable the j.u.zip implementation to migrate away from its use of finalizer to the newly intorduced java.lang.ref.Cleaner.

          Solution
          --------

          To remove the overriden finalize() methods from Deflater, Inflater and ZipFile, and use Cleaner to do the resource cleanup when the object has become unreachable.

          To update the specification of the end() method (for both Deflater and Inflater) to remove the requirement that the end() "will be called by the finalizer() automately".

          To add additional @apiNote in class javadoc for Deflater, Inflater and ZipFile to describe the spec and behavioral change.

          http://cr.openjdk.java.net/~sherman/8185582/webrev

          Specification
          -------------

          src/java.base/share/classes/java/util/zip/Deflater.java

          [adding]

          + * <p>
          + * @apiNote
          + * Earlier versions of this class overrides {@link Object#finalize} to invokes
          + * {@code end} to close the compressor and release all resources when the instance
          + * becomes unreachable and therefor finalized. The {@code finalize} method has been
          + * removed in this version. The {@link java.lang.ref.Cleaner} is used to close the
          + * compressor when the instance becomes phantom-reachable, if the {@code end} is not
          + * invoked explicitly.
          + * <p>
          + *

          [updating, the updated version]

               /**
                * Closes the compressor and discards any unprocessed input.
                * This method should be called when the compressor is no longer
                * being used. Once this method is called, the behavior of the
                * Deflater object is undefined.
                */
               public void end() {

          [removing]

          - /**
          - * Closes the compressor when garbage is collected.
          - *
          - * @deprecated The {@code finalize} method has been deprecated.
          - * Subclasses that override {@code finalize} in order to perform cleanup
          - * should be modified to use alternative cleanup mechanisms and
          - * to remove the overriding {@code finalize} method.
          - * When overriding the {@code finalize} method, its implementation must explicitly
          - * ensure that {@code super.finalize()} is invoked as described in {@link Object#finalize}.
          - * See the specification for {@link Object#finalize()} for further
          - * information about migration options.
          - */
          - @Deprecated(since="9")
          - protected void finalize() {
          - end();
          - }

          src/java.base/share/classes/java/util/zip/Inflater.java

          [adding]

          + * <p>
          + * @apiNote
          + * Earlier versions of this class overrides {@link Object#finalize} to invokes
          + * {@code end} to close the decompressor and release all resources when the instance
          + * becomes unreachable and therefor finalized. The {@code finalize} method has been
          + * removed in this version. The {@link java.lang.ref.Cleaner} is used to close the
          + * decompressor when the instance becomes phantom-reachable, if the {@code end} is
          + * not invoked explicitly.
          + * <p>

          [updating, the updated version]

              /**
                * Closes the decompressor and discards any unprocessed input.
                * This method should be called when the decompressor is no longer
                * being used. Once this method is called, the behavior of the
                * Inflater object is undefined.
                */
               public void end() {

          [removing]

          - /**
          - * Closes the decompressor when garbage is collected.
          - *
          - * @deprecated The {@code finalize} method has been deprecated.
          - * Subclasses that override {@code finalize} in order to perform cleanup
          - * should be modified to use alternative cleanup mechanisms and
          - * to remove the overriding {@code finalize} method.
          - * When overriding the {@code finalize} method, its implementation must explicitly
          - * ensure that {@code super.finalize()} is invoked as described in {@link Object#finalize}.
          - * See the specification for {@link Object#finalize()} for further
          - * information about migration options.
          - */
          - @Deprecated(since="9")
          - protected void finalize() {
          - end();
          - }

          src/java.base/share/classes/java/util/zip/ZipFile.java

          [adding]

          + * <p>
          + * @apiNote
          + * Earlier versions of this class overrides {@link Object#finalize} to invokes
          + * {@code close} to close the ZipFile object and release all system resources held
          + * by it when the instance becomes unreachable and therefor finalized. The
          + * {@code finalize} method has been removed in this version.
          + * The {@link java.lang.ref.Cleaner} is used to close the object when the instance
          + * becomes phantom-reachable, if the {@code close} is not invoked explicitly.
          + * <p>
          + * Since the time when Cleaner would clean this object is undetermined, it is
          + * strongly recommended that applications invoke the {@code close} method as soon
          + * they have finished accessing this {@code ZipFile}. This will prevent holding up
          + * system resources for an undetermined length of time.
          + * <p>
          + *


          [removing]

          - /**
          - * Ensures that the system resources held by this ZipFile object are
          - * released when there are no more references to it.
          - * <p>
          - * Since the time when GC would invoke this method is undetermined,
          - * it is strongly recommended that applications invoke the {@code close}
          - * method as soon they have finished accessing this {@code ZipFile}.
          - * This will prevent holding up system resources for an undetermined
          - * length of time.
          - *
          - * @deprecated The {@code finalize} method has been deprecated.
          - * Subclasses that override {@code finalize} in order to perform cleanup
          - * should be modified to use alternative cleanup mechanisms and
          - * to remove the overriding {@code finalize} method.
          - * When overriding the {@code finalize} method, its implementation must explicitly
          - * ensure that {@code super.finalize()} is invoked as described in {@link Object#finalize}.
          - * See the specification for {@link Object#finalize()} for further
          - * information about migration options.
          - * @throws IOException if an I/O error has occurred
          - * @see java.util.zip.ZipFile#close()
          - */
          - @Deprecated(since="9")
          - protected void finalize() throws IOException {
          Summary
          -------

          To replace the finalizer mechanism with java.lang.ref.Cleaner to close the object java.util.zip.ZipFile/Inflater/Deflater, and cleanup/release its underlying native resources when the object is no longer reachable.

          Problem
          -------

          The finalization mechanism has a history of usage and performnace issues, it is desirable the j.u.zip implementation to migrate away from its use of finalizer to the newly intorduced java.lang.ref.Cleaner.

          Solution
          --------

          To remove the overriden finalize() methods from Deflater, Inflater and ZipFile, and use Cleaner to do the resource cleanup when the object has become unreachable.

          To update the specification of the end() method (for both Deflater and Inflater) to remove the requirement that the end() "will be called by the finalizer() automatically".

          To add additional @apiNote in class javadoc for Deflater, Inflater and ZipFile to describe the spec and behavioral change.

          http://cr.openjdk.java.net/~sherman/8185582/webrev

          Specification
          -------------

          src/java.base/share/classes/java/util/zip/Deflater.java

          [adding]
          ```
          + * <p>
          + * @apiNote
          + * Earlier versions of this class overrides {@link Object#finalize} to invokes
          + * {@code end} to close the compressor and release all resources when the instance
          + * becomes unreachable and therefor finalized. The {@code finalize} method has been
          + * removed in this version. The {@link java.lang.ref.Cleaner} is used to close the
          + * compressor when the instance becomes phantom-reachable, if the {@code end} is not
          + * invoked explicitly.
          + * <p>
          + *
          ```
          [updating, the updated version]
          ```
               /**
                * Closes the compressor and discards any unprocessed input.
                * This method should be called when the compressor is no longer
                * being used. Once this method is called, the behavior of the
                * Deflater object is undefined.
                */
               public void end() {
          ```
          [removing]
          ```
          - /**
          - * Closes the compressor when garbage is collected.
          - *
          - * @deprecated The {@code finalize} method has been deprecated.
          - * Subclasses that override {@code finalize} in order to perform cleanup
          - * should be modified to use alternative cleanup mechanisms and
          - * to remove the overriding {@code finalize} method.
          - * When overriding the {@code finalize} method, its implementation must explicitly
          - * ensure that {@code super.finalize()} is invoked as described in {@link Object#finalize}.
          - * See the specification for {@link Object#finalize()} for further
          - * information about migration options.
          - */
          - @Deprecated(since="9")
          - protected void finalize() {
          - end();
          - }
          ```
          src/java.base/share/classes/java/util/zip/Inflater.java

          [adding]
          ```
          + * <p>
          + * @apiNote
          + * Earlier versions of this class overrides {@link Object#finalize} to invokes
          + * {@code end} to close the decompressor and release all resources when the instance
          + * becomes unreachable and therefor finalized. The {@code finalize} method has been
          + * removed in this version. The {@link java.lang.ref.Cleaner} is used to close the
          + * decompressor when the instance becomes phantom-reachable, if the {@code end} is
          + * not invoked explicitly.
          + * <p>
          ```
          [updating, the updated version]
          ```
              /**
                * Closes the decompressor and discards any unprocessed input.
                * This method should be called when the decompressor is no longer
                * being used. Once this method is called, the behavior of the
                * Inflater object is undefined.
                */
               public void end() {
          ```
          [removing]
          ```
          - /**
          - * Closes the decompressor when garbage is collected.
          - *
          - * @deprecated The {@code finalize} method has been deprecated.
          - * Subclasses that override {@code finalize} in order to perform cleanup
          - * should be modified to use alternative cleanup mechanisms and
          - * to remove the overriding {@code finalize} method.
          - * When overriding the {@code finalize} method, its implementation must explicitly
          - * ensure that {@code super.finalize()} is invoked as described in {@link Object#finalize}.
          - * See the specification for {@link Object#finalize()} for further
          - * information about migration options.
          - */
          - @Deprecated(since="9")
          - protected void finalize() {
          - end();
          - }
          ```
          src/java.base/share/classes/java/util/zip/ZipFile.java

          [adding]
          ```
          + * <p>
          + * @apiNote
          + * Earlier versions of this class overrides {@link Object#finalize} to invokes
          + * {@code close} to close the ZipFile object and release all system resources held
          + * by it when the instance becomes unreachable and therefor finalized. The
          + * {@code finalize} method has been removed in this version.
          + * The {@link java.lang.ref.Cleaner} is used to close the object when the instance
          + * becomes phantom-reachable, if the {@code close} is not invoked explicitly.
          + * <p>
          + * Since the time when Cleaner would clean this object is undetermined, it is
          + * strongly recommended that applications invoke the {@code close} method as soon
          + * they have finished accessing this {@code ZipFile}. This will prevent holding up
          + * system resources for an undetermined length of time.
          + * <p>
          + *
          ```

          [removing]
          ```
          - /**
          - * Ensures that the system resources held by this ZipFile object are
          - * released when there are no more references to it.
          - * <p>
          - * Since the time when GC would invoke this method is undetermined,
          - * it is strongly recommended that applications invoke the {@code close}
          - * method as soon they have finished accessing this {@code ZipFile}.
          - * This will prevent holding up system resources for an undetermined
          - * length of time.
          - *
          - * @deprecated The {@code finalize} method has been deprecated.
          - * Subclasses that override {@code finalize} in order to perform cleanup
          - * should be modified to use alternative cleanup mechanisms and
          - * to remove the overriding {@code finalize} method.
          - * When overriding the {@code finalize} method, its implementation must explicitly
          - * ensure that {@code super.finalize()} is invoked as described in {@link Object#finalize}.
          - * See the specification for {@link Object#finalize()} for further
          - * information about migration options.
          - * @throws IOException if an I/O error has occurred
          - * @see java.util.zip.ZipFile#close()
          - */
          - @Deprecated(since="9")
          - protected void finalize() throws IOException {
          ```
          rriggs Roger Riggs made changes -
          Description Summary
          -------

          To replace the finalizer mechanism with java.lang.ref.Cleaner to close the object java.util.zip.ZipFile/Inflater/Deflater, and cleanup/release its underlying native resources when the object is no longer reachable.

          Problem
          -------

          The finalization mechanism has a history of usage and performnace issues, it is desirable the j.u.zip implementation to migrate away from its use of finalizer to the newly intorduced java.lang.ref.Cleaner.

          Solution
          --------

          To remove the overriden finalize() methods from Deflater, Inflater and ZipFile, and use Cleaner to do the resource cleanup when the object has become unreachable.

          To update the specification of the end() method (for both Deflater and Inflater) to remove the requirement that the end() "will be called by the finalizer() automatically".

          To add additional @apiNote in class javadoc for Deflater, Inflater and ZipFile to describe the spec and behavioral change.

          http://cr.openjdk.java.net/~sherman/8185582/webrev

          Specification
          -------------

          src/java.base/share/classes/java/util/zip/Deflater.java

          [adding]
          ```
          + * <p>
          + * @apiNote
          + * Earlier versions of this class overrides {@link Object#finalize} to invokes
          + * {@code end} to close the compressor and release all resources when the instance
          + * becomes unreachable and therefor finalized. The {@code finalize} method has been
          + * removed in this version. The {@link java.lang.ref.Cleaner} is used to close the
          + * compressor when the instance becomes phantom-reachable, if the {@code end} is not
          + * invoked explicitly.
          + * <p>
          + *
          ```
          [updating, the updated version]
          ```
               /**
                * Closes the compressor and discards any unprocessed input.
                * This method should be called when the compressor is no longer
                * being used. Once this method is called, the behavior of the
                * Deflater object is undefined.
                */
               public void end() {
          ```
          [removing]
          ```
          - /**
          - * Closes the compressor when garbage is collected.
          - *
          - * @deprecated The {@code finalize} method has been deprecated.
          - * Subclasses that override {@code finalize} in order to perform cleanup
          - * should be modified to use alternative cleanup mechanisms and
          - * to remove the overriding {@code finalize} method.
          - * When overriding the {@code finalize} method, its implementation must explicitly
          - * ensure that {@code super.finalize()} is invoked as described in {@link Object#finalize}.
          - * See the specification for {@link Object#finalize()} for further
          - * information about migration options.
          - */
          - @Deprecated(since="9")
          - protected void finalize() {
          - end();
          - }
          ```
          src/java.base/share/classes/java/util/zip/Inflater.java

          [adding]
          ```
          + * <p>
          + * @apiNote
          + * Earlier versions of this class overrides {@link Object#finalize} to invokes
          + * {@code end} to close the decompressor and release all resources when the instance
          + * becomes unreachable and therefor finalized. The {@code finalize} method has been
          + * removed in this version. The {@link java.lang.ref.Cleaner} is used to close the
          + * decompressor when the instance becomes phantom-reachable, if the {@code end} is
          + * not invoked explicitly.
          + * <p>
          ```
          [updating, the updated version]
          ```
              /**
                * Closes the decompressor and discards any unprocessed input.
                * This method should be called when the decompressor is no longer
                * being used. Once this method is called, the behavior of the
                * Inflater object is undefined.
                */
               public void end() {
          ```
          [removing]
          ```
          - /**
          - * Closes the decompressor when garbage is collected.
          - *
          - * @deprecated The {@code finalize} method has been deprecated.
          - * Subclasses that override {@code finalize} in order to perform cleanup
          - * should be modified to use alternative cleanup mechanisms and
          - * to remove the overriding {@code finalize} method.
          - * When overriding the {@code finalize} method, its implementation must explicitly
          - * ensure that {@code super.finalize()} is invoked as described in {@link Object#finalize}.
          - * See the specification for {@link Object#finalize()} for further
          - * information about migration options.
          - */
          - @Deprecated(since="9")
          - protected void finalize() {
          - end();
          - }
          ```
          src/java.base/share/classes/java/util/zip/ZipFile.java

          [adding]
          ```
          + * <p>
          + * @apiNote
          + * Earlier versions of this class overrides {@link Object#finalize} to invokes
          + * {@code close} to close the ZipFile object and release all system resources held
          + * by it when the instance becomes unreachable and therefor finalized. The
          + * {@code finalize} method has been removed in this version.
          + * The {@link java.lang.ref.Cleaner} is used to close the object when the instance
          + * becomes phantom-reachable, if the {@code close} is not invoked explicitly.
          + * <p>
          + * Since the time when Cleaner would clean this object is undetermined, it is
          + * strongly recommended that applications invoke the {@code close} method as soon
          + * they have finished accessing this {@code ZipFile}. This will prevent holding up
          + * system resources for an undetermined length of time.
          + * <p>
          + *
          ```

          [removing]
          ```
          - /**
          - * Ensures that the system resources held by this ZipFile object are
          - * released when there are no more references to it.
          - * <p>
          - * Since the time when GC would invoke this method is undetermined,
          - * it is strongly recommended that applications invoke the {@code close}
          - * method as soon they have finished accessing this {@code ZipFile}.
          - * This will prevent holding up system resources for an undetermined
          - * length of time.
          - *
          - * @deprecated The {@code finalize} method has been deprecated.
          - * Subclasses that override {@code finalize} in order to perform cleanup
          - * should be modified to use alternative cleanup mechanisms and
          - * to remove the overriding {@code finalize} method.
          - * When overriding the {@code finalize} method, its implementation must explicitly
          - * ensure that {@code super.finalize()} is invoked as described in {@link Object#finalize}.
          - * See the specification for {@link Object#finalize()} for further
          - * information about migration options.
          - * @throws IOException if an I/O error has occurred
          - * @see java.util.zip.ZipFile#close()
          - */
          - @Deprecated(since="9")
          - protected void finalize() throws IOException {
          ```
          Summary
          -------

          To replace the finalizer mechanism with java.lang.ref.Cleaner to close the object java.util.zip.ZipFile/Inflater/Deflater, and cleanup/release its underlying native resources when the object is no longer reachable.

          Problem
          -------

          The finalization mechanism has a history of usage and performnace issues, it is desirable the j.u.zip implementation to migrate away from its use of finalizer to the newly introduced java.lang.ref.Cleaner.

          Solution
          --------

          To remove the overriden finalize() methods from Deflater, Inflater and ZipFile, and use Cleaner to do the resource cleanup when the object has become unreachable.

          To update the specification of the end() method (for both Deflater and Inflater) to remove the requirement that the end() "will be called by the finalizer() automatically".

          To add additional @apiNote in class javadoc for Deflater, Inflater and ZipFile to describe the spec and behavioral change.

          http://cr.openjdk.java.net/~sherman/8185582/webrev

          Specification
          -------------

          src/java.base/share/classes/java/util/zip/Deflater.java

          [adding]
          ```
          + * <p>
          + * @apiNote
          + * Earlier versions of this class overrides {@link Object#finalize} to invokes
          + * {@code end} to close the compressor and release all resources when the instance
          + * becomes unreachable and therefor finalized. The {@code finalize} method has been
          + * removed in this version. The {@link java.lang.ref.Cleaner} is used to close the
          + * compressor when the instance becomes phantom-reachable, if the {@code end} is not
          + * invoked explicitly.
          + * <p>
          + *
          ```
          [updating, the updated version]
          ```
               /**
                * Closes the compressor and discards any unprocessed input.
                * This method should be called when the compressor is no longer
                * being used. Once this method is called, the behavior of the
                * Deflater object is undefined.
                */
               public void end() {
          ```
          [removing]
          ```
          - /**
          - * Closes the compressor when garbage is collected.
          - *
          - * @deprecated The {@code finalize} method has been deprecated.
          - * Subclasses that override {@code finalize} in order to perform cleanup
          - * should be modified to use alternative cleanup mechanisms and
          - * to remove the overriding {@code finalize} method.
          - * When overriding the {@code finalize} method, its implementation must explicitly
          - * ensure that {@code super.finalize()} is invoked as described in {@link Object#finalize}.
          - * See the specification for {@link Object#finalize()} for further
          - * information about migration options.
          - */
          - @Deprecated(since="9")
          - protected void finalize() {
          - end();
          - }
          ```
          src/java.base/share/classes/java/util/zip/Inflater.java

          [adding]
          ```
          + * <p>
          + * @apiNote
          + * Earlier versions of this class overrides {@link Object#finalize} to invokes
          + * {@code end} to close the decompressor and release all resources when the instance
          + * becomes unreachable and therefor finalized. The {@code finalize} method has been
          + * removed in this version. The {@link java.lang.ref.Cleaner} is used to close the
          + * decompressor when the instance becomes phantom-reachable, if the {@code end} is
          + * not invoked explicitly.
          + * <p>
          ```
          [updating, the updated version]
          ```
              /**
                * Closes the decompressor and discards any unprocessed input.
                * This method should be called when the decompressor is no longer
                * being used. Once this method is called, the behavior of the
                * Inflater object is undefined.
                */
               public void end() {
          ```
          [removing]
          ```
          - /**
          - * Closes the decompressor when garbage is collected.
          - *
          - * @deprecated The {@code finalize} method has been deprecated.
          - * Subclasses that override {@code finalize} in order to perform cleanup
          - * should be modified to use alternative cleanup mechanisms and
          - * to remove the overriding {@code finalize} method.
          - * When overriding the {@code finalize} method, its implementation must explicitly
          - * ensure that {@code super.finalize()} is invoked as described in {@link Object#finalize}.
          - * See the specification for {@link Object#finalize()} for further
          - * information about migration options.
          - */
          - @Deprecated(since="9")
          - protected void finalize() {
          - end();
          - }
          ```
          src/java.base/share/classes/java/util/zip/ZipFile.java

          [adding]
          ```
          + * <p>
          + * @apiNote
          + * Earlier versions of this class overrides {@link Object#finalize} to invokes
          + * {@code close} to close the ZipFile object and release all system resources held
          + * by it when the instance becomes unreachable and therefor finalized. The
          + * {@code finalize} method has been removed in this version.
          + * The {@link java.lang.ref.Cleaner} is used to close the object when the instance
          + * becomes phantom-reachable, if the {@code close} is not invoked explicitly.
          + * <p>
          + * Since the time when Cleaner would clean this object is undetermined, it is
          + * strongly recommended that applications invoke the {@code close} method as soon
          + * they have finished accessing this {@code ZipFile}. This will prevent holding up
          + * system resources for an undetermined length of time.
          + * <p>
          + *
          ```

          [removing]
          ```
          - /**
          - * Ensures that the system resources held by this ZipFile object are
          - * released when there are no more references to it.
          - * <p>
          - * Since the time when GC would invoke this method is undetermined,
          - * it is strongly recommended that applications invoke the {@code close}
          - * method as soon they have finished accessing this {@code ZipFile}.
          - * This will prevent holding up system resources for an undetermined
          - * length of time.
          - *
          - * @deprecated The {@code finalize} method has been deprecated.
          - * Subclasses that override {@code finalize} in order to perform cleanup
          - * should be modified to use alternative cleanup mechanisms and
          - * to remove the overriding {@code finalize} method.
          - * When overriding the {@code finalize} method, its implementation must explicitly
          - * ensure that {@code super.finalize()} is invoked as described in {@link Object#finalize}.
          - * See the specification for {@link Object#finalize()} for further
          - * information about migration options.
          - * @throws IOException if an I/O error has occurred
          - * @see java.util.zip.ZipFile#close()
          - */
          - @Deprecated(since="9")
          - protected void finalize() throws IOException {
          ```
          sherman Xueming Shen made changes -
          Interface Kind Java API [ 19803 ]
          Compatibility Kind source,behavioral [ 19800, 19802 ]
          sherman Xueming Shen made changes -
          Description Summary
          -------

          To replace the finalizer mechanism with java.lang.ref.Cleaner to close the object java.util.zip.ZipFile/Inflater/Deflater, and cleanup/release its underlying native resources when the object is no longer reachable.

          Problem
          -------

          The finalization mechanism has a history of usage and performnace issues, it is desirable the j.u.zip implementation to migrate away from its use of finalizer to the newly introduced java.lang.ref.Cleaner.

          Solution
          --------

          To remove the overriden finalize() methods from Deflater, Inflater and ZipFile, and use Cleaner to do the resource cleanup when the object has become unreachable.

          To update the specification of the end() method (for both Deflater and Inflater) to remove the requirement that the end() "will be called by the finalizer() automatically".

          To add additional @apiNote in class javadoc for Deflater, Inflater and ZipFile to describe the spec and behavioral change.

          http://cr.openjdk.java.net/~sherman/8185582/webrev

          Specification
          -------------

          src/java.base/share/classes/java/util/zip/Deflater.java

          [adding]
          ```
          + * <p>
          + * @apiNote
          + * Earlier versions of this class overrides {@link Object#finalize} to invokes
          + * {@code end} to close the compressor and release all resources when the instance
          + * becomes unreachable and therefor finalized. The {@code finalize} method has been
          + * removed in this version. The {@link java.lang.ref.Cleaner} is used to close the
          + * compressor when the instance becomes phantom-reachable, if the {@code end} is not
          + * invoked explicitly.
          + * <p>
          + *
          ```
          [updating, the updated version]
          ```
               /**
                * Closes the compressor and discards any unprocessed input.
                * This method should be called when the compressor is no longer
                * being used. Once this method is called, the behavior of the
                * Deflater object is undefined.
                */
               public void end() {
          ```
          [removing]
          ```
          - /**
          - * Closes the compressor when garbage is collected.
          - *
          - * @deprecated The {@code finalize} method has been deprecated.
          - * Subclasses that override {@code finalize} in order to perform cleanup
          - * should be modified to use alternative cleanup mechanisms and
          - * to remove the overriding {@code finalize} method.
          - * When overriding the {@code finalize} method, its implementation must explicitly
          - * ensure that {@code super.finalize()} is invoked as described in {@link Object#finalize}.
          - * See the specification for {@link Object#finalize()} for further
          - * information about migration options.
          - */
          - @Deprecated(since="9")
          - protected void finalize() {
          - end();
          - }
          ```
          src/java.base/share/classes/java/util/zip/Inflater.java

          [adding]
          ```
          + * <p>
          + * @apiNote
          + * Earlier versions of this class overrides {@link Object#finalize} to invokes
          + * {@code end} to close the decompressor and release all resources when the instance
          + * becomes unreachable and therefor finalized. The {@code finalize} method has been
          + * removed in this version. The {@link java.lang.ref.Cleaner} is used to close the
          + * decompressor when the instance becomes phantom-reachable, if the {@code end} is
          + * not invoked explicitly.
          + * <p>
          ```
          [updating, the updated version]
          ```
              /**
                * Closes the decompressor and discards any unprocessed input.
                * This method should be called when the decompressor is no longer
                * being used. Once this method is called, the behavior of the
                * Inflater object is undefined.
                */
               public void end() {
          ```
          [removing]
          ```
          - /**
          - * Closes the decompressor when garbage is collected.
          - *
          - * @deprecated The {@code finalize} method has been deprecated.
          - * Subclasses that override {@code finalize} in order to perform cleanup
          - * should be modified to use alternative cleanup mechanisms and
          - * to remove the overriding {@code finalize} method.
          - * When overriding the {@code finalize} method, its implementation must explicitly
          - * ensure that {@code super.finalize()} is invoked as described in {@link Object#finalize}.
          - * See the specification for {@link Object#finalize()} for further
          - * information about migration options.
          - */
          - @Deprecated(since="9")
          - protected void finalize() {
          - end();
          - }
          ```
          src/java.base/share/classes/java/util/zip/ZipFile.java

          [adding]
          ```
          + * <p>
          + * @apiNote
          + * Earlier versions of this class overrides {@link Object#finalize} to invokes
          + * {@code close} to close the ZipFile object and release all system resources held
          + * by it when the instance becomes unreachable and therefor finalized. The
          + * {@code finalize} method has been removed in this version.
          + * The {@link java.lang.ref.Cleaner} is used to close the object when the instance
          + * becomes phantom-reachable, if the {@code close} is not invoked explicitly.
          + * <p>
          + * Since the time when Cleaner would clean this object is undetermined, it is
          + * strongly recommended that applications invoke the {@code close} method as soon
          + * they have finished accessing this {@code ZipFile}. This will prevent holding up
          + * system resources for an undetermined length of time.
          + * <p>
          + *
          ```

          [removing]
          ```
          - /**
          - * Ensures that the system resources held by this ZipFile object are
          - * released when there are no more references to it.
          - * <p>
          - * Since the time when GC would invoke this method is undetermined,
          - * it is strongly recommended that applications invoke the {@code close}
          - * method as soon they have finished accessing this {@code ZipFile}.
          - * This will prevent holding up system resources for an undetermined
          - * length of time.
          - *
          - * @deprecated The {@code finalize} method has been deprecated.
          - * Subclasses that override {@code finalize} in order to perform cleanup
          - * should be modified to use alternative cleanup mechanisms and
          - * to remove the overriding {@code finalize} method.
          - * When overriding the {@code finalize} method, its implementation must explicitly
          - * ensure that {@code super.finalize()} is invoked as described in {@link Object#finalize}.
          - * See the specification for {@link Object#finalize()} for further
          - * information about migration options.
          - * @throws IOException if an I/O error has occurred
          - * @see java.util.zip.ZipFile#close()
          - */
          - @Deprecated(since="9")
          - protected void finalize() throws IOException {
          ```
          Summary
          -------

          To replace the finalizer mechanism with java.lang.ref.Cleaner to close the object java.util.zip.ZipFile/Inflater/Deflater, and cleanup/release its underlying native resources when the object is no longer reachable.

          Problem
          -------

          The finalization mechanism has a history of usage and performnace issues, it is desirable the j.u.zip implementation to migrate away from its use of finalizer to the newly introduced java.lang.ref.Cleaner.

          Solution
          --------

          To remove the overriden finalize() methods from Deflater, Inflater and ZipFile, and use Cleaner to do the resource cleanup when the object has become unreachable.

          To update the specification of the end() method (for both Deflater and Inflater) to remove the requirement that the end() "will be called by the finalizer() automatically".

          To add additional @apiNote in class javadoc for Deflater, Inflater and ZipFile to describe the spec and behavioral change.

          http://cr.openjdk.java.net/~sherman/8185582/webrev

          Specification
          -------------

          src/java.base/share/classes/java/util/zip/Deflater.java

          [adding]
          ```
          + * <p>
          + * @apiNote
          + * Earlier versions of this class override {@link Object#finalize} to invoke
          + * {@code end} to close the compressor and release all resources when the instance
          + * becomes unreachable and therefore finalized. The {@code finalize} method has been
          + * removed in this version. The resources of the compressor will be released when the
          + * instance becomes phantom-reachable, if the {@code end} is not invoked explicitly.
          + * <p>
          + *
          ```
          [updating]
          ```
               /**
                * Closes the compressor and discards any unprocessed input.
                * This method should be called when the compressor is no longer
          - * being used, but will also be called automatically by the
          - * finalize() method. Once this method is called, the behavior
          - * of the Deflater object is undefined.
          + * being used. Once this method is called, the behavior of the
          + * Deflater object is undefined.
                */
               public void end() {
          ```
          [removing]
          ```
          - /**
          - * Closes the compressor when garbage is collected.
          - *
          - * @deprecated The {@code finalize} method has been deprecated.
          - * Subclasses that override {@code finalize} in order to perform cleanup
          - * should be modified to use alternative cleanup mechanisms and
          - * to remove the overriding {@code finalize} method.
          - * When overriding the {@code finalize} method, its implementation must explicitly
          - * ensure that {@code super.finalize()} is invoked as described in {@link Object#finalize}.
          - * See the specification for {@link Object#finalize()} for further
          - * information about migration options.
          - */
          - @Deprecated(since="9")
          - protected void finalize() {
          - end();
          - }
          ```
          src/java.base/share/classes/java/util/zip/Inflater.java

          [adding]
          ```
          + * <p>
          + * @apiNote
          + * Earlier versions of this class override {@link Object#finalize} to invoke
          + * {@code end} to close the decompressor and release all resources when the instance
          + * becomes unreachable and therefore finalized. The {@code finalize} method has been
          + * removed in this version. The resources of the compressor will be released when the
          + * instance becomes phantom-reachable, if the {@code end} is not invoked explicitly.
          + * <p>
          ```
          [updating]
          ```
               /**
                * Closes the decompressor and discards any unprocessed input.
                * This method should be called when the decompressor is no longer
          - * being used, but will also be called automatically by the finalize()
          - * method. Once this method is called, the behavior of the Inflater
          - * object is undefined.
          + * being used. Once this method is called, the behavior of the
          + * Inflater object is undefined.
                */
               public void end() {
          ```
          [removing]
          ```
          - /**
          - * Closes the decompressor when garbage is collected.
          - *
          - * @deprecated The {@code finalize} method has been deprecated.
          - * Subclasses that override {@code finalize} in order to perform cleanup
          - * should be modified to use alternative cleanup mechanisms and
          - * to remove the overriding {@code finalize} method.
          - * When overriding the {@code finalize} method, its implementation must explicitly
          - * ensure that {@code super.finalize()} is invoked as described in {@link Object#finalize}.
          - * See the specification for {@link Object#finalize()} for further
          - * information about migration options.
          - */
          - @Deprecated(since="9")
          - protected void finalize() {
          - end();
          - }
          ```
          src/java.base/share/classes/java/util/zip/ZipFile.java

          [adding]
          ```
          + * <p>
          + * @apiNote
          + * Earlier versions of this class override {@link Object#finalize} to invoke
          + * {@code close} to close the ZipFile object and release all system resources held
          + * by it when the instance becomes unreachable and therefore finalized. The
          + * {@code finalize} method has been removed in this version.
          + * The resources held by this object will be released when the instance becomes
          + * phantom-reachable, if the {@code close} is not invoked explicitly.
          + * <p>
          + *
          ```
          [updating]
          ```
          + * <p>
          + * Since the time when the resources held by this object will be released
          + * is undetermined, if this method is not invoked explicitly, it is strongly
          + * recommended that applications invoke this method as soon they have
          + * finished accessing this {@code ZipFile}. This will prevent holding up
          + * system resources for an undetermined length of time.
          + * <p>
          + *
          + * @throws IOException if an I/O error has occurred
          + */
          + public void close() throws IOException {
          + if (closeRequested) {
          ```
          [removing]
          ```
          - /**
          - * Ensures that the system resources held by this ZipFile object are
          - * released when there are no more references to it.
          - * <p>
          - * Since the time when GC would invoke this method is undetermined,
          - * it is strongly recommended that applications invoke the {@code close}
          - * method as soon they have finished accessing this {@code ZipFile}.
          - * This will prevent holding up system resources for an undetermined
          - * length of time.
          - *
          - * @deprecated The {@code finalize} method has been deprecated.
          - * Subclasses that override {@code finalize} in order to perform cleanup
          - * should be modified to use alternative cleanup mechanisms and
          - * to remove the overriding {@code finalize} method.
          - * When overriding the {@code finalize} method, its implementation must explicitly
          - * ensure that {@code super.finalize()} is invoked as described in {@link Object#finalize}.
          - * See the specification for {@link Object#finalize()} for further
          - * information about migration options.
          - * @throws IOException if an I/O error has occurred
          - * @see java.util.zip.ZipFile#close()
          - */
          - @Deprecated(since="9")
          - protected void finalize() throws IOException {
          ```
          rriggs Roger Riggs made changes -
          Reviewed By Roger Riggs [ rriggs ]
          sherman Xueming Shen made changes -
          Compatibility Risk Description Both Deflater and Inflater's end() method have the specification wordings as "... will also be called automatically by the finalize() method"

           public void end() {
               ...
               end(addr);
               ...
           }

          And for the ZipFile, even the specification is not specified that its inflater() method will call close(), its implementation currently does just that.

          protected void finalize() throws IOException {
              close();
          }

          Give that there are two kinds of "incompatible risk" caused by the proposed changes

          (1) Behavioral incompatibility

          It's possilbe that there are existing subclasses (of Deflater, Inflater and ZipFile) over there that has the dependency on the existing behavior, in which the "end()/close()" method is being invoked during finalization. Those subclasses might override the "end()/close() with some additional implementation logic with the expection that these additioanl logic will be executed when the object is being gc-ed. With this change, it no longer happens.

          (2) Source incompatiblity

          Inflater/Deflater.finalize() does not throw any exception
          ZipFile.finalize() only throws IOException.

          With the removal() of finalize() from Deflater, Inflater and ZipFile, any existing subclass (of these 3 classes) that overrides finalize() might not be compiled anymore as now their overriding finalize() needs to catch the "Throwable" from Object.finalize().

          It is believed that the compatibility risk should be low but marked as medium because it is uncertain how existing applications depend on these behaviors.
          Both Deflater and Inflater's end() method have the specification wordings as "... will also be called automatically by the finalize() method"

           public void end() {
               ...
               end(addr);
               ...
           }

          And for the ZipFile, even the specification is not specified that its inflater() method will call close(), its implementation currently does just that.

          protected void finalize() throws IOException {
              close();
          }

          Give that there are two kinds of "incompatible risk" caused by the proposed changes

          (1) Behavioral incompatibility

          It's possilbe that there are existing subclasses (of Deflater, Inflater and ZipFile) over there that has the dependency on the existing behavior, in which the "end()/close()" method is being invoked during finalization. Those subclasses might override the "end()/close() with some additional implementation logic with the expection that these additional logic will be executed when the object is being gc-ed. With this change, it no longer happens.

          (2) Source incompatiblity

          Inflater/Deflater.finalize() does not throw any exception
          ZipFile.finalize() only throws IOException.

          With the removal() of finalize() from Deflater, Inflater and ZipFile, any existing subclass (of these 3 classes) that overrides finalize() might not be compiled anymore as now their overriding finalize() needs to catch the "Throwable" from Object.finalize().

          It is believed that the compatibility risk should be low but marked as medium because it is uncertain how existing applications depend on these behaviors.
          sherman Xueming Shen made changes -
          Description Summary
          -------

          To replace the finalizer mechanism with java.lang.ref.Cleaner to close the object java.util.zip.ZipFile/Inflater/Deflater, and cleanup/release its underlying native resources when the object is no longer reachable.

          Problem
          -------

          The finalization mechanism has a history of usage and performnace issues, it is desirable the j.u.zip implementation to migrate away from its use of finalizer to the newly introduced java.lang.ref.Cleaner.

          Solution
          --------

          To remove the overriden finalize() methods from Deflater, Inflater and ZipFile, and use Cleaner to do the resource cleanup when the object has become unreachable.

          To update the specification of the end() method (for both Deflater and Inflater) to remove the requirement that the end() "will be called by the finalizer() automatically".

          To add additional @apiNote in class javadoc for Deflater, Inflater and ZipFile to describe the spec and behavioral change.

          http://cr.openjdk.java.net/~sherman/8185582/webrev

          Specification
          -------------

          src/java.base/share/classes/java/util/zip/Deflater.java

          [adding]
          ```
          + * <p>
          + * @apiNote
          + * Earlier versions of this class override {@link Object#finalize} to invoke
          + * {@code end} to close the compressor and release all resources when the instance
          + * becomes unreachable and therefore finalized. The {@code finalize} method has been
          + * removed in this version. The resources of the compressor will be released when the
          + * instance becomes phantom-reachable, if the {@code end} is not invoked explicitly.
          + * <p>
          + *
          ```
          [updating]
          ```
               /**
                * Closes the compressor and discards any unprocessed input.
                * This method should be called when the compressor is no longer
          - * being used, but will also be called automatically by the
          - * finalize() method. Once this method is called, the behavior
          - * of the Deflater object is undefined.
          + * being used. Once this method is called, the behavior of the
          + * Deflater object is undefined.
                */
               public void end() {
          ```
          [removing]
          ```
          - /**
          - * Closes the compressor when garbage is collected.
          - *
          - * @deprecated The {@code finalize} method has been deprecated.
          - * Subclasses that override {@code finalize} in order to perform cleanup
          - * should be modified to use alternative cleanup mechanisms and
          - * to remove the overriding {@code finalize} method.
          - * When overriding the {@code finalize} method, its implementation must explicitly
          - * ensure that {@code super.finalize()} is invoked as described in {@link Object#finalize}.
          - * See the specification for {@link Object#finalize()} for further
          - * information about migration options.
          - */
          - @Deprecated(since="9")
          - protected void finalize() {
          - end();
          - }
          ```
          src/java.base/share/classes/java/util/zip/Inflater.java

          [adding]
          ```
          + * <p>
          + * @apiNote
          + * Earlier versions of this class override {@link Object#finalize} to invoke
          + * {@code end} to close the decompressor and release all resources when the instance
          + * becomes unreachable and therefore finalized. The {@code finalize} method has been
          + * removed in this version. The resources of the compressor will be released when the
          + * instance becomes phantom-reachable, if the {@code end} is not invoked explicitly.
          + * <p>
          ```
          [updating]
          ```
               /**
                * Closes the decompressor and discards any unprocessed input.
                * This method should be called when the decompressor is no longer
          - * being used, but will also be called automatically by the finalize()
          - * method. Once this method is called, the behavior of the Inflater
          - * object is undefined.
          + * being used. Once this method is called, the behavior of the
          + * Inflater object is undefined.
                */
               public void end() {
          ```
          [removing]
          ```
          - /**
          - * Closes the decompressor when garbage is collected.
          - *
          - * @deprecated The {@code finalize} method has been deprecated.
          - * Subclasses that override {@code finalize} in order to perform cleanup
          - * should be modified to use alternative cleanup mechanisms and
          - * to remove the overriding {@code finalize} method.
          - * When overriding the {@code finalize} method, its implementation must explicitly
          - * ensure that {@code super.finalize()} is invoked as described in {@link Object#finalize}.
          - * See the specification for {@link Object#finalize()} for further
          - * information about migration options.
          - */
          - @Deprecated(since="9")
          - protected void finalize() {
          - end();
          - }
          ```
          src/java.base/share/classes/java/util/zip/ZipFile.java

          [adding]
          ```
          + * <p>
          + * @apiNote
          + * Earlier versions of this class override {@link Object#finalize} to invoke
          + * {@code close} to close the ZipFile object and release all system resources held
          + * by it when the instance becomes unreachable and therefore finalized. The
          + * {@code finalize} method has been removed in this version.
          + * The resources held by this object will be released when the instance becomes
          + * phantom-reachable, if the {@code close} is not invoked explicitly.
          + * <p>
          + *
          ```
          [updating]
          ```
          + * <p>
          + * Since the time when the resources held by this object will be released
          + * is undetermined, if this method is not invoked explicitly, it is strongly
          + * recommended that applications invoke this method as soon they have
          + * finished accessing this {@code ZipFile}. This will prevent holding up
          + * system resources for an undetermined length of time.
          + * <p>
          + *
          + * @throws IOException if an I/O error has occurred
          + */
          + public void close() throws IOException {
          + if (closeRequested) {
          ```
          [removing]
          ```
          - /**
          - * Ensures that the system resources held by this ZipFile object are
          - * released when there are no more references to it.
          - * <p>
          - * Since the time when GC would invoke this method is undetermined,
          - * it is strongly recommended that applications invoke the {@code close}
          - * method as soon they have finished accessing this {@code ZipFile}.
          - * This will prevent holding up system resources for an undetermined
          - * length of time.
          - *
          - * @deprecated The {@code finalize} method has been deprecated.
          - * Subclasses that override {@code finalize} in order to perform cleanup
          - * should be modified to use alternative cleanup mechanisms and
          - * to remove the overriding {@code finalize} method.
          - * When overriding the {@code finalize} method, its implementation must explicitly
          - * ensure that {@code super.finalize()} is invoked as described in {@link Object#finalize}.
          - * See the specification for {@link Object#finalize()} for further
          - * information about migration options.
          - * @throws IOException if an I/O error has occurred
          - * @see java.util.zip.ZipFile#close()
          - */
          - @Deprecated(since="9")
          - protected void finalize() throws IOException {
          ```
          Summary
          -------

          To replace the finalizer mechanism with java.lang.ref.Cleaner to close the object java.util.zip.ZipFile/Inflater/Deflater, and cleanup/release its underlying native resources when the object is no longer reachable.

          Problem
          -------

          The finalization mechanism has a history of usage and performnace issues, it is desirable the j.u.zip implementation to migrate away from its use of finalizer to the newly introduced java.lang.ref.Cleaner.

          Solution
          --------

          To remove the overridden finalize() methods from Deflater, Inflater and ZipFile, and use Cleaner to do the resource cleanup when the object has become unreachable.

          To update the specification of the end() method (for both Deflater and Inflater) to remove the requirement that the end() "will be called by the finalizer() automatically".

          To add additional @apiNote in class javadoc for Deflater, Inflater and ZipFile to describe the spec and behavioral change.

          http://cr.openjdk.java.net/~sherman/8185582/webrev

          Specification
          -------------

          src/java.base/share/classes/java/util/zip/Deflater.java

          [adding]
          ```
          + * <p>
          + * In previous releases the {@link Object#finalize} method was overridden and
          + * specified to invoke the {@code end} method to close the compressor and release
          + * its resource when the instance becomes unreachable and therefore finalized.
          + * The {@code finalize} method is no longer defined.
          + *
          + * @implNote
          + * The resource of the compressor will be released when the instance becomes
          + * phantom-reachable, if the {@code end} is not invoked explicitly.
          + * <p>
          + *
          ```
          [updating]
          ```
               /**
                * Closes the compressor and discards any unprocessed input.
                * This method should be called when the compressor is no longer
          - * being used, but will also be called automatically by the
          - * finalize() method. Once this method is called, the behavior
          - * of the Deflater object is undefined.
          + * being used. Once this method is called, the behavior of the
          + * Deflater object is undefined.
                */
               public void end() {
          ```
          [removing]
          ```
          - /**
          - * Closes the compressor when garbage is collected.
          - *
          - * @deprecated The {@code finalize} method has been deprecated.
          - * Subclasses that override {@code finalize} in order to perform cleanup
          - * should be modified to use alternative cleanup mechanisms and
          - * to remove the overriding {@code finalize} method.
          - * When overriding the {@code finalize} method, its implementation must explicitly
          - * ensure that {@code super.finalize()} is invoked as described in {@link Object#finalize}.
          - * See the specification for {@link Object#finalize()} for further
          - * information about migration options.
          - */
          - @Deprecated(since="9")
          - protected void finalize() {
          - end();
          - }
          ```
          src/java.base/share/classes/java/util/zip/Inflater.java

          [adding]
          ```
          + * <p>
          + * @apiNote
          + * In previous releases the {@link Object#finalize} method was overridden and
          + * specified to invoke the {@code end} method to close the decompressor and release
          + * its resource when the instance becomes unreachable and therefore finalized.
          + * The {@code finalize} method is no longer defined.
          + *
          + * @implNote
          + * The resource of the decompressor will be released when the instance becomes
          + * phantom-reachable, if the {@code end} is not invoked explicitly.
          + * <p>
          + *
          ```
          [updating]
          ```
               /**
                * Closes the decompressor and discards any unprocessed input.
                * This method should be called when the decompressor is no longer
          - * being used, but will also be called automatically by the finalize()
          - * method. Once this method is called, the behavior of the Inflater
          - * object is undefined.
          + * being used. Once this method is called, the behavior of the
          + * Inflater object is undefined.
                */
               public void end() {
          ```
          [removing]
          ```
          - /**
          - * Closes the decompressor when garbage is collected.
          - *
          - * @deprecated The {@code finalize} method has been deprecated.
          - * Subclasses that override {@code finalize} in order to perform cleanup
          - * should be modified to use alternative cleanup mechanisms and
          - * to remove the overriding {@code finalize} method.
          - * When overriding the {@code finalize} method, its implementation must explicitly
          - * ensure that {@code super.finalize()} is invoked as described in {@link Object#finalize}.
          - * See the specification for {@link Object#finalize()} for further
          - * information about migration options.
          - */
          - @Deprecated(since="9")
          - protected void finalize() {
          - end();
          - }
          ```
          src/java.base/share/classes/java/util/zip/ZipFile.java

          [adding]
          ```
          + * <p>
          + * @apiNote
          + * The {@link Object#finalize} method was overridden and specified in previous
          + * releases to close the ZipFile object and release its system resource when
          + * the instance becomes unreachable and therefore finalized. The {@code finalize}
          + * method is no longer defined.
          + *
          + * @implNote
          + * The resources held by this object will be released when the instance becomes
          + * phantom-reachable, if the {@code close} is not invoked explicitly.
          + * <p>
          + *
          ```
          [updating]
          ```
          + * <p>
          + * Since the time when the resources held by this object will be released
          + * is undetermined, if this method is not invoked explicitly, it is strongly
          + * recommended that applications invoke this method as soon they have
          + * finished accessing this {@code ZipFile}. This will prevent holding up
          + * system resources for an undetermined length of time.
          + * <p>
          + *
          + * @throws IOException if an I/O error has occurred
          + */
          + public void close() throws IOException {
          + if (closeRequested) {
          ```
          [removing]
          ```
          - /**
          - * Ensures that the system resources held by this ZipFile object are
          - * released when there are no more references to it.
          - * <p>
          - * Since the time when GC would invoke this method is undetermined,
          - * it is strongly recommended that applications invoke the {@code close}
          - * method as soon they have finished accessing this {@code ZipFile}.
          - * This will prevent holding up system resources for an undetermined
          - * length of time.
          - *
          - * @deprecated The {@code finalize} method has been deprecated.
          - * Subclasses that override {@code finalize} in order to perform cleanup
          - * should be modified to use alternative cleanup mechanisms and
          - * to remove the overriding {@code finalize} method.
          - * When overriding the {@code finalize} method, its implementation must explicitly
          - * ensure that {@code super.finalize()} is invoked as described in {@link Object#finalize}.
          - * See the specification for {@link Object#finalize()} for further
          - * information about migration options.
          - * @throws IOException if an I/O error has occurred
          - * @see java.util.zip.ZipFile#close()
          - */
          - @Deprecated(since="9")
          - protected void finalize() throws IOException {
          ```
          sherman Xueming Shen made changes -
          Compatibility Risk Description Both Deflater and Inflater's end() method have the specification wordings as "... will also be called automatically by the finalize() method"

           public void end() {
               ...
               end(addr);
               ...
           }

          And for the ZipFile, even the specification is not specified that its inflater() method will call close(), its implementation currently does just that.

          protected void finalize() throws IOException {
              close();
          }

          Give that there are two kinds of "incompatible risk" caused by the proposed changes

          (1) Behavioral incompatibility

          It's possilbe that there are existing subclasses (of Deflater, Inflater and ZipFile) over there that has the dependency on the existing behavior, in which the "end()/close()" method is being invoked during finalization. Those subclasses might override the "end()/close() with some additional implementation logic with the expection that these additional logic will be executed when the object is being gc-ed. With this change, it no longer happens.

          (2) Source incompatiblity

          Inflater/Deflater.finalize() does not throw any exception
          ZipFile.finalize() only throws IOException.

          With the removal() of finalize() from Deflater, Inflater and ZipFile, any existing subclass (of these 3 classes) that overrides finalize() might not be compiled anymore as now their overriding finalize() needs to catch the "Throwable" from Object.finalize().

          It is believed that the compatibility risk should be low but marked as medium because it is uncertain how existing applications depend on these behaviors.
          Both Deflater and Inflater's end() method have the specification wordings as "... will also be called automatically by the finalize() method"

           public void end() {
               ...
               end(addr);
               ...
           }

          And for the ZipFile, even the specification is not specified that its inflater() method will call close(), its implementation currently does just that.

          protected void finalize() throws IOException {
              close();
          }

          Give that there are two kinds of "incompatible risk" caused by the proposed changes

          (1) Behavioral incompatibility

          It's possilbe that there are existing subclasses (of Deflater, Inflater and ZipFile) over there that has the dependency on the existing behavior, in which the "end()/close()" method is being invoked during finalization. Those subclasses might override the "end()/close() with some additional implementation logic with the expection that these additional logic will be executed when the object is being gc-ed. With this change, it no longer happens.

          To solve this problem the subclass can override the finalize() and invoke the corresponding end() or close() directly in it. Or it might be desired to consider to use the java.lang.ref.Cleaner as well in its implementation to do the last cleanup work.

          (2) Source incompatiblity

          Inflater/Deflater.finalize() does not throw any exception
          ZipFile.finalize() only throws IOException.

          With the removal() of finalize() from Deflater, Inflater and ZipFile, any existing subclass (of these 3 classes) that overrides finalize() might not be compiled anymore as now their overriding finalize() needs to catch the "Throwable" from Object.finalize().

          The source code needs to update to catch the exception accordingly in its finalize() method in this situation.

          It is believed that the compatibility risk should be low but marked as medium because it is uncertain how existing applications depend on these behaviors.
          sherman Xueming Shen made changes -
          Compatibility Risk Description Both Deflater and Inflater's end() method have the specification wordings as "... will also be called automatically by the finalize() method"

           public void end() {
               ...
               end(addr);
               ...
           }

          And for the ZipFile, even the specification is not specified that its inflater() method will call close(), its implementation currently does just that.

          protected void finalize() throws IOException {
              close();
          }

          Give that there are two kinds of "incompatible risk" caused by the proposed changes

          (1) Behavioral incompatibility

          It's possilbe that there are existing subclasses (of Deflater, Inflater and ZipFile) over there that has the dependency on the existing behavior, in which the "end()/close()" method is being invoked during finalization. Those subclasses might override the "end()/close() with some additional implementation logic with the expection that these additional logic will be executed when the object is being gc-ed. With this change, it no longer happens.

          To solve this problem the subclass can override the finalize() and invoke the corresponding end() or close() directly in it. Or it might be desired to consider to use the java.lang.ref.Cleaner as well in its implementation to do the last cleanup work.

          (2) Source incompatiblity

          Inflater/Deflater.finalize() does not throw any exception
          ZipFile.finalize() only throws IOException.

          With the removal() of finalize() from Deflater, Inflater and ZipFile, any existing subclass (of these 3 classes) that overrides finalize() might not be compiled anymore as now their overriding finalize() needs to catch the "Throwable" from Object.finalize().

          The source code needs to update to catch the exception accordingly in its finalize() method in this situation.

          It is believed that the compatibility risk should be low but marked as medium because it is uncertain how existing applications depend on these behaviors.
          Both Deflater and Inflater's end() method have the specification wordings as "... will also be called automatically by the finalize() method"

           public void end() {
               ...
               end(addr);
               ...
           }

          And for the ZipFile, even the specification is not specified that its inflater() method will call close(), its implementation currently does just that.

          protected void finalize() throws IOException {
              close();
          }

          Give that there are two kinds of "incompatible risk" caused by the proposed changes

          (1) Behavioral incompatibility

          It's possilbe that there are existing subclasses (of Deflater, Inflater and ZipFile) over there that has the dependency on the existing behavior, in which the "end()/close()" method is being invoked during finalization. Those subclasses might override the "end()/close() with some additional implementation logic with the expection that these additional logic will be executed when the object is being gc-ed. With this change, it no longer happens.

          To solve this incompatibility the subclass need to find somewhere in its cleanup code to invoke the end()/close() explicitly.

          (2) Source incompatiblity

          Inflater/Deflater.finalize() does not throw any exception
          ZipFile.finalize() only throws IOException.

          With the removal() of finalize() from Deflater, Inflater and ZipFile, any existing subclass (of these 3 classes) that overrides finalize() might not be compiled anymore as now their overriding finalize() needs to catch the "Throwable" from Object.finalize().

          The source code needs to update to catch the exception accordingly in its finalize() method in this situation.

          It is believed that the compatibility risk should be low but marked as medium because it is uncertain how existing applications depend on these behaviors.
          sherman Xueming Shen made changes -
          Compatibility Risk Description Both Deflater and Inflater's end() method have the specification wordings as "... will also be called automatically by the finalize() method"

           public void end() {
               ...
               end(addr);
               ...
           }

          And for the ZipFile, even the specification is not specified that its inflater() method will call close(), its implementation currently does just that.

          protected void finalize() throws IOException {
              close();
          }

          Give that there are two kinds of "incompatible risk" caused by the proposed changes

          (1) Behavioral incompatibility

          It's possilbe that there are existing subclasses (of Deflater, Inflater and ZipFile) over there that has the dependency on the existing behavior, in which the "end()/close()" method is being invoked during finalization. Those subclasses might override the "end()/close() with some additional implementation logic with the expection that these additional logic will be executed when the object is being gc-ed. With this change, it no longer happens.

          To solve this incompatibility the subclass need to find somewhere in its cleanup code to invoke the end()/close() explicitly.

          (2) Source incompatiblity

          Inflater/Deflater.finalize() does not throw any exception
          ZipFile.finalize() only throws IOException.

          With the removal() of finalize() from Deflater, Inflater and ZipFile, any existing subclass (of these 3 classes) that overrides finalize() might not be compiled anymore as now their overriding finalize() needs to catch the "Throwable" from Object.finalize().

          The source code needs to update to catch the exception accordingly in its finalize() method in this situation.

          It is believed that the compatibility risk should be low but marked as medium because it is uncertain how existing applications depend on these behaviors.
          Both Deflater and Inflater's end() method have the specification wordings as "... will also be called automatically by the finalize() method"

           public void end() {
               ...
               end(addr);
               ...
           }

          And for the ZipFile, even the specification is not specified that its inflater() method will call close(), its implementation currently does just that.

          protected void finalize() throws IOException {
              close();
          }

          Give that there are two kinds of "incompatible risk" caused by the proposed changes

          (1) Behavioral incompatibility

          It's possilbe that there are existing subclasses (of Deflater, Inflater and ZipFile) over there that has the dependency on the existing behavior, in which the "end()/close()" method is being invoked during finalization. Those subclasses might override the "end()/close() with some additional implementation logic with the expection that these additional logic will be executed when the object is being gc-ed. With this change, it no longer happens.

          To solve this incompatibility the subclass need to find somewhere in its cleanup code to invoke the end()/close() explicitly.

          (2) Source incompatiblity

          Inflater/Deflater.finalize() does not throw any exception
          ZipFile.finalize() only throws IOException.

          With the removal() of finalize() from Deflater, Inflater and ZipFile, any existing subclass (of these 3 classes) that overrides finalize() might not be compiled anymore as now their overriding finalize() needs to catch the "Throwable" from Object.finalize().

          The source code needs to update to catch the exception accordingly in its finalize() method in this situation.

          Based on the Maven central search result It is believed that the compatibility risk should be low but marked as medium because it is uncertain how existing applications depend on these behaviors.
          sherman Xueming Shen made changes -
          Description Summary
          -------

          To replace the finalizer mechanism with java.lang.ref.Cleaner to close the object java.util.zip.ZipFile/Inflater/Deflater, and cleanup/release its underlying native resources when the object is no longer reachable.

          Problem
          -------

          The finalization mechanism has a history of usage and performnace issues, it is desirable the j.u.zip implementation to migrate away from its use of finalizer to the newly introduced java.lang.ref.Cleaner.

          Solution
          --------

          To remove the overridden finalize() methods from Deflater, Inflater and ZipFile, and use Cleaner to do the resource cleanup when the object has become unreachable.

          To update the specification of the end() method (for both Deflater and Inflater) to remove the requirement that the end() "will be called by the finalizer() automatically".

          To add additional @apiNote in class javadoc for Deflater, Inflater and ZipFile to describe the spec and behavioral change.

          http://cr.openjdk.java.net/~sherman/8185582/webrev

          Specification
          -------------

          src/java.base/share/classes/java/util/zip/Deflater.java

          [adding]
          ```
          + * <p>
          + * In previous releases the {@link Object#finalize} method was overridden and
          + * specified to invoke the {@code end} method to close the compressor and release
          + * its resource when the instance becomes unreachable and therefore finalized.
          + * The {@code finalize} method is no longer defined.
          + *
          + * @implNote
          + * The resource of the compressor will be released when the instance becomes
          + * phantom-reachable, if the {@code end} is not invoked explicitly.
          + * <p>
          + *
          ```
          [updating]
          ```
               /**
                * Closes the compressor and discards any unprocessed input.
                * This method should be called when the compressor is no longer
          - * being used, but will also be called automatically by the
          - * finalize() method. Once this method is called, the behavior
          - * of the Deflater object is undefined.
          + * being used. Once this method is called, the behavior of the
          + * Deflater object is undefined.
                */
               public void end() {
          ```
          [removing]
          ```
          - /**
          - * Closes the compressor when garbage is collected.
          - *
          - * @deprecated The {@code finalize} method has been deprecated.
          - * Subclasses that override {@code finalize} in order to perform cleanup
          - * should be modified to use alternative cleanup mechanisms and
          - * to remove the overriding {@code finalize} method.
          - * When overriding the {@code finalize} method, its implementation must explicitly
          - * ensure that {@code super.finalize()} is invoked as described in {@link Object#finalize}.
          - * See the specification for {@link Object#finalize()} for further
          - * information about migration options.
          - */
          - @Deprecated(since="9")
          - protected void finalize() {
          - end();
          - }
          ```
          src/java.base/share/classes/java/util/zip/Inflater.java

          [adding]
          ```
          + * <p>
          + * @apiNote
          + * In previous releases the {@link Object#finalize} method was overridden and
          + * specified to invoke the {@code end} method to close the decompressor and release
          + * its resource when the instance becomes unreachable and therefore finalized.
          + * The {@code finalize} method is no longer defined.
          + *
          + * @implNote
          + * The resource of the decompressor will be released when the instance becomes
          + * phantom-reachable, if the {@code end} is not invoked explicitly.
          + * <p>
          + *
          ```
          [updating]
          ```
               /**
                * Closes the decompressor and discards any unprocessed input.
                * This method should be called when the decompressor is no longer
          - * being used, but will also be called automatically by the finalize()
          - * method. Once this method is called, the behavior of the Inflater
          - * object is undefined.
          + * being used. Once this method is called, the behavior of the
          + * Inflater object is undefined.
                */
               public void end() {
          ```
          [removing]
          ```
          - /**
          - * Closes the decompressor when garbage is collected.
          - *
          - * @deprecated The {@code finalize} method has been deprecated.
          - * Subclasses that override {@code finalize} in order to perform cleanup
          - * should be modified to use alternative cleanup mechanisms and
          - * to remove the overriding {@code finalize} method.
          - * When overriding the {@code finalize} method, its implementation must explicitly
          - * ensure that {@code super.finalize()} is invoked as described in {@link Object#finalize}.
          - * See the specification for {@link Object#finalize()} for further
          - * information about migration options.
          - */
          - @Deprecated(since="9")
          - protected void finalize() {
          - end();
          - }
          ```
          src/java.base/share/classes/java/util/zip/ZipFile.java

          [adding]
          ```
          + * <p>
          + * @apiNote
          + * The {@link Object#finalize} method was overridden and specified in previous
          + * releases to close the ZipFile object and release its system resource when
          + * the instance becomes unreachable and therefore finalized. The {@code finalize}
          + * method is no longer defined.
          + *
          + * @implNote
          + * The resources held by this object will be released when the instance becomes
          + * phantom-reachable, if the {@code close} is not invoked explicitly.
          + * <p>
          + *
          ```
          [updating]
          ```
          + * <p>
          + * Since the time when the resources held by this object will be released
          + * is undetermined, if this method is not invoked explicitly, it is strongly
          + * recommended that applications invoke this method as soon they have
          + * finished accessing this {@code ZipFile}. This will prevent holding up
          + * system resources for an undetermined length of time.
          + * <p>
          + *
          + * @throws IOException if an I/O error has occurred
          + */
          + public void close() throws IOException {
          + if (closeRequested) {
          ```
          [removing]
          ```
          - /**
          - * Ensures that the system resources held by this ZipFile object are
          - * released when there are no more references to it.
          - * <p>
          - * Since the time when GC would invoke this method is undetermined,
          - * it is strongly recommended that applications invoke the {@code close}
          - * method as soon they have finished accessing this {@code ZipFile}.
          - * This will prevent holding up system resources for an undetermined
          - * length of time.
          - *
          - * @deprecated The {@code finalize} method has been deprecated.
          - * Subclasses that override {@code finalize} in order to perform cleanup
          - * should be modified to use alternative cleanup mechanisms and
          - * to remove the overriding {@code finalize} method.
          - * When overriding the {@code finalize} method, its implementation must explicitly
          - * ensure that {@code super.finalize()} is invoked as described in {@link Object#finalize}.
          - * See the specification for {@link Object#finalize()} for further
          - * information about migration options.
          - * @throws IOException if an I/O error has occurred
          - * @see java.util.zip.ZipFile#close()
          - */
          - @Deprecated(since="9")
          - protected void finalize() throws IOException {
          ```
          Summary
          -------

          To replace the finalizer mechanism with java.lang.ref.Cleaner to close the object java.util.zip.ZipFile/Inflater/Deflater, and cleanup/release its underlying native resources when the object is no longer reachable.

          Problem
          -------

          The finalization mechanism has a history of usage and performnace issues, it is desirable the j.u.zip implementation to migrate away from its use of finalizer to the newly introduced java.lang.ref.Cleaner.

          Solution
          --------

          To remove the overridden finalize() methods from Deflater, Inflater and ZipFile, and use Cleaner to do the resource cleanup when the object has become unreachable.

          To update the specification of the end() method (for both Deflater and Inflater) to remove the requirement that the end() "will be called by the finalizer() automatically".

          To add additional @apiNote in class javadoc for Deflater, Inflater and ZipFile to describe the spec and behavioral change.

          http://cr.openjdk.java.net/~sherman/8185582/webrev

          Specification
          -------------

          src/java.base/share/classes/java/util/zip/Deflater.java

          [adding]
          ```
          + * <p>
          + * In previous releases the {@link Object#finalize} method was overridden and
          + * specified to invoke the {@code end} method to close the compressor and release
          + * its resource when the instance becomes unreachable and therefore finalized.
          + * The {@code finalize} method is no longer defined.
          + *
          + * @implNote
          + * The resource of the compressor will be released when the instance becomes
          + * phantom-reachable, if the {@code end} is not invoked explicitly.
          + * <p>
          + *
          ```
          [updating]
          ```
               /**
                * Closes the compressor and discards any unprocessed input.
          + *
                * This method should be called when the compressor is no longer
          - * being used, but will also be called automatically by the
          - * finalize() method. Once this method is called, the behavior
          - * of the Deflater object is undefined.
          + * being used. Once this method is called, the behavior of the
          + * Deflater object is undefined.
          + *
          + * @apiNote
          + * It is strongly recommended to call this method to close the
          + * compressor explicitly to release the resource and discard any
          + * unprocessed input when the compressor is no longer in use.
                */
               public void end() {
          ```
          [removing]
          ```
          - /**
          - * Closes the compressor when garbage is collected.
          - *
          - * @deprecated The {@code finalize} method has been deprecated.
          - * Subclasses that override {@code finalize} in order to perform cleanup
          - * should be modified to use alternative cleanup mechanisms and
          - * to remove the overriding {@code finalize} method.
          - * When overriding the {@code finalize} method, its implementation must explicitly
          - * ensure that {@code super.finalize()} is invoked as described in {@link Object#finalize}.
          - * See the specification for {@link Object#finalize()} for further
          - * information about migration options.
          - */
          - @Deprecated(since="9")
          - protected void finalize() {
          - end();
          - }
          ```
          src/java.base/share/classes/java/util/zip/Inflater.java

          [adding]
          ```
          + * <p>
          + * @apiNote
          + * In previous releases the {@link Object#finalize} method was overridden and
          + * specified to invoke the {@code end} method to close the decompressor and release
          + * its resource when the instance becomes unreachable and therefore finalized.
          + * The {@code finalize} method is no longer defined.
          + *
          + * @implNote
          + * The resource of the decompressor will be released when the instance becomes
          + * phantom-reachable, if the {@code end} is not invoked explicitly.
          + * <p>
          + *
          ```
          [updating]
          ```
               /**
                * Closes the decompressor and discards any unprocessed input.
          + *
                * This method should be called when the decompressor is no longer
          - * being used, but will also be called automatically by the finalize()
          - * method. Once this method is called, the behavior of the Inflater
          - * object is undefined.
          + * being used. Once this method is called, the behavior of the
          + * Inflater object is undefined.
          + *
          + * @apiNote
          + * It is strongly recommended to call this method to close the
          + * decompressor explicitly to release the resource and discard any
          + * unprocessed input when the decompressor is no longer in use.
                */
               public void end() {
          ```
          [removing]
          ```
          - /**
          - * Closes the decompressor when garbage is collected.
          - *
          - * @deprecated The {@code finalize} method has been deprecated.
          - * Subclasses that override {@code finalize} in order to perform cleanup
          - * should be modified to use alternative cleanup mechanisms and
          - * to remove the overriding {@code finalize} method.
          - * When overriding the {@code finalize} method, its implementation must explicitly
          - * ensure that {@code super.finalize()} is invoked as described in {@link Object#finalize}.
          - * See the specification for {@link Object#finalize()} for further
          - * information about migration options.
          - */
          - @Deprecated(since="9")
          - protected void finalize() {
          - end();
          - }
          ```
          src/java.base/share/classes/java/util/zip/ZipFile.java

          [adding]
          ```
          + * <p>
          + * @apiNote
          + * The {@link Object#finalize} method was overridden and specified in previous
          + * releases to close the ZipFile object and release its system resource when
          + * the instance becomes unreachable and therefore finalized. The {@code finalize}
          + * method is no longer defined.
          + *
          + * @implNote
          + * The resources held by this object will be released when the instance becomes
          + * phantom-reachable, if the {@code close} is not invoked explicitly.
          + * <p>
          + *
          ```
          [updating]
          ```
          + * <p>
          + * Since the time when the resources held by this object will be released
          + * is undetermined, if this method is not invoked explicitly, it is strongly
          + * recommended that applications invoke this method as soon they have
          + * finished accessing this {@code ZipFile}. This will prevent holding up
          + * system resources for an undetermined length of time.
          + * <p>
          + *
          + * @throws IOException if an I/O error has occurred
          + */
          + public void close() throws IOException {
          + if (closeRequested) {
          ```
          [removing]
          ```
          - /**
          - * Ensures that the system resources held by this ZipFile object are
          - * released when there are no more references to it.
          - * <p>
          - * Since the time when GC would invoke this method is undetermined,
          - * it is strongly recommended that applications invoke the {@code close}
          - * method as soon they have finished accessing this {@code ZipFile}.
          - * This will prevent holding up system resources for an undetermined
          - * length of time.
          - *
          - * @deprecated The {@code finalize} method has been deprecated.
          - * Subclasses that override {@code finalize} in order to perform cleanup
          - * should be modified to use alternative cleanup mechanisms and
          - * to remove the overriding {@code finalize} method.
          - * When overriding the {@code finalize} method, its implementation must explicitly
          - * ensure that {@code super.finalize()} is invoked as described in {@link Object#finalize}.
          - * See the specification for {@link Object#finalize()} for further
          - * information about migration options.
          - * @throws IOException if an I/O error has occurred
          - * @see java.util.zip.ZipFile#close()
          - */
          - @Deprecated(since="9")
          - protected void finalize() throws IOException {
          ```
          sherman Xueming Shen made changes -
          Description Summary
          -------

          To replace the finalizer mechanism with java.lang.ref.Cleaner to close the object java.util.zip.ZipFile/Inflater/Deflater, and cleanup/release its underlying native resources when the object is no longer reachable.

          Problem
          -------

          The finalization mechanism has a history of usage and performnace issues, it is desirable the j.u.zip implementation to migrate away from its use of finalizer to the newly introduced java.lang.ref.Cleaner.

          Solution
          --------

          To remove the overridden finalize() methods from Deflater, Inflater and ZipFile, and use Cleaner to do the resource cleanup when the object has become unreachable.

          To update the specification of the end() method (for both Deflater and Inflater) to remove the requirement that the end() "will be called by the finalizer() automatically".

          To add additional @apiNote in class javadoc for Deflater, Inflater and ZipFile to describe the spec and behavioral change.

          http://cr.openjdk.java.net/~sherman/8185582/webrev

          Specification
          -------------

          src/java.base/share/classes/java/util/zip/Deflater.java

          [adding]
          ```
          + * <p>
          + * In previous releases the {@link Object#finalize} method was overridden and
          + * specified to invoke the {@code end} method to close the compressor and release
          + * its resource when the instance becomes unreachable and therefore finalized.
          + * The {@code finalize} method is no longer defined.
          + *
          + * @implNote
          + * The resource of the compressor will be released when the instance becomes
          + * phantom-reachable, if the {@code end} is not invoked explicitly.
          + * <p>
          + *
          ```
          [updating]
          ```
               /**
                * Closes the compressor and discards any unprocessed input.
          + *
                * This method should be called when the compressor is no longer
          - * being used, but will also be called automatically by the
          - * finalize() method. Once this method is called, the behavior
          - * of the Deflater object is undefined.
          + * being used. Once this method is called, the behavior of the
          + * Deflater object is undefined.
          + *
          + * @apiNote
          + * It is strongly recommended to call this method to close the
          + * compressor explicitly to release the resource and discard any
          + * unprocessed input when the compressor is no longer in use.
                */
               public void end() {
          ```
          [removing]
          ```
          - /**
          - * Closes the compressor when garbage is collected.
          - *
          - * @deprecated The {@code finalize} method has been deprecated.
          - * Subclasses that override {@code finalize} in order to perform cleanup
          - * should be modified to use alternative cleanup mechanisms and
          - * to remove the overriding {@code finalize} method.
          - * When overriding the {@code finalize} method, its implementation must explicitly
          - * ensure that {@code super.finalize()} is invoked as described in {@link Object#finalize}.
          - * See the specification for {@link Object#finalize()} for further
          - * information about migration options.
          - */
          - @Deprecated(since="9")
          - protected void finalize() {
          - end();
          - }
          ```
          src/java.base/share/classes/java/util/zip/Inflater.java

          [adding]
          ```
          + * <p>
          + * @apiNote
          + * In previous releases the {@link Object#finalize} method was overridden and
          + * specified to invoke the {@code end} method to close the decompressor and release
          + * its resource when the instance becomes unreachable and therefore finalized.
          + * The {@code finalize} method is no longer defined.
          + *
          + * @implNote
          + * The resource of the decompressor will be released when the instance becomes
          + * phantom-reachable, if the {@code end} is not invoked explicitly.
          + * <p>
          + *
          ```
          [updating]
          ```
               /**
                * Closes the decompressor and discards any unprocessed input.
          + *
                * This method should be called when the decompressor is no longer
          - * being used, but will also be called automatically by the finalize()
          - * method. Once this method is called, the behavior of the Inflater
          - * object is undefined.
          + * being used. Once this method is called, the behavior of the
          + * Inflater object is undefined.
          + *
          + * @apiNote
          + * It is strongly recommended to call this method to close the
          + * decompressor explicitly to release the resource and discard any
          + * unprocessed input when the decompressor is no longer in use.
                */
               public void end() {
          ```
          [removing]
          ```
          - /**
          - * Closes the decompressor when garbage is collected.
          - *
          - * @deprecated The {@code finalize} method has been deprecated.
          - * Subclasses that override {@code finalize} in order to perform cleanup
          - * should be modified to use alternative cleanup mechanisms and
          - * to remove the overriding {@code finalize} method.
          - * When overriding the {@code finalize} method, its implementation must explicitly
          - * ensure that {@code super.finalize()} is invoked as described in {@link Object#finalize}.
          - * See the specification for {@link Object#finalize()} for further
          - * information about migration options.
          - */
          - @Deprecated(since="9")
          - protected void finalize() {
          - end();
          - }
          ```
          src/java.base/share/classes/java/util/zip/ZipFile.java

          [adding]
          ```
          + * <p>
          + * @apiNote
          + * The {@link Object#finalize} method was overridden and specified in previous
          + * releases to close the ZipFile object and release its system resource when
          + * the instance becomes unreachable and therefore finalized. The {@code finalize}
          + * method is no longer defined.
          + *
          + * @implNote
          + * The resources held by this object will be released when the instance becomes
          + * phantom-reachable, if the {@code close} is not invoked explicitly.
          + * <p>
          + *
          ```
          [updating]
          ```
          + * <p>
          + * Since the time when the resources held by this object will be released
          + * is undetermined, if this method is not invoked explicitly, it is strongly
          + * recommended that applications invoke this method as soon they have
          + * finished accessing this {@code ZipFile}. This will prevent holding up
          + * system resources for an undetermined length of time.
          + * <p>
          + *
          + * @throws IOException if an I/O error has occurred
          + */
          + public void close() throws IOException {
          + if (closeRequested) {
          ```
          [removing]
          ```
          - /**
          - * Ensures that the system resources held by this ZipFile object are
          - * released when there are no more references to it.
          - * <p>
          - * Since the time when GC would invoke this method is undetermined,
          - * it is strongly recommended that applications invoke the {@code close}
          - * method as soon they have finished accessing this {@code ZipFile}.
          - * This will prevent holding up system resources for an undetermined
          - * length of time.
          - *
          - * @deprecated The {@code finalize} method has been deprecated.
          - * Subclasses that override {@code finalize} in order to perform cleanup
          - * should be modified to use alternative cleanup mechanisms and
          - * to remove the overriding {@code finalize} method.
          - * When overriding the {@code finalize} method, its implementation must explicitly
          - * ensure that {@code super.finalize()} is invoked as described in {@link Object#finalize}.
          - * See the specification for {@link Object#finalize()} for further
          - * information about migration options.
          - * @throws IOException if an I/O error has occurred
          - * @see java.util.zip.ZipFile#close()
          - */
          - @Deprecated(since="9")
          - protected void finalize() throws IOException {
          ```
          Summary
          -------

          To replace the finalizer mechanism with java.lang.ref.Cleaner to close the object java.util.zip.ZipFile/Inflater/Deflater, and cleanup/release its underlying native resources when the object is no longer reachable.

          Problem
          -------

          The finalization mechanism has a history of usage and performnace issues, it is desirable the j.u.zip implementation to migrate away from its use of finalizer to the newly introduced java.lang.ref.Cleaner.

          Solution
          --------

          To remove the overridden finalize() methods from Deflater, Inflater and ZipFile, and use Cleaner to do the resource cleanup when the object has become unreachable.

          To update the specification of the end() method (for both Deflater and Inflater) to remove the requirement that the end() "will be called by the finalizer() automatically".

          To add additional @apiNote in class javadoc for Deflater, Inflater and ZipFile to describe the spec and behavioral change.

          http://cr.openjdk.java.net/~sherman/8185582/webrev

          Specification
          -------------

          src/java.base/share/classes/java/util/zip/Deflater.java

          [adding]
          ```
          + * <p>
          + * In previous releases the {@link Object#finalize} method was overridden and
          + * specified to invoke the {@code end} method to close the compressor and release
          + * its resource when the instance becomes unreachable and therefore finalized.
          + * The {@code finalize} method is no longer defined.
          + *
          + * @implNote
          + * The resource of the compressor will be released when the instance becomes
          + * phantom-reachable, if the {@code end} is not invoked explicitly.
          + * <p>
          + *
          ```
          [updating]
          ```
               /**
                * Closes the compressor and discards any unprocessed input.
          + *
                * This method should be called when the compressor is no longer
          - * being used, but will also be called automatically by the
          - * finalize() method. Once this method is called, the behavior
          - * of the Deflater object is undefined.
          + * being used. Once this method is called, the behavior of the
          + * Deflater object is undefined.
          + *
          + * @apiNote
          + * It is strongly recommended to call this method to close the
          + * compressor explicitly to release the resource and discard any
          + * unprocessed input when the compressor is no longer in use,
          + * otherwise the time when the resource held by this object will
          + * be released is undetermined.
                */
               public void end() {
          ```
          [removing]
          ```
          - /**
          - * Closes the compressor when garbage is collected.
          - *
          - * @deprecated The {@code finalize} method has been deprecated.
          - * Subclasses that override {@code finalize} in order to perform cleanup
          - * should be modified to use alternative cleanup mechanisms and
          - * to remove the overriding {@code finalize} method.
          - * When overriding the {@code finalize} method, its implementation must explicitly
          - * ensure that {@code super.finalize()} is invoked as described in {@link Object#finalize}.
          - * See the specification for {@link Object#finalize()} for further
          - * information about migration options.
          - */
          - @Deprecated(since="9")
          - protected void finalize() {
          - end();
          - }
          ```
          src/java.base/share/classes/java/util/zip/Inflater.java

          [adding]
          ```
          + * <p>
          + * @apiNote
          + * In previous releases the {@link Object#finalize} method was overridden and
          + * specified to invoke the {@code end} method to close the decompressor and release
          + * its resource when the instance becomes unreachable and therefore finalized.
          + * The {@code finalize} method is no longer defined.
          + *
          + * @implNote
          + * The resource of the decompressor will be released when the instance becomes
          + * phantom-reachable, if the {@code end} is not invoked explicitly.
          + * <p>
          + *
          ```
          [updating]
          ```
               /**
                * Closes the decompressor and discards any unprocessed input.
          + *
                * This method should be called when the decompressor is no longer
          - * being used, but will also be called automatically by the finalize()
          - * method. Once this method is called, the behavior of the Inflater
          - * object is undefined.
          + * being used. Once this method is called, the behavior of the
          + * Inflater object is undefined.
          + *
          + * @apiNote
          + * It is strongly recommended to call this method to close the
          + * decompressor explicitly to release the resource and discard any
          + * unprocessed input when the decompressor is no longer in use,
          + * otherwise the time when the resource held by this object will
          + * be released is undetermined.
                */
               public void end() {
          ```
          [removing]
          ```
          - /**
          - * Closes the decompressor when garbage is collected.
          - *
          - * @deprecated The {@code finalize} method has been deprecated.
          - * Subclasses that override {@code finalize} in order to perform cleanup
          - * should be modified to use alternative cleanup mechanisms and
          - * to remove the overriding {@code finalize} method.
          - * When overriding the {@code finalize} method, its implementation must explicitly
          - * ensure that {@code super.finalize()} is invoked as described in {@link Object#finalize}.
          - * See the specification for {@link Object#finalize()} for further
          - * information about migration options.
          - */
          - @Deprecated(since="9")
          - protected void finalize() {
          - end();
          - }
          ```
          src/java.base/share/classes/java/util/zip/ZipFile.java

          [adding]
          ```
          + * <p>
          + * @apiNote
          + * The {@link Object#finalize} method was overridden and specified in previous
          + * releases to close the ZipFile object and release its system resource when
          + * the instance becomes unreachable and therefore finalized. The {@code finalize}
          + * method is no longer defined.
          + *
          + * @implNote
          + * The resources held by this object will be released when the instance becomes
          + * phantom-reachable, if the {@code close} is not invoked explicitly.
          + * <p>
          + *
          ```
          [updating]
          ```
          + * <p>
          + * Since the time when the resources held by this object will be released
          + * is undetermined, if this method is not invoked explicitly, it is strongly
          + * recommended that applications invoke this method as soon they have
          + * finished accessing this {@code ZipFile}. This will prevent holding up
          + * system resources for an undetermined length of time.
          + * <p>
          + *
          + * @throws IOException if an I/O error has occurred
          + */
          + public void close() throws IOException {
          + if (closeRequested) {
          ```
          [removing]
          ```
          - /**
          - * Ensures that the system resources held by this ZipFile object are
          - * released when there are no more references to it.
          - * <p>
          - * Since the time when GC would invoke this method is undetermined,
          - * it is strongly recommended that applications invoke the {@code close}
          - * method as soon they have finished accessing this {@code ZipFile}.
          - * This will prevent holding up system resources for an undetermined
          - * length of time.
          - *
          - * @deprecated The {@code finalize} method has been deprecated.
          - * Subclasses that override {@code finalize} in order to perform cleanup
          - * should be modified to use alternative cleanup mechanisms and
          - * to remove the overriding {@code finalize} method.
          - * When overriding the {@code finalize} method, its implementation must explicitly
          - * ensure that {@code super.finalize()} is invoked as described in {@link Object#finalize}.
          - * See the specification for {@link Object#finalize()} for further
          - * information about migration options.
          - * @throws IOException if an I/O error has occurred
          - * @see java.util.zip.ZipFile#close()
          - */
          - @Deprecated(since="9")
          - protected void finalize() throws IOException {
          ```
          sherman Xueming Shen made changes -
          Description Summary
          -------

          To replace the finalizer mechanism with java.lang.ref.Cleaner to close the object java.util.zip.ZipFile/Inflater/Deflater, and cleanup/release its underlying native resources when the object is no longer reachable.

          Problem
          -------

          The finalization mechanism has a history of usage and performnace issues, it is desirable the j.u.zip implementation to migrate away from its use of finalizer to the newly introduced java.lang.ref.Cleaner.

          Solution
          --------

          To remove the overridden finalize() methods from Deflater, Inflater and ZipFile, and use Cleaner to do the resource cleanup when the object has become unreachable.

          To update the specification of the end() method (for both Deflater and Inflater) to remove the requirement that the end() "will be called by the finalizer() automatically".

          To add additional @apiNote in class javadoc for Deflater, Inflater and ZipFile to describe the spec and behavioral change.

          http://cr.openjdk.java.net/~sherman/8185582/webrev

          Specification
          -------------

          src/java.base/share/classes/java/util/zip/Deflater.java

          [adding]
          ```
          + * <p>
          + * In previous releases the {@link Object#finalize} method was overridden and
          + * specified to invoke the {@code end} method to close the compressor and release
          + * its resource when the instance becomes unreachable and therefore finalized.
          + * The {@code finalize} method is no longer defined.
          + *
          + * @implNote
          + * The resource of the compressor will be released when the instance becomes
          + * phantom-reachable, if the {@code end} is not invoked explicitly.
          + * <p>
          + *
          ```
          [updating]
          ```
               /**
                * Closes the compressor and discards any unprocessed input.
          + *
                * This method should be called when the compressor is no longer
          - * being used, but will also be called automatically by the
          - * finalize() method. Once this method is called, the behavior
          - * of the Deflater object is undefined.
          + * being used. Once this method is called, the behavior of the
          + * Deflater object is undefined.
          + *
          + * @apiNote
          + * It is strongly recommended to call this method to close the
          + * compressor explicitly to release the resource and discard any
          + * unprocessed input when the compressor is no longer in use,
          + * otherwise the time when the resource held by this object will
          + * be released is undetermined.
                */
               public void end() {
          ```
          [removing]
          ```
          - /**
          - * Closes the compressor when garbage is collected.
          - *
          - * @deprecated The {@code finalize} method has been deprecated.
          - * Subclasses that override {@code finalize} in order to perform cleanup
          - * should be modified to use alternative cleanup mechanisms and
          - * to remove the overriding {@code finalize} method.
          - * When overriding the {@code finalize} method, its implementation must explicitly
          - * ensure that {@code super.finalize()} is invoked as described in {@link Object#finalize}.
          - * See the specification for {@link Object#finalize()} for further
          - * information about migration options.
          - */
          - @Deprecated(since="9")
          - protected void finalize() {
          - end();
          - }
          ```
          src/java.base/share/classes/java/util/zip/Inflater.java

          [adding]
          ```
          + * <p>
          + * @apiNote
          + * In previous releases the {@link Object#finalize} method was overridden and
          + * specified to invoke the {@code end} method to close the decompressor and release
          + * its resource when the instance becomes unreachable and therefore finalized.
          + * The {@code finalize} method is no longer defined.
          + *
          + * @implNote
          + * The resource of the decompressor will be released when the instance becomes
          + * phantom-reachable, if the {@code end} is not invoked explicitly.
          + * <p>
          + *
          ```
          [updating]
          ```
               /**
                * Closes the decompressor and discards any unprocessed input.
          + *
                * This method should be called when the decompressor is no longer
          - * being used, but will also be called automatically by the finalize()
          - * method. Once this method is called, the behavior of the Inflater
          - * object is undefined.
          + * being used. Once this method is called, the behavior of the
          + * Inflater object is undefined.
          + *
          + * @apiNote
          + * It is strongly recommended to call this method to close the
          + * decompressor explicitly to release the resource and discard any
          + * unprocessed input when the decompressor is no longer in use,
          + * otherwise the time when the resource held by this object will
          + * be released is undetermined.
                */
               public void end() {
          ```
          [removing]
          ```
          - /**
          - * Closes the decompressor when garbage is collected.
          - *
          - * @deprecated The {@code finalize} method has been deprecated.
          - * Subclasses that override {@code finalize} in order to perform cleanup
          - * should be modified to use alternative cleanup mechanisms and
          - * to remove the overriding {@code finalize} method.
          - * When overriding the {@code finalize} method, its implementation must explicitly
          - * ensure that {@code super.finalize()} is invoked as described in {@link Object#finalize}.
          - * See the specification for {@link Object#finalize()} for further
          - * information about migration options.
          - */
          - @Deprecated(since="9")
          - protected void finalize() {
          - end();
          - }
          ```
          src/java.base/share/classes/java/util/zip/ZipFile.java

          [adding]
          ```
          + * <p>
          + * @apiNote
          + * The {@link Object#finalize} method was overridden and specified in previous
          + * releases to close the ZipFile object and release its system resource when
          + * the instance becomes unreachable and therefore finalized. The {@code finalize}
          + * method is no longer defined.
          + *
          + * @implNote
          + * The resources held by this object will be released when the instance becomes
          + * phantom-reachable, if the {@code close} is not invoked explicitly.
          + * <p>
          + *
          ```
          [updating]
          ```
          + * <p>
          + * Since the time when the resources held by this object will be released
          + * is undetermined, if this method is not invoked explicitly, it is strongly
          + * recommended that applications invoke this method as soon they have
          + * finished accessing this {@code ZipFile}. This will prevent holding up
          + * system resources for an undetermined length of time.
          + * <p>
          + *
          + * @throws IOException if an I/O error has occurred
          + */
          + public void close() throws IOException {
          + if (closeRequested) {
          ```
          [removing]
          ```
          - /**
          - * Ensures that the system resources held by this ZipFile object are
          - * released when there are no more references to it.
          - * <p>
          - * Since the time when GC would invoke this method is undetermined,
          - * it is strongly recommended that applications invoke the {@code close}
          - * method as soon they have finished accessing this {@code ZipFile}.
          - * This will prevent holding up system resources for an undetermined
          - * length of time.
          - *
          - * @deprecated The {@code finalize} method has been deprecated.
          - * Subclasses that override {@code finalize} in order to perform cleanup
          - * should be modified to use alternative cleanup mechanisms and
          - * to remove the overriding {@code finalize} method.
          - * When overriding the {@code finalize} method, its implementation must explicitly
          - * ensure that {@code super.finalize()} is invoked as described in {@link Object#finalize}.
          - * See the specification for {@link Object#finalize()} for further
          - * information about migration options.
          - * @throws IOException if an I/O error has occurred
          - * @see java.util.zip.ZipFile#close()
          - */
          - @Deprecated(since="9")
          - protected void finalize() throws IOException {
          ```
          Summary
          -------

          To replace the finalizer mechanism with java.lang.ref.Cleaner to close the object java.util.zip.ZipFile/Inflater/Deflater, and cleanup/release its underlying native resources when the object is no longer reachable.

          Problem
          -------

          The finalization mechanism has a history of usage and performnace issues, it is desirable the j.u.zip implementation to migrate away from its use of finalizer to the newly introduced java.lang.ref.Cleaner.

          Solution
          --------

          To remove the overridden finalize() methods from Deflater, Inflater and ZipFile, and use Cleaner to do the resource cleanup when the object has become unreachable.

          To update the specification of the end() method (for both Deflater and Inflater) to remove the requirement that the end() "will be called by the finalizer() automatically".

          To add additional @apiNote in class javadoc for Deflater, Inflater and ZipFile to describe the spec and behavioral change.

          http://cr.openjdk.java.net/~sherman/8185582/webrev

          Specification
          -------------

          src/java.base/share/classes/java/util/zip/Deflater.java

          [adding]
          ```
          + * <p>
          + * @apiNote
          + * In previous releases the {@link Object#finalize} method was overridden and
          + * specified to invoke the {@code end} method to close the compressor and release
          + * its resource when the instance becomes unreachable and therefore finalized.
          + * The {@code finalize} method is no longer defined and the {@code end} method
          + * is no longer specified to be called by {@code finalize} method automatically.
          + * <p>
          + * The recommended cleanup for compressor is to explicitly call {@code end}
          + * method when it is no longer in use. Existing subclasses of {@code Deflater}
          + * that override {@code end} and require {@code end} to be invoked when the
          + * instance is unreachable should explicitly override {@link Object#finalize}
          + * and call {@code end}.
          + *
          + * @implNote
          + * The resource of the compressor will be released when the instance becomes
          + * phantom-reachable, if the {@code end} is not invoked explicitly.
          + * <p>
          + *
          ```
          [updating]
          ```
               /**
                * Closes the compressor and discards any unprocessed input.
          + *
                * This method should be called when the compressor is no longer
          - * being used, but will also be called automatically by the
          - * finalize() method. Once this method is called, the behavior
          - * of the Deflater object is undefined.
          + * being used. Once this method is called, the behavior of the
          + * Deflater object is undefined.
          + *
                */
               public void end() {
          ```
          [removing]
          ```
          - /**
          - * Closes the compressor when garbage is collected.
          - *
          - * @deprecated The {@code finalize} method has been deprecated.
          - * Subclasses that override {@code finalize} in order to perform cleanup
          - * should be modified to use alternative cleanup mechanisms and
          - * to remove the overriding {@code finalize} method.
          - * When overriding the {@code finalize} method, its implementation must explicitly
          - * ensure that {@code super.finalize()} is invoked as described in {@link Object#finalize}.
          - * See the specification for {@link Object#finalize()} for further
          - * information about migration options.
          - */
          - @Deprecated(since="9")
          - protected void finalize() {
          - end();
          - }
          ```
          src/java.base/share/classes/java/util/zip/Inflater.java

          [adding]
          ```
          + * <p>
          + * @apiNote
          + * In previous releases the {@link Object#finalize} method was overridden and
          + * specified to invoke the {@code end} method to close the decompressor and release
          + * its resource when the instance becomes unreachable and therefore finalized.
          + * The {@code finalize} method is no longer defined and the {@code end} method
          + * is no longer specified to be called by {@code finalize} method automatically.
          + * <p>
          + * The recommended cleanup for decompressor is to explicitly call {@code end}
          + * method when it is no longer in use. Existing subclasses of {@code Inflater}
          + * that override {@code end} and require {@code end} to be invoked when the
          + * instance is unreachable should explicitly override {@link Object#finalize}
          + * and call {@code end}.
          + *
          + * @implNote
          + * The resource of the decompressor will be released when the instance becomes
          + * phantom-reachable, if the {@code end} is not invoked explicitly.
          + * <p>
          + *
          ```
          [updating]
          ```
               /**
                * Closes the decompressor and discards any unprocessed input.
          + *
                * This method should be called when the decompressor is no longer
          - * being used, but will also be called automatically by the finalize()
          - * method. Once this method is called, the behavior of the Inflater
          - * object is undefined.
          + * being used. Once this method is called, the behavior of the
          + * Inflater object is undefined.
          + *
                */
               public void end() {
          ```
          [removing]
          ```
          - /**
          - * Closes the decompressor when garbage is collected.
          - *
          - * @deprecated The {@code finalize} method has been deprecated.
          - * Subclasses that override {@code finalize} in order to perform cleanup
          - * should be modified to use alternative cleanup mechanisms and
          - * to remove the overriding {@code finalize} method.
          - * When overriding the {@code finalize} method, its implementation must explicitly
          - * ensure that {@code super.finalize()} is invoked as described in {@link Object#finalize}.
          - * See the specification for {@link Object#finalize()} for further
          - * information about migration options.
          - */
          - @Deprecated(since="9")
          - protected void finalize() {
          - end();
          - }
          ```
          src/java.base/share/classes/java/util/zip/ZipFile.java

          [adding]
          ```
          + * <p>
          + * @apiNote
          + * The {@link Object#finalize} method was overridden and specified in previous
          + * releases to close the ZipFile object and release its system resource when
          + * the instance becomes unreachable and therefore finalized. The {@code finalize}
          + * method is no longer defined. The recommended cleanup for ZipFile object is
          + * to explicitly invoke {@code close} method when it is no longer in use.
          + *
          + * @implNote
          + * The resources held by this object will be released when the instance becomes
          + * phantom-reachable, if the {@code close} is not invoked explicitly.
          + * <p>
          + *
          ```
          [updating]
          ```
          + * <p>
          + * Since the time when the resources held by this object will be released
          + * is undetermined, if this method is not invoked explicitly, it is strongly
          + * recommended that applications invoke this method as soon they have
          + * finished accessing this {@code ZipFile}. This will prevent holding up
          + * system resources for an undetermined length of time.
          + * <p>
          + *
          + * @throws IOException if an I/O error has occurred
          + */
          + public void close() throws IOException {
          + if (closeRequested) {
          ```
          [removing]
          ```
          - /**
          - * Ensures that the system resources held by this ZipFile object are
          - * released when there are no more references to it.
          - * <p>
          - * Since the time when GC would invoke this method is undetermined,
          - * it is strongly recommended that applications invoke the {@code close}
          - * method as soon they have finished accessing this {@code ZipFile}.
          - * This will prevent holding up system resources for an undetermined
          - * length of time.
          - *
          - * @deprecated The {@code finalize} method has been deprecated.
          - * Subclasses that override {@code finalize} in order to perform cleanup
          - * should be modified to use alternative cleanup mechanisms and
          - * to remove the overriding {@code finalize} method.
          - * When overriding the {@code finalize} method, its implementation must explicitly
          - * ensure that {@code super.finalize()} is invoked as described in {@link Object#finalize}.
          - * See the specification for {@link Object#finalize()} for further
          - * information about migration options.
          - * @throws IOException if an I/O error has occurred
          - * @see java.util.zip.ZipFile#close()
          - */
          - @Deprecated(since="9")
          - protected void finalize() throws IOException {
          ```
          mchung Mandy Chung made changes -
          Reviewed By Roger Riggs [ rriggs ] Mandy Chung, Roger Riggs [ mchung, rriggs ]
          sherman Xueming Shen made changes -
          Description Summary
          -------

          To replace the finalizer mechanism with java.lang.ref.Cleaner to close the object java.util.zip.ZipFile/Inflater/Deflater, and cleanup/release its underlying native resources when the object is no longer reachable.

          Problem
          -------

          The finalization mechanism has a history of usage and performnace issues, it is desirable the j.u.zip implementation to migrate away from its use of finalizer to the newly introduced java.lang.ref.Cleaner.

          Solution
          --------

          To remove the overridden finalize() methods from Deflater, Inflater and ZipFile, and use Cleaner to do the resource cleanup when the object has become unreachable.

          To update the specification of the end() method (for both Deflater and Inflater) to remove the requirement that the end() "will be called by the finalizer() automatically".

          To add additional @apiNote in class javadoc for Deflater, Inflater and ZipFile to describe the spec and behavioral change.

          http://cr.openjdk.java.net/~sherman/8185582/webrev

          Specification
          -------------

          src/java.base/share/classes/java/util/zip/Deflater.java

          [adding]
          ```
          + * <p>
          + * @apiNote
          + * In previous releases the {@link Object#finalize} method was overridden and
          + * specified to invoke the {@code end} method to close the compressor and release
          + * its resource when the instance becomes unreachable and therefore finalized.
          + * The {@code finalize} method is no longer defined and the {@code end} method
          + * is no longer specified to be called by {@code finalize} method automatically.
          + * <p>
          + * The recommended cleanup for compressor is to explicitly call {@code end}
          + * method when it is no longer in use. Existing subclasses of {@code Deflater}
          + * that override {@code end} and require {@code end} to be invoked when the
          + * instance is unreachable should explicitly override {@link Object#finalize}
          + * and call {@code end}.
          + *
          + * @implNote
          + * The resource of the compressor will be released when the instance becomes
          + * phantom-reachable, if the {@code end} is not invoked explicitly.
          + * <p>
          + *
          ```
          [updating]
          ```
               /**
                * Closes the compressor and discards any unprocessed input.
          + *
                * This method should be called when the compressor is no longer
          - * being used, but will also be called automatically by the
          - * finalize() method. Once this method is called, the behavior
          - * of the Deflater object is undefined.
          + * being used. Once this method is called, the behavior of the
          + * Deflater object is undefined.
          + *
                */
               public void end() {
          ```
          [removing]
          ```
          - /**
          - * Closes the compressor when garbage is collected.
          - *
          - * @deprecated The {@code finalize} method has been deprecated.
          - * Subclasses that override {@code finalize} in order to perform cleanup
          - * should be modified to use alternative cleanup mechanisms and
          - * to remove the overriding {@code finalize} method.
          - * When overriding the {@code finalize} method, its implementation must explicitly
          - * ensure that {@code super.finalize()} is invoked as described in {@link Object#finalize}.
          - * See the specification for {@link Object#finalize()} for further
          - * information about migration options.
          - */
          - @Deprecated(since="9")
          - protected void finalize() {
          - end();
          - }
          ```
          src/java.base/share/classes/java/util/zip/Inflater.java

          [adding]
          ```
          + * <p>
          + * @apiNote
          + * In previous releases the {@link Object#finalize} method was overridden and
          + * specified to invoke the {@code end} method to close the decompressor and release
          + * its resource when the instance becomes unreachable and therefore finalized.
          + * The {@code finalize} method is no longer defined and the {@code end} method
          + * is no longer specified to be called by {@code finalize} method automatically.
          + * <p>
          + * The recommended cleanup for decompressor is to explicitly call {@code end}
          + * method when it is no longer in use. Existing subclasses of {@code Inflater}
          + * that override {@code end} and require {@code end} to be invoked when the
          + * instance is unreachable should explicitly override {@link Object#finalize}
          + * and call {@code end}.
          + *
          + * @implNote
          + * The resource of the decompressor will be released when the instance becomes
          + * phantom-reachable, if the {@code end} is not invoked explicitly.
          + * <p>
          + *
          ```
          [updating]
          ```
               /**
                * Closes the decompressor and discards any unprocessed input.
          + *
                * This method should be called when the decompressor is no longer
          - * being used, but will also be called automatically by the finalize()
          - * method. Once this method is called, the behavior of the Inflater
          - * object is undefined.
          + * being used. Once this method is called, the behavior of the
          + * Inflater object is undefined.
          + *
                */
               public void end() {
          ```
          [removing]
          ```
          - /**
          - * Closes the decompressor when garbage is collected.
          - *
          - * @deprecated The {@code finalize} method has been deprecated.
          - * Subclasses that override {@code finalize} in order to perform cleanup
          - * should be modified to use alternative cleanup mechanisms and
          - * to remove the overriding {@code finalize} method.
          - * When overriding the {@code finalize} method, its implementation must explicitly
          - * ensure that {@code super.finalize()} is invoked as described in {@link Object#finalize}.
          - * See the specification for {@link Object#finalize()} for further
          - * information about migration options.
          - */
          - @Deprecated(since="9")
          - protected void finalize() {
          - end();
          - }
          ```
          src/java.base/share/classes/java/util/zip/ZipFile.java

          [adding]
          ```
          + * <p>
          + * @apiNote
          + * The {@link Object#finalize} method was overridden and specified in previous
          + * releases to close the ZipFile object and release its system resource when
          + * the instance becomes unreachable and therefore finalized. The {@code finalize}
          + * method is no longer defined. The recommended cleanup for ZipFile object is
          + * to explicitly invoke {@code close} method when it is no longer in use.
          + *
          + * @implNote
          + * The resources held by this object will be released when the instance becomes
          + * phantom-reachable, if the {@code close} is not invoked explicitly.
          + * <p>
          + *
          ```
          [updating]
          ```
          + * <p>
          + * Since the time when the resources held by this object will be released
          + * is undetermined, if this method is not invoked explicitly, it is strongly
          + * recommended that applications invoke this method as soon they have
          + * finished accessing this {@code ZipFile}. This will prevent holding up
          + * system resources for an undetermined length of time.
          + * <p>
          + *
          + * @throws IOException if an I/O error has occurred
          + */
          + public void close() throws IOException {
          + if (closeRequested) {
          ```
          [removing]
          ```
          - /**
          - * Ensures that the system resources held by this ZipFile object are
          - * released when there are no more references to it.
          - * <p>
          - * Since the time when GC would invoke this method is undetermined,
          - * it is strongly recommended that applications invoke the {@code close}
          - * method as soon they have finished accessing this {@code ZipFile}.
          - * This will prevent holding up system resources for an undetermined
          - * length of time.
          - *
          - * @deprecated The {@code finalize} method has been deprecated.
          - * Subclasses that override {@code finalize} in order to perform cleanup
          - * should be modified to use alternative cleanup mechanisms and
          - * to remove the overriding {@code finalize} method.
          - * When overriding the {@code finalize} method, its implementation must explicitly
          - * ensure that {@code super.finalize()} is invoked as described in {@link Object#finalize}.
          - * See the specification for {@link Object#finalize()} for further
          - * information about migration options.
          - * @throws IOException if an I/O error has occurred
          - * @see java.util.zip.ZipFile#close()
          - */
          - @Deprecated(since="9")
          - protected void finalize() throws IOException {
          ```
          Summary
          -------

          To replace the finalizer mechanism with java.lang.ref.Cleaner to close the object java.util.zip.ZipFile/Inflater/Deflater, and cleanup/release its underlying native resources when the object is no longer reachable.

          Problem
          -------

          The finalization mechanism has a history of usage and performnace issues, it is desirable the j.u.zip implementation to migrate away from its use of finalizer to the newly introduced java.lang.ref.Cleaner.

          Solution
          --------

          To remove the overridden finalize() methods from Deflater, Inflater and ZipFile, and use Cleaner to do the resource cleanup when the object has become unreachable.

          To update the specification of the end() method (for both Deflater and Inflater) to remove the requirement that the end() "will be called by the finalizer() automatically".

          To add additional @apiNote in class javadoc for Deflater, Inflater and ZipFile to describe the spec and behavioral change.

          http://cr.openjdk.java.net/~sherman/8185582/webrev

          Specification
          -------------

          src/java.base/share/classes/java/util/zip/Deflater.java

          [adding]
          ```
          + * <p>
          + * @apiNote
          + * In earlier versions the {@link Object#finalize} method was overridden and
          + * specified to call the {@code end} method to close the {@code deflater} and
          + * release the resource when the instance becomes unreachable.
          + * The {@code finalize} method is no longer defined.
          + * <p>
          + * The recommended cleanup for compressor is to explicitly call {@code end}
          + * method when it is no longer in use. Existing subclasses of {@code Deflater}
          + * that override {@code end} and require {@code end} to be invoked when the
          + * instance is unreachable should explicitly override {@link Object#finalize}
          + * and call {@code end}.
          + *
          + * @implNote
          + * The resource of the compressor will be released when the instance becomes
          + * phantom-reachable, if the {@code end} is not invoked explicitly.
          + * <p>
          + *
          ```
          [updating]
          ```
               /**
                * Closes the compressor and discards any unprocessed input.
          + *
                * This method should be called when the compressor is no longer
          - * being used, but will also be called automatically by the
          - * finalize() method. Once this method is called, the behavior
          - * of the Deflater object is undefined.
          + * being used. Once this method is called, the behavior of the
          + * Deflater object is undefined.
          + *
                */
               public void end() {
          ```
          [removing]
          ```
          - /**
          - * Closes the compressor when garbage is collected.
          - *
          - * @deprecated The {@code finalize} method has been deprecated.
          - * Subclasses that override {@code finalize} in order to perform cleanup
          - * should be modified to use alternative cleanup mechanisms and
          - * to remove the overriding {@code finalize} method.
          - * When overriding the {@code finalize} method, its implementation must explicitly
          - * ensure that {@code super.finalize()} is invoked as described in {@link Object#finalize}.
          - * See the specification for {@link Object#finalize()} for further
          - * information about migration options.
          - */
          - @Deprecated(since="9")
          - protected void finalize() {
          - end();
          - }
          ```
          src/java.base/share/classes/java/util/zip/Inflater.java

          [adding]
          ```
          + * <p>
          + * @apiNote
          + * In earlier versions the {@link Object#finalize} method was overridden and
          + * specified to call the {@code end} method to close the {@code inflater} and
          + * release the resource when the instance becomes unreachable.
          + * The {@code finalize} method is no longer defined.
          + * <p>
          + * The recommended cleanup for decompressor is to explicitly call {@code end}
          + * method when it is no longer in use. Existing subclasses of {@code Inflater}
          + * that override {@code end} and require {@code end} to be invoked when the
          + * instance is unreachable should explicitly override {@link Object#finalize}
          + * and call {@code end}.
          + *
          + * @implNote
          + * The resource of the decompressor will be released when the instance becomes
          + * phantom-reachable, if the {@code end} is not invoked explicitly.
          + * <p>
          + *
          ```
          [updating]
          ```
               /**
                * Closes the decompressor and discards any unprocessed input.
          + *
                * This method should be called when the decompressor is no longer
          - * being used, but will also be called automatically by the finalize()
          - * method. Once this method is called, the behavior of the Inflater
          - * object is undefined.
          + * being used. Once this method is called, the behavior of the
          + * Inflater object is undefined.
          + *
                */
               public void end() {
          ```
          [removing]
          ```
          - /**
          - * Closes the decompressor when garbage is collected.
          - *
          - * @deprecated The {@code finalize} method has been deprecated.
          - * Subclasses that override {@code finalize} in order to perform cleanup
          - * should be modified to use alternative cleanup mechanisms and
          - * to remove the overriding {@code finalize} method.
          - * When overriding the {@code finalize} method, its implementation must explicitly
          - * ensure that {@code super.finalize()} is invoked as described in {@link Object#finalize}.
          - * See the specification for {@link Object#finalize()} for further
          - * information about migration options.
          - */
          - @Deprecated(since="9")
          - protected void finalize() {
          - end();
          - }
          ```
          src/java.base/share/classes/java/util/zip/ZipFile.java

          [adding]
          ```
          + * <p>
          + * @apiNote
          + * In earlier versions, the {@link Object#finalize} method was overridden and
          + * specified to close the ZipFile object and release its system resource when
          + * the instance becomes unreachable. The {@code finalize} method is no longer
          + * defined. The recommended cleanup for ZipFile object is to explicitly invoke
          + * {@code close} method when it is no longer in use, or use try-with-resources.
          + *
          + * @implNote
          + * The resources held by this object will be released when the instance becomes
          + * phantom-reachable, if the {@code close} is not invoked explicitly.
          + * <p>
          + *
          ```
          [removing]
          ```
          - /**
          - * Ensures that the system resources held by this ZipFile object are
          - * released when there are no more references to it.
          - * <p>
          - * Since the time when GC would invoke this method is undetermined,
          - * it is strongly recommended that applications invoke the {@code close}
          - * method as soon they have finished accessing this {@code ZipFile}.
          - * This will prevent holding up system resources for an undetermined
          - * length of time.
          - *
          - * @deprecated The {@code finalize} method has been deprecated.
          - * Subclasses that override {@code finalize} in order to perform cleanup
          - * should be modified to use alternative cleanup mechanisms and
          - * to remove the overriding {@code finalize} method.
          - * When overriding the {@code finalize} method, its implementation must explicitly
          - * ensure that {@code super.finalize()} is invoked as described in {@link Object#finalize}.
          - * See the specification for {@link Object#finalize()} for further
          - * information about migration options.
          - * @throws IOException if an I/O error has occurred
          - * @see java.util.zip.ZipFile#close()
          - */
          - @Deprecated(since="9")
          - protected void finalize() throws IOException {
          ```
          alanb Alan Bateman made changes -
          Reviewed By Mandy Chung, Roger Riggs [ mchung, rriggs ] Alan Bateman, Mandy Chung, Roger Riggs [ alanb, mchung, rriggs ]
          Scope SE [ 19106 ]
          sherman Xueming Shen made changes -
          Compatibility Risk Description Both Deflater and Inflater's end() method have the specification wordings as "... will also be called automatically by the finalize() method"

           public void end() {
               ...
               end(addr);
               ...
           }

          And for the ZipFile, even the specification is not specified that its inflater() method will call close(), its implementation currently does just that.

          protected void finalize() throws IOException {
              close();
          }

          Give that there are two kinds of "incompatible risk" caused by the proposed changes

          (1) Behavioral incompatibility

          It's possilbe that there are existing subclasses (of Deflater, Inflater and ZipFile) over there that has the dependency on the existing behavior, in which the "end()/close()" method is being invoked during finalization. Those subclasses might override the "end()/close() with some additional implementation logic with the expection that these additional logic will be executed when the object is being gc-ed. With this change, it no longer happens.

          To solve this incompatibility the subclass need to find somewhere in its cleanup code to invoke the end()/close() explicitly.

          (2) Source incompatiblity

          Inflater/Deflater.finalize() does not throw any exception
          ZipFile.finalize() only throws IOException.

          With the removal() of finalize() from Deflater, Inflater and ZipFile, any existing subclass (of these 3 classes) that overrides finalize() might not be compiled anymore as now their overriding finalize() needs to catch the "Throwable" from Object.finalize().

          The source code needs to update to catch the exception accordingly in its finalize() method in this situation.

          Based on the Maven central search result It is believed that the compatibility risk should be low but marked as medium because it is uncertain how existing applications depend on these behaviors.
          Both Deflater and Inflater's end() method have the specification wordings as "... will also be called automatically by the finalize() method"

           public void end() {
               ...
               end(addr);
               ...
           }

          And for the ZipFile, even the specification is not specified that its finalize() method will call close(), its implementation currently does just that.

          protected void finalize() throws IOException {
              close();
          }

          Give that there are two kinds of "incompatible risk" caused by the proposed changes

          (1) Behavioral incompatibility

          It's possilbe that there are existing subclasses (of Deflater, Inflater and ZipFile) over there that has the dependency on the existing behavior, in which the "end()/close()" method is being invoked during finalization. Those subclasses might override the "end()/close() with some additional implementation logic with the expection that these additional logic will be executed when the object is being gc-ed. With this change, it no longer happens.

          To solve this incompatibility the subclass need to find somewhere in its cleanup code to invoke the end()/close() explicitly.

          (2) Source incompatiblity

          Inflater/Deflater.finalize() does not throw any exception
          ZipFile.finalize() only throws IOException.

          With the removal() of finalize() from Deflater, Inflater and ZipFile, any existing subclass (of these 3 classes) that overrides finalize() might not be compiled anymore as now their overriding finalize() needs to catch the "Throwable" from Object.finalize().

          The source code needs to update to catch the exception accordingly in its finalize() method in this situation.

          Based on the Maven central search result It is believed that the compatibility risk should be low but marked as medium because it is uncertain how existing applications depend on these behaviors.
          sherman Xueming Shen made changes -
          Status Draft [ 10001 ] Finalized [ 10110 ]
          dbessono Dmitry Bessonov made changes -
          Link This issue relates to JCK-7308861 [ JCK-7308861 ]
          dbessono Dmitry Bessonov made changes -
          Link This issue relates to JCK-7308879 [ JCK-7308879 ]
          darcy Joe Darcy made changes -
          Link This issue relates to JDK-8187325 [ JDK-8187325 ]
          Hide
          darcy Joe Darcy added a comment -

          Sorry for the belated comments.

          Similar reaction as to JDK-8187325, I think that removing the finalize method without first having the method be deprecated-for-removal for at least one release is too aggressive.

          Making the request as pended.

          Show
          darcy Joe Darcy added a comment - Sorry for the belated comments. Similar reaction as to JDK-8187325, I think that removing the finalize method without first having the method be deprecated-for-removal for at least one release is too aggressive. Making the request as pended.
          darcy Joe Darcy made changes -
          Status Finalized [ 10110 ] Pended [ 10211 ]
          Hide
          darcy Joe Darcy added a comment -

          A reminder, the CSR request will stay in a pended state unless there is more discussion or a revised proposal from the CSR assignee.

          Show
          darcy Joe Darcy added a comment - A reminder, the CSR request will stay in a pended state unless there is more discussion or a revised proposal from the CSR assignee.
          rriggs Roger Riggs made changes -
          Labels finalizer
          sherman Xueming Shen made changes -
          Status Pended [ 10211 ] Draft [ 10001 ]
          sherman Xueming Shen made changes -
          Compatibility Risk Description Both Deflater and Inflater's end() method have the specification wordings as "... will also be called automatically by the finalize() method"

           public void end() {
               ...
               end(addr);
               ...
           }

          And for the ZipFile, even the specification is not specified that its finalize() method will call close(), its implementation currently does just that.

          protected void finalize() throws IOException {
              close();
          }

          Give that there are two kinds of "incompatible risk" caused by the proposed changes

          (1) Behavioral incompatibility

          It's possilbe that there are existing subclasses (of Deflater, Inflater and ZipFile) over there that has the dependency on the existing behavior, in which the "end()/close()" method is being invoked during finalization. Those subclasses might override the "end()/close() with some additional implementation logic with the expection that these additional logic will be executed when the object is being gc-ed. With this change, it no longer happens.

          To solve this incompatibility the subclass need to find somewhere in its cleanup code to invoke the end()/close() explicitly.

          (2) Source incompatiblity

          Inflater/Deflater.finalize() does not throw any exception
          ZipFile.finalize() only throws IOException.

          With the removal() of finalize() from Deflater, Inflater and ZipFile, any existing subclass (of these 3 classes) that overrides finalize() might not be compiled anymore as now their overriding finalize() needs to catch the "Throwable" from Object.finalize().

          The source code needs to update to catch the exception accordingly in its finalize() method in this situation.

          Based on the Maven central search result It is believed that the compatibility risk should be low but marked as medium because it is uncertain how existing applications depend on these behaviors.
          sherman Xueming Shen made changes -
          Compatibility Risk medium [ 19603 ] minimal [ 19601 ]
          sherman Xueming Shen made changes -
          Description Summary
          -------

          To replace the finalizer mechanism with java.lang.ref.Cleaner to close the object java.util.zip.ZipFile/Inflater/Deflater, and cleanup/release its underlying native resources when the object is no longer reachable.

          Problem
          -------

          The finalization mechanism has a history of usage and performnace issues, it is desirable the j.u.zip implementation to migrate away from its use of finalizer to the newly introduced java.lang.ref.Cleaner.

          Solution
          --------

          To remove the overridden finalize() methods from Deflater, Inflater and ZipFile, and use Cleaner to do the resource cleanup when the object has become unreachable.

          To update the specification of the end() method (for both Deflater and Inflater) to remove the requirement that the end() "will be called by the finalizer() automatically".

          To add additional @apiNote in class javadoc for Deflater, Inflater and ZipFile to describe the spec and behavioral change.

          http://cr.openjdk.java.net/~sherman/8185582/webrev

          Specification
          -------------

          src/java.base/share/classes/java/util/zip/Deflater.java

          [adding]
          ```
          + * <p>
          + * @apiNote
          + * In earlier versions the {@link Object#finalize} method was overridden and
          + * specified to call the {@code end} method to close the {@code deflater} and
          + * release the resource when the instance becomes unreachable.
          + * The {@code finalize} method is no longer defined.
          + * <p>
          + * The recommended cleanup for compressor is to explicitly call {@code end}
          + * method when it is no longer in use. Existing subclasses of {@code Deflater}
          + * that override {@code end} and require {@code end} to be invoked when the
          + * instance is unreachable should explicitly override {@link Object#finalize}
          + * and call {@code end}.
          + *
          + * @implNote
          + * The resource of the compressor will be released when the instance becomes
          + * phantom-reachable, if the {@code end} is not invoked explicitly.
          + * <p>
          + *
          ```
          [updating]
          ```
               /**
                * Closes the compressor and discards any unprocessed input.
          + *
                * This method should be called when the compressor is no longer
          - * being used, but will also be called automatically by the
          - * finalize() method. Once this method is called, the behavior
          - * of the Deflater object is undefined.
          + * being used. Once this method is called, the behavior of the
          + * Deflater object is undefined.
          + *
                */
               public void end() {
          ```
          [removing]
          ```
          - /**
          - * Closes the compressor when garbage is collected.
          - *
          - * @deprecated The {@code finalize} method has been deprecated.
          - * Subclasses that override {@code finalize} in order to perform cleanup
          - * should be modified to use alternative cleanup mechanisms and
          - * to remove the overriding {@code finalize} method.
          - * When overriding the {@code finalize} method, its implementation must explicitly
          - * ensure that {@code super.finalize()} is invoked as described in {@link Object#finalize}.
          - * See the specification for {@link Object#finalize()} for further
          - * information about migration options.
          - */
          - @Deprecated(since="9")
          - protected void finalize() {
          - end();
          - }
          ```
          src/java.base/share/classes/java/util/zip/Inflater.java

          [adding]
          ```
          + * <p>
          + * @apiNote
          + * In earlier versions the {@link Object#finalize} method was overridden and
          + * specified to call the {@code end} method to close the {@code inflater} and
          + * release the resource when the instance becomes unreachable.
          + * The {@code finalize} method is no longer defined.
          + * <p>
          + * The recommended cleanup for decompressor is to explicitly call {@code end}
          + * method when it is no longer in use. Existing subclasses of {@code Inflater}
          + * that override {@code end} and require {@code end} to be invoked when the
          + * instance is unreachable should explicitly override {@link Object#finalize}
          + * and call {@code end}.
          + *
          + * @implNote
          + * The resource of the decompressor will be released when the instance becomes
          + * phantom-reachable, if the {@code end} is not invoked explicitly.
          + * <p>
          + *
          ```
          [updating]
          ```
               /**
                * Closes the decompressor and discards any unprocessed input.
          + *
                * This method should be called when the decompressor is no longer
          - * being used, but will also be called automatically by the finalize()
          - * method. Once this method is called, the behavior of the Inflater
          - * object is undefined.
          + * being used. Once this method is called, the behavior of the
          + * Inflater object is undefined.
          + *
                */
               public void end() {
          ```
          [removing]
          ```
          - /**
          - * Closes the decompressor when garbage is collected.
          - *
          - * @deprecated The {@code finalize} method has been deprecated.
          - * Subclasses that override {@code finalize} in order to perform cleanup
          - * should be modified to use alternative cleanup mechanisms and
          - * to remove the overriding {@code finalize} method.
          - * When overriding the {@code finalize} method, its implementation must explicitly
          - * ensure that {@code super.finalize()} is invoked as described in {@link Object#finalize}.
          - * See the specification for {@link Object#finalize()} for further
          - * information about migration options.
          - */
          - @Deprecated(since="9")
          - protected void finalize() {
          - end();
          - }
          ```
          src/java.base/share/classes/java/util/zip/ZipFile.java

          [adding]
          ```
          + * <p>
          + * @apiNote
          + * In earlier versions, the {@link Object#finalize} method was overridden and
          + * specified to close the ZipFile object and release its system resource when
          + * the instance becomes unreachable. The {@code finalize} method is no longer
          + * defined. The recommended cleanup for ZipFile object is to explicitly invoke
          + * {@code close} method when it is no longer in use, or use try-with-resources.
          + *
          + * @implNote
          + * The resources held by this object will be released when the instance becomes
          + * phantom-reachable, if the {@code close} is not invoked explicitly.
          + * <p>
          + *
          ```
          [removing]
          ```
          - /**
          - * Ensures that the system resources held by this ZipFile object are
          - * released when there are no more references to it.
          - * <p>
          - * Since the time when GC would invoke this method is undetermined,
          - * it is strongly recommended that applications invoke the {@code close}
          - * method as soon they have finished accessing this {@code ZipFile}.
          - * This will prevent holding up system resources for an undetermined
          - * length of time.
          - *
          - * @deprecated The {@code finalize} method has been deprecated.
          - * Subclasses that override {@code finalize} in order to perform cleanup
          - * should be modified to use alternative cleanup mechanisms and
          - * to remove the overriding {@code finalize} method.
          - * When overriding the {@code finalize} method, its implementation must explicitly
          - * ensure that {@code super.finalize()} is invoked as described in {@link Object#finalize}.
          - * See the specification for {@link Object#finalize()} for further
          - * information about migration options.
          - * @throws IOException if an I/O error has occurred
          - * @see java.util.zip.ZipFile#close()
          - */
          - @Deprecated(since="9")
          - protected void finalize() throws IOException {
          ```
          Summary
          -------

          To replace the finalizer mechanism with java.lang.ref.Cleaner to close the object java.util.zip.ZipFile/Inflater/Deflater, and cleanup/release its underlying native resources when the object is no longer reachable.

          Problem
          -------

          The finalization mechanism has a history of usage and performnace issues, it is desirable the j.u.zip implementation to migrate away from its use of finalizer to the newly introduced java.lang.ref.Cleaner.

          Solution
          --------

          1) To mark the overridden finalize() method of ZipFile/Deflater/Inflater class as "@Deprecated(since="9", forRemoval=true)" and implement it with an empty body (to leverage the VM feature that vm does not put an object into the finalization process if its finalize() has an empty-body-ed implementation). The new implementation uses Cleaner to do the resource cleanup when the object has become unreachable, with the exception that if the ZipFile/Inflater/Deflater has been subclassed and its corresponding close()/end() method has been overridden. In this case, the finalization mechanism is used to do the cleanup, and for behavioral compatibility, the corresponding close()/end() method will be called when the ZipFile/Inflater/Deflater object is unreachable.

          2) To update the specification of the end() method (for both Deflater and Inflater) to remove the requirement that the end() "will be called by the finalizer() automatically".

          3) To add additional @apiNote in class spec and @implSpec in finalize() method spec to clarify (a) the recommended approach to cleanup the resource after use, and (b) there is no guarantee that the close()/end() method will be called directly by finalize(), though the method in subclass will be called when the object is unreachable, via an implementation specific mechanism, for behavioral compatibility.

          to describe the spec and behavioral change.

          http://cr.openjdk.java.net/~sherman/8185582/webrev

          Specification
          -------------

          src/java.base/share/classes/java/util/zip/Deflater.java

          [adding class spec]
          ```
          + * @apiNote
          + * To release resources used by this {@code Deflater}, the {@link #end()} method
          + * should be called explicitly. Subclasses are responsible for the cleanup of resources
          + * acquired by the subclass. Subclasses that override {@link #finalize()} in order
          + * to perform cleanup should be modified to use alternative cleanup mechanisms such
          + * as {@link java.lang.ref.Cleaner} and remove the overriding {@code finalize} method.
          + *
          ```
          [updating end() spec]
          ```
               /**
                * Closes the compressor and discards any unprocessed input.
          + *
                * This method should be called when the compressor is no longer
          - * being used, but will also be called automatically by the
          - * finalize() method. Once this method is called, the behavior
          - * of the Deflater object is undefined.
          + * being used. Once this method is called, the behavior of the
          + * Deflater object is undefined.
          + *
                */
               public void end() {...}
          ```
          [updating finalize() spec]
          ```
               /**
                * Closes the compressor when garbage is collected.
                *
          - * @deprecated The {@code finalize} method has been deprecated.
          - * Subclasses that override {@code finalize} in order to perform cleanup
          - * should be modified to use alternative cleanup mechanisms and
          - * to remove the overriding {@code finalize} method.
          - * When overriding the {@code finalize} method, its implementation must explicitly
          - * ensure that {@code super.finalize()} is invoked as described in {@link Object#finalize}.
          - * See the specification for {@link Object#finalize()} for further
          - * information about migration options.
          - */
          - @Deprecated(since="9")
          - protected void finalize() {
          - end();
          - }
          + * @implSpec
          + * If this {@code Deflater} has been subclassed and the {@code end} method
          + * has been overridden, the {@code end} method will be called when the
          + * inflater is unreachable.
          + *
          + * @deprecated The {@code finalize} method has been deprecated and
          + * implemented as a no-op. Subclasses that override {@code finalize}
          + * in order to perform cleanup should be modified to use alternative
          + * cleanup mechanisms and to remove the overriding {@code finalize}
          + * method. The recommended cleanup for compressor is to explicitly
          + * call {@code end} method when it is no longer in use. If the
          + * {@code end} is not invoked explicitly the resource of the compressor
          + * will be released when the instance becomes phantom-reachable.
          + */
          + @Deprecated(since="9", forRemoval=true)
          + protected void finalize() {}
          ```
          src/java.base/share/classes/java/util/zip/Inflater.java

          [adding class spec]
          ```
          + * @apiNote
          + * To release resources used by this {@code Inflater}, the {@link #end()} method
          + * should be called explicitly. Subclasses are responsible for the cleanup of resources
          + * acquired by the subclass. Subclasses that override {@link #finalize()} in order
          + * to perform cleanup should be modified to use alternative cleanup mechanisms such
          + * as {@link java.lang.ref.Cleaner} and remove the overriding {@code finalize} method.
          + *
          ```
          [updating end() spec]
          ```
               /**
                * Closes the decompressor and discards any unprocessed input.
          + *
                * This method should be called when the decompressor is no longer
          - * being used, but will also be called automatically by the finalize()
          - * method. Once this method is called, the behavior of the Inflater
          - * object is undefined.
          + * being used. Once this method is called, the behavior of the
          + * Inflater object is undefined.
          + *
                */
               public void end() {
          ```
          [updating finalize() spec]
          ```
               /**
                * Closes the decompressor when garbage is collected.
                *
          - * @deprecated The {@code finalize} method has been deprecated.
          - * Subclasses that override {@code finalize} in order to perform cleanup
          - * should be modified to use alternative cleanup mechanisms and
          - * to remove the overriding {@code finalize} method.
          - * When overriding the {@code finalize} method, its implementation must explicitly
          - * ensure that {@code super.finalize()} is invoked as described in {@link Object#finalize}.
          - * See the specification for {@link Object#finalize()} for further
          - * information about migration options.
          - */
          - @Deprecated(since="9")
          - protected void finalize() {
          - end();
          - }
          + * @implSpec
          + * If this {@code Inflater} has been subclassed and the {@code end} method
          + * has been overridden, the {@code end} method will be called when the
          + * inflater is unreachable.
          + *
          + * @deprecated The {@code finalize} method has been deprecated and
          + * implemented as a no-op. Subclasses that override {@code finalize}
          + * in order to perform cleanup should be modified to use alternative
          + * cleanup mechanisms and remove the overriding {@code finalize}
          + * method. The recommended cleanup for compressor is to explicitly
          + * call {@code end} method when it is no longer in use. If the
          + * {@code end} is not invoked explicitly the resource of the compressor
          + * will be released when the instance becomes phantom-reachable,
          + */
          + @Deprecated(since="9", forRemoval=true)
          + protected void finalize() {}
           
          ```
          src/java.base/share/classes/java/util/zip/ZipFile.java

          [adding class spec]
          ```
          + * @apiNote
          + * To release resources used by this {@code ZipFile}, the {@link #close()} method
          + * should be called explicitly or by try-with-resources. Subclasses are responsible
          + * for the cleanup of resources acquired by the subclass. Subclasses that override
          + * {@link #finalize()} in order to perform cleanup should be modified to use alternative
          + * cleanup mechanisms such as {@link java.lang.ref.Cleaner} and remove the overriding
          + * {@code finalize} method.
          + *
          ```
          [updating finalize() spec]
          ```
               /**
                * Ensures that the system resources held by this ZipFile object are
                * released when there are no more references to it.
                *
          - * <p>
          - * Since the time when GC would invoke this method is undetermined,
          - * it is strongly recommended that applications invoke the {@code close}
          - * method as soon they have finished accessing this {@code ZipFile}.
          - * This will prevent holding up system resources for an undetermined
          - * length of time.
          - *
          - * @deprecated The {@code finalize} method has been deprecated.
          - * Subclasses that override {@code finalize} in order to perform cleanup
          - * should be modified to use alternative cleanup mechanisms and
          - * to remove the overriding {@code finalize} method.
          - * When overriding the {@code finalize} method, its implementation must explicitly
          - * ensure that {@code super.finalize()} is invoked as described in {@link Object#finalize}.
          - * See the specification for {@link Object#finalize()} for further
          - * information about migration options.
          + * @implSpec
          + * If this {@code ZipFile} has been subclassed and the {@code close} method
          + * has been overridden, the {@code close} method will be called when the
          + * {@code ZipFile} is unreachable.
          + *
          + * @deprecated The {@code finalize} method has been deprecated and
          + * implemented as a no-op. Subclasses that override {@code finalize}
          + * in order to perform cleanup should be modified to use alternative
          + * cleanup mechanisms and to remove the overriding {@code finalize}
          + * method. The recommended cleanup for ZipFile object is to explicitly
          + * invoke {@code close} method when it is no longer in use, or use
          + * try-with-resources. If the {@code close} is not invoked explicitly
          + * the resources held by this object will be released when the instance
          + * becomes phantom-reachable.
          + *
                * @throws IOException if an I/O error has occurred
          - * @see java.util.zip.ZipFile#close()
                */
          - @Deprecated(since="9")
          + @Deprecated(since="9", forRemoval=true)
          + protected void finalize() throws IOException {}
          ```
          sherman Xueming Shen made changes -
          Description Summary
          -------

          To replace the finalizer mechanism with java.lang.ref.Cleaner to close the object java.util.zip.ZipFile/Inflater/Deflater, and cleanup/release its underlying native resources when the object is no longer reachable.

          Problem
          -------

          The finalization mechanism has a history of usage and performnace issues, it is desirable the j.u.zip implementation to migrate away from its use of finalizer to the newly introduced java.lang.ref.Cleaner.

          Solution
          --------

          1) To mark the overridden finalize() method of ZipFile/Deflater/Inflater class as "@Deprecated(since="9", forRemoval=true)" and implement it with an empty body (to leverage the VM feature that vm does not put an object into the finalization process if its finalize() has an empty-body-ed implementation). The new implementation uses Cleaner to do the resource cleanup when the object has become unreachable, with the exception that if the ZipFile/Inflater/Deflater has been subclassed and its corresponding close()/end() method has been overridden. In this case, the finalization mechanism is used to do the cleanup, and for behavioral compatibility, the corresponding close()/end() method will be called when the ZipFile/Inflater/Deflater object is unreachable.

          2) To update the specification of the end() method (for both Deflater and Inflater) to remove the requirement that the end() "will be called by the finalizer() automatically".

          3) To add additional @apiNote in class spec and @implSpec in finalize() method spec to clarify (a) the recommended approach to cleanup the resource after use, and (b) there is no guarantee that the close()/end() method will be called directly by finalize(), though the method in subclass will be called when the object is unreachable, via an implementation specific mechanism, for behavioral compatibility.

          to describe the spec and behavioral change.

          http://cr.openjdk.java.net/~sherman/8185582/webrev

          Specification
          -------------

          src/java.base/share/classes/java/util/zip/Deflater.java

          [adding class spec]
          ```
          + * @apiNote
          + * To release resources used by this {@code Deflater}, the {@link #end()} method
          + * should be called explicitly. Subclasses are responsible for the cleanup of resources
          + * acquired by the subclass. Subclasses that override {@link #finalize()} in order
          + * to perform cleanup should be modified to use alternative cleanup mechanisms such
          + * as {@link java.lang.ref.Cleaner} and remove the overriding {@code finalize} method.
          + *
          ```
          [updating end() spec]
          ```
               /**
                * Closes the compressor and discards any unprocessed input.
          + *
                * This method should be called when the compressor is no longer
          - * being used, but will also be called automatically by the
          - * finalize() method. Once this method is called, the behavior
          - * of the Deflater object is undefined.
          + * being used. Once this method is called, the behavior of the
          + * Deflater object is undefined.
          + *
                */
               public void end() {...}
          ```
          [updating finalize() spec]
          ```
               /**
                * Closes the compressor when garbage is collected.
                *
          - * @deprecated The {@code finalize} method has been deprecated.
          - * Subclasses that override {@code finalize} in order to perform cleanup
          - * should be modified to use alternative cleanup mechanisms and
          - * to remove the overriding {@code finalize} method.
          - * When overriding the {@code finalize} method, its implementation must explicitly
          - * ensure that {@code super.finalize()} is invoked as described in {@link Object#finalize}.
          - * See the specification for {@link Object#finalize()} for further
          - * information about migration options.
          - */
          - @Deprecated(since="9")
          - protected void finalize() {
          - end();
          - }
          + * @implSpec
          + * If this {@code Deflater} has been subclassed and the {@code end} method
          + * has been overridden, the {@code end} method will be called when the
          + * inflater is unreachable.
          + *
          + * @deprecated The {@code finalize} method has been deprecated and
          + * implemented as a no-op. Subclasses that override {@code finalize}
          + * in order to perform cleanup should be modified to use alternative
          + * cleanup mechanisms and to remove the overriding {@code finalize}
          + * method. The recommended cleanup for compressor is to explicitly
          + * call {@code end} method when it is no longer in use. If the
          + * {@code end} is not invoked explicitly the resource of the compressor
          + * will be released when the instance becomes phantom-reachable.
          + */
          + @Deprecated(since="9", forRemoval=true)
          + protected void finalize() {}
          ```
          src/java.base/share/classes/java/util/zip/Inflater.java

          [adding class spec]
          ```
          + * @apiNote
          + * To release resources used by this {@code Inflater}, the {@link #end()} method
          + * should be called explicitly. Subclasses are responsible for the cleanup of resources
          + * acquired by the subclass. Subclasses that override {@link #finalize()} in order
          + * to perform cleanup should be modified to use alternative cleanup mechanisms such
          + * as {@link java.lang.ref.Cleaner} and remove the overriding {@code finalize} method.
          + *
          ```
          [updating end() spec]
          ```
               /**
                * Closes the decompressor and discards any unprocessed input.
          + *
                * This method should be called when the decompressor is no longer
          - * being used, but will also be called automatically by the finalize()
          - * method. Once this method is called, the behavior of the Inflater
          - * object is undefined.
          + * being used. Once this method is called, the behavior of the
          + * Inflater object is undefined.
          + *
                */
               public void end() {
          ```
          [updating finalize() spec]
          ```
               /**
                * Closes the decompressor when garbage is collected.
                *
          - * @deprecated The {@code finalize} method has been deprecated.
          - * Subclasses that override {@code finalize} in order to perform cleanup
          - * should be modified to use alternative cleanup mechanisms and
          - * to remove the overriding {@code finalize} method.
          - * When overriding the {@code finalize} method, its implementation must explicitly
          - * ensure that {@code super.finalize()} is invoked as described in {@link Object#finalize}.
          - * See the specification for {@link Object#finalize()} for further
          - * information about migration options.
          - */
          - @Deprecated(since="9")
          - protected void finalize() {
          - end();
          - }
          + * @implSpec
          + * If this {@code Inflater} has been subclassed and the {@code end} method
          + * has been overridden, the {@code end} method will be called when the
          + * inflater is unreachable.
          + *
          + * @deprecated The {@code finalize} method has been deprecated and
          + * implemented as a no-op. Subclasses that override {@code finalize}
          + * in order to perform cleanup should be modified to use alternative
          + * cleanup mechanisms and remove the overriding {@code finalize}
          + * method. The recommended cleanup for compressor is to explicitly
          + * call {@code end} method when it is no longer in use. If the
          + * {@code end} is not invoked explicitly the resource of the compressor
          + * will be released when the instance becomes phantom-reachable,
          + */
          + @Deprecated(since="9", forRemoval=true)
          + protected void finalize() {}
           
          ```
          src/java.base/share/classes/java/util/zip/ZipFile.java

          [adding class spec]
          ```
          + * @apiNote
          + * To release resources used by this {@code ZipFile}, the {@link #close()} method
          + * should be called explicitly or by try-with-resources. Subclasses are responsible
          + * for the cleanup of resources acquired by the subclass. Subclasses that override
          + * {@link #finalize()} in order to perform cleanup should be modified to use alternative
          + * cleanup mechanisms such as {@link java.lang.ref.Cleaner} and remove the overriding
          + * {@code finalize} method.
          + *
          ```
          [updating finalize() spec]
          ```
               /**
                * Ensures that the system resources held by this ZipFile object are
                * released when there are no more references to it.
                *
          - * <p>
          - * Since the time when GC would invoke this method is undetermined,
          - * it is strongly recommended that applications invoke the {@code close}
          - * method as soon they have finished accessing this {@code ZipFile}.
          - * This will prevent holding up system resources for an undetermined
          - * length of time.
          - *
          - * @deprecated The {@code finalize} method has been deprecated.
          - * Subclasses that override {@code finalize} in order to perform cleanup
          - * should be modified to use alternative cleanup mechanisms and
          - * to remove the overriding {@code finalize} method.
          - * When overriding the {@code finalize} method, its implementation must explicitly
          - * ensure that {@code super.finalize()} is invoked as described in {@link Object#finalize}.
          - * See the specification for {@link Object#finalize()} for further
          - * information about migration options.
          + * @implSpec
          + * If this {@code ZipFile} has been subclassed and the {@code close} method
          + * has been overridden, the {@code close} method will be called when the
          + * {@code ZipFile} is unreachable.
          + *
          + * @deprecated The {@code finalize} method has been deprecated and
          + * implemented as a no-op. Subclasses that override {@code finalize}
          + * in order to perform cleanup should be modified to use alternative
          + * cleanup mechanisms and to remove the overriding {@code finalize}
          + * method. The recommended cleanup for ZipFile object is to explicitly
          + * invoke {@code close} method when it is no longer in use, or use
          + * try-with-resources. If the {@code close} is not invoked explicitly
          + * the resources held by this object will be released when the instance
          + * becomes phantom-reachable.
          + *
                * @throws IOException if an I/O error has occurred
          - * @see java.util.zip.ZipFile#close()
                */
          - @Deprecated(since="9")
          + @Deprecated(since="9", forRemoval=true)
          + protected void finalize() throws IOException {}
          ```
          Summary
          -------

          To replace the finalizer mechanism with java.lang.ref.Cleaner to close the object java.util.zip.ZipFile/Inflater/Deflater, and cleanup/release its underlying native resources when the object is no longer reachable.

          Problem
          -------

          The finalization mechanism has a history of usage and performnace issues, it is desirable the j.u.zip implementation to migrate away from its use of finalizer to the newly introduced java.lang.ref.Cleaner.

          Solution
          --------

          1) To mark the overridden finalize() method of ZipFile/Deflater/Inflater class as "@Deprecated(since="9", forRemoval=true)" and implement it with an empty body (to leverage the VM feature that vm does not put an object into the finalization process if its finalize() has an empty-body-ed implementation). The new implementation uses Cleaner to do the resource cleanup when the object has become unreachable, with the exception that if the ZipFile/Inflater/Deflater has been subclassed and its corresponding close()/end() method has been overridden. In this case, the finalization mechanism is used to do the cleanup, and for behavioral compatibility, the corresponding close()/end() method will be called when the ZipFile/Inflater/Deflater object is unreachable.

          2) To update the specification of the end() method (for both Deflater and Inflater) to remove the requirement that the end() "will be called by the finalizer() automatically".

          3) To add additional @apiNote in class spec and @implSpec in finalize() method spec to clarify (a) the recommended approach to cleanup the resource after use, and (b) there is no guarantee that the close()/end() method will be called directly by finalize(), though the method in subclass will be called after the object is unreachable, via an implementation specific mechanism, for behavioral compatibility.

          http://cr.openjdk.java.net/~sherman/8185582/webrev

          Specification
          -------------

          src/java.base/share/classes/java/util/zip/Deflater.java

          [adding class spec]
          ```
          + * @apiNote
          + * To release resources used by this {@code Deflater}, the {@link #end()} method
          + * should be called explicitly. Subclasses are responsible for the cleanup of resources
          + * acquired by the subclass. Subclasses that override {@link #finalize()} in order
          + * to perform cleanup should be modified to use alternative cleanup mechanisms such
          + * as {@link java.lang.ref.Cleaner} and remove the overriding {@code finalize} method.
          + *
          ```
          [updating end() spec]
          ```
               /**
                * Closes the compressor and discards any unprocessed input.
          + *
                * This method should be called when the compressor is no longer
          - * being used, but will also be called automatically by the
          - * finalize() method. Once this method is called, the behavior
          - * of the Deflater object is undefined.
          + * being used. Once this method is called, the behavior of the
          + * Deflater object is undefined.
          + *
                */
               public void end() {...}
          ```
          [updating finalize() spec]
          ```
               /**
                * Closes the compressor when garbage is collected.
                *
          - * @deprecated The {@code finalize} method has been deprecated.
          - * Subclasses that override {@code finalize} in order to perform cleanup
          - * should be modified to use alternative cleanup mechanisms and
          - * to remove the overriding {@code finalize} method.
          - * When overriding the {@code finalize} method, its implementation must explicitly
          - * ensure that {@code super.finalize()} is invoked as described in {@link Object#finalize}.
          - * See the specification for {@link Object#finalize()} for further
          - * information about migration options.
          - */
          - @Deprecated(since="9")
          - protected void finalize() {
          - end();
          - }
          + * @implSpec
          + * If this {@code Deflater} has been subclassed and the {@code end} method
          + * has been overridden, the {@code end} method will be called when the
          + * inflater is unreachable.
          + *
          + * @deprecated The {@code finalize} method has been deprecated and
          + * implemented as a no-op. Subclasses that override {@code finalize}
          + * in order to perform cleanup should be modified to use alternative
          + * cleanup mechanisms and to remove the overriding {@code finalize}
          + * method. The recommended cleanup for compressor is to explicitly
          + * call {@code end} method when it is no longer in use. If the
          + * {@code end} is not invoked explicitly the resource of the compressor
          + * will be released when the instance becomes phantom-reachable.
          + */
          + @Deprecated(since="9", forRemoval=true)
          + protected void finalize() {}
          ```
          src/java.base/share/classes/java/util/zip/Inflater.java

          [adding class spec]
          ```
          + * @apiNote
          + * To release resources used by this {@code Inflater}, the {@link #end()} method
          + * should be called explicitly. Subclasses are responsible for the cleanup of resources
          + * acquired by the subclass. Subclasses that override {@link #finalize()} in order
          + * to perform cleanup should be modified to use alternative cleanup mechanisms such
          + * as {@link java.lang.ref.Cleaner} and remove the overriding {@code finalize} method.
          + *
          ```
          [updating end() spec]
          ```
               /**
                * Closes the decompressor and discards any unprocessed input.
          + *
                * This method should be called when the decompressor is no longer
          - * being used, but will also be called automatically by the finalize()
          - * method. Once this method is called, the behavior of the Inflater
          - * object is undefined.
          + * being used. Once this method is called, the behavior of the
          + * Inflater object is undefined.
          + *
                */
               public void end() {
          ```
          [updating finalize() spec]
          ```
               /**
                * Closes the decompressor when garbage is collected.
                *
          - * @deprecated The {@code finalize} method has been deprecated.
          - * Subclasses that override {@code finalize} in order to perform cleanup
          - * should be modified to use alternative cleanup mechanisms and
          - * to remove the overriding {@code finalize} method.
          - * When overriding the {@code finalize} method, its implementation must explicitly
          - * ensure that {@code super.finalize()} is invoked as described in {@link Object#finalize}.
          - * See the specification for {@link Object#finalize()} for further
          - * information about migration options.
          - */
          - @Deprecated(since="9")
          - protected void finalize() {
          - end();
          - }
          + * @implSpec
          + * If this {@code Inflater} has been subclassed and the {@code end} method
          + * has been overridden, the {@code end} method will be called when the
          + * inflater is unreachable.
          + *
          + * @deprecated The {@code finalize} method has been deprecated and
          + * implemented as a no-op. Subclasses that override {@code finalize}
          + * in order to perform cleanup should be modified to use alternative
          + * cleanup mechanisms and remove the overriding {@code finalize}
          + * method. The recommended cleanup for compressor is to explicitly
          + * call {@code end} method when it is no longer in use. If the
          + * {@code end} is not invoked explicitly the resource of the compressor
          + * will be released when the instance becomes phantom-reachable,
          + */
          + @Deprecated(since="9", forRemoval=true)
          + protected void finalize() {}
           
          ```
          src/java.base/share/classes/java/util/zip/ZipFile.java

          [adding class spec]
          ```
          + * @apiNote
          + * To release resources used by this {@code ZipFile}, the {@link #close()} method
          + * should be called explicitly or by try-with-resources. Subclasses are responsible
          + * for the cleanup of resources acquired by the subclass. Subclasses that override
          + * {@link #finalize()} in order to perform cleanup should be modified to use alternative
          + * cleanup mechanisms such as {@link java.lang.ref.Cleaner} and remove the overriding
          + * {@code finalize} method.
          + *
          ```
          [updating finalize() spec]
          ```
               /**
                * Ensures that the system resources held by this ZipFile object are
                * released when there are no more references to it.
                *
          - * <p>
          - * Since the time when GC would invoke this method is undetermined,
          - * it is strongly recommended that applications invoke the {@code close}
          - * method as soon they have finished accessing this {@code ZipFile}.
          - * This will prevent holding up system resources for an undetermined
          - * length of time.
          - *
          - * @deprecated The {@code finalize} method has been deprecated.
          - * Subclasses that override {@code finalize} in order to perform cleanup
          - * should be modified to use alternative cleanup mechanisms and
          - * to remove the overriding {@code finalize} method.
          - * When overriding the {@code finalize} method, its implementation must explicitly
          - * ensure that {@code super.finalize()} is invoked as described in {@link Object#finalize}.
          - * See the specification for {@link Object#finalize()} for further
          - * information about migration options.
          + * @implSpec
          + * If this {@code ZipFile} has been subclassed and the {@code close} method
          + * has been overridden, the {@code close} method will be called when the
          + * {@code ZipFile} is unreachable.
          + *
          + * @deprecated The {@code finalize} method has been deprecated and
          + * implemented as a no-op. Subclasses that override {@code finalize}
          + * in order to perform cleanup should be modified to use alternative
          + * cleanup mechanisms and to remove the overriding {@code finalize}
          + * method. The recommended cleanup for ZipFile object is to explicitly
          + * invoke {@code close} method when it is no longer in use, or use
          + * try-with-resources. If the {@code close} is not invoked explicitly
          + * the resources held by this object will be released when the instance
          + * becomes phantom-reachable.
          + *
                * @throws IOException if an I/O error has occurred
          - * @see java.util.zip.ZipFile#close()
                */
          - @Deprecated(since="9")
          + @Deprecated(since="9", forRemoval=true)
          + protected void finalize() throws IOException {}
          ```
          sherman Xueming Shen made changes -
          Compatibility Risk minimal [ 19601 ] low [ 19602 ]
          sherman Xueming Shen made changes -
          Compatibility Risk Description The change to clarify in spec that there is no guarantee the close/end will be called directly by `finalize()` should have a negligible effect. The recommended use to free resources is to call close/end. If not close/end-ed explicitly, the resources will be released when the ZipFile/Inflater/Deflater becomes unreachable.
          sherman Xueming Shen made changes -
          Description Summary
          -------

          To replace the finalizer mechanism with java.lang.ref.Cleaner to close the object java.util.zip.ZipFile/Inflater/Deflater, and cleanup/release its underlying native resources when the object is no longer reachable.

          Problem
          -------

          The finalization mechanism has a history of usage and performnace issues, it is desirable the j.u.zip implementation to migrate away from its use of finalizer to the newly introduced java.lang.ref.Cleaner.

          Solution
          --------

          1) To mark the overridden finalize() method of ZipFile/Deflater/Inflater class as "@Deprecated(since="9", forRemoval=true)" and implement it with an empty body (to leverage the VM feature that vm does not put an object into the finalization process if its finalize() has an empty-body-ed implementation). The new implementation uses Cleaner to do the resource cleanup when the object has become unreachable, with the exception that if the ZipFile/Inflater/Deflater has been subclassed and its corresponding close()/end() method has been overridden. In this case, the finalization mechanism is used to do the cleanup, and for behavioral compatibility, the corresponding close()/end() method will be called when the ZipFile/Inflater/Deflater object is unreachable.

          2) To update the specification of the end() method (for both Deflater and Inflater) to remove the requirement that the end() "will be called by the finalizer() automatically".

          3) To add additional @apiNote in class spec and @implSpec in finalize() method spec to clarify (a) the recommended approach to cleanup the resource after use, and (b) there is no guarantee that the close()/end() method will be called directly by finalize(), though the method in subclass will be called after the object is unreachable, via an implementation specific mechanism, for behavioral compatibility.

          http://cr.openjdk.java.net/~sherman/8185582/webrev

          Specification
          -------------

          src/java.base/share/classes/java/util/zip/Deflater.java

          [adding class spec]
          ```
          + * @apiNote
          + * To release resources used by this {@code Deflater}, the {@link #end()} method
          + * should be called explicitly. Subclasses are responsible for the cleanup of resources
          + * acquired by the subclass. Subclasses that override {@link #finalize()} in order
          + * to perform cleanup should be modified to use alternative cleanup mechanisms such
          + * as {@link java.lang.ref.Cleaner} and remove the overriding {@code finalize} method.
          + *
          ```
          [updating end() spec]
          ```
               /**
                * Closes the compressor and discards any unprocessed input.
          + *
                * This method should be called when the compressor is no longer
          - * being used, but will also be called automatically by the
          - * finalize() method. Once this method is called, the behavior
          - * of the Deflater object is undefined.
          + * being used. Once this method is called, the behavior of the
          + * Deflater object is undefined.
          + *
                */
               public void end() {...}
          ```
          [updating finalize() spec]
          ```
               /**
                * Closes the compressor when garbage is collected.
                *
          - * @deprecated The {@code finalize} method has been deprecated.
          - * Subclasses that override {@code finalize} in order to perform cleanup
          - * should be modified to use alternative cleanup mechanisms and
          - * to remove the overriding {@code finalize} method.
          - * When overriding the {@code finalize} method, its implementation must explicitly
          - * ensure that {@code super.finalize()} is invoked as described in {@link Object#finalize}.
          - * See the specification for {@link Object#finalize()} for further
          - * information about migration options.
          - */
          - @Deprecated(since="9")
          - protected void finalize() {
          - end();
          - }
          + * @implSpec
          + * If this {@code Deflater} has been subclassed and the {@code end} method
          + * has been overridden, the {@code end} method will be called when the
          + * inflater is unreachable.
          + *
          + * @deprecated The {@code finalize} method has been deprecated and
          + * implemented as a no-op. Subclasses that override {@code finalize}
          + * in order to perform cleanup should be modified to use alternative
          + * cleanup mechanisms and to remove the overriding {@code finalize}
          + * method. The recommended cleanup for compressor is to explicitly
          + * call {@code end} method when it is no longer in use. If the
          + * {@code end} is not invoked explicitly the resource of the compressor
          + * will be released when the instance becomes phantom-reachable.
          + */
          + @Deprecated(since="9", forRemoval=true)
          + protected void finalize() {}
          ```
          src/java.base/share/classes/java/util/zip/Inflater.java

          [adding class spec]
          ```
          + * @apiNote
          + * To release resources used by this {@code Inflater}, the {@link #end()} method
          + * should be called explicitly. Subclasses are responsible for the cleanup of resources
          + * acquired by the subclass. Subclasses that override {@link #finalize()} in order
          + * to perform cleanup should be modified to use alternative cleanup mechanisms such
          + * as {@link java.lang.ref.Cleaner} and remove the overriding {@code finalize} method.
          + *
          ```
          [updating end() spec]
          ```
               /**
                * Closes the decompressor and discards any unprocessed input.
          + *
                * This method should be called when the decompressor is no longer
          - * being used, but will also be called automatically by the finalize()
          - * method. Once this method is called, the behavior of the Inflater
          - * object is undefined.
          + * being used. Once this method is called, the behavior of the
          + * Inflater object is undefined.
          + *
                */
               public void end() {
          ```
          [updating finalize() spec]
          ```
               /**
                * Closes the decompressor when garbage is collected.
                *
          - * @deprecated The {@code finalize} method has been deprecated.
          - * Subclasses that override {@code finalize} in order to perform cleanup
          - * should be modified to use alternative cleanup mechanisms and
          - * to remove the overriding {@code finalize} method.
          - * When overriding the {@code finalize} method, its implementation must explicitly
          - * ensure that {@code super.finalize()} is invoked as described in {@link Object#finalize}.
          - * See the specification for {@link Object#finalize()} for further
          - * information about migration options.
          - */
          - @Deprecated(since="9")
          - protected void finalize() {
          - end();
          - }
          + * @implSpec
          + * If this {@code Inflater} has been subclassed and the {@code end} method
          + * has been overridden, the {@code end} method will be called when the
          + * inflater is unreachable.
          + *
          + * @deprecated The {@code finalize} method has been deprecated and
          + * implemented as a no-op. Subclasses that override {@code finalize}
          + * in order to perform cleanup should be modified to use alternative
          + * cleanup mechanisms and remove the overriding {@code finalize}
          + * method. The recommended cleanup for compressor is to explicitly
          + * call {@code end} method when it is no longer in use. If the
          + * {@code end} is not invoked explicitly the resource of the compressor
          + * will be released when the instance becomes phantom-reachable,
          + */
          + @Deprecated(since="9", forRemoval=true)
          + protected void finalize() {}
           
          ```
          src/java.base/share/classes/java/util/zip/ZipFile.java

          [adding class spec]
          ```
          + * @apiNote
          + * To release resources used by this {@code ZipFile}, the {@link #close()} method
          + * should be called explicitly or by try-with-resources. Subclasses are responsible
          + * for the cleanup of resources acquired by the subclass. Subclasses that override
          + * {@link #finalize()} in order to perform cleanup should be modified to use alternative
          + * cleanup mechanisms such as {@link java.lang.ref.Cleaner} and remove the overriding
          + * {@code finalize} method.
          + *
          ```
          [updating finalize() spec]
          ```
               /**
                * Ensures that the system resources held by this ZipFile object are
                * released when there are no more references to it.
                *
          - * <p>
          - * Since the time when GC would invoke this method is undetermined,
          - * it is strongly recommended that applications invoke the {@code close}
          - * method as soon they have finished accessing this {@code ZipFile}.
          - * This will prevent holding up system resources for an undetermined
          - * length of time.
          - *
          - * @deprecated The {@code finalize} method has been deprecated.
          - * Subclasses that override {@code finalize} in order to perform cleanup
          - * should be modified to use alternative cleanup mechanisms and
          - * to remove the overriding {@code finalize} method.
          - * When overriding the {@code finalize} method, its implementation must explicitly
          - * ensure that {@code super.finalize()} is invoked as described in {@link Object#finalize}.
          - * See the specification for {@link Object#finalize()} for further
          - * information about migration options.
          + * @implSpec
          + * If this {@code ZipFile} has been subclassed and the {@code close} method
          + * has been overridden, the {@code close} method will be called when the
          + * {@code ZipFile} is unreachable.
          + *
          + * @deprecated The {@code finalize} method has been deprecated and
          + * implemented as a no-op. Subclasses that override {@code finalize}
          + * in order to perform cleanup should be modified to use alternative
          + * cleanup mechanisms and to remove the overriding {@code finalize}
          + * method. The recommended cleanup for ZipFile object is to explicitly
          + * invoke {@code close} method when it is no longer in use, or use
          + * try-with-resources. If the {@code close} is not invoked explicitly
          + * the resources held by this object will be released when the instance
          + * becomes phantom-reachable.
          + *
                * @throws IOException if an I/O error has occurred
          - * @see java.util.zip.ZipFile#close()
                */
          - @Deprecated(since="9")
          + @Deprecated(since="9", forRemoval=true)
          + protected void finalize() throws IOException {}
          ```
          Summary
          -------

          To replace the finalizer mechanism with java.lang.ref.Cleaner to close the object java.util.zip.ZipFile/Inflater/Deflater, and cleanup/release its underlying native resources when the object is no longer reachable.

          Problem
          -------

          The finalization mechanism has a history of usage and performnace issues, it is desirable the j.u.zip implementation to migrate away from its use of finalizer to the newly introduced java.lang.ref.Cleaner.

          Solution
          --------

          1) To mark the overridden finalize() method of ZipFile/Deflater/Inflater class as "@Deprecated(, forRemoval=true)" and implement it with an empty body (to leverage the VM feature that vm does not put an object into the finalization process if its finalize() has an empty-body-ed implementation). The new implementation uses Cleaner to do the resource cleanup when the object has become unreachable, with the exception when the ZipFile/Inflater/Deflater has been subclassed and its corresponding close()/end() method has been overridden. In this case, the finalization mechanism is used to do the cleanup, and for behavioral compatibility, the corresponding close()/end() in subclass method will be called when the ZipFile/Inflater/Deflater object is unreachable.

          2) To update the specification of the end() method (for both Deflater and Inflater) to remove the requirement that the end() "will be called by the finalizer() automatically".

          3) To add additional @apiNote in class spec and @implSpec in finalize() method spec to clarify (a) the recommended approach to cleanup the resource after use, and (b) there is no guarantee that the close()/end() method will be called directly by finalize(), though the method in subclass will be called after the object is unreachable, via an implementation specific mechanism, for behavioral compatibility.

          http://cr.openjdk.java.net/~sherman/8185582/webrev

          Specification
          -------------

          src/java.base/share/classes/java/util/zip/Deflater.java

          [adding class spec]
          ```
          + * @apiNote
          + * To release resources used by this {@code Deflater}, the {@link #end()} method
          + * should be called explicitly. Subclasses are responsible for the cleanup of resources
          + * acquired by the subclass. Subclasses that override {@link #finalize()} in order
          + * to perform cleanup should be modified to use alternative cleanup mechanisms such
          + * as {@link java.lang.ref.Cleaner} and remove the overriding {@code finalize} method.
          + *
          ```
          [updating end() spec]
          ```
               /**
                * Closes the compressor and discards any unprocessed input.
          + *
                * This method should be called when the compressor is no longer
          - * being used, but will also be called automatically by the
          - * finalize() method. Once this method is called, the behavior
          - * of the Deflater object is undefined.
          + * being used. Once this method is called, the behavior of the
          + * Deflater object is undefined.
          + *
                */
               public void end() {...}
          ```
          [updating finalize() spec]
          ```
               /**
                * Closes the compressor when garbage is collected.
                *
          - * @deprecated The {@code finalize} method has been deprecated.
          - * Subclasses that override {@code finalize} in order to perform cleanup
          - * should be modified to use alternative cleanup mechanisms and
          - * to remove the overriding {@code finalize} method.
          - * When overriding the {@code finalize} method, its implementation must explicitly
          - * ensure that {@code super.finalize()} is invoked as described in {@link Object#finalize}.
          - * See the specification for {@link Object#finalize()} for further
          - * information about migration options.
          - */
          - @Deprecated(since="9")
          - protected void finalize() {
          - end();
          - }
          + * @implSpec
          + * If this {@code Deflater} has been subclassed and the {@code end} method
          + * has been overridden, the {@code end} method will be called when the
          + * inflater is unreachable.
          + *
          + * @deprecated The {@code finalize} method has been deprecated and
          + * implemented as a no-op. Subclasses that override {@code finalize}
          + * in order to perform cleanup should be modified to use alternative
          + * cleanup mechanisms and to remove the overriding {@code finalize}
          + * method. The recommended cleanup for compressor is to explicitly
          + * call {@code end} method when it is no longer in use. If the
          + * {@code end} is not invoked explicitly the resource of the compressor
          + * will be released when the instance becomes phantom-reachable.
          + */
          + @Deprecated(since="9", forRemoval=true)
          + protected void finalize() {}
          ```
          src/java.base/share/classes/java/util/zip/Inflater.java

          [adding class spec]
          ```
          + * @apiNote
          + * To release resources used by this {@code Inflater}, the {@link #end()} method
          + * should be called explicitly. Subclasses are responsible for the cleanup of resources
          + * acquired by the subclass. Subclasses that override {@link #finalize()} in order
          + * to perform cleanup should be modified to use alternative cleanup mechanisms such
          + * as {@link java.lang.ref.Cleaner} and remove the overriding {@code finalize} method.
          + *
          ```
          [updating end() spec]
          ```
               /**
                * Closes the decompressor and discards any unprocessed input.
          + *
                * This method should be called when the decompressor is no longer
          - * being used, but will also be called automatically by the finalize()
          - * method. Once this method is called, the behavior of the Inflater
          - * object is undefined.
          + * being used. Once this method is called, the behavior of the
          + * Inflater object is undefined.
          + *
                */
               public void end() {
          ```
          [updating finalize() spec]
          ```
               /**
                * Closes the decompressor when garbage is collected.
                *
          - * @deprecated The {@code finalize} method has been deprecated.
          - * Subclasses that override {@code finalize} in order to perform cleanup
          - * should be modified to use alternative cleanup mechanisms and
          - * to remove the overriding {@code finalize} method.
          - * When overriding the {@code finalize} method, its implementation must explicitly
          - * ensure that {@code super.finalize()} is invoked as described in {@link Object#finalize}.
          - * See the specification for {@link Object#finalize()} for further
          - * information about migration options.
          - */
          - @Deprecated(since="9")
          - protected void finalize() {
          - end();
          - }
          + * @implSpec
          + * If this {@code Inflater} has been subclassed and the {@code end} method
          + * has been overridden, the {@code end} method will be called when the
          + * inflater is unreachable.
          + *
          + * @deprecated The {@code finalize} method has been deprecated and
          + * implemented as a no-op. Subclasses that override {@code finalize}
          + * in order to perform cleanup should be modified to use alternative
          + * cleanup mechanisms and remove the overriding {@code finalize}
          + * method. The recommended cleanup for compressor is to explicitly
          + * call {@code end} method when it is no longer in use. If the
          + * {@code end} is not invoked explicitly the resource of the compressor
          + * will be released when the instance becomes phantom-reachable,
          + */
          + @Deprecated(since="9", forRemoval=true)
          + protected void finalize() {}
           
          ```
          src/java.base/share/classes/java/util/zip/ZipFile.java

          [adding class spec]
          ```
          + * @apiNote
          + * To release resources used by this {@code ZipFile}, the {@link #close()} method
          + * should be called explicitly or by try-with-resources. Subclasses are responsible
          + * for the cleanup of resources acquired by the subclass. Subclasses that override
          + * {@link #finalize()} in order to perform cleanup should be modified to use alternative
          + * cleanup mechanisms such as {@link java.lang.ref.Cleaner} and remove the overriding
          + * {@code finalize} method.
          + *
          ```
          [updating finalize() spec]
          ```
               /**
                * Ensures that the system resources held by this ZipFile object are
                * released when there are no more references to it.
                *
          - * <p>
          - * Since the time when GC would invoke this method is undetermined,
          - * it is strongly recommended that applications invoke the {@code close}
          - * method as soon they have finished accessing this {@code ZipFile}.
          - * This will prevent holding up system resources for an undetermined
          - * length of time.
          - *
          - * @deprecated The {@code finalize} method has been deprecated.
          - * Subclasses that override {@code finalize} in order to perform cleanup
          - * should be modified to use alternative cleanup mechanisms and
          - * to remove the overriding {@code finalize} method.
          - * When overriding the {@code finalize} method, its implementation must explicitly
          - * ensure that {@code super.finalize()} is invoked as described in {@link Object#finalize}.
          - * See the specification for {@link Object#finalize()} for further
          - * information about migration options.
          + * @implSpec
          + * If this {@code ZipFile} has been subclassed and the {@code close} method
          + * has been overridden, the {@code close} method will be called when the
          + * {@code ZipFile} is unreachable.
          + *
          + * @deprecated The {@code finalize} method has been deprecated and
          + * implemented as a no-op. Subclasses that override {@code finalize}
          + * in order to perform cleanup should be modified to use alternative
          + * cleanup mechanisms and to remove the overriding {@code finalize}
          + * method. The recommended cleanup for ZipFile object is to explicitly
          + * invoke {@code close} method when it is no longer in use, or use
          + * try-with-resources. If the {@code close} is not invoked explicitly
          + * the resources held by this object will be released when the instance
          + * becomes phantom-reachable.
          + *
                * @throws IOException if an I/O error has occurred
          - * @see java.util.zip.ZipFile#close()
                */
          - @Deprecated(since="9")
          + @Deprecated(since="9", forRemoval=true)
          + protected void finalize() throws IOException {}
          ```
          sherman Xueming Shen made changes -
          Compatibility Kind source,behavioral [ 19800, 19802 ] behavioral [ 19802 ]
          sherman Xueming Shen made changes -
          Description Summary
          -------

          To replace the finalizer mechanism with java.lang.ref.Cleaner to close the object java.util.zip.ZipFile/Inflater/Deflater, and cleanup/release its underlying native resources when the object is no longer reachable.

          Problem
          -------

          The finalization mechanism has a history of usage and performnace issues, it is desirable the j.u.zip implementation to migrate away from its use of finalizer to the newly introduced java.lang.ref.Cleaner.

          Solution
          --------

          1) To mark the overridden finalize() method of ZipFile/Deflater/Inflater class as "@Deprecated(, forRemoval=true)" and implement it with an empty body (to leverage the VM feature that vm does not put an object into the finalization process if its finalize() has an empty-body-ed implementation). The new implementation uses Cleaner to do the resource cleanup when the object has become unreachable, with the exception when the ZipFile/Inflater/Deflater has been subclassed and its corresponding close()/end() method has been overridden. In this case, the finalization mechanism is used to do the cleanup, and for behavioral compatibility, the corresponding close()/end() in subclass method will be called when the ZipFile/Inflater/Deflater object is unreachable.

          2) To update the specification of the end() method (for both Deflater and Inflater) to remove the requirement that the end() "will be called by the finalizer() automatically".

          3) To add additional @apiNote in class spec and @implSpec in finalize() method spec to clarify (a) the recommended approach to cleanup the resource after use, and (b) there is no guarantee that the close()/end() method will be called directly by finalize(), though the method in subclass will be called after the object is unreachable, via an implementation specific mechanism, for behavioral compatibility.

          http://cr.openjdk.java.net/~sherman/8185582/webrev

          Specification
          -------------

          src/java.base/share/classes/java/util/zip/Deflater.java

          [adding class spec]
          ```
          + * @apiNote
          + * To release resources used by this {@code Deflater}, the {@link #end()} method
          + * should be called explicitly. Subclasses are responsible for the cleanup of resources
          + * acquired by the subclass. Subclasses that override {@link #finalize()} in order
          + * to perform cleanup should be modified to use alternative cleanup mechanisms such
          + * as {@link java.lang.ref.Cleaner} and remove the overriding {@code finalize} method.
          + *
          ```
          [updating end() spec]
          ```
               /**
                * Closes the compressor and discards any unprocessed input.
          + *
                * This method should be called when the compressor is no longer
          - * being used, but will also be called automatically by the
          - * finalize() method. Once this method is called, the behavior
          - * of the Deflater object is undefined.
          + * being used. Once this method is called, the behavior of the
          + * Deflater object is undefined.
          + *
                */
               public void end() {...}
          ```
          [updating finalize() spec]
          ```
               /**
                * Closes the compressor when garbage is collected.
                *
          - * @deprecated The {@code finalize} method has been deprecated.
          - * Subclasses that override {@code finalize} in order to perform cleanup
          - * should be modified to use alternative cleanup mechanisms and
          - * to remove the overriding {@code finalize} method.
          - * When overriding the {@code finalize} method, its implementation must explicitly
          - * ensure that {@code super.finalize()} is invoked as described in {@link Object#finalize}.
          - * See the specification for {@link Object#finalize()} for further
          - * information about migration options.
          - */
          - @Deprecated(since="9")
          - protected void finalize() {
          - end();
          - }
          + * @implSpec
          + * If this {@code Deflater} has been subclassed and the {@code end} method
          + * has been overridden, the {@code end} method will be called when the
          + * inflater is unreachable.
          + *
          + * @deprecated The {@code finalize} method has been deprecated and
          + * implemented as a no-op. Subclasses that override {@code finalize}
          + * in order to perform cleanup should be modified to use alternative
          + * cleanup mechanisms and to remove the overriding {@code finalize}
          + * method. The recommended cleanup for compressor is to explicitly
          + * call {@code end} method when it is no longer in use. If the
          + * {@code end} is not invoked explicitly the resource of the compressor
          + * will be released when the instance becomes phantom-reachable.
          + */
          + @Deprecated(since="9", forRemoval=true)
          + protected void finalize() {}
          ```
          src/java.base/share/classes/java/util/zip/Inflater.java

          [adding class spec]
          ```
          + * @apiNote
          + * To release resources used by this {@code Inflater}, the {@link #end()} method
          + * should be called explicitly. Subclasses are responsible for the cleanup of resources
          + * acquired by the subclass. Subclasses that override {@link #finalize()} in order
          + * to perform cleanup should be modified to use alternative cleanup mechanisms such
          + * as {@link java.lang.ref.Cleaner} and remove the overriding {@code finalize} method.
          + *
          ```
          [updating end() spec]
          ```
               /**
                * Closes the decompressor and discards any unprocessed input.
          + *
                * This method should be called when the decompressor is no longer
          - * being used, but will also be called automatically by the finalize()
          - * method. Once this method is called, the behavior of the Inflater
          - * object is undefined.
          + * being used. Once this method is called, the behavior of the
          + * Inflater object is undefined.
          + *
                */
               public void end() {
          ```
          [updating finalize() spec]
          ```
               /**
                * Closes the decompressor when garbage is collected.
                *
          - * @deprecated The {@code finalize} method has been deprecated.
          - * Subclasses that override {@code finalize} in order to perform cleanup
          - * should be modified to use alternative cleanup mechanisms and
          - * to remove the overriding {@code finalize} method.
          - * When overriding the {@code finalize} method, its implementation must explicitly
          - * ensure that {@code super.finalize()} is invoked as described in {@link Object#finalize}.
          - * See the specification for {@link Object#finalize()} for further
          - * information about migration options.
          - */
          - @Deprecated(since="9")
          - protected void finalize() {
          - end();
          - }
          + * @implSpec
          + * If this {@code Inflater} has been subclassed and the {@code end} method
          + * has been overridden, the {@code end} method will be called when the
          + * inflater is unreachable.
          + *
          + * @deprecated The {@code finalize} method has been deprecated and
          + * implemented as a no-op. Subclasses that override {@code finalize}
          + * in order to perform cleanup should be modified to use alternative
          + * cleanup mechanisms and remove the overriding {@code finalize}
          + * method. The recommended cleanup for compressor is to explicitly
          + * call {@code end} method when it is no longer in use. If the
          + * {@code end} is not invoked explicitly the resource of the compressor
          + * will be released when the instance becomes phantom-reachable,
          + */
          + @Deprecated(since="9", forRemoval=true)
          + protected void finalize() {}
           
          ```
          src/java.base/share/classes/java/util/zip/ZipFile.java

          [adding class spec]
          ```
          + * @apiNote
          + * To release resources used by this {@code ZipFile}, the {@link #close()} method
          + * should be called explicitly or by try-with-resources. Subclasses are responsible
          + * for the cleanup of resources acquired by the subclass. Subclasses that override
          + * {@link #finalize()} in order to perform cleanup should be modified to use alternative
          + * cleanup mechanisms such as {@link java.lang.ref.Cleaner} and remove the overriding
          + * {@code finalize} method.
          + *
          ```
          [updating finalize() spec]
          ```
               /**
                * Ensures that the system resources held by this ZipFile object are
                * released when there are no more references to it.
                *
          - * <p>
          - * Since the time when GC would invoke this method is undetermined,
          - * it is strongly recommended that applications invoke the {@code close}
          - * method as soon they have finished accessing this {@code ZipFile}.
          - * This will prevent holding up system resources for an undetermined
          - * length of time.
          - *
          - * @deprecated The {@code finalize} method has been deprecated.
          - * Subclasses that override {@code finalize} in order to perform cleanup
          - * should be modified to use alternative cleanup mechanisms and
          - * to remove the overriding {@code finalize} method.
          - * When overriding the {@code finalize} method, its implementation must explicitly
          - * ensure that {@code super.finalize()} is invoked as described in {@link Object#finalize}.
          - * See the specification for {@link Object#finalize()} for further
          - * information about migration options.
          + * @implSpec
          + * If this {@code ZipFile} has been subclassed and the {@code close} method
          + * has been overridden, the {@code close} method will be called when the
          + * {@code ZipFile} is unreachable.
          + *
          + * @deprecated The {@code finalize} method has been deprecated and
          + * implemented as a no-op. Subclasses that override {@code finalize}
          + * in order to perform cleanup should be modified to use alternative
          + * cleanup mechanisms and to remove the overriding {@code finalize}
          + * method. The recommended cleanup for ZipFile object is to explicitly
          + * invoke {@code close} method when it is no longer in use, or use
          + * try-with-resources. If the {@code close} is not invoked explicitly
          + * the resources held by this object will be released when the instance
          + * becomes phantom-reachable.
          + *
                * @throws IOException if an I/O error has occurred
          - * @see java.util.zip.ZipFile#close()
                */
          - @Deprecated(since="9")
          + @Deprecated(since="9", forRemoval=true)
          + protected void finalize() throws IOException {}
          ```
          Summary
          -------

          To replace the finalizer mechanism with java.lang.ref.Cleaner to close the object java.util.zip.ZipFile/Inflater/Deflater, and cleanup/release its underlying native resources when the object is no longer reachable.

          Problem
          -------

          The finalization mechanism has a history of usage and performnace issues, it is desirable the j.u.zip implementation to migrate away from its use of finalizer to the newly introduced java.lang.ref.Cleaner.

          Solution
          --------

          1) To mark the overridden finalize() method of ZipFile/Deflater/Inflater class as "@Deprecated(, forRemoval=true)" and implement it with an empty body (to leverage the VM feature that vm does not put an object into the finalization process if its finalize() has an empty-body-ed implementation). The new implementation uses Cleaner to do the resource cleanup when the object has become unreachable, with the exception when the ZipFile/Inflater/Deflater has been subclassed and its corresponding close()/end() method has been overridden. In this case, the finalization mechanism is used to do the cleanup, and for behavioral compatibility, the corresponding close()/end() in subclass method will be called when the ZipFile/Inflater/Deflater object is unreachable.

          2) To update the specification of the end() method (for both Deflater and Inflater) to remove the requirement that the end() "will be called by the finalizer() automatically".

          3) To add additional @apiNote in class spec and @implSpec in finalize() method spec to clarify (a) the recommended approach to cleanup the resource after use, and (b) there is no guarantee that the close()/end() method will be called directly by finalize(), though the method in subclass will be called after the object is unreachable, via an implementation specific mechanism, for behavioral compatibility.

          http://cr.openjdk.java.net/~sherman/8185582/webrev

          Specification
          -------------

          src/java.base/share/classes/java/util/zip/Deflater.java

          [adding class spec]
          ```
          + * @apiNote
          + * To release resources used by this {@code Deflater}, the {@link #end()} method
          + * should be called explicitly. Subclasses are responsible for the cleanup of resources
          + * acquired by the subclass. Subclasses that override {@link #finalize()} in order
          + * to perform cleanup should be modified to use alternative cleanup mechanisms such
          + * as {@link java.lang.ref.Cleaner} and remove the overriding {@code finalize} method.
          + *
          ```
          [updating end() spec]
          ```
               /**
                * Closes the compressor and discards any unprocessed input.
          + *
                * This method should be called when the compressor is no longer
          - * being used, but will also be called automatically by the
          - * finalize() method. Once this method is called, the behavior
          - * of the Deflater object is undefined.
          + * being used. Once this method is called, the behavior of the
          + * Deflater object is undefined.
          + *
                */
               public void end() {...}
          ```
          [updating finalize() spec]
          ```
               /**
                * Closes the compressor when garbage is collected.
                *
          - * @deprecated The {@code finalize} method has been deprecated.
          - * Subclasses that override {@code finalize} in order to perform cleanup
          - * should be modified to use alternative cleanup mechanisms and
          - * to remove the overriding {@code finalize} method.
          - * When overriding the {@code finalize} method, its implementation must explicitly
          - * ensure that {@code super.finalize()} is invoked as described in {@link Object#finalize}.
          - * See the specification for {@link Object#finalize()} for further
          - * information about migration options.
          - */
          - @Deprecated(since="9")
          - protected void finalize() {
          - end();
          - }
          + * @implSpec
          + * If this {@code Deflater} has been subclassed and the {@code end} method
          + * has been overridden, the {@code end} method will be called when the
          + * inflater is unreachable.
          + *
          + * @deprecated The {@code finalize} method has been deprecated and
          + * implemented as a no-op. Subclasses that override {@code finalize}
          + * in order to perform cleanup should be modified to use alternative
          + * cleanup mechanisms and to remove the overriding {@code finalize}
          + * method. The recommended cleanup for compressor is to explicitly
          + * call {@code end} method when it is no longer in use. If the
          + * {@code end} is not invoked explicitly the resource of the compressor
          + * will be released when the instance becomes unreachable.
          + */
          + @Deprecated(since="9", forRemoval=true)
          + protected void finalize() {}
          ```
          src/java.base/share/classes/java/util/zip/Inflater.java

          [adding class spec]
          ```
          + * @apiNote
          + * To release resources used by this {@code Inflater}, the {@link #end()} method
          + * should be called explicitly. Subclasses are responsible for the cleanup of resources
          + * acquired by the subclass. Subclasses that override {@link #finalize()} in order
          + * to perform cleanup should be modified to use alternative cleanup mechanisms such
          + * as {@link java.lang.ref.Cleaner} and remove the overriding {@code finalize} method.
          + *
          ```
          [updating end() spec]
          ```
               /**
                * Closes the decompressor and discards any unprocessed input.
          + *
                * This method should be called when the decompressor is no longer
          - * being used, but will also be called automatically by the finalize()
          - * method. Once this method is called, the behavior of the Inflater
          - * object is undefined.
          + * being used. Once this method is called, the behavior of the
          + * Inflater object is undefined.
          + *
                */
               public void end() {
          ```
          [updating finalize() spec]
          ```
               /**
                * Closes the decompressor when garbage is collected.
                *
          - * @deprecated The {@code finalize} method has been deprecated.
          - * Subclasses that override {@code finalize} in order to perform cleanup
          - * should be modified to use alternative cleanup mechanisms and
          - * to remove the overriding {@code finalize} method.
          - * When overriding the {@code finalize} method, its implementation must explicitly
          - * ensure that {@code super.finalize()} is invoked as described in {@link Object#finalize}.
          - * See the specification for {@link Object#finalize()} for further
          - * information about migration options.
          - */
          - @Deprecated(since="9")
          - protected void finalize() {
          - end();
          - }
          + * @implSpec
          + * If this {@code Inflater} has been subclassed and the {@code end} method
          + * has been overridden, the {@code end} method will be called when the
          + * inflater is unreachable.
          + *
          + * @deprecated The {@code finalize} method has been deprecated and
          + * implemented as a no-op. Subclasses that override {@code finalize}
          + * in order to perform cleanup should be modified to use alternative
          + * cleanup mechanisms and remove the overriding {@code finalize}
          + * method. The recommended cleanup for compressor is to explicitly
          + * call {@code end} method when it is no longer in use. If the
          + * {@code end} is not invoked explicitly the resource of the compressor
          + * will be released when the instance becomes unreachable,
          + */
          + @Deprecated(since="9", forRemoval=true)
          + protected void finalize() {}
           
          ```
          src/java.base/share/classes/java/util/zip/ZipFile.java

          [adding class spec]
          ```
          + * @apiNote
          + * To release resources used by this {@code ZipFile}, the {@link #close()} method
          + * should be called explicitly or by try-with-resources. Subclasses are responsible
          + * for the cleanup of resources acquired by the subclass. Subclasses that override
          + * {@link #finalize()} in order to perform cleanup should be modified to use alternative
          + * cleanup mechanisms such as {@link java.lang.ref.Cleaner} and remove the overriding
          + * {@code finalize} method.
          + *
          ```
          [updating finalize() spec]
          ```
               /**
                * Ensures that the system resources held by this ZipFile object are
                * released when there are no more references to it.
                *
          - * <p>
          - * Since the time when GC would invoke this method is undetermined,
          - * it is strongly recommended that applications invoke the {@code close}
          - * method as soon they have finished accessing this {@code ZipFile}.
          - * This will prevent holding up system resources for an undetermined
          - * length of time.
          - *
          - * @deprecated The {@code finalize} method has been deprecated.
          - * Subclasses that override {@code finalize} in order to perform cleanup
          - * should be modified to use alternative cleanup mechanisms and
          - * to remove the overriding {@code finalize} method.
          - * When overriding the {@code finalize} method, its implementation must explicitly
          - * ensure that {@code super.finalize()} is invoked as described in {@link Object#finalize}.
          - * See the specification for {@link Object#finalize()} for further
          - * information about migration options.
          + * @implSpec
          + * If this {@code ZipFile} has been subclassed and the {@code close} method
          + * has been overridden, the {@code close} method will be called when the
          + * {@code ZipFile} is unreachable.
          + *
          + * @deprecated The {@code finalize} method has been deprecated and
          + * implemented as a no-op. Subclasses that override {@code finalize}
          + * in order to perform cleanup should be modified to use alternative
          + * cleanup mechanisms and to remove the overriding {@code finalize}
          + * method. The recommended cleanup for ZipFile object is to explicitly
          + * invoke {@code close} method when it is no longer in use, or use
          + * try-with-resources. If the {@code close} is not invoked explicitly
          + * the resources held by this object will be released when the instance
          + * becomes unreachable.
          + *
                * @throws IOException if an I/O error has occurred
          - * @see java.util.zip.ZipFile#close()
                */
          - @Deprecated(since="9")
          + @Deprecated(since="9", forRemoval=true)
          + protected void finalize() throws IOException {}
          ```
          sherman Xueming Shen made changes -
          Description Summary
          -------

          To replace the finalizer mechanism with java.lang.ref.Cleaner to close the object java.util.zip.ZipFile/Inflater/Deflater, and cleanup/release its underlying native resources when the object is no longer reachable.

          Problem
          -------

          The finalization mechanism has a history of usage and performnace issues, it is desirable the j.u.zip implementation to migrate away from its use of finalizer to the newly introduced java.lang.ref.Cleaner.

          Solution
          --------

          1) To mark the overridden finalize() method of ZipFile/Deflater/Inflater class as "@Deprecated(, forRemoval=true)" and implement it with an empty body (to leverage the VM feature that vm does not put an object into the finalization process if its finalize() has an empty-body-ed implementation). The new implementation uses Cleaner to do the resource cleanup when the object has become unreachable, with the exception when the ZipFile/Inflater/Deflater has been subclassed and its corresponding close()/end() method has been overridden. In this case, the finalization mechanism is used to do the cleanup, and for behavioral compatibility, the corresponding close()/end() in subclass method will be called when the ZipFile/Inflater/Deflater object is unreachable.

          2) To update the specification of the end() method (for both Deflater and Inflater) to remove the requirement that the end() "will be called by the finalizer() automatically".

          3) To add additional @apiNote in class spec and @implSpec in finalize() method spec to clarify (a) the recommended approach to cleanup the resource after use, and (b) there is no guarantee that the close()/end() method will be called directly by finalize(), though the method in subclass will be called after the object is unreachable, via an implementation specific mechanism, for behavioral compatibility.

          http://cr.openjdk.java.net/~sherman/8185582/webrev

          Specification
          -------------

          src/java.base/share/classes/java/util/zip/Deflater.java

          [adding class spec]
          ```
          + * @apiNote
          + * To release resources used by this {@code Deflater}, the {@link #end()} method
          + * should be called explicitly. Subclasses are responsible for the cleanup of resources
          + * acquired by the subclass. Subclasses that override {@link #finalize()} in order
          + * to perform cleanup should be modified to use alternative cleanup mechanisms such
          + * as {@link java.lang.ref.Cleaner} and remove the overriding {@code finalize} method.
          + *
          ```
          [updating end() spec]
          ```
               /**
                * Closes the compressor and discards any unprocessed input.
          + *
                * This method should be called when the compressor is no longer
          - * being used, but will also be called automatically by the
          - * finalize() method. Once this method is called, the behavior
          - * of the Deflater object is undefined.
          + * being used. Once this method is called, the behavior of the
          + * Deflater object is undefined.
          + *
                */
               public void end() {...}
          ```
          [updating finalize() spec]
          ```
               /**
                * Closes the compressor when garbage is collected.
                *
          - * @deprecated The {@code finalize} method has been deprecated.
          - * Subclasses that override {@code finalize} in order to perform cleanup
          - * should be modified to use alternative cleanup mechanisms and
          - * to remove the overriding {@code finalize} method.
          - * When overriding the {@code finalize} method, its implementation must explicitly
          - * ensure that {@code super.finalize()} is invoked as described in {@link Object#finalize}.
          - * See the specification for {@link Object#finalize()} for further
          - * information about migration options.
          - */
          - @Deprecated(since="9")
          - protected void finalize() {
          - end();
          - }
          + * @implSpec
          + * If this {@code Deflater} has been subclassed and the {@code end} method
          + * has been overridden, the {@code end} method will be called when the
          + * inflater is unreachable.
          + *
          + * @deprecated The {@code finalize} method has been deprecated and
          + * implemented as a no-op. Subclasses that override {@code finalize}
          + * in order to perform cleanup should be modified to use alternative
          + * cleanup mechanisms and to remove the overriding {@code finalize}
          + * method. The recommended cleanup for compressor is to explicitly
          + * call {@code end} method when it is no longer in use. If the
          + * {@code end} is not invoked explicitly the resource of the compressor
          + * will be released when the instance becomes unreachable.
          + */
          + @Deprecated(since="9", forRemoval=true)
          + protected void finalize() {}
          ```
          src/java.base/share/classes/java/util/zip/Inflater.java

          [adding class spec]
          ```
          + * @apiNote
          + * To release resources used by this {@code Inflater}, the {@link #end()} method
          + * should be called explicitly. Subclasses are responsible for the cleanup of resources
          + * acquired by the subclass. Subclasses that override {@link #finalize()} in order
          + * to perform cleanup should be modified to use alternative cleanup mechanisms such
          + * as {@link java.lang.ref.Cleaner} and remove the overriding {@code finalize} method.
          + *
          ```
          [updating end() spec]
          ```
               /**
                * Closes the decompressor and discards any unprocessed input.
          + *
                * This method should be called when the decompressor is no longer
          - * being used, but will also be called automatically by the finalize()
          - * method. Once this method is called, the behavior of the Inflater
          - * object is undefined.
          + * being used. Once this method is called, the behavior of the
          + * Inflater object is undefined.
          + *
                */
               public void end() {
          ```
          [updating finalize() spec]
          ```
               /**
                * Closes the decompressor when garbage is collected.
                *
          - * @deprecated The {@code finalize} method has been deprecated.
          - * Subclasses that override {@code finalize} in order to perform cleanup
          - * should be modified to use alternative cleanup mechanisms and
          - * to remove the overriding {@code finalize} method.
          - * When overriding the {@code finalize} method, its implementation must explicitly
          - * ensure that {@code super.finalize()} is invoked as described in {@link Object#finalize}.
          - * See the specification for {@link Object#finalize()} for further
          - * information about migration options.
          - */
          - @Deprecated(since="9")
          - protected void finalize() {
          - end();
          - }
          + * @implSpec
          + * If this {@code Inflater} has been subclassed and the {@code end} method
          + * has been overridden, the {@code end} method will be called when the
          + * inflater is unreachable.
          + *
          + * @deprecated The {@code finalize} method has been deprecated and
          + * implemented as a no-op. Subclasses that override {@code finalize}
          + * in order to perform cleanup should be modified to use alternative
          + * cleanup mechanisms and remove the overriding {@code finalize}
          + * method. The recommended cleanup for compressor is to explicitly
          + * call {@code end} method when it is no longer in use. If the
          + * {@code end} is not invoked explicitly the resource of the compressor
          + * will be released when the instance becomes unreachable,
          + */
          + @Deprecated(since="9", forRemoval=true)
          + protected void finalize() {}
           
          ```
          src/java.base/share/classes/java/util/zip/ZipFile.java

          [adding class spec]
          ```
          + * @apiNote
          + * To release resources used by this {@code ZipFile}, the {@link #close()} method
          + * should be called explicitly or by try-with-resources. Subclasses are responsible
          + * for the cleanup of resources acquired by the subclass. Subclasses that override
          + * {@link #finalize()} in order to perform cleanup should be modified to use alternative
          + * cleanup mechanisms such as {@link java.lang.ref.Cleaner} and remove the overriding
          + * {@code finalize} method.
          + *
          ```
          [updating finalize() spec]
          ```
               /**
                * Ensures that the system resources held by this ZipFile object are
                * released when there are no more references to it.
                *
          - * <p>
          - * Since the time when GC would invoke this method is undetermined,
          - * it is strongly recommended that applications invoke the {@code close}
          - * method as soon they have finished accessing this {@code ZipFile}.
          - * This will prevent holding up system resources for an undetermined
          - * length of time.
          - *
          - * @deprecated The {@code finalize} method has been deprecated.
          - * Subclasses that override {@code finalize} in order to perform cleanup
          - * should be modified to use alternative cleanup mechanisms and
          - * to remove the overriding {@code finalize} method.
          - * When overriding the {@code finalize} method, its implementation must explicitly
          - * ensure that {@code super.finalize()} is invoked as described in {@link Object#finalize}.
          - * See the specification for {@link Object#finalize()} for further
          - * information about migration options.
          + * @implSpec
          + * If this {@code ZipFile} has been subclassed and the {@code close} method
          + * has been overridden, the {@code close} method will be called when the
          + * {@code ZipFile} is unreachable.
          + *
          + * @deprecated The {@code finalize} method has been deprecated and
          + * implemented as a no-op. Subclasses that override {@code finalize}
          + * in order to perform cleanup should be modified to use alternative
          + * cleanup mechanisms and to remove the overriding {@code finalize}
          + * method. The recommended cleanup for ZipFile object is to explicitly
          + * invoke {@code close} method when it is no longer in use, or use
          + * try-with-resources. If the {@code close} is not invoked explicitly
          + * the resources held by this object will be released when the instance
          + * becomes unreachable.
          + *
                * @throws IOException if an I/O error has occurred
          - * @see java.util.zip.ZipFile#close()
                */
          - @Deprecated(since="9")
          + @Deprecated(since="9", forRemoval=true)
          + protected void finalize() throws IOException {}
          ```
          Summary
          -------

          To replace the finalizer mechanism with java.lang.ref.Cleaner to close the object java.util.zip.ZipFile/Inflater/Deflater, and cleanup/release its underlying native resources when the object is no longer reachable.

          Problem
          -------

          The finalization mechanism has a history of usage and performnace issues, it is desirable the j.u.zip implementation to migrate away from its use of finalizer to the newly introduced java.lang.ref.Cleaner.

          Solution
          --------

          1) To mark the overridden finalize() method of ZipFile/Deflater/Inflater class as "@Deprecated(, forRemoval=true)" and implement it with an empty body (to leverage the VM feature that vm does not put an object into the finalization process if its finalize() has an empty-body-ed implementation). The new implementation uses Cleaner to do the resource cleanup when the object has become unreachable, with the exception when the ZipFile/Inflater/Deflater has been subclassed and its corresponding close()/end() method has been overridden. In this case, the finalization mechanism is used to do the cleanup, and for behavioral compatibility, the corresponding close()/end() in subclass method will be called when the ZipFile/Inflater/Deflater object is unreachable.

          2) To update the specification of the end() method (for both Deflater and Inflater) to remove the requirement that the end() "will be called by the finalizer() automatically".

          3) To add additional @apiNote in class spec and @implSpec in finalize() method spec to clarify (a) the recommended approach to cleanup the resource after use, and (b) there is no guarantee that the close()/end() method will be called directly by finalize(), though the method in subclass will be called after the object is unreachable, via an implementation specific mechanism, for behavioral compatibility.

          http://cr.openjdk.java.net/~sherman/8185582/webrev

          Specification
          -------------


          src/java.base/share/classes/java/util/zip/Deflater.java

          [adding class spec]
          ```
          + * @apiNote
          + * To release resources used by this {@code Deflater}, the {@link #end()} method
          + * should be called explicitly. Subclasses are responsible for the cleanup of resources
          + * acquired by the subclass. Subclasses that override {@link #finalize()} in order
          + * to perform cleanup should be modified to use alternative cleanup mechanisms such
          + * as {@link java.lang.ref.Cleaner} and remove the overriding {@code finalize} method.
          + *
          + * @implSpec
          + * If this {@code Deflater} has been subclassed and the {@code end} method has been
          + * overridden, the {@code end} method will be called when the deflater is unreachable.
          + * But the subclasses should not depend on this specific implementation; the
          + * finalization is not reliable and the {@code finalize} method is deprecated to be
          + * removed.
          + *
          ```
          [updating end() spec]
          ```
               /**
                * Closes the compressor and discards any unprocessed input.
          + *
                * This method should be called when the compressor is no longer
          - * being used, but will also be called automatically by the
          - * finalize() method. Once this method is called, the behavior
          - * of the Deflater object is undefined.
          + * being used. Once this method is called, the behavior of the
          + * Deflater object is undefined.
          + *
                */
               public void end() {...}
          ```
          [updating finalize() spec]
          ```
               /**
                * Closes the compressor when garbage is collected.
                *
          - * @deprecated The {@code finalize} method has been deprecated.
          - * Subclasses that override {@code finalize} in order to perform cleanup
          - * should be modified to use alternative cleanup mechanisms and
          - * to remove the overriding {@code finalize} method.
          - * When overriding the {@code finalize} method, its implementation must explicitly
          - * ensure that {@code super.finalize()} is invoked as described in {@link Object#finalize}.
          - * See the specification for {@link Object#finalize()} for further
          - * information about migration options.
          - */
          - @Deprecated(since="9")
          - protected void finalize() {
          - end();
          - }
          + * @deprecated The {@code finalize} method has been deprecated and will be
          + * removed. It is implemented as a no-op. Subclasses that override
          + * {@code finalize} in order to perform cleanup should be modified to use
          + * alternative cleanup mechanisms and to remove the overriding {@code finalize}
          + * method. The recommended cleanup for compressor is to explicitly call
          + * {@code end} method when it is no longer in use. If the {@code end} is
          + * not invoked explicitly the resource of the compressor will be released
          + * when the instance becomes unreachable.
          + */
          + @Deprecated(since="9", forRemoval=true)
          + protected void finalize() {}
          ```

          src/java.base/share/classes/java/util/zip/Inflater.java

          [adding class spec]
          ```
          + * @apiNote
          + * To release resources used by this {@code Inflater}, the {@link #end()} method
          + * should be called explicitly. Subclasses are responsible for the cleanup of resources
          + * acquired by the subclass. Subclasses that override {@link #finalize()} in order
          + * to perform cleanup should be modified to use alternative cleanup mechanisms such
          + * as {@link java.lang.ref.Cleaner} and remove the overriding {@code finalize} method.
          + *
          + * @implSpec
          + * If this {@code Inflater} has been subclassed and the {@code end} method has been
          + * overridden, the {@code end} method will be called when the inflater is unreachable.
          + * But the subclasses should not depend on this specific implementation; the
          + * finalization is not reliable and the {@code finalize} method is deprecated to be
          + * removed.
          + *
          ```
          [updating end() spec]
          ```
               /**
                * Closes the decompressor and discards any unprocessed input.
          + *
                * This method should be called when the decompressor is no longer
          - * being used, but will also be called automatically by the finalize()
          - * method. Once this method is called, the behavior of the Inflater
          - * object is undefined.
          + * being used. Once this method is called, the behavior of the
          + * Inflater object is undefined.
          + *
                */
               public void end() {
          ```
          [updating finalize() spec]
          ```
                /**
                * Closes the decompressor when garbage is collected.
                *
          - * @deprecated The {@code finalize} method has been deprecated.
          - * Subclasses that override {@code finalize} in order to perform cleanup
          - * should be modified to use alternative cleanup mechanisms and
          - * to remove the overriding {@code finalize} method.
          - * When overriding the {@code finalize} method, its implementation must explicitly
          - * ensure that {@code super.finalize()} is invoked as described in {@link Object#finalize}.
          - * See the specification for {@link Object#finalize()} for further
          - * information about migration options.
          - */
          - @Deprecated(since="9")
          - protected void finalize() {
          - end();
          - }
          + * @implSpec
          + * If this {@code Inflater} has been subclassed and the {@code end} method
          + * has been overridden, the {@code end} method will be called when the
          + * inflater is unreachable.
          + *
          + * @deprecated The {@code finalize} method has been deprecated and will be
          + * removed. It is implemented as a no-op. Subclasses that override
          + * {@code finalize} in order to perform cleanup should be modified to use
          + * alternative cleanup mechanisms and remove the overriding {@code finalize}
          + * method. The recommended cleanup for compressor is to explicitly call
          + * {@code end} method when it is no longer in use. If the {@code end} is
          + * not invoked explicitly the resource of the compressor will be released
          + * when the instance becomes unreachable,
          + */
          + @Deprecated(since="9", forRemoval=true)
          + protected void finalize() {}
          ```

          src/java.base/share/classes/java/util/zip/ZipFile.java

          [adding class spec]
          ```
          + * @apiNote
          + * To release resources used by this {@code ZipFile}, the {@link #close()} method
          + * should be called explicitly or by try-with-resources. Subclasses are responsible
          + * for the cleanup of resources acquired by the subclass. Subclasses that override
          + * {@link #finalize()} in order to perform cleanup should be modified to use alternative
          + * cleanup mechanisms such as {@link java.lang.ref.Cleaner} and remove the overriding
          + * {@code finalize} method.
          + *
          + * @implSpec
          + * If this {@code ZipFile} has been subclassed and the {@code close} method has
          + * been overridden, the {@code close} method will be called by the finalization
          + * when {@code ZipFile} is unreachable. But the subclasses should not depend on
          + * this specific implementation; the finalization is not reliable and the
          + * {@code finalize} method is deprecated to be removed.
          + *
          ```
          [updating finalize() spec]
          ```
               /**
                * Ensures that the system resources held by this ZipFile object are
                * released when there are no more references to it.
                *
          - * <p>
          - * Since the time when GC would invoke this method is undetermined,
          - * it is strongly recommended that applications invoke the {@code close}
          - * method as soon they have finished accessing this {@code ZipFile}.
          - * This will prevent holding up system resources for an undetermined
          - * length of time.
          - *
          - * @deprecated The {@code finalize} method has been deprecated.
          - * Subclasses that override {@code finalize} in order to perform cleanup
          - * should be modified to use alternative cleanup mechanisms and
          - * to remove the overriding {@code finalize} method.
          - * When overriding the {@code finalize} method, its implementation must explicitly
          - * ensure that {@code super.finalize()} is invoked as described in {@link Object#finalize}.
          - * See the specification for {@link Object#finalize()} for further
          - * information about migration options.
          + * @deprecated The {@code finalize} method has been deprecated and will be
          + * removed. It is implemented as a no-op. Subclasses that override
          + * {@code finalize} in order to perform cleanup should be modified to
          + * use alternative cleanup mechanisms and to remove the overriding
          + * {@code finalize} method. The recommended cleanup for ZipFile object
          + * is to explicitly invoke {@code close} method when it is no longer in
          + * use, or use try-with-resources. If the {@code close} is not invoked
          + * explicitly the resources held by this object will be released when
          + * the instance becomes unreachable.
          + *
                * @throws IOException if an I/O error has occurred
          - * @see java.util.zip.ZipFile#close()
                */
          - @Deprecated(since="9")
          - protected void finalize() throws IOException {}
          ```
          sherman Xueming Shen made changes -
          Description Summary
          -------

          To replace the finalizer mechanism with java.lang.ref.Cleaner to close the object java.util.zip.ZipFile/Inflater/Deflater, and cleanup/release its underlying native resources when the object is no longer reachable.

          Problem
          -------

          The finalization mechanism has a history of usage and performnace issues, it is desirable the j.u.zip implementation to migrate away from its use of finalizer to the newly introduced java.lang.ref.Cleaner.

          Solution
          --------

          1) To mark the overridden finalize() method of ZipFile/Deflater/Inflater class as "@Deprecated(, forRemoval=true)" and implement it with an empty body (to leverage the VM feature that vm does not put an object into the finalization process if its finalize() has an empty-body-ed implementation). The new implementation uses Cleaner to do the resource cleanup when the object has become unreachable, with the exception when the ZipFile/Inflater/Deflater has been subclassed and its corresponding close()/end() method has been overridden. In this case, the finalization mechanism is used to do the cleanup, and for behavioral compatibility, the corresponding close()/end() in subclass method will be called when the ZipFile/Inflater/Deflater object is unreachable.

          2) To update the specification of the end() method (for both Deflater and Inflater) to remove the requirement that the end() "will be called by the finalizer() automatically".

          3) To add additional @apiNote in class spec and @implSpec in finalize() method spec to clarify (a) the recommended approach to cleanup the resource after use, and (b) there is no guarantee that the close()/end() method will be called directly by finalize(), though the method in subclass will be called after the object is unreachable, via an implementation specific mechanism, for behavioral compatibility.

          http://cr.openjdk.java.net/~sherman/8185582/webrev

          Specification
          -------------


          src/java.base/share/classes/java/util/zip/Deflater.java

          [adding class spec]
          ```
          + * @apiNote
          + * To release resources used by this {@code Deflater}, the {@link #end()} method
          + * should be called explicitly. Subclasses are responsible for the cleanup of resources
          + * acquired by the subclass. Subclasses that override {@link #finalize()} in order
          + * to perform cleanup should be modified to use alternative cleanup mechanisms such
          + * as {@link java.lang.ref.Cleaner} and remove the overriding {@code finalize} method.
          + *
          + * @implSpec
          + * If this {@code Deflater} has been subclassed and the {@code end} method has been
          + * overridden, the {@code end} method will be called when the deflater is unreachable.
          + * But the subclasses should not depend on this specific implementation; the
          + * finalization is not reliable and the {@code finalize} method is deprecated to be
          + * removed.
          + *
          ```
          [updating end() spec]
          ```
               /**
                * Closes the compressor and discards any unprocessed input.
          + *
                * This method should be called when the compressor is no longer
          - * being used, but will also be called automatically by the
          - * finalize() method. Once this method is called, the behavior
          - * of the Deflater object is undefined.
          + * being used. Once this method is called, the behavior of the
          + * Deflater object is undefined.
          + *
                */
               public void end() {...}
          ```
          [updating finalize() spec]
          ```
               /**
                * Closes the compressor when garbage is collected.
                *
          - * @deprecated The {@code finalize} method has been deprecated.
          - * Subclasses that override {@code finalize} in order to perform cleanup
          - * should be modified to use alternative cleanup mechanisms and
          - * to remove the overriding {@code finalize} method.
          - * When overriding the {@code finalize} method, its implementation must explicitly
          - * ensure that {@code super.finalize()} is invoked as described in {@link Object#finalize}.
          - * See the specification for {@link Object#finalize()} for further
          - * information about migration options.
          - */
          - @Deprecated(since="9")
          - protected void finalize() {
          - end();
          - }
          + * @deprecated The {@code finalize} method has been deprecated and will be
          + * removed. It is implemented as a no-op. Subclasses that override
          + * {@code finalize} in order to perform cleanup should be modified to use
          + * alternative cleanup mechanisms and to remove the overriding {@code finalize}
          + * method. The recommended cleanup for compressor is to explicitly call
          + * {@code end} method when it is no longer in use. If the {@code end} is
          + * not invoked explicitly the resource of the compressor will be released
          + * when the instance becomes unreachable.
          + */
          + @Deprecated(since="9", forRemoval=true)
          + protected void finalize() {}
          ```

          src/java.base/share/classes/java/util/zip/Inflater.java

          [adding class spec]
          ```
          + * @apiNote
          + * To release resources used by this {@code Inflater}, the {@link #end()} method
          + * should be called explicitly. Subclasses are responsible for the cleanup of resources
          + * acquired by the subclass. Subclasses that override {@link #finalize()} in order
          + * to perform cleanup should be modified to use alternative cleanup mechanisms such
          + * as {@link java.lang.ref.Cleaner} and remove the overriding {@code finalize} method.
          + *
          + * @implSpec
          + * If this {@code Inflater} has been subclassed and the {@code end} method has been
          + * overridden, the {@code end} method will be called when the inflater is unreachable.
          + * But the subclasses should not depend on this specific implementation; the
          + * finalization is not reliable and the {@code finalize} method is deprecated to be
          + * removed.
          + *
          ```
          [updating end() spec]
          ```
               /**
                * Closes the decompressor and discards any unprocessed input.
          + *
                * This method should be called when the decompressor is no longer
          - * being used, but will also be called automatically by the finalize()
          - * method. Once this method is called, the behavior of the Inflater
          - * object is undefined.
          + * being used. Once this method is called, the behavior of the
          + * Inflater object is undefined.
          + *
                */
               public void end() {
          ```
          [updating finalize() spec]
          ```
                /**
                * Closes the decompressor when garbage is collected.
                *
          - * @deprecated The {@code finalize} method has been deprecated.
          - * Subclasses that override {@code finalize} in order to perform cleanup
          - * should be modified to use alternative cleanup mechanisms and
          - * to remove the overriding {@code finalize} method.
          - * When overriding the {@code finalize} method, its implementation must explicitly
          - * ensure that {@code super.finalize()} is invoked as described in {@link Object#finalize}.
          - * See the specification for {@link Object#finalize()} for further
          - * information about migration options.
          - */
          - @Deprecated(since="9")
          - protected void finalize() {
          - end();
          - }
          + * @implSpec
          + * If this {@code Inflater} has been subclassed and the {@code end} method
          + * has been overridden, the {@code end} method will be called when the
          + * inflater is unreachable.
          + *
          + * @deprecated The {@code finalize} method has been deprecated and will be
          + * removed. It is implemented as a no-op. Subclasses that override
          + * {@code finalize} in order to perform cleanup should be modified to use
          + * alternative cleanup mechanisms and remove the overriding {@code finalize}
          + * method. The recommended cleanup for compressor is to explicitly call
          + * {@code end} method when it is no longer in use. If the {@code end} is
          + * not invoked explicitly the resource of the compressor will be released
          + * when the instance becomes unreachable,
          + */
          + @Deprecated(since="9", forRemoval=true)
          + protected void finalize() {}
          ```

          src/java.base/share/classes/java/util/zip/ZipFile.java

          [adding class spec]
          ```
          + * @apiNote
          + * To release resources used by this {@code ZipFile}, the {@link #close()} method
          + * should be called explicitly or by try-with-resources. Subclasses are responsible
          + * for the cleanup of resources acquired by the subclass. Subclasses that override
          + * {@link #finalize()} in order to perform cleanup should be modified to use alternative
          + * cleanup mechanisms such as {@link java.lang.ref.Cleaner} and remove the overriding
          + * {@code finalize} method.
          + *
          + * @implSpec
          + * If this {@code ZipFile} has been subclassed and the {@code close} method has
          + * been overridden, the {@code close} method will be called by the finalization
          + * when {@code ZipFile} is unreachable. But the subclasses should not depend on
          + * this specific implementation; the finalization is not reliable and the
          + * {@code finalize} method is deprecated to be removed.
          + *
          ```
          [updating finalize() spec]
          ```
               /**
                * Ensures that the system resources held by this ZipFile object are
                * released when there are no more references to it.
                *
          - * <p>
          - * Since the time when GC would invoke this method is undetermined,
          - * it is strongly recommended that applications invoke the {@code close}
          - * method as soon they have finished accessing this {@code ZipFile}.
          - * This will prevent holding up system resources for an undetermined
          - * length of time.
          - *
          - * @deprecated The {@code finalize} method has been deprecated.
          - * Subclasses that override {@code finalize} in order to perform cleanup
          - * should be modified to use alternative cleanup mechanisms and
          - * to remove the overriding {@code finalize} method.
          - * When overriding the {@code finalize} method, its implementation must explicitly
          - * ensure that {@code super.finalize()} is invoked as described in {@link Object#finalize}.
          - * See the specification for {@link Object#finalize()} for further
          - * information about migration options.
          + * @deprecated The {@code finalize} method has been deprecated and will be
          + * removed. It is implemented as a no-op. Subclasses that override
          + * {@code finalize} in order to perform cleanup should be modified to
          + * use alternative cleanup mechanisms and to remove the overriding
          + * {@code finalize} method. The recommended cleanup for ZipFile object
          + * is to explicitly invoke {@code close} method when it is no longer in
          + * use, or use try-with-resources. If the {@code close} is not invoked
          + * explicitly the resources held by this object will be released when
          + * the instance becomes unreachable.
          + *
                * @throws IOException if an I/O error has occurred
          - * @see java.util.zip.ZipFile#close()
                */
          - @Deprecated(since="9")
          - protected void finalize() throws IOException {}
          ```
          Summary
          -------

          To replace the finalizer mechanism with java.lang.ref.Cleaner to close the object java.util.zip.ZipFile/Inflater/Deflater, and cleanup/release its underlying native resources when the object is no longer reachable.

          Problem
          -------

          The finalization mechanism has a history of usage and performnace issues, it is desirable the j.u.zip implementation to migrate away from its use of finalizer to the newly introduced java.lang.ref.Cleaner.

          Solution
          --------

          1) To mark the overridden finalize() method of ZipFile/Deflater/Inflater class as "@Deprecated(, forRemoval=true)" and implement it with an empty body (to leverage the VM feature that vm does not put an object into the finalization process if its finalize() has an empty-body-ed implementation). The new implementation uses Cleaner to do the resource cleanup when the object has become unreachable, with the exception when the ZipFile/Inflater/Deflater has been subclassed and its corresponding close()/end() method has been overridden. In this case, the finalization mechanism is used to do the cleanup, and for behavioral compatibility, the corresponding close()/end() in subclass method will be called when the ZipFile/Inflater/Deflater object is unreachable.

          2) To update the specification of the end() method (for both Deflater and Inflater) to remove the requirement that the end() "will be called by the finalizer() automatically".

          3) To add additional @apiNote in class spec and @implSpec in finalize() method spec to clarify (a) the recommended approach to cleanup the resource after use, and (b) there is no guarantee that the close()/end() method will be called directly by finalize(), though the method in subclass will be called after the object is unreachable, via an implementation specific mechanism, for behavioral compatibility.

          http://cr.openjdk.java.net/~sherman/8185582/webrev

          Specification
          -------------


          src/java.base/share/classes/java/util/zip/Deflater.java

          [adding class spec]
          ```
          + * @apiNote
          + * To release resources used by this {@code Deflater}, the {@link #end()} method
          + * should be called explicitly. Subclasses are responsible for the cleanup of resources
          + * acquired by the subclass. Subclasses that override {@link #finalize()} in order
          + * to perform cleanup should be modified to use alternative cleanup mechanisms such
          + * as {@link java.lang.ref.Cleaner} and remove the overriding {@code finalize} method.
          + *
          + * @implSpec
          + * If this {@code Deflater} has been subclassed and the {@code end} method has been
          + * overridden, the {@code end} method will be called by the finalization when the
          + * deflater is unreachable. But the subclasses should not depend on this specific
          + * implementation; the finalization is not reliable and the {@code finalize} method
          + * is deprecated to be removed.
          + *
          ```
          [updating end() spec]
          ```
               /**
                * Closes the compressor and discards any unprocessed input.
          + *
                * This method should be called when the compressor is no longer
          - * being used, but will also be called automatically by the
          - * finalize() method. Once this method is called, the behavior
          - * of the Deflater object is undefined.
          + * being used. Once this method is called, the behavior of the
          + * Deflater object is undefined.
          + *
                */
               public void end() {...}
          ```
          [updating finalize() spec]
          ```
               /**
                * Closes the compressor when garbage is collected.
                *
          - * @deprecated The {@code finalize} method has been deprecated.
          - * Subclasses that override {@code finalize} in order to perform cleanup
          - * should be modified to use alternative cleanup mechanisms and
          - * to remove the overriding {@code finalize} method.
          - * When overriding the {@code finalize} method, its implementation must explicitly
          - * ensure that {@code super.finalize()} is invoked as described in {@link Object#finalize}.
          - * See the specification for {@link Object#finalize()} for further
          - * information about migration options.
          - */
          - @Deprecated(since="9")
          - protected void finalize() {
          - end();
          - }
          + * @deprecated The {@code finalize} method has been deprecated and will be
          + * removed. It is implemented as a no-op. Subclasses that override
          + * {@code finalize} in order to perform cleanup should be modified to use
          + * alternative cleanup mechanisms and to remove the overriding {@code finalize}
          + * method. The recommended cleanup for compressor is to explicitly call
          + * {@code end} method when it is no longer in use. If the {@code end} is
          + * not invoked explicitly the resource of the compressor will be released
          + * when the instance becomes unreachable.
          + */
          + @Deprecated(since="9", forRemoval=true)
          + protected void finalize() {}
          ```

          src/java.base/share/classes/java/util/zip/Inflater.java

          [adding class spec]
          ```
          + * @apiNote
          + * To release resources used by this {@code Inflater}, the {@link #end()} method
          + * should be called explicitly. Subclasses are responsible for the cleanup of resources
          + * acquired by the subclass. Subclasses that override {@link #finalize()} in order
          + * to perform cleanup should be modified to use alternative cleanup mechanisms such
          + * as {@link java.lang.ref.Cleaner} and remove the overriding {@code finalize} method.
          + *
          + * @implSpec
          + * If this {@code Inflater} has been subclassed and the {@code end} method has been
          + * overridden, the {@code end} method will be called by the finalization when the
          + * inflater is unreachable. But the subclasses should not depend on this specific
          + * implementation; the finalization is not reliable and the {@code finalize} method
          + * is deprecated to be removed.
          + *
          ```
          [updating end() spec]
          ```
               /**
                * Closes the decompressor and discards any unprocessed input.
          + *
                * This method should be called when the decompressor is no longer
          - * being used, but will also be called automatically by the finalize()
          - * method. Once this method is called, the behavior of the Inflater
          - * object is undefined.
          + * being used. Once this method is called, the behavior of the
          + * Inflater object is undefined.
          + *
                */
               public void end() {
          ```
          [updating finalize() spec]
          ```
                /**
                * Closes the decompressor when garbage is collected.
                *
          - * @deprecated The {@code finalize} method has been deprecated.
          - * Subclasses that override {@code finalize} in order to perform cleanup
          - * should be modified to use alternative cleanup mechanisms and
          - * to remove the overriding {@code finalize} method.
          - * When overriding the {@code finalize} method, its implementation must explicitly
          - * ensure that {@code super.finalize()} is invoked as described in {@link Object#finalize}.
          - * See the specification for {@link Object#finalize()} for further
          - * information about migration options.
          - */
          - @Deprecated(since="9")
          - protected void finalize() {
          - end();
          - }
          + * @implSpec
          + * If this {@code Inflater} has been subclassed and the {@code end} method
          + * has been overridden, the {@code end} method will be called when the
          + * inflater is unreachable.
          + *
          + * @deprecated The {@code finalize} method has been deprecated and will be
          + * removed. It is implemented as a no-op. Subclasses that override
          + * {@code finalize} in order to perform cleanup should be modified to use
          + * alternative cleanup mechanisms and remove the overriding {@code finalize}
          + * method. The recommended cleanup for compressor is to explicitly call
          + * {@code end} method when it is no longer in use. If the {@code end} is
          + * not invoked explicitly the resource of the compressor will be released
          + * when the instance becomes unreachable,
          + */
          + @Deprecated(since="9", forRemoval=true)
          + protected void finalize() {}
          ```

          src/java.base/share/classes/java/util/zip/ZipFile.java

          [adding class spec]
          ```
          + * @apiNote
          + * To release resources used by this {@code ZipFile}, the {@link #close()} method
          + * should be called explicitly or by try-with-resources. Subclasses are responsible
          + * for the cleanup of resources acquired by the subclass. Subclasses that override
          + * {@link #finalize()} in order to perform cleanup should be modified to use alternative
          + * cleanup mechanisms such as {@link java.lang.ref.Cleaner} and remove the overriding
          + * {@code finalize} method.
          + *
          + * @implSpec
          + * If this {@code ZipFile} has been subclassed and the {@code close} method has
          + * been overridden, the {@code close} method will be called by the finalization
          + * when {@code ZipFile} is unreachable. But the subclasses should not depend on
          + * this specific implementation; the finalization is not reliable and the
          + * {@code finalize} method is deprecated to be removed.
          + *
          ```
          [updating finalize() spec]
          ```
               /**
                * Ensures that the system resources held by this ZipFile object are
                * released when there are no more references to it.
                *
          - * <p>
          - * Since the time when GC would invoke this method is undetermined,
          - * it is strongly recommended that applications invoke the {@code close}
          - * method as soon they have finished accessing this {@code ZipFile}.
          - * This will prevent holding up system resources for an undetermined
          - * length of time.
          - *
          - * @deprecated The {@code finalize} method has been deprecated.
          - * Subclasses that override {@code finalize} in order to perform cleanup
          - * should be modified to use alternative cleanup mechanisms and
          - * to remove the overriding {@code finalize} method.
          - * When overriding the {@code finalize} method, its implementation must explicitly
          - * ensure that {@code super.finalize()} is invoked as described in {@link Object#finalize}.
          - * See the specification for {@link Object#finalize()} for further
          - * information about migration options.
          + * @deprecated The {@code finalize} method has been deprecated and will be
          + * removed. It is implemented as a no-op. Subclasses that override
          + * {@code finalize} in order to perform cleanup should be modified to
          + * use alternative cleanup mechanisms and to remove the overriding
          + * {@code finalize} method. The recommended cleanup for ZipFile object
          + * is to explicitly invoke {@code close} method when it is no longer in
          + * use, or use try-with-resources. If the {@code close} is not invoked
          + * explicitly the resources held by this object will be released when
          + * the instance becomes unreachable.
          + *
                * @throws IOException if an I/O error has occurred
          - * @see java.util.zip.ZipFile#close()
                */
          - @Deprecated(since="9")
          - protected void finalize() throws IOException {}
          ```
          sherman Xueming Shen made changes -
          Status Draft [ 10001 ] Finalized [ 10110 ]
          Hide
          darcy Joe Darcy added a comment -

          Moving amended request to Approved.

          Show
          darcy Joe Darcy added a comment - Moving amended request to Approved.
          darcy Joe Darcy made changes -
          Resolution Approved [ 10000 ]
          Status Finalized [ 10110 ] Closed [ 6 ]

            People

            • Assignee:
              sherman Xueming Shen
              Reporter:
              rriggs Roger Riggs
              Reviewed By:
              Alan Bateman, Mandy Chung, Roger Riggs
            • Votes:
              0 Vote for this issue
              Watchers:
              4 Start watching this issue

              Dates

              • Created:
                Updated:
                Resolved: