From db8676cb6dbc2e5177edcbaf13de1502326250a0 Mon Sep 17 00:00:00 2001 From: Andrea Cavalli Date: Wed, 30 Aug 2023 11:57:13 +0200 Subject: [PATCH] Fix java 8 build --- .../java/it/tdlight/client/SimpleTelegramClient.java | 3 ++- .../src/main/java/it/tdlight/util/FutureSupport.java | 10 ++++++++++ .../src/main/java11/it/tdlight/util/FutureSupport.java | 10 ++++++++++ 3 files changed, 22 insertions(+), 1 deletion(-) create mode 100644 tdlight-java/src/main/java/it/tdlight/util/FutureSupport.java create mode 100644 tdlight-java/src/main/java11/it/tdlight/util/FutureSupport.java diff --git a/tdlight-java/src/main/java/it/tdlight/client/SimpleTelegramClient.java b/tdlight-java/src/main/java/it/tdlight/client/SimpleTelegramClient.java index 3e64a6c11..1a3caf3d8 100644 --- a/tdlight-java/src/main/java/it/tdlight/client/SimpleTelegramClient.java +++ b/tdlight-java/src/main/java/it/tdlight/client/SimpleTelegramClient.java @@ -8,6 +8,7 @@ import it.tdlight.TelegramClient; import it.tdlight.jni.TdApi.Message; import it.tdlight.jni.TdApi.Update; +import it.tdlight.util.FutureSupport; import it.tdlight.util.UnsupportedNativeLibraryException; import it.tdlight.jni.TdApi; import it.tdlight.jni.TdApi.ChatListArchive; @@ -359,7 +360,7 @@ public void waitForExit() throws InterruptedException { * Wait until TDLight is closed */ public CompletableFuture waitForExitAsync() { - return closed.copy(); + return FutureSupport.copy(closed); } private void onCloseUpdate() { diff --git a/tdlight-java/src/main/java/it/tdlight/util/FutureSupport.java b/tdlight-java/src/main/java/it/tdlight/util/FutureSupport.java new file mode 100644 index 000000000..4fff8e57f --- /dev/null +++ b/tdlight-java/src/main/java/it/tdlight/util/FutureSupport.java @@ -0,0 +1,10 @@ +package it.tdlight.util; + +import java.util.concurrent.CompletableFuture; + +public class FutureSupport { + + public static CompletableFuture copy(CompletableFuture future) { + return CompletableFuture.completedFuture(true).thenCompose(ignored -> future); + } +} diff --git a/tdlight-java/src/main/java11/it/tdlight/util/FutureSupport.java b/tdlight-java/src/main/java11/it/tdlight/util/FutureSupport.java new file mode 100644 index 000000000..5b42d9636 --- /dev/null +++ b/tdlight-java/src/main/java11/it/tdlight/util/FutureSupport.java @@ -0,0 +1,10 @@ +package it.tdlight.util; + +import java.util.concurrent.CompletableFuture; + +public class FutureSupport { + + public static CompletableFuture copy(CompletableFuture future) { + return future.copy(); + } +}