File 0005-Fix-to-avoid-incompatibility-if-compile-with-jdk9.patch of Package gradle4

From 716b81701259d0ea2bb47fb07daea436f5991cc4 Mon Sep 17 00:00:00 2001
From: =?UTF-8?q?Klaus=20K=C3=A4mpf?= <kkaempf@suse.de>
Date: Thu, 18 Apr 2019 18:33:39 +0200
Subject: [PATCH 5/5] Fix to avoid incompatibility if compile with jdk9
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 8bit

From https://github.com/apache/felix/pull/114

Java 9 introduces overridden methods with covariant return types for
the following methods in java.nio.ByteBuffer:

position​(int newPosition)
limit​(int newLimit)
flip​()
clear​()
mark​()
reset​()
rewind​()
In Java 9 they all now return ByteBuffer, whereas the methods they
override return Buffer,
resulting in exceptions like this when executing on Java 8 and lower:
java.lang.NoSuchMethodError:
java.nio.ByteBuffer.limit(I)Ljava/nio/ByteBuffer
This is because the generated byte code includes the static return
type of the method, which is not found on Java 8 and lower because the
overloaded methods with covariant return types don't exist (the issue
appears even with source and target 8 or lower in compilation
parameters).
The solution is to cast ByteBuffer instances to Buffer before calling
the method.
---
 .../remote/internal/inet/SocketConnection.java   | 16 ++++++++--------
 1 file changed, 8 insertions(+), 8 deletions(-)

diff --git 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
index 5f2ce63ccd41..693f7d6d83b7 100755
--- 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
@@ -156,7 +156,7 @@ public class SocketConnection<T> implements RemoteConnection<T> {
             selector = Selector.open();
             socket.register(selector, SelectionKey.OP_READ);
             buffer = ByteBuffer.allocateDirect(4096);
-            buffer.limit(0);
+            ((Buffer)buffer).limit(0);
         }
 
         @Override
@@ -174,7 +174,7 @@ public class SocketConnection<T> implements RemoteConnection<T> {
                 return 0;
             }
 
-            if (buffer.remaining() == 0) {
+            if (((Buffer)buffer).remaining() == 0) {
                 try {
                     selector.select();
                 } catch (ClosedSelectorException e) {
@@ -190,8 +190,8 @@ public class SocketConnection<T> implements RemoteConnection<T> {
                     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;
@@ -203,7 +203,7 @@ public class SocketConnection<T> implements RemoteConnection<T> {
                 }
             }
 
-            int count = Math.min(buffer.remaining(), max);
+            int count = Math.min(((Buffer)buffer).remaining(), max);
             buffer.get(dest, offset, count);
             return count;
         }
@@ -237,13 +237,13 @@ public class SocketConnection<T> implements RemoteConnection<T> {
             int remaining = max;
             int currentPos = offset;
             while (remaining > 0) {
-                int count = Math.min(remaining, buffer.remaining());
+                int count = Math.min(remaining, ((Buffer)buffer).remaining());
                 if (count > 0) {
                     buffer.put(src, currentPos, count);
                     remaining -= count;
                     currentPos += count;
                 }
-                while (buffer.remaining() == 0) {
+                while (((Buffer)buffer).remaining() == 0) {
                     writeBufferToChannel();
                 }
             }
@@ -251,7 +251,7 @@ public class SocketConnection<T> implements RemoteConnection<T> {
 
         @Override
         public void flush() throws IOException {
-            while (buffer.position() > 0) {
+            while (((Buffer)buffer).position() > 0) {
                 writeBufferToChannel();
             }
         }
-- 
2.21.0

openSUSE Build Service is sponsored by