File 0006-Fix-to-avoid-incompatibility-if-compile-with-jdk9.patch of Package gradle5

From 98efd2116459556e3aa7493f55bea566332106e1 Mon Sep 17 00:00:00 2001
From: =?UTF-8?q?Klaus=20K=C3=A4mpf?= <kkaempf@suse.de>
Date: Thu, 18 Apr 2019 18:24:57 +0200
Subject: [PATCH 6/7] 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      | 13 +++++++------
 1 file changed, 7 insertions(+), 6 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 fb38fbc262f0..d3dc9183d17f 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
@@ -33,6 +33,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;
@@ -159,7 +160,7 @@ public SocketInputStream(SocketChannel socket) throws IOException {
             selector = Selector.open();
             socket.register(selector, SelectionKey.OP_READ);
             buffer = ByteBuffer.allocateDirect(4096);
-            BufferCaster.cast(buffer).limit(0);
+            BufferCaster.cast((Buffer)buffer).limit(0);
         }
 
         @Override
@@ -187,19 +188,19 @@ public int read(byte[] dest, int offset, int max) throws IOException {
                     return -1;
                 }
 
-                BufferCaster.cast(buffer).clear();
+                BufferCaster.cast((Buffer)buffer).clear();
                 int nread;
                 try {
                     nread = socket.read(buffer);
                 } catch (IOException e) {
                     if (isEndOfStream(e)) {
-                        BufferCaster.cast(buffer).position(0);
-                        BufferCaster.cast(buffer).limit(0);
+                        BufferCaster.cast((Buffer)buffer).position(0);
+                        BufferCaster.cast((Buffer)buffer).limit(0);
                         return -1;
                     }
                     throw e;
                 }
-                BufferCaster.cast(buffer).flip();
+                BufferCaster.cast((Buffer)buffer).flip();
 
                 if (nread < 0) {
                     return -1;
@@ -260,7 +261,7 @@ public void flush() throws IOException {
         }
 
         private void writeBufferToChannel() throws IOException {
-            BufferCaster.cast(buffer).flip();
+            BufferCaster.cast((Buffer)buffer).flip();
             int count = writeWithNonBlockingRetry();
             if (count == 0) {
                 // buffer was still full after non-blocking retries, now block
-- 
2.23.0

openSUSE Build Service is sponsored by