[wpiutil] Rename Java package to edu.wpi.first.util (#3431)

This is more consistent with wpimath being edu.wpi.first.math.
This commit is contained in:
Peter Johnson
2021-06-12 01:17:09 -07:00
committed by GitHub
parent cfa1ca96f2
commit f60994ad24
31 changed files with 42 additions and 42 deletions

View File

@@ -0,0 +1,66 @@
// Copyright (c) FIRST and other WPILib contributors.
// Open Source Software; you can modify and/or share it under the terms of
// the WPILib BSD license file in the root directory of this project.
package edu.wpi.first.util;
import java.io.IOException;
import java.util.concurrent.atomic.AtomicBoolean;
public final class WPIUtilJNI {
static boolean libraryLoaded = false;
static RuntimeLoader<WPIUtilJNI> loader = null;
public static class Helper {
private static AtomicBoolean extractOnStaticLoad = new AtomicBoolean(true);
public static boolean getExtractOnStaticLoad() {
return extractOnStaticLoad.get();
}
public static void setExtractOnStaticLoad(boolean load) {
extractOnStaticLoad.set(load);
}
}
static {
if (Helper.getExtractOnStaticLoad()) {
try {
loader =
new RuntimeLoader<>(
"wpiutiljni", RuntimeLoader.getDefaultExtractionRoot(), WPIUtilJNI.class);
loader.loadLibrary();
} catch (IOException ex) {
ex.printStackTrace();
System.exit(1);
}
libraryLoaded = true;
}
}
/**
* Force load the library.
*
* @throws IOException if the library failed to load
*/
public static synchronized void forceLoad() throws IOException {
if (libraryLoaded) {
return;
}
loader =
new RuntimeLoader<>(
"wpiutiljni", RuntimeLoader.getDefaultExtractionRoot(), WPIUtilJNI.class);
loader.loadLibrary();
libraryLoaded = true;
}
public static native void enableMockTime();
public static native void setMockTime(long time);
public static native long now();
public static native void addPortForwarder(int port, String remoteHost, int remotePort);
public static native void removePortForwarder(int port);
}