Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Prevent JVM System.loadLibrary call that looks through all paths #457

Open
wants to merge 2 commits into
base: master
Choose a base branch
from
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 4 additions & 2 deletions src/main/java/org/bytedeco/javacpp/Loader.java
Original file line number Diff line number Diff line change
Expand Up @@ -916,10 +916,12 @@ public static URL[] findResources(Class cls, String name, int maxLength) throws
static boolean canCreateSymbolicLink = true;

static boolean pathsFirst = false;


static {
String s = System.getProperty("org.bytedeco.javacpp.pathsfirst", "false").toLowerCase();
s = System.getProperty("org.bytedeco.javacpp.pathsFirst", s).toLowerCase();
pathsFirst = s.equals("true") || s.equals("t") || s.equals("");
pathsFirst = s.equals("true") || s.equals("t") || s.equals("");
}

/** Creates and returns {@code System.getProperty("org.bytedeco.javacpp.cachedir")} or {@code ~/.javacpp/cache/} when not set. */
Expand Down Expand Up @@ -1701,7 +1703,7 @@ public static synchronized String loadLibrary(Class<?> cls, URL[] urls, String l
}
}
}
if (!loadedByLoadLibrary0) {
if (!loadedByLoadLibrary0 && System.getProperty("java.library.path", "").length() > 0) {
System.loadLibrary(libname);
}
return libname;
Expand Down