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

Conversation

abbasvalliani
Copy link

Currently, even if java.library.path is set to nothing, the System.loadLibrary is called which searches through all paths to load the libraries. This creates a significant delay in startup.

@saudet
Copy link
Member

saudet commented Feb 5, 2021

It doesn't do that to start with, this is not an issue: #456 (comment)

@saudet
Copy link
Member

saudet commented Feb 12, 2021

Please let me know how to reproduce the initial issue. It's not worth merging this if everything works as expected already.

@abbasvalliani
Copy link
Author

abbasvalliani commented Feb 12, 2021 via email

@saudet
Copy link
Member

saudet commented Feb 12, 2021

I can't reproduce this on my installation of Windows 10 either. This is what I get with libopenblas.dll from MSYS2 in the PATH:

public class TestLoad {
    public static void main(String[] args) {
        System.loadLibrary("libopenblas");
    }
}
$ java -version
java version "1.8.0_152"
Java(TM) SE Runtime Environment (build 1.8.0_152-b16)
Java HotSpot(TM) 64-Bit Server VM (build 25.152-b16, mixed mode)

$ java TestLoad

$ java -Djava.library.path= TestLoad
Exception in thread "main" java.lang.UnsatisfiedLinkError: no libopenblas in java.library.path
        at java.lang.ClassLoader.loadLibrary(ClassLoader.java:1867)
        at java.lang.Runtime.loadLibrary0(Runtime.java:870)
        at java.lang.System.loadLibrary(System.java:1122)
        at TestLoad.main(TestLoad.java:3)

@saudet
Copy link
Member

saudet commented Mar 1, 2021

BTW, if you've only tried it with mvn -Djava.library.path= ..., it might be because Maven sets the system property too late.
Try instead setting the environment variable MAVEN_OPTS=-Djava.library.path=.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

2 participants