[wpiutil] Remove RuntimeDetector and simplify RuntimeLoader (#6600)

This commit is contained in:
Jade
2024-05-25 01:48:59 +08:00
committed by GitHub
parent 72a6d22d9a
commit 6220c6be4d
22 changed files with 99 additions and 474 deletions

View File

@@ -5,13 +5,13 @@
package edu.wpi.first.ntcore;
import edu.wpi.first.networktables.NetworkTablesJNI;
import edu.wpi.first.util.RuntimeDetector;
import edu.wpi.first.util.CombinedRuntimeLoader;
public final class DevMain {
/** Main method. */
public static void main(String[] args) {
System.out.println("Hello World!");
System.out.println(RuntimeDetector.getPlatformPath());
System.out.println(CombinedRuntimeLoader.getPlatformPath());
NetworkTablesJNI.flush(NetworkTablesJNI.getDefaultInstance());
}

View File

@@ -17,7 +17,6 @@ import java.util.concurrent.atomic.AtomicBoolean;
/** NetworkTables JNI. */
public final class NetworkTablesJNI {
static boolean libraryLoaded = false;
static RuntimeLoader<NetworkTablesJNI> loader = null;
/** Sets whether JNI should be loaded in the static block. */
public static class Helper {
@@ -48,10 +47,7 @@ public final class NetworkTablesJNI {
static {
if (Helper.getExtractOnStaticLoad()) {
try {
loader =
new RuntimeLoader<>(
"ntcorejni", RuntimeLoader.getDefaultExtractionRoot(), NetworkTablesJNI.class);
loader.loadLibrary();
RuntimeLoader.loadLibrary("ntcorejni");
} catch (IOException ex) {
ex.printStackTrace();
System.exit(1);
@@ -69,10 +65,7 @@ public final class NetworkTablesJNI {
if (libraryLoaded) {
return;
}
loader =
new RuntimeLoader<>(
"ntcorejni", RuntimeLoader.getDefaultExtractionRoot(), NetworkTablesJNI.class);
loader.loadLibrary();
RuntimeLoader.loadLibrary("ntcorejni");
libraryLoaded = true;
}

View File

@@ -17,7 +17,6 @@ import java.util.concurrent.atomic.AtomicBoolean;
/** NetworkTables JNI. */
public final class NetworkTablesJNI {
static boolean libraryLoaded = false;
static RuntimeLoader<NetworkTablesJNI> loader = null;
/** Sets whether JNI should be loaded in the static block. */
public static class Helper {
@@ -48,10 +47,7 @@ public final class NetworkTablesJNI {
static {
if (Helper.getExtractOnStaticLoad()) {
try {
loader =
new RuntimeLoader<>(
"ntcorejni", RuntimeLoader.getDefaultExtractionRoot(), NetworkTablesJNI.class);
loader.loadLibrary();
RuntimeLoader.loadLibrary("ntcorejni");
} catch (IOException ex) {
ex.printStackTrace();
System.exit(1);
@@ -69,10 +65,7 @@ public final class NetworkTablesJNI {
if (libraryLoaded) {
return;
}
loader =
new RuntimeLoader<>(
"ntcorejni", RuntimeLoader.getDefaultExtractionRoot(), NetworkTablesJNI.class);
loader.loadLibrary();
RuntimeLoader.loadLibrary("ntcorejni");
libraryLoaded = true;
}