Skip to content

NativeLibraries.loadLibrary fails on some systems (fix suggestion included) #592

@ThomasHaas

Description

@ThomasHaas

We have encountered (a while ago) an issue with NativeLibraries.loadLibrary failing on some operating systems like NetBSD (see hernanponcedeleon/Dat3M#835).
Fixing this is easy on our side by falling back to System.loadLibrary.

        try {
            NativeLibraries.loadLibrary(libName);
        } catch (Exception e) {
            System.loadLibrary(libName);
        }

However, I think this could be integrated directly into NativeLibraries.loadLibrary which already has a fallback call to System.loadLibrary(name):

    // In NativeLibraries
    public static void loadLibrary(String name) {
        Optional<Path> path = findPathForLibrary(name);
        if (path.isPresent()) {
            System.load(((Path)path.orElseThrow()).toAbsolutePath().toString());
        } else {
            System.loadLibrary(name);
        }
    }

Just execute the else-case if the then-case throws an exceptions.

If you do not want to change this on your side, feel free to close this issue.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions