From 5c7ade08a56d94fc07ea044600716d19521b42e0 Mon Sep 17 00:00:00 2001 From: Alex Andres Date: Tue, 27 Oct 2026 08:09:14 +0100 Subject: [PATCH] build!: require Java 11 All modules compile at release 11 in one pass, without the second pass that compiled the classes for Java 8. ClientFuture overrides newIncompleteFuture as an ordinary override. --- design/client-api.md | 8 ++--- docs/guide/build.md | 2 +- docs/guide/client-api.md | 6 ++-- pom.xml | 25 ++-------------- webrtc-examples/pom.xml | 17 ----------- webrtc-javafx/pom.xml | 29 ------------------- .../onvoid/webrtc/client/ClientFuture.java | 10 +++---- .../dev/onvoid/webrtc/client/PeerTests.java | 2 +- 8 files changed, 16 insertions(+), 83 deletions(-) diff --git a/design/client-api.md b/design/client-api.md index 91ab90286..1038234ad 100644 --- a/design/client-api.md +++ b/design/client-api.md @@ -9,7 +9,7 @@ low-level API stays as it is. - Package `dev.onvoid.webrtc.client`, in the existing `webrtc-java` jar, exported by the `webrtc.java` module. -- Java 8, like the rest of the module: no records, no sealed types, no `var`. +- Java 11, like the rest of the module: no records, no sealed types. - Pure Java. Phase 1 needs no native or JNI changes and changes no existing signature. ## Decisions @@ -20,7 +20,7 @@ These were open questions in the mockup. Each went with its recommendation. |---|---|---| | Where does it live? | A package in the existing jar, not a separate artifact. | Users get it without another dependency. It follows the core's releases. | | Default perfect negotiation role? | Impolite by default. | Glare between two impolite peers fails with a `NegotiationException` that names the fix (make one side polite). Every example sets the role explicitly. | -| Plain `CompletableFuture` or an own type? | Plain `CompletableFuture`. | On Java 8, stages derived from a subclass are plain `CompletableFuture`s, so `BlockingCallException` only catches a `join()`/`get()` on the future the API returned. The exception message and the event thread names help with the rest. | +| Plain `CompletableFuture` or an own type? | Plain `CompletableFuture`. | The API returns a `ClientFuture` subclass behind the type, whose derived stages are `ClientFuture`s too, so `BlockingCallException` catches a `join()`/`get()` on them as well. The exception message and the event thread names help with the rest. | | Does `Peer.close()` block? | No, never. | Safe in handlers and on UI threads. `closeAsync()` returns a future for callers who want to wait. `WebRtc.close()` is the one call that waits for everything. | | A camera opened twice? | Shared when the options match, `MediaException` when they differ. | One capture per device. Most platforms can't open a device with two capabilities anyway. | | Entry point name? | `WebRtc`. | `try (WebRtc rtc = WebRtc.create()) { ... }` | @@ -750,8 +750,8 @@ How the threading model is built: - Native observer completions are posted back to the control executor before anything is chained on them, so no internal code ever runs on a WebRTC thread. - Public futures are `ClientFuture`s completed on the event executor. `join()`/`get()` on an - unfinished one from any event thread throws `BlockingCallException`. On Java 9+ derived stages - refuse too, through `newIncompleteFuture`. + unfinished one from any event thread throws `BlockingCallException`. Derived stages refuse too, + through `newIncompleteFuture`. - Frame and audio subscriptions each get a `SerialExecutor` over a frame pool, with the drop policies described above. - `CustomAudio` is cut into 10 ms chunks and pushed from the runtime's timer thread, every 10 ms. diff --git a/docs/guide/build.md b/docs/guide/build.md index 8c56882b8..0b299a4ea 100644 --- a/docs/guide/build.md +++ b/docs/guide/build.md @@ -10,7 +10,7 @@ You don't have to install Chromium's `depot_tools`, Siso or GN: the build clones | Tool | Notes | | --------------------- | ----------------------------------------------------------------------------------------- | -| JDK 17 or newer | The libraries target Java 8, but the JavaFX module needs 11 and the examples need 17. | +| JDK 17 or newer | The libraries target Java 11, and the examples need 17. | | Maven 3.6.3 or newer | | | Git | Clones `depot_tools`, the WebRTC sources and the submodules. | | CMake 3.13 or newer | Must be on the `PATH`. The Maven build does not download it. | diff --git a/docs/guide/client-api.md b/docs/guide/client-api.md index bada11a41..77c79a3dd 100644 --- a/docs/guide/client-api.md +++ b/docs/guide/client-api.md @@ -331,10 +331,10 @@ A future that is already done may be read anywhere, and any thread that is not a Each call returns a future of its own, also of `closeAsync()`, `whenClosed()`, `whenConnected()` and `whenOpen()`. Cancelling one only stops waiting: the close goes on, and the futures of other callers, and of the runtime's own close, are not affected. -::: warning -On Java 8, only the futures the API returns refuse to be waited on. Futures derived from them with `thenApply` and the like do not, so waiting for one of those in a handler hangs that peer. From Java 9 on, the derived futures refuse too. +Futures derived from them with `thenApply` and the like refuse to be waited on as well. -A UI thread used as event executor is the same: waiting on it for a future of this API hangs the UI, since the future completes on it. +::: warning +A UI thread used as event executor does not refuse: waiting on it for a future of this API hangs the UI, since the future completes on it. ::: ## Sending Media diff --git a/pom.xml b/pom.xml index c64d5a35e..c628056c7 100644 --- a/pom.xml +++ b/pom.xml @@ -75,33 +75,12 @@ org.apache.maven.plugins maven-compiler-plugin 3.16.0 - - - default-compile - - 9 - - - - - base-compile - - compile - - - - - module-info.java - - - - - 8 + 11 - 9 + 11 true true diff --git a/webrtc-examples/pom.xml b/webrtc-examples/pom.xml index 08d717f6f..cbc1014cf 100644 --- a/webrtc-examples/pom.xml +++ b/webrtc-examples/pom.xml @@ -47,23 +47,6 @@ org.apache.maven.plugins maven-compiler-plugin - - - - default-compile - compile - - compile - - - 17 - - - - base-compile - none - - 17 diff --git a/webrtc-javafx/pom.xml b/webrtc-javafx/pom.xml index 5c23291e3..68fcced65 100644 --- a/webrtc-javafx/pom.xml +++ b/webrtc-javafx/pom.xml @@ -22,35 +22,6 @@ 17.0.20 - - - - - org.apache.maven.plugins - maven-compiler-plugin - - - default-compile - - 11 - - - - base-compile - none - - - - 11 - - - - - dev.onvoid.webrtc diff --git a/webrtc/src/main/java/dev/onvoid/webrtc/client/ClientFuture.java b/webrtc/src/main/java/dev/onvoid/webrtc/client/ClientFuture.java index 4ab921d3f..34df78805 100644 --- a/webrtc/src/main/java/dev/onvoid/webrtc/client/ClientFuture.java +++ b/webrtc/src/main/java/dev/onvoid/webrtc/client/ClientFuture.java @@ -27,8 +27,8 @@ * {@link #get()} refuse with a {@link BlockingCallException} instead of * deadlocking. A future that is already done may be read anywhere. *

- * On Java 9 and later the futures derived from this one, with {@code - * thenApply} and the like, are of this class too and refuse the same way. + * The futures derived from this one, with {@code thenApply} and the like, are + * of this class too and refuse the same way. * * @param the result type. */ @@ -81,14 +81,14 @@ public T join() { } /** - * Makes the futures derived from this one, on Java 9 and later, refuse to - * be waited on from an event thread as well. Java 8 has no such method and - * never calls it. + * Makes the futures derived from this one refuse to be waited on from an + * event thread as well. * * @param the result type of the derived future. * * @return a new incomplete future. */ + @Override public CompletableFuture newIncompleteFuture() { return new ClientFuture<>(); } diff --git a/webrtc/src/test/java/dev/onvoid/webrtc/client/PeerTests.java b/webrtc/src/test/java/dev/onvoid/webrtc/client/PeerTests.java index 7fd31d282..6a68831c7 100644 --- a/webrtc/src/test/java/dev/onvoid/webrtc/client/PeerTests.java +++ b/webrtc/src/test/java/dev/onvoid/webrtc/client/PeerTests.java @@ -275,7 +275,7 @@ void joinOnEventThreadRefused() throws Exception { assertInstanceOf(BlockingCallException.class, await(refused)); - // On Java 9 and later, so do the futures derived from them. + // So do the futures derived from them. CompletableFuture derivedRefused = new CompletableFuture<>(); peers[1].onStateChange(state -> { try {