[JDK-6341887] RFR: Patch V3: java.util.zip: Add ByteBuffer methods to Inflater/Deflater

Xueming Shen xueming.shen at oracle.com
Wed Apr 11 03:49:01 UTC 2018


Hi David,

The CSR has been approved
https://bugs.openjdk.java.net/browse/JDK-8200527

API docs have been updated slightly based on the review suggestion.

(1) added some words in the class spec for both Inflater and Deflater.

|*<p>
  * This class deflates sequences of bytes into ZLIB compressed data format.
  * The input byte sequence is provided in either byte array or byte buffer,
  * via one of the {@code setInput()} methods. The output byte sequence is
  * written to the output byte array or byte buffer passed to the
  * {@code deflate()} methods.
  *<p>|

|*<p>
  * This class inflates sequences of ZLIB compressed bytes. The input byte
  * sequence is provided in either byte array or byte buffer, via one of the
  * {@code setInput()} methods. The output byte sequence is written to the
  * output byte array or byte buffer passed to the {@code deflate()} methods.
  *<p>|


(2) adjusted the workding a little for those setInput() methods

|      *<p>
      * One of the {@code setInput()} methods should be called whenever
      * {@code needsInput()} returns true indicating that more input data
      * is required.
      *<p>|


Two issues have been noticed when running tier1/2/3 tests

(1) there is a error at ln#Inflater.c#243, the "input" is being released 
instead of "output"
     
http://cr.openjdk.java.net/~sherman/6341887.David.Lloyd/webrev.00/src/java.base/share/native/libzip/Inflater.c.sdiff.html

     which triggered crash for some tests. fixed.

(2) sun/nio/ch/TestMaxCachedBufferSize.java failed "because of" the 
"defaultBuf"
      uses direct ByteBuffer. This is probably the issue of the test but 
I simply update
      the "defaultBuf" to be the heap buffer/0, instead of touch the 
failed test case.
      I don't have problem if you prefer to "fix" the test and keep the 
"defaultBuf" as
      direct buffer instead.

    // static final ByteBuffer defaultBuf = ByteBuffer.allocateDirect(0);
     static final ByteBuffer defaultBuf = ByteBuffer.allocate(0);

(3) I also updated test/jdk/java/util/zip/DeInflate.java with more tests 
for the new APIs.
      More tests might be desired though.

The latest webrev is at

http://cr.openjdk.java.net/~sherman/6341887.David.Lloyd/webrev/

Thanks,
Sherman



More information about the core-libs-dev mailing list