mirror of
https://github.com/HMCL-dev/HMCL.git
synced 2025-03-07 17:36:52 +08:00
fix build fails with Java 19 (#1784)
This commit is contained in:
parent
f83d3cd769
commit
2649e79d47
@ -44,7 +44,12 @@ public class LocalServerBroadcaster implements AutoCloseable {
|
||||
|
||||
public LocalServerBroadcaster(String address) {
|
||||
this.address = address;
|
||||
this.threadGroup.setDaemon(true);
|
||||
}
|
||||
|
||||
private Thread newThread(Runnable task, String name) {
|
||||
Thread thread = new Thread(threadGroup, task, name);
|
||||
thread.setDaemon(true);
|
||||
return thread;
|
||||
}
|
||||
|
||||
@Override
|
||||
@ -64,7 +69,7 @@ public class LocalServerBroadcaster implements AutoCloseable {
|
||||
public static final Pattern ADDRESS_PATTERN = Pattern.compile("^\\s*(\\d{1,3}\\.\\d{1,3}\\.\\d{1,3}\\.\\d{1,3}):(\\d{1,5})\\s*$");
|
||||
|
||||
public void start() {
|
||||
Thread forwardPortThread = new Thread(threadGroup, this::forwardPort, "ForwardPort");
|
||||
Thread forwardPortThread = newThread(this::forwardPort, "ForwardPort");
|
||||
forwardPortThread.start();
|
||||
}
|
||||
|
||||
@ -81,7 +86,7 @@ public class LocalServerBroadcaster implements AutoCloseable {
|
||||
|
||||
serverSocket.bind(null);
|
||||
|
||||
Thread broadcastMOTDThread = new Thread(threadGroup, () -> broadcastMOTD(serverSocket.getLocalPort()), "BroadcastMOTD");
|
||||
Thread broadcastMOTDThread = newThread(() -> broadcastMOTD(serverSocket.getLocalPort()), "BroadcastMOTD");
|
||||
broadcastMOTDThread.start();
|
||||
|
||||
LOG.log(Level.INFO, "Listening " + serverSocket.getLocalSocketAddress());
|
||||
@ -89,8 +94,8 @@ public class LocalServerBroadcaster implements AutoCloseable {
|
||||
while (running) {
|
||||
Socket forwardedSocket = serverSocket.accept();
|
||||
LOG.log(Level.INFO, "Accepting client");
|
||||
new Thread(threadGroup, () -> forwardTraffic(forwardingSocket, forwardedSocket), "Forward S->D").start();
|
||||
new Thread(threadGroup, () -> forwardTraffic(forwardedSocket, forwardingSocket), "Forward D->S").start();
|
||||
newThread(() -> forwardTraffic(forwardingSocket, forwardedSocket), "Forward S->D").start();
|
||||
newThread(() -> forwardTraffic(forwardedSocket, forwardingSocket), "Forward D->S").start();
|
||||
}
|
||||
}
|
||||
} catch (IOException | UnresolvedAddressException e) {
|
||||
|
@ -47,22 +47,22 @@ public abstract class BindingMapping<T, U> extends ObjectBinding<U> {
|
||||
return of(Bindings.createObjectBinding(() -> mapper.apply(watched), watched));
|
||||
}
|
||||
|
||||
protected final ObservableValue<T> predecessor;
|
||||
protected final ObservableValue<? extends T> predecessor;
|
||||
|
||||
public BindingMapping(ObservableValue<T> predecessor) {
|
||||
public BindingMapping(ObservableValue<? extends T> predecessor) {
|
||||
this.predecessor = requireNonNull(predecessor);
|
||||
bind(predecessor);
|
||||
}
|
||||
|
||||
public <V> BindingMapping<?, V> map(Function<U, V> mapper) {
|
||||
public <V> BindingMapping<?, V> map(Function<? super U, ? extends V> mapper) {
|
||||
return new MappedBinding<>(this, mapper);
|
||||
}
|
||||
|
||||
public <V> BindingMapping<?, V> flatMap(Function<U, ? extends ObservableValue<V>> mapper) {
|
||||
public <V> BindingMapping<?, V> flatMap(Function<? super U, ? extends ObservableValue<? extends V>> mapper) {
|
||||
return flatMap(mapper, null);
|
||||
}
|
||||
|
||||
public <V> BindingMapping<?, V> flatMap(Function<U, ? extends ObservableValue<V>> mapper, Supplier<V> nullAlternative) {
|
||||
public <V> BindingMapping<?, V> flatMap(Function<? super U, ? extends ObservableValue<? extends V>> mapper, Supplier<? extends V> nullAlternative) {
|
||||
return new FlatMappedBinding<>(map(mapper), nullAlternative);
|
||||
}
|
||||
|
||||
@ -82,7 +82,7 @@ public abstract class BindingMapping<T, U> extends ObjectBinding<U> {
|
||||
}
|
||||
|
||||
@Override
|
||||
public <V> BindingMapping<?, V> map(Function<T, V> mapper) {
|
||||
public <V> BindingMapping<?, V> map(Function<? super T, ? extends V> mapper) {
|
||||
return new MappedBinding<>(predecessor, mapper);
|
||||
}
|
||||
|
||||
@ -94,9 +94,9 @@ public abstract class BindingMapping<T, U> extends ObjectBinding<U> {
|
||||
|
||||
private static class MappedBinding<T, U> extends BindingMapping<T, U> {
|
||||
|
||||
private final Function<T, U> mapper;
|
||||
private final Function<? super T, ? extends U> mapper;
|
||||
|
||||
public MappedBinding(ObservableValue<T> predecessor, Function<T, U> mapper) {
|
||||
public MappedBinding(ObservableValue<? extends T> predecessor, Function<? super T, ? extends U> mapper) {
|
||||
super(predecessor);
|
||||
this.mapper = mapper;
|
||||
}
|
||||
@ -107,12 +107,12 @@ public abstract class BindingMapping<T, U> extends ObjectBinding<U> {
|
||||
}
|
||||
}
|
||||
|
||||
private static class FlatMappedBinding<T extends ObservableValue<U>, U> extends BindingMapping<T, U> {
|
||||
private static class FlatMappedBinding<T extends ObservableValue<? extends U>, U> extends BindingMapping<T, U> {
|
||||
|
||||
private final Supplier<U> nullAlternative;
|
||||
private final Supplier<? extends U> nullAlternative;
|
||||
private T lastObservable = null;
|
||||
|
||||
public FlatMappedBinding(ObservableValue<T> predecessor, Supplier<U> nullAlternative) {
|
||||
public FlatMappedBinding(ObservableValue<? extends T> predecessor, Supplier<? extends U> nullAlternative) {
|
||||
super(predecessor);
|
||||
this.nullAlternative = nullAlternative;
|
||||
}
|
||||
@ -148,11 +148,11 @@ public abstract class BindingMapping<T, U> extends ObjectBinding<U> {
|
||||
private T prev;
|
||||
private U value;
|
||||
|
||||
private final Function<T, CompletableFuture<U>> mapper;
|
||||
private final Function<? super T, ? extends CompletableFuture<? extends U>> mapper;
|
||||
private T computingPrev;
|
||||
private boolean computing = false;
|
||||
|
||||
public AsyncMappedBinding(ObservableValue<T> predecessor, Function<T, CompletableFuture<U>> mapper, U initial) {
|
||||
public AsyncMappedBinding(ObservableValue<? extends T> predecessor, Function<? super T, ? extends CompletableFuture<? extends U>> mapper, U initial) {
|
||||
super(predecessor);
|
||||
this.value = initial;
|
||||
this.mapper = mapper;
|
||||
@ -168,7 +168,7 @@ public abstract class BindingMapping<T, U> extends ObjectBinding<U> {
|
||||
computingPrev = currentPrev;
|
||||
}
|
||||
|
||||
CompletableFuture<U> task;
|
||||
CompletableFuture<? extends U> task;
|
||||
try {
|
||||
task = requireNonNull(mapper.apply(currentPrev));
|
||||
} catch (Throwable e) {
|
||||
|
@ -256,6 +256,7 @@ public enum OperatingSystem {
|
||||
return Optional.empty();
|
||||
}
|
||||
|
||||
@SuppressWarnings("removal")
|
||||
public static void forceGC() {
|
||||
System.gc();
|
||||
try {
|
||||
|
Loading…
Reference in New Issue
Block a user