From 966549324449b3962c935464d5c1b3658ac3dc7a Mon Sep 17 00:00:00 2001 From: Marcono1234 Date: Wed, 4 Sep 2024 21:52:18 +0200 Subject: [PATCH] fix: Fix incorrect Javadoc For loading a `Language` cannot use `Arena.ofConfined()` because that will directly unload the library again and then seems to crash the JVM afterwards, at least on Windows. And `SymbolLookup#libraryLookup` does not consider `java.library.path`, see https://bugs.openjdk.org/browse/JDK-8311090. --- .../java/io/github/treesitter/jtreesitter/Language.java | 9 +++------ .../io/github/treesitter/jtreesitter/package-info.java | 5 ++++- 2 files changed, 7 insertions(+), 7 deletions(-) diff --git a/src/main/java/io/github/treesitter/jtreesitter/Language.java b/src/main/java/io/github/treesitter/jtreesitter/Language.java index 47324d7..98ab102 100644 --- a/src/main/java/io/github/treesitter/jtreesitter/Language.java +++ b/src/main/java/io/github/treesitter/jtreesitter/Language.java @@ -60,12 +60,9 @@ private static UnsatisfiedLinkError unresolved(String name) { *

Example

* *

{@snippet lang="java" : - * Language language; - * try (Arena arena = Arena.ofConfined()) { - * String library = System.mapLibraryName("tree-sitter-java"); - * SymbolLookup symbols = SymbolLookup.libraryLookup(library, arena); - * language = Language.load(symbols, "tree_sitter_java"); - * } + * String library = System.mapLibraryName("tree-sitter-java"); + * SymbolLookup symbols = SymbolLookup.libraryLookup(library, Arena.ofAuto()); + * Language language = Language.load(symbols, "tree_sitter_java"); * } * * @throws RuntimeException If the language could not be loaded. diff --git a/src/main/java/io/github/treesitter/jtreesitter/package-info.java b/src/main/java/io/github/treesitter/jtreesitter/package-info.java index a43b4b0..7f4f58b 100644 --- a/src/main/java/io/github/treesitter/jtreesitter/package-info.java +++ b/src/main/java/io/github/treesitter/jtreesitter/package-info.java @@ -15,7 +15,10 @@ *

  • Shared libraries for languages
  • * * - * The shared libraries must be installed system-wide or in {@systemProperty java.library.path} + * The shared libraries must be installed in the OS-specific library path. + * For example on Unix the `libtree-sitter.so` might have to be on `LD_LIBRARY_PATH` + * and on Windows `tree-sitter.dll` has to be in the current working directory or `PATH` + * (see the documentation of your OS for details). * *

    Basic Usage

    *