Skip to content

fix: invalidate native lib cache by content, not size only - #30

Merged
kdroidFilter merged 1 commit into
mainfrom
fix/29-stale-native-cache-content-check
Aug 31, 2026
Merged

fix: invalidate native lib cache by content, not size only#30
kdroidFilter merged 1 commit into
mainfrom
fix/29-stale-native-cache-content-check

Conversation

@kdroidFilter

Copy link
Copy Markdown
Collaborator

Summary

Fixes #29.

KneRuntime.loadLibrary (tier 2 JAR extract) only refreshed the on-disk cache when the extracted library file size changed. A rebuilt library of identical size (e.g. after renaming WindowsHostNativeHost) kept serving stale symbols from the cache, causing:

java.lang.UnsatisfiedLinkError: Symbol not found: lapsehost_NativeHost_new

Changes

  • The generated staleness check now keeps the size comparison as a fast path and falls back to comparing the cached file bytes against the JAR resource bytes (contentEquals) before trusting the cache.
  • Added a regression test asserting the generated runtime performs the content comparison.

Testing

  • ./gradlew :nna:test — full plugin suite green.

The generated KneRuntime only refreshed the extracted-library cache when
the file size changed. A rebuilt library of identical size (e.g. after a
symbol rename) kept serving stale symbols, causing UnsatisfiedLinkError.

Keep the size check as a fast path and fall back to a byte comparison of
the cached file against the JAR resource before trusting the cache.

Fixes #29
@kdroidFilter
kdroidFilter merged commit afa1208 into main Aug 31, 2026
1 check passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

KneRuntime cache invalidates native libs by size only, serving stale symbols after API rename

1 participant