Update VendorJNI to not use RuntimeLoader (#34)
This commit is contained in:
parent
63dc8dc664
commit
0262900d2c
18
src/main/java/com/vendor/jni/VendorJNI.java
vendored
18
src/main/java/com/vendor/jni/VendorJNI.java
vendored
@ -1,16 +1,12 @@
|
|||||||
package com.vendor.jni;
|
package com.vendor.jni;
|
||||||
|
|
||||||
import java.io.IOException;
|
|
||||||
import java.util.concurrent.atomic.AtomicBoolean;
|
import java.util.concurrent.atomic.AtomicBoolean;
|
||||||
|
|
||||||
import edu.wpi.first.util.RuntimeLoader;
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Demo class for loading the driver via JNI.
|
* Demo class for loading the driver via JNI.
|
||||||
*/
|
*/
|
||||||
public class VendorJNI {
|
public class VendorJNI {
|
||||||
static boolean libraryLoaded = false;
|
static boolean libraryLoaded = false;
|
||||||
static RuntimeLoader<VendorJNI> loader = null;
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Helper class for determining whether or not to load the driver on static initialization.
|
* Helper class for determining whether or not to load the driver on static initialization.
|
||||||
@ -37,27 +33,19 @@ public class VendorJNI {
|
|||||||
|
|
||||||
static {
|
static {
|
||||||
if (Helper.getExtractOnStaticLoad()) {
|
if (Helper.getExtractOnStaticLoad()) {
|
||||||
try {
|
System.loadLibrary("VendorDriver");
|
||||||
loader = new RuntimeLoader<>("VendorDriver", RuntimeLoader.getDefaultExtractionRoot(), VendorJNI.class);
|
|
||||||
loader.loadLibrary();
|
|
||||||
} catch (IOException ex) {
|
|
||||||
ex.printStackTrace();
|
|
||||||
System.exit(1);
|
|
||||||
}
|
|
||||||
libraryLoaded = true;
|
libraryLoaded = true;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Force load the library.
|
* 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) {
|
if (libraryLoaded) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
loader = new RuntimeLoader<>("VendorDriver", RuntimeLoader.getDefaultExtractionRoot(), VendorJNI.class);
|
System.loadLibrary("VendorDriver");
|
||||||
loader.loadLibrary();
|
|
||||||
libraryLoaded = true;
|
libraryLoaded = true;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user