Skip to content

Commit 5c7ade0

Browse files
committed
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.
1 parent 0a87d42 commit 5c7ade0

8 files changed

Lines changed: 16 additions & 83 deletions

File tree

‎design/client-api.md‎

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@ low-level API stays as it is.
99

1010
- Package `dev.onvoid.webrtc.client`, in the existing `webrtc-java` jar, exported by the
1111
`webrtc.java` module.
12-
- Java 8, like the rest of the module: no records, no sealed types, no `var`.
12+
- Java 11, like the rest of the module: no records, no sealed types.
1313
- Pure Java. Phase 1 needs no native or JNI changes and changes no existing signature.
1414

1515
## Decisions
@@ -20,7 +20,7 @@ These were open questions in the mockup. Each went with its recommendation.
2020
|---|---|---|
2121
| 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. |
2222
| 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. |
23-
| 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. |
23+
| 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. |
2424
| 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. |
2525
| 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. |
2626
| Entry point name? | `WebRtc`. | `try (WebRtc rtc = WebRtc.create()) { ... }` |
@@ -750,8 +750,8 @@ How the threading model is built:
750750
- Native observer completions are posted back to the control executor before anything is chained
751751
on them, so no internal code ever runs on a WebRTC thread.
752752
- Public futures are `ClientFuture`s completed on the event executor. `join()`/`get()` on an
753-
unfinished one from any event thread throws `BlockingCallException`. On Java 9+ derived stages
754-
refuse too, through `newIncompleteFuture`.
753+
unfinished one from any event thread throws `BlockingCallException`. Derived stages refuse too,
754+
through `newIncompleteFuture`.
755755
- Frame and audio subscriptions each get a `SerialExecutor` over a frame pool, with the drop
756756
policies described above.
757757
- `CustomAudio` is cut into 10 ms chunks and pushed from the runtime's timer thread, every 10 ms.

‎docs/guide/build.md‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@ You don't have to install Chromium's `depot_tools`, Siso or GN: the build clones
1010

1111
| Tool | Notes |
1212
| --------------------- | ----------------------------------------------------------------------------------------- |
13-
| JDK 17 or newer | The libraries target Java 8, but the JavaFX module needs 11 and the examples need 17. |
13+
| JDK 17 or newer | The libraries target Java 11, and the examples need 17. |
1414
| Maven 3.6.3 or newer | |
1515
| Git | Clones `depot_tools`, the WebRTC sources and the submodules. |
1616
| CMake 3.13 or newer | Must be on the `PATH`. The Maven build does not download it. |

‎docs/guide/client-api.md‎

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -331,10 +331,10 @@ A future that is already done may be read anywhere, and any thread that is not a
331331

332332
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.
333333

334-
::: warning
335-
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.
334+
Futures derived from them with `thenApply` and the like refuse to be waited on as well.
336335

337-
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.
336+
::: warning
337+
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.
338338
:::
339339

340340
## Sending Media

‎pom.xml‎

Lines changed: 2 additions & 23 deletions
Original file line numberDiff line numberDiff line change
@@ -75,33 +75,12 @@
7575
<groupId>org.apache.maven.plugins</groupId>
7676
<artifactId>maven-compiler-plugin</artifactId>
7777
<version>3.16.0</version>
78-
<executions>
79-
<execution>
80-
<id>default-compile</id>
81-
<configuration>
82-
<release>9</release>
83-
<!-- No excludes: compile everything to ensure module-info contains the right entries -->
84-
</configuration>
85-
</execution>
86-
<execution>
87-
<id>base-compile</id>
88-
<goals>
89-
<goal>compile</goal>
90-
</goals>
91-
<configuration>
92-
<!-- Recompile everything for the target VM except the module-info.java -->
93-
<excludes>
94-
<exclude>module-info.java</exclude>
95-
</excludes>
96-
</configuration>
97-
</execution>
98-
</executions>
9978
<!-- Defaults for compiler and testCompile -->
10079
<configuration>
101-
<release>8</release><!-- compatibility expectations -->
80+
<release>11</release><!-- compatibility expectations -->
10281
<!-- Only required when haven't configured the maven-toolchains-plugin -->
10382
<jdkToolchain>
104-
<version>9</version>
83+
<version>11</version>
10584
</jdkToolchain>
10685
<showDeprecation>true</showDeprecation>
10786
<showWarnings>true</showWarnings>

‎webrtc-examples/pom.xml‎

Lines changed: 0 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -47,23 +47,6 @@
4747
<plugin>
4848
<groupId>org.apache.maven.plugins</groupId>
4949
<artifactId>maven-compiler-plugin</artifactId>
50-
<executions>
51-
<!-- Clear parent executions -->
52-
<execution>
53-
<id>default-compile</id>
54-
<phase>compile</phase>
55-
<goals>
56-
<goal>compile</goal>
57-
</goals>
58-
<configuration>
59-
<release>17</release>
60-
</configuration>
61-
</execution>
62-
<execution>
63-
<id>base-compile</id>
64-
<phase>none</phase>
65-
</execution>
66-
</executions>
6750
<configuration>
6851
<release>17</release>
6952
<jdkToolchain>

‎webrtc-javafx/pom.xml‎

Lines changed: 0 additions & 29 deletions
Original file line numberDiff line numberDiff line change
@@ -22,35 +22,6 @@
2222
<javafx.version>17.0.20</javafx.version>
2323
</properties>
2424

25-
<build>
26-
<plugins>
27-
<!-- OpenJFX is built for Java 11, so this module cannot target the
28-
Java 8 the rest of the library does. The module descriptor
29-
compiles at Java 11 too, which makes the parent's second pass,
30-
the one that recompiles the classes for Java 8 without the
31-
descriptor, unnecessary. -->
32-
<plugin>
33-
<groupId>org.apache.maven.plugins</groupId>
34-
<artifactId>maven-compiler-plugin</artifactId>
35-
<executions>
36-
<execution>
37-
<id>default-compile</id>
38-
<configuration>
39-
<release>11</release>
40-
</configuration>
41-
</execution>
42-
<execution>
43-
<id>base-compile</id>
44-
<phase>none</phase>
45-
</execution>
46-
</executions>
47-
<configuration>
48-
<release>11</release>
49-
</configuration>
50-
</plugin>
51-
</plugins>
52-
</build>
53-
5425
<dependencies>
5526
<dependency>
5627
<groupId>dev.onvoid.webrtc</groupId>

‎webrtc/src/main/java/dev/onvoid/webrtc/client/ClientFuture.java‎

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -27,8 +27,8 @@
2727
* {@link #get()} refuse with a {@link BlockingCallException} instead of
2828
* deadlocking. A future that is already done may be read anywhere.
2929
* <p>
30-
* On Java 9 and later the futures derived from this one, with {@code
31-
* thenApply} and the like, are of this class too and refuse the same way.
30+
* The futures derived from this one, with {@code thenApply} and the like, are
31+
* of this class too and refuse the same way.
3232
*
3333
* @param <T> the result type.
3434
*/
@@ -81,14 +81,14 @@ public T join() {
8181
}
8282

8383
/**
84-
* Makes the futures derived from this one, on Java 9 and later, refuse to
85-
* be waited on from an event thread as well. Java 8 has no such method and
86-
* never calls it.
84+
* Makes the futures derived from this one refuse to be waited on from an
85+
* event thread as well.
8786
*
8887
* @param <U> the result type of the derived future.
8988
*
9089
* @return a new incomplete future.
9190
*/
91+
@Override
9292
public <U> CompletableFuture<U> newIncompleteFuture() {
9393
return new ClientFuture<>();
9494
}

‎webrtc/src/test/java/dev/onvoid/webrtc/client/PeerTests.java‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -275,7 +275,7 @@ void joinOnEventThreadRefused() throws Exception {
275275

276276
assertInstanceOf(BlockingCallException.class, await(refused));
277277

278-
// On Java 9 and later, so do the futures derived from them.
278+
// So do the futures derived from them.
279279
CompletableFuture<Throwable> derivedRefused = new CompletableFuture<>();
280280
peers[1].onStateChange(state -> {
281281
try {

0 commit comments

Comments
 (0)