<!DOCTYPE html><html><head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8">
  </head>
  <body>
    On 16/02/2024 19:20, Eirik Bjørsnøs wrote:<br>
    <blockquote type="cite" cite="mid:CA+pBWhsLaev2o64v4g4tLfczEw2Fi0trxnTMpr2DbHmQ4ShHaQ@mail.gmail.com">
      
      <div dir="ltr">Hi,<br>
        <div><br>
        </div>
        <div>Initially, the Deflater and Inflater classes in
          java.util.zip only supported up to 2GB of inflated or deflated
          data, the reason being that their getTotalIn and getTotalOut
          methods returns an int.</div>
        <div><br>
        </div>
        <div>Around 2004, this limitation was remedied by introducing
          the new methods getBytesRead and getBytesWritten returning
          long. The legacy methods getTotalIn and getTotalOut were
          updated to simply delegate to the new method with an added
          cast to int.</div>
        <div><br>
        </div>
        <div>The legacy methods include notes in their Javadoc similar
          to this:</div>
        <div><br>
        </div>
        <blockquote class="gmail_quote" style="margin:0px 0px 0px 0.8ex;border-left:1px solid rgb(204,204,204);padding-left:1ex"> 
             * <p>Since the number of bytes may be greater than<br>
               * Integer.MAX_VALUE, the {@link #getBytesRead()} method
          is now<br>
               * the preferred means of obtaining this
          information.</p></blockquote>
        <div><br>
        </div>
        <div>but these methods are not marked as @Deprecated in Javadoc
          or with annotations.</div>
        <div><br>
        </div>
        <div>Is there any good reason why these four methods have not
          been officially deprecated in the past? If not, would it be
          worthwhile doing so now?</div>
        <br>
      </div>
    </blockquote>
    <br>
    Good question. I'm surprised the spec for these methods wasn't
    clarified in Java 5 when the new methods to return long were added.
    Right not, it's not clear from the spec how the older methods behave
    when the number of bytes is greater than Integer.MAX_VALUE. Long
    standing behavior is to cast to int so they will return a negative
    value once the total in/out exceeds Integer.MAX_VALUE.  Methods such
    as URLConnection::getContentLength are clamped so they return
    Integer.MAX_VALUE when the content length is larger than that. Both
    behaviors are a hazard but arguably the Inflater/Delater behavior is
    worse. So I think there is good case for deprecating the old
    methods.<br>
    <br>
    -Alan<br>
  </body>
</html>