forked from TuxCoding/FastLogin
Use reflection for test to fix compiling core to older Java versions
This commit is contained in:
@ -46,6 +46,7 @@ You can download them from here: https://ci.codemc.org/job/Games647/job/FastLogi
|
||||
|
||||
fastlogin.bukkit.command.premium
|
||||
fastlogin.bukkit.command.cracked
|
||||
|
||||
fastlogin.command.premium.other
|
||||
fastlogin.command.cracked.other
|
||||
|
||||
|
@ -40,10 +40,8 @@
|
||||
<packaging>jar</packaging>
|
||||
|
||||
<properties>
|
||||
<maven.compiler.source>8</maven.compiler.source>
|
||||
<maven.compiler.target>8</maven.compiler.target>
|
||||
<!-- Make Java 21 test method available in this multi-release project: Caution of breaking older systems -->
|
||||
<maven.compiler.release>21</maven.compiler.release>
|
||||
<!-- Still force Java 8 for the remaining project -->
|
||||
<maven.compiler.release>8</maven.compiler.release>
|
||||
</properties>
|
||||
|
||||
<name>FastLoginCore</name>
|
||||
|
@ -33,6 +33,7 @@ import org.junit.jupiter.api.condition.JRE;
|
||||
import org.slf4j.Logger;
|
||||
import org.slf4j.LoggerFactory;
|
||||
|
||||
import java.lang.reflect.InvocationTargetException;
|
||||
import java.util.concurrent.Executors;
|
||||
import java.util.concurrent.atomic.AtomicBoolean;
|
||||
|
||||
@ -63,8 +64,14 @@ class AsyncSchedulerTest {
|
||||
}
|
||||
|
||||
private static void setVirtual(AtomicBoolean virtual) {
|
||||
if (Thread.currentThread().isVirtual()) {
|
||||
virtual.set(true);
|
||||
boolean isVirtual;
|
||||
try {
|
||||
isVirtual = (boolean) Thread.class.getDeclaredMethod("isVirtual").invoke(Thread.currentThread());
|
||||
if (isVirtual) {
|
||||
virtual.set(true);
|
||||
}
|
||||
} catch (IllegalAccessException | InvocationTargetException | NoSuchMethodException ex) {
|
||||
ex.printStackTrace();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
Reference in New Issue
Block a user