Skip to content

Setting java.library.path doesn't seem to work #59

@odenix

Description

@odenix

I'm trying to load the tree-sitter native library from a specific directory by setting system property java.library.path as advertised here: https://tree-sitter.github.io/java-tree-sitter/io/github/treesitter/jtreesitter/package-summary.html

However, I'm getting the following exception:

java.lang.ExceptionInInitializerError
   at io.github.treesitter.jtreesitter.Language.<clinit>(Language.java:18)
   ...
Caused by: java.lang.IllegalArgumentException: Cannot open library: tree-sitter.dll
   at java.base/java.lang.foreign.SymbolLookup.libraryLookup(SymbolLookup.java:348)
   at java.base/java.lang.foreign.SymbolLookup.libraryLookup(SymbolLookup.java:299)
   at io.github.treesitter.jtreesitter.internal.TreeSitter.<clinit>(TreeSitter.java:58)

TreeSitter.java:58 contains:

static final SymbolLookup SYMBOL_LOOKUP = SymbolLookup.libraryLookup(System.mapLibraryName("tree-sitter"), LIBRARY_ARENA)
          .or(SymbolLookup.loaderLookup())
          .or(Linker.nativeLinker().defaultLookup());

Here, initialization of field SYMBOL_LOOKUP fails because SymbolLookup.libraryLookup(System.mapLibraryName("tree-sitter"), LIBRARY_ARENA) throws:

throw new IllegalArgumentException("Cannot open library: " + name);

In other words, this seems to fail long before it tries to load anything from java.library.path.

Windows 11, java-tree-sitter 0.24.0

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