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

fix: Fix incorrect Javadoc #24

Closed
wants to merge 1 commit into from
Closed
Show file tree
Hide file tree
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
9 changes: 3 additions & 6 deletions src/main/java/io/github/treesitter/jtreesitter/Language.java
Original file line number Diff line number Diff line change
Expand Up @@ -60,12 +60,9 @@ private static UnsatisfiedLinkError unresolved(String name) {
* <h4 id="load-example">Example</h4>
*
* <p>{@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());
Copy link
Contributor Author

@Marcono1234 Marcono1234 Sep 4, 2024

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I hope Arena.ofAuto() is actually safe here and jtreesitter always holds a strong reference to the Language. Otherwise this could crash the JVM as well in case the Arena is not reachable anymore and is garbage collected (?).

Arena.ofAuto() is currently also used in the TreeSitterJava binding (here in the tests and in tree-sitter/tree-sitter-java#182; but there at least the TreeSitterJava class has a strong reference to the Arena.

* Language language = Language.load(symbols, "tree_sitter_java");
* }
*
* @throws RuntimeException If the language could not be loaded.
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,10 @@
* <li>Shared libraries for languages</li>
* </ul>
*
* <em>The shared libraries must be installed system-wide or in {@systemProperty java.library.path}</em>
* <em>The shared libraries must be installed in the OS-specific library path.</em>
* 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).
*
* <h2 id="usage">Basic Usage</h2>
*
Expand Down