Skip to content

Commit

Permalink
Update VendorJNI to not use RuntimeLoader (#34)
Browse files Browse the repository at this point in the history
  • Loading branch information
rzblue authored May 31, 2024
1 parent 63dc8dc commit 0262900
Showing 1 changed file with 3 additions and 15 deletions.
18 changes: 3 additions & 15 deletions src/main/java/com/vendor/jni/VendorJNI.java
Original file line number Diff line number Diff line change
@@ -1,16 +1,12 @@
package com.vendor.jni;

import java.io.IOException;
import java.util.concurrent.atomic.AtomicBoolean;

import edu.wpi.first.util.RuntimeLoader;

/**
* Demo class for loading the driver via JNI.
*/
public class VendorJNI {
static boolean libraryLoaded = false;
static RuntimeLoader<VendorJNI> loader = null;

/**
* Helper class for determining whether or not to load the driver on static initialization.
Expand All @@ -37,27 +33,19 @@ public static void setExtractOnStaticLoad(boolean load) {

static {
if (Helper.getExtractOnStaticLoad()) {
try {
loader = new RuntimeLoader<>("VendorDriver", RuntimeLoader.getDefaultExtractionRoot(), VendorJNI.class);
loader.loadLibrary();
} catch (IOException ex) {
ex.printStackTrace();
System.exit(1);
}
System.loadLibrary("VendorDriver");
libraryLoaded = true;
}
}

/**
* Force load the library.
* @throws java.io.IOException thrown if the native library cannot be found
*/
public static synchronized void forceLoad() throws IOException {
public static synchronized void forceLoad() {
if (libraryLoaded) {
return;
}
loader = new RuntimeLoader<>("VendorDriver", RuntimeLoader.getDefaultExtractionRoot(), VendorJNI.class);
loader.loadLibrary();
System.loadLibrary("VendorDriver");
libraryLoaded = true;
}

Expand Down

0 comments on commit 0262900

Please sign in to comment.