fix: build
This commit is contained in:
@@ -17,7 +17,6 @@
|
||||
*/
|
||||
package org.jackhuang.hmcl.util;
|
||||
|
||||
import javafx.embed.swing.JFXPanel;
|
||||
import org.jackhuang.hmcl.task.Schedulers;
|
||||
import org.jackhuang.hmcl.task.Task;
|
||||
import org.jackhuang.hmcl.task.TaskExecutor;
|
||||
@@ -26,6 +25,9 @@ import org.junit.Assert;
|
||||
import org.junit.Assume;
|
||||
import org.junit.Test;
|
||||
|
||||
import java.lang.invoke.MethodHandle;
|
||||
import java.lang.invoke.MethodHandles;
|
||||
import java.lang.invoke.MethodType;
|
||||
import java.util.concurrent.CancellationException;
|
||||
import java.util.concurrent.CompletableFuture;
|
||||
import java.util.concurrent.CountDownLatch;
|
||||
@@ -78,7 +80,20 @@ public class TaskTest {
|
||||
}
|
||||
|
||||
public void testThenAccept() {
|
||||
new JFXPanel(); // init JavaFX Toolkit
|
||||
// init JavaFX Toolkit
|
||||
try {
|
||||
// Java 9 or Latter
|
||||
final MethodHandle startup =
|
||||
MethodHandles.publicLookup().findStatic(
|
||||
javafx.application.Platform.class, "startup", MethodType.methodType(void.class, Runnable.class));
|
||||
startup.invokeExact((Runnable) () -> {});
|
||||
} catch (Throwable e) {
|
||||
// Java 8
|
||||
try {
|
||||
Class.forName("javafx.embed.swing.JFXPanel").getDeclaredConstructor().newInstance();
|
||||
} catch (Throwable ignored) {
|
||||
}
|
||||
}
|
||||
AtomicBoolean flag = new AtomicBoolean();
|
||||
boolean result = Task.supplyAsync(JavaVersion::fromCurrentEnvironment)
|
||||
.thenAcceptAsync(Schedulers.javafx(), javaVersion -> {
|
||||
|
||||
Reference in New Issue
Block a user