aboutsummaryrefslogtreecommitdiffhomepage
path: root/src/main/java/com/google/devtools/build/lib/windows/jni
diff options
context:
space:
mode:
Diffstat (limited to 'src/main/java/com/google/devtools/build/lib/windows/jni')
-rw-r--r--src/main/java/com/google/devtools/build/lib/windows/jni/WindowsJniLoader.java25
1 files changed, 18 insertions, 7 deletions
diff --git a/src/main/java/com/google/devtools/build/lib/windows/jni/WindowsJniLoader.java b/src/main/java/com/google/devtools/build/lib/windows/jni/WindowsJniLoader.java
index d53a10c479..7e4aba28f3 100644
--- a/src/main/java/com/google/devtools/build/lib/windows/jni/WindowsJniLoader.java
+++ b/src/main/java/com/google/devtools/build/lib/windows/jni/WindowsJniLoader.java
@@ -19,6 +19,12 @@ import java.io.IOException;
/** Loads native code under Windows. */
public class WindowsJniLoader {
+ private static final String[] SEARCH_PATHS = {
+ "io_bazel/src/main/native/windows/windows_jni.dll",
+ "io_bazel/external/bazel_tools/src/main/native/windows/windows_jni.dll",
+ "bazel_tools/src/main/native/windows/windows_jni.dll",
+ };
+
private static boolean jniLoaded = false;
public static synchronized void loadJni() {
@@ -30,17 +36,22 @@ public class WindowsJniLoader {
System.loadLibrary("windows_jni");
} catch (UnsatisfiedLinkError ex) {
// Try to find the library in the runfiles.
- if (!loadFromRunfileOrThrow("io_bazel/src/main/native/windows/windows_jni.dll", ex)) {
- if (!loadFromRunfileOrThrow(
- "io_bazel/external/bazel_tools/src/main/native/windows/windows_jni.dll", ex)) {
- // We throw the UnsatisfiedLinkError if we cannot find the DLL under any known location.
- throw ex;
- }
- }
+ loadFromRunfileOrThrow(ex);
}
jniLoaded = true;
}
+ private static void loadFromRunfileOrThrow(UnsatisfiedLinkError ex) {
+ for (String path : SEARCH_PATHS) {
+ if (loadFromRunfileOrThrow(path, ex)) {
+ return;
+ }
+ }
+
+ // We throw the UnsatisfiedLinkError if we cannot find the DLL under any known location.
+ throw ex;
+ }
+
private static boolean loadFromRunfileOrThrow(String runfile, UnsatisfiedLinkError ex) {
// Try to find the library in the runfiles.
String path;