Skip to content

Commit 28dc9e6

Browse files
committed
Remove the lib.name documentation lie + dead LlamaSystemProperties.getLibName()
Deep forensic comparison against kherud/java-llama.cpp (the upstream) showed that net.ladenthin.llama.lib.name has been a documentation-only ghost since 2023: Upstream history of "lib.name": c8f57f7 (initial JNI commit) - Javadoc mention AND real code consumer: String nativeLibName = System.getProperty("de.kherud.llama.lib.name"); if (nativeLibName == null) { ... } 7a852d1 - README documents it (-Dde.kherud.llama.lib.name=myname.so) 6bb63e1 ("add ggml shared library to binding") - CODE CONSUMER DELETED. The loader was extended to load multiple shared libraries (ggml and jllama as separate files); the single-name-override model became incompatible. Javadoc + README mentions were left behind. 6d0c4af - README mention removed. The Javadoc lie in LlamaLoader.java survives upstream to this day. Bernard's fork inherited the Javadoc lie verbatim and later added a LlamaSystemProperties.getLibName() getter for "completeness" (every documented property gets a registry getter) - but the loader code still hardcodes "jllama" and ignores the override. Why delete rather than re-wire: - Upstream deliberately removed the consumer to support multi-library loading. Re-wiring would either reintroduce the same single-name limitation upstream removed, or need a new design covering both libraries. - This fork has added even more dimensions (CPU / CUDA / OpenCL-Adreno classifiers); the "one override filename" idea is even less applicable now than in upstream's day. - No caller has ever asked for it; the README will be more honest with one fewer documented-but-broken row. Changes: - LlamaSystemProperties.getLibName() deleted (~5 lines). - LlamaLoader.java Javadoc fixed: lib.name removed from the "set these properties" sentence; replaced with a multi-paragraph history note citing upstream commit 6bb63e1 so future readers understand the property's lifecycle and don't try to "re-add" it. - README System Properties Reference: lib.name row dropped (was 9 rows, now 8). - CLAUDE.md: the registry-cleanup TODO is closed for both subitems (lib.name DELETED here; osinfo.architecture FIXED in 3ae6c81 by routing OSInfo.getArchName() through the registry getter). Tests: OSInfoTest 16/16 + LlamaLoaderTest 21/21 = 37/37 pass. mvn compile clean.
1 parent 3ae6c81 commit 28dc9e6

4 files changed

Lines changed: 16 additions & 16 deletions

File tree

CLAUDE.md

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -688,9 +688,9 @@ See [`../workspace/policies/jqwik-prompt-injection.md`](../workspace/policies/jq
688688
689689
- **Cross-repo code-quality TODOs** — see [`../workspace/policies/code-quality-todos.md`](../workspace/policies/code-quality-todos.md) for the canonical `@VisibleForTesting` design-fit review, package hierarchy review, and class/method naming review. This repo has no `@VisibleForTesting` usages today; package and naming reviews remain open.
690690
691-
- **`LlamaSystemProperties` registry cleanup (deep-scan finding).** The deep scan that produced the README [System Properties Reference](README.md#system-properties-reference) surfaced two small inconsistencies between the registry class and its actual consumers — worth a focused cleanup but low priority:
692-
- `LlamaSystemProperties.getLibName()` is **declared but has zero callers** in `src/main/java`. Either wire it into `LlamaLoader`'s filename-resolution path (so `-Dnet.ladenthin.llama.lib.name=…` actually does something), or delete the getter as dead code. The README table documents the property as "currently no production caller" so users are not misled in the meantime.
693-
- `OSInfo.java:390` reads `System.getProperty("net.ladenthin.llama.osinfo.architecture")` directly with the literal string, **bypassing** `LlamaSystemProperties.getOsinfoArchitecture()`. The duplication parallels the recent BAF `Radix.HEX` consolidation: the registry-side getter exists but is not the single source of truth. Route `OSInfo` through the registry getter so a future property rename only has to land in one place.
691+
- ~~**`LlamaSystemProperties` registry cleanup (deep-scan finding).**~~ ✅ **BOTH RESOLVED** (this session). The deep scan that produced the README [System Properties Reference](README.md#system-properties-reference) surfaced two registry-bypass smells; both have now been fixed:
692+
- ~~`LlamaSystemProperties.getLibName()` is declared but has zero callers~~ ✅ **DELETED**. Forensic trace against `kherud/java-llama.cpp` history (cloned into `/tmp` this session) showed the loader code that originally read `lib.name` was removed in upstream commit `6bb63e1` (*"add ggml shared library to binding"*) when the loader was extended to load multiple shared libraries (ggml + jllama) as separate files — the single-name-override model became incompatible. The Javadoc + README mentions of `lib.name` lived on in both upstream and this fork as a documentation lie ever since. Re-wiring it would either reintroduce the one-library limitation upstream removed, or need a much bigger multi-library design with no caller asking for it. Cleanup landed: getter deleted from `LlamaSystemProperties`, Javadoc lie removed from `LlamaLoader` (with a comment block citing `6bb63e1` so future readers know the history), README row dropped.
693+
- ~~`OSInfo.java:390` bypasses `LlamaSystemProperties.getOsinfoArchitecture()`~~ ✅ **FIXED** in commit `3ae6c81` — `OSInfo.getArchName()` now routes through `new LlamaSystemProperties().getOsinfoArchitecture()`; the literal property string lives in exactly one place (the registry). Direct parallel to the recent BAF `Radix.HEX` consolidation.
694694
695695
- ~~**Abstract the Java and test writing guidelines to a workspace-level shared layer.**~~ **DONE.** This repo is Java 8; follow the workspace version chain at [`../workspace/guides/src/CODE_WRITING_GUIDE-8.md`](../workspace/guides/src/CODE_WRITING_GUIDE-8.md) and [`../workspace/guides/test/TEST_WRITING_GUIDE-8.md`](../workspace/guides/test/TEST_WRITING_GUIDE-8.md). Canonical TDD skill at [`../workspace/.claude/skills/java-tdd-guide/SKILL.md`](../workspace/.claude/skills/java-tdd-guide/SKILL.md). This repo has no project-specific writing-guide supplements.
696696

README.md

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -254,7 +254,6 @@ Every `net.ladenthin.llama.*` system property recognised by the library, deep-sc
254254
| Property | Default | Scope | Consumer | Description |
255255
|---|---|---|---|---|
256256
| `net.ladenthin.llama.lib.path` | unset (falls back to `java.library.path`) | runtime | `LlamaLoader` | Directory containing the native `jllama` shared library. Checked first, before `java.library.path`. Set with `-Dnet.ladenthin.llama.lib.path=/path/to/dir`. |
257-
| `net.ladenthin.llama.lib.name` | unset (platform-determined, e.g. `jllama.so`) | runtime | `LlamaSystemProperties.getLibName()` (declared, currently no production caller) | Override for the native library filename. |
258257
| `net.ladenthin.llama.tmpdir` | unset (falls back to `java.io.tmpdir`) | runtime | `LlamaLoader` | Custom temporary directory used when extracting the native library from the JAR. |
259258
| `net.ladenthin.llama.osinfo.architecture` | unset (uses `os.arch`) | runtime | `OSInfo` | Override for the architecture string used to locate the bundled library inside the JAR. Useful when `os.arch` reports an unexpected value (e.g. inside dockcross / chrooted environments). |
260259
| `net.ladenthin.llama.test.ngl` | `43` | test | `LlamaModelTest`, `RerankingModelTest`, `ChatScenarioTest`, `ChatAdvancedTest`, `ErrorHandlingTest`, `SessionConcurrencyTest`, `ConfigureParallelInferenceTest`, `MultimodalIntegrationTest` (via `Integer.getInteger(TestConstants.PROP_TEST_NGL, TestConstants.DEFAULT_TEST_NGL)`) | Number of GPU layers used during testing. Pin to `0` on CPU-only hosts: `mvn test -Dnet.ladenthin.llama.test.ngl=0`. |

src/main/java/net/ladenthin/llama/LlamaLoader.java

Lines changed: 13 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -19,12 +19,22 @@
1919
import org.jspecify.annotations.Nullable;
2020

2121
/**
22-
* Set the system properties {@code net.ladenthin.llama.lib.path} /
23-
* {@code net.ladenthin.llama.lib.name} appropriately so that the library can
24-
* find *.dll, *.dylib and *.so files, according to the current OS (win, linux, mac).
22+
* Set the system property {@code net.ladenthin.llama.lib.path} appropriately
23+
* so that the library can find {@code *.dll}, {@code *.dylib} and
24+
* {@code *.so} files, according to the current OS (Windows, Linux, macOS).
2525
*
2626
* <p>The library files are automatically extracted from this project's package (JAR).
2727
*
28+
* <p>Historically the loader also honoured a {@code net.ladenthin.llama.lib.name}
29+
* property that overrode the resolved library filename. Upstream removed the
30+
* code path that read it in {@code kherud/java-llama.cpp} commit {@code 6bb63e1}
31+
* (&quot;add ggml shared library to binding&quot;) when the loader was extended to
32+
* load multiple shared libraries (ggml + jllama) as separate files &mdash; the
33+
* single-name-override model is incompatible with that. The Javadoc mention
34+
* has since been a documentation lie in both upstream and this fork; it has
35+
* now been removed here, and the corresponding {@code getLibName()} getter
36+
* has been deleted from {@code LlamaSystemProperties}.
37+
*
2838
* <p>usage: call {@link #initialize()} before using the library.
2939
*
3040
* @author leo

src/main/java/net/ladenthin/llama/LlamaSystemProperties.java

Lines changed: 0 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -31,15 +31,6 @@ public LlamaSystemProperties() {}
3131
return getProperty(".lib.path");
3232
}
3333

34-
/**
35-
* Override for the native library file name.
36-
*
37-
* @return the configured library file name, or {@code null} if unset
38-
*/
39-
public @Nullable String getLibName() {
40-
return getProperty(".lib.name");
41-
}
42-
4334
/**
4435
* Custom temporary directory used when extracting the native library from
4536
* the JAR. Falls back to {@code java.io.tmpdir} if absent.

0 commit comments

Comments
 (0)