[gradle] 03/04: Fixed a runtime error when Gradle is built with Java 9 and runs with Java 8 (LP: #1760359)

Emmanuel Bourg ebourg-guest at moszumanska.debian.org
Wed Apr 4 15:33:04 UTC 2018


This is an automated email from the git hooks/post-receive script.

ebourg-guest pushed a commit to branch master
in repository gradle.

commit f2799a0faf862e4417e20995ead31637e4ef0907
Author: Emmanuel Bourg <ebourg at apache.org>
Date:   Wed Apr 4 17:16:50 2018 +0200

    Fixed a runtime error when Gradle is built with Java 9 and runs with Java 8 (LP: #1760359)
---
 debian/changelog                         |  2 +
 debian/patches/java8-compatibility.patch | 69 ++++++++++++++++++++++++++++++++
 debian/patches/series                    |  1 +
 3 files changed, 72 insertions(+)

diff --git a/debian/changelog b/debian/changelog
index cab7f03..874c410 100644
--- a/debian/changelog
+++ b/debian/changelog
@@ -3,6 +3,8 @@ gradle (3.4.1-5) UNRELEASED; urgency=medium
   * Team upload.
   * Backported a fix to support the javac --module-source-path option
   * Fixed the build failure with Ant 1.10 (Closes: #894641)
+  * Fixed a runtime error when Gradle is built with Java 9 and runs with Java 8
+    (LP: #1760359)
 
  -- Emmanuel Bourg <ebourg at apache.org>  Wed, 04 Apr 2018 13:34:54 +0200
 
diff --git a/debian/patches/java8-compatibility.patch b/debian/patches/java8-compatibility.patch
new file mode 100644
index 0000000..b96bccf
--- /dev/null
+++ b/debian/patches/java8-compatibility.patch
@@ -0,0 +1,69 @@
+Description: Makes Gradle usable with Java 8 even if compiled with Java 9
+Author: Emmanuel Bourg <ebourg at apache.org>
+Forwarded: not-needed
+Bug-Ubuntu: https://bugs.launchpad.net/ubuntu/+source/gradle/+bug/1760359
+--- a/subprojects/messaging/src/main/java/org/gradle/internal/remote/internal/inet/SocketConnection.java
++++ b/subprojects/messaging/src/main/java/org/gradle/internal/remote/internal/inet/SocketConnection.java
+@@ -32,6 +32,7 @@
+ 
+ import java.io.*;
+ import java.net.InetSocketAddress;
++import java.nio.Buffer;
+ import java.nio.ByteBuffer;
+ import java.nio.channels.ClosedSelectorException;
+ import java.nio.channels.SelectionKey;
+@@ -151,7 +152,7 @@
+             selector = Selector.open();
+             socket.register(selector, SelectionKey.OP_READ);
+             buffer = ByteBuffer.allocateDirect(4096);
+-            buffer.limit(0);
++            ((Buffer) buffer).limit(0);
+         }
+ 
+         @Override
+@@ -185,13 +186,13 @@
+                     nread = socket.read(buffer);
+                 } catch (IOException e) {
+                     if (isEndOfStream(e)) {
+-                        buffer.position(0);
+-                        buffer.limit(0);
++                        ((Buffer) buffer).position(0);
++                        ((Buffer) buffer).limit(0);
+                         return -1;
+                     }
+                     throw e;
+                 }
+-                buffer.flip();
++                ((Buffer) buffer).flip();
+ 
+                 if (nread < 0) {
+                     return -1;
+@@ -252,7 +253,7 @@
+         }
+ 
+         private void writeBufferToChannel() throws IOException {
+-            buffer.flip();
++            ((Buffer) buffer).flip();
+             int count = writeWithNonBlockingRetry();
+             if (count == 0) {
+                 // buffer was still full after non-blocking retries, now block
+--- a/subprojects/base-services/src/main/java/org/gradle/internal/io/StreamByteBuffer.java
++++ b/subprojects/base-services/src/main/java/org/gradle/internal/io/StreamByteBuffer.java
+@@ -191,7 +191,7 @@
+                 // copy one by one until the underflow has been resolved
+                 buf = ByteBuffer.allocate(buf.remaining() + 1).put(buf);
+                 buf.put(nextBuf.get());
+-                buf.flip();
++                ((java.nio.Buffer) buf).flip();
+             } else {
+                 if (hasRemaining(nextBuf)) {
+                     buf = nextBuf;
+@@ -234,7 +234,7 @@
+                 throw UncheckedException.throwAsUncheckedException(e);
+             }
+         }
+-        charbuffer.flip();
++        ((java.nio.Buffer) charbuffer).flip();
+         return charbuffer;
+     }
+ 
diff --git a/debian/patches/series b/debian/patches/series
index f7a5fb7..5286c91 100644
--- a/debian/patches/series
+++ b/debian/patches/series
@@ -29,3 +29,4 @@ add-test-case-for-10-internal_c1fe5e40a76b.patch
 support-zulu9-version-number_d9c35cf9d74c.patch
 disallow-both-module-source-path-and-source-path.patch
 source-level.patch
+java8-compatibility.patch

-- 
Alioth's /usr/local/bin/git-commit-notice on /srv/git.debian.org/git/pkg-java/gradle.git



More information about the pkg-java-commits mailing list