Skip to content

Narrow down java.library.path to prevent loading stale dylibs#673

Merged
ktoso merged 2 commits intoswiftlang:mainfrom
sidepelican:fix_sample_libpath
Apr 6, 2026
Merged

Narrow down java.library.path to prevent loading stale dylibs#673
ktoso merged 2 commits intoswiftlang:mainfrom
sidepelican:fix_sample_libpath

Conversation

@sidepelican
Copy link
Copy Markdown
Contributor

java.library.path is currently too broad, causing the sample app to load a stale libSwiftJava.dylib from the repository root's .build directory instead of the latest local build.
This made testing changes extremely confusing and difficult to debug.

Narrowed the search path to prevent unintended binary shadowing and ensure the app consistently loads the correct, newly built library.

@sidepelican sidepelican requested a review from ktoso as a code owner April 6, 2026 07:31
Copy link
Copy Markdown
Collaborator

@ktoso ktoso left a comment

Choose a reason for hiding this comment

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

Good catch, thank you

"--enable-native-access=ALL-UNNAMED",
// Include the library paths where our dylibs are that we want to load and call
"-Djava.library.path=" + (javaLibraryPaths(rootDir) + javaLibraryPaths(project.projectDir)).joinToString(":"),
"-Djava.library.path=" + javaLibraryPaths(project.projectDir).joinToString(":"),
Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

Let's cleanup the : while we're here and use File.pathSeparator?

Suggested change
"-Djava.library.path=" + javaLibraryPaths(project.projectDir).joinToString(":"),
"-Djava.library.path=" + javaLibraryPaths(project.projectDir).joinToString(File.pathSeparator),

@ktoso ktoso merged commit 5be4f45 into swiftlang:main Apr 6, 2026
48 of 61 checks passed
@sidepelican sidepelican deleted the fix_sample_libpath branch April 7, 2026 01:53
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.

2 participants