This is an automated email from the ASF dual-hosted git repository.
jkf pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/ant.git
The following commit(s) were added to refs/heads/master by this push:
new 823a531 PR 53457 - ByteBuffer::limit and ByteBuffer::rewind are new
methods linked when building on jdk11 this prevents running ZIP related tasks
on jdk8 from completing successfully
823a531 is described below
commit 823a5316eb69f49d72838c24ded4478ecf29b970
Author: jkf <[email protected]>
AuthorDate: Sat Jun 1 10:33:06 2019 +0200
PR 53457 - ByteBuffer::limit and ByteBuffer::rewind are new methods linked
when building on jdk11 this prevents running ZIP related tasks on jdk8 from
completing successfully
---
src/main/org/apache/tools/zip/NioZipEncoding.java | 5 +++--
.../org/apache/tools/zip/Simple8BitZipEncoding.java | 4 ++--
src/main/org/apache/tools/zip/ZipEncodingHelper.java | 17 ++++++++++++++---
3 files changed, 19 insertions(+), 7 deletions(-)
diff --git a/src/main/org/apache/tools/zip/NioZipEncoding.java
b/src/main/org/apache/tools/zip/NioZipEncoding.java
index bef8cf3..4853d2e 100644
--- a/src/main/org/apache/tools/zip/NioZipEncoding.java
+++ b/src/main/org/apache/tools/zip/NioZipEncoding.java
@@ -20,6 +20,7 @@
package org.apache.tools.zip;
import java.io.IOException;
+import java.nio.Buffer;
import java.nio.ByteBuffer;
import java.nio.CharBuffer;
import java.nio.charset.Charset;
@@ -102,8 +103,8 @@ class NioZipEncoding implements ZipEncoding {
}
}
- out.limit(out.position());
- out.rewind();
+ ZipEncodingHelper.prepareBufferForRead(out);
+
return out;
}
diff --git a/src/main/org/apache/tools/zip/Simple8BitZipEncoding.java
b/src/main/org/apache/tools/zip/Simple8BitZipEncoding.java
index f70e02c..b3c1132 100644
--- a/src/main/org/apache/tools/zip/Simple8BitZipEncoding.java
+++ b/src/main/org/apache/tools/zip/Simple8BitZipEncoding.java
@@ -20,6 +20,7 @@
package org.apache.tools.zip;
import java.io.IOException;
+import java.nio.Buffer;
import java.nio.ByteBuffer;
import java.util.ArrayList;
import java.util.Collections;
@@ -247,8 +248,7 @@ class Simple8BitZipEncoding implements ZipEncoding {
}
}
- out.limit(out.position());
- out.rewind();
+ ZipEncodingHelper.prepareBufferForRead(out);
return out;
}
diff --git a/src/main/org/apache/tools/zip/ZipEncodingHelper.java
b/src/main/org/apache/tools/zip/ZipEncodingHelper.java
index 8e670d5..be6b0ec 100644
--- a/src/main/org/apache/tools/zip/ZipEncodingHelper.java
+++ b/src/main/org/apache/tools/zip/ZipEncodingHelper.java
@@ -18,6 +18,7 @@
package org.apache.tools.zip;
+import java.nio.Buffer;
import java.nio.ByteBuffer;
import java.nio.charset.Charset;
import java.nio.charset.UnsupportedCharsetException;
@@ -147,15 +148,25 @@ public abstract class ZipEncodingHelper {
*
*/
static ByteBuffer growBuffer(final ByteBuffer b, final int newCapacity) {
- b.limit(b.position());
- b.rewind();
-
+ prepareBufferForRead(b);
final int c2 = b.capacity() * 2;
final ByteBuffer on = ByteBuffer.allocate(c2 < newCapacity ?
newCapacity : c2);
on.put(b);
return on;
}
+
+ /**
+ * Prepares a buffer to be read after writing.
+ *
+ * @param b The buffer
+ */
+ static void prepareBufferForRead(final Buffer b) {
+ // ByteBuffer has overridden methods in java 11 but not in java 8
+ // so the Buffer is significant to get java 8 compatible classes
+ b.limit(b.position());
+ b.rewind();
+ }
/**