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

Native loading refactor #162

Merged
merged 84 commits into from
Dec 19, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
84 commits
Select commit Hold shift + click to select a range
e275db2
Alignment: bytes package
DariusIMP Oct 21, 2024
bd94fe3
Alignment: encoding update
DariusIMP Oct 21, 2024
9b62e1e
Alignment: config package
DariusIMP Oct 21, 2024
e9ba08a
Alignment: replacing all exceptions with ZError
DariusIMP Oct 21, 2024
941efe8
Alignment: ext package
DariusIMP Oct 21, 2024
1ee563b
Alignment: jni callbacks
DariusIMP Oct 21, 2024
95a13e5
Alignment: config
DariusIMP Oct 21, 2024
7f372b9
Alignment: JNIKeyExpr
DariusIMP Oct 21, 2024
9cb1dcc
Alignment: JNIPublisher
DariusIMP Oct 21, 2024
4390040
Alignment: JNIQuery
DariusIMP Oct 21, 2024
c9e0416
Alignment: JNIScout
DariusIMP Oct 21, 2024
5b2194f
Alignment: JNISession
DariusIMP Oct 21, 2024
5ed9777
Alignment JNIZBytes & JNIZenohId
DariusIMP Oct 22, 2024
aee2546
Alignment: KeyExpr & SetIntersectionLevel
DariusIMP Oct 22, 2024
52300e5
Alignment: pubsub package
DariusIMP Oct 22, 2024
afe3766
Alignment: Publisher & qos package
DariusIMP Oct 22, 2024
c68cef3
Alignment: query package - wip
DariusIMP Oct 22, 2024
a643bca
Alignment: adding scouting package
DariusIMP Oct 22, 2024
1d2121c
Alignment: removing Value
DariusIMP Oct 22, 2024
377661a
Alignment: logger
DariusIMP Oct 23, 2024
5d3705c
Alignmment: Zenoh.kt - wip
DariusIMP Oct 23, 2024
ba0fd31
Alignment: publisher - adding encoding and reliability to builder
DariusIMP Oct 23, 2024
14844c6
Alignment: subscriber
DariusIMP Oct 23, 2024
383f86e
Alignment: sample
DariusIMP Oct 23, 2024
eb9eeb8
Alignment: query & reply - wip
DariusIMP Oct 25, 2024
1f9b13d
Alignment: Put & Session
DariusIMP Oct 28, 2024
283c1f3
Alignment: fix 'IntoSelector'
DariusIMP Oct 28, 2024
6dcfe69
Alignment: updating zenoh-jni
DariusIMP Oct 29, 2024
68b18cf
Alignment: wip - converting tests to java tests. Added config tests.
DariusIMP Nov 12, 2024
4869b07
Alignment: wip - converting tests to java tests. Added delete test.
DariusIMP Nov 12, 2024
f2d666d
Alignment: wip - converting tests to java tests. Added encoding tests.
DariusIMP Nov 13, 2024
8badd0c
Alignment: wip - converting tests to java tests. Added get tests.
DariusIMP Nov 13, 2024
5f1c920
Alignment: wip - converting tests to java tests. Added key expr tests.
DariusIMP Nov 13, 2024
ce8147a
Alignment: wip - converting tests to java tests. Added parameters tests.
DariusIMP Nov 13, 2024
faccac9
Alignment: wip - converting tests to java tests. Added publisher tests.
DariusIMP Nov 13, 2024
6b9d6e1
Alignment: wip - converting tests to java tests. Added Queryable tests.
DariusIMP Nov 13, 2024
163b953
Alignment: wip - converting tests to java tests. Added Put tests.
DariusIMP Nov 14, 2024
790a131
Alignment: wip - Added Scouting tests + adding scouting builder.
DariusIMP Nov 14, 2024
f94ee4b
Alignment: wrapping up scouting, closing queue upon scout close.
DariusIMP Nov 18, 2024
5426942
Alignment: adding selector tests
DariusIMP Nov 18, 2024
98db96e
Alignment: fix SessionInfo + adding tests
DariusIMP Nov 18, 2024
1fa7d9d
Alignment: fix Scouting queue test
DariusIMP Nov 18, 2024
9a859e1
amend! Alignment: fix SessionInfo + adding tests
DariusIMP Nov 18, 2024
384ba33
Alignment: session tests
DariusIMP Nov 18, 2024
2424498
Alignment: user attachment tests
DariusIMP Nov 20, 2024
025bcf4
Alignment: subscriber tests
DariusIMP Nov 20, 2024
f5565f2
Alignment: removing the zenoh-ext package (to be added later in anoth…
DariusIMP Nov 21, 2024
14a615e
Alignment: Publisher config params
DariusIMP Nov 22, 2024
5d53262
Alignment: Subscriber config params
DariusIMP Nov 22, 2024
a98180d
Alignment: Queryable config params
DariusIMP Nov 25, 2024
66f158f
Alignment: Subscriber config params refactor
DariusIMP Nov 25, 2024
d9eca7d
Alignment: Queryable declaration and Query.reply config params.
DariusIMP Nov 26, 2024
bebd45f
Alignment: Get config params
DariusIMP Nov 26, 2024
73fad03
Alignment: Subscriber config params refactor
DariusIMP Nov 26, 2024
9962353
Fix config test
DariusIMP Nov 27, 2024
6e6c86d
Alignment - Scouting config params
DariusIMP Nov 27, 2024
95f86aa
Alignment: adding Liveliness
DariusIMP Nov 28, 2024
8c59360
Gitignore update
DariusIMP Nov 28, 2024
6b35c68
Alignment: fix logging
DariusIMP Nov 28, 2024
b580619
Alignment: publisher put and delete config param
DariusIMP Nov 29, 2024
2cc4260
Alignment: examples - adding picocli for CLI args
DariusIMP Nov 29, 2024
931b980
Alignment: examples - adding missing examples
DariusIMP Nov 29, 2024
bbf20c2
Alignment: examples - adding ping and pong examples
DariusIMP Nov 29, 2024
da98b95
Alignment: examples refactor + refactor queryable config logic
DariusIMP Dec 2, 2024
e18807a
Alignment: fix publisher put encoding fallback
DariusIMP Dec 2, 2024
997108a
Alignment: removing SubscriberConfig.kt
DariusIMP Dec 4, 2024
4e1bc01
Alignment: renaming PublisherConfig to PublisherOptions
DariusIMP Dec 4, 2024
7affa19
Alignment: renaming DeleteConfig to DeleteOptions and removing 'build…
DariusIMP Dec 4, 2024
3b916ed
Alignment: renaming GetConfig to GetOptions and removing 'builder' fu…
DariusIMP Dec 4, 2024
4d9dfe8
Alignment: renaming PutConfig to PutOptions and removing 'builder' fu…
DariusIMP Dec 4, 2024
569438f
Alignment: renaming ReplyConfig to ReplyOptions and removing 'builder…
DariusIMP Dec 5, 2024
94bbab4
Alignment: renaming ReplyDelConfig to ReplyDelOptions and removing 'b…
DariusIMP Dec 5, 2024
07f22dc
Alignment: renaming ReplyErrConfig to ReplyErrOptions and removing 'b…
DariusIMP Dec 5, 2024
c5d92dd
Alignment: renaming QueryableConfig to QueryableOptions and removing …
DariusIMP Dec 5, 2024
752c453
Alignment: renaming ScoutConfig to ScoutOptions and removing 'builder…
DariusIMP Dec 5, 2024
0577e5b
Alignment: renaming Liveliness.SubscriberConfig + renaming variables
DariusIMP Dec 5, 2024
1e72dd6
Alignment: queryable options refactor
DariusIMP Dec 5, 2024
1dffad8
Alignment: removing Resolvable
DariusIMP Dec 5, 2024
e3cdd11
Alignment: splitting Queryable, Subscriber and Get into Handler and C…
DariusIMP Dec 10, 2024
795fbff
Alignment: removing JNIZBytes
DariusIMP Dec 11, 2024
2f74120
Alignment: removing unused kotlin json dependency
DariusIMP Dec 11, 2024
1645dab
Alignment: options refactor on QoS param
DariusIMP Dec 18, 2024
3f49774
Native loading refactor
DariusIMP Dec 18, 2024
0743f9b
Merge branch 'main' of github.com:eclipse-zenoh/zenoh-java into zenoh…
DariusIMP Dec 19, 2024
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
2 changes: 1 addition & 1 deletion zenoh-java/src/jvmMain/kotlin/io/zenoh/Target.kt
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@

package io.zenoh

enum class Target {
internal enum class Target {
WINDOWS_X86_64_MSVC,
LINUX_X86_64,
LINUX_AARCH64,
Expand Down
38 changes: 26 additions & 12 deletions zenoh-java/src/jvmMain/kotlin/io/zenoh/Zenoh.kt
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@ import java.util.zip.ZipInputStream
internal actual object ZenohLoad {
private const val ZENOH_LIB_NAME = "zenoh_jni"

init {
init {
// Try first to load the local native library for cases in which the module was built locally,
// otherwise try to load from the JAR.
if (tryLoadingLocalLibrary().isFailure) {
Expand All @@ -45,24 +45,33 @@ internal actual object ZenohLoad {
*/
private fun determineTarget(): Result<Target> = runCatching {
val osName = System.getProperty("os.name").lowercase()
val osArch = System.getProperty("os.arch")
val osArch = System.getProperty("os.arch").lowercase()

val target = when {
osName.contains("win") -> when {
osArch.contains("x86_64") || osArch.contains("amd64") -> Target.WINDOWS_X86_64_MSVC
else -> throw UnsupportedOperationException("Unsupported architecture: $osArch")
osArch.contains("x86_64") || osArch.contains("amd64") || osArch.contains("x64") ->
Target.WINDOWS_X86_64_MSVC
else -> throw UnsupportedOperationException("Unsupported architecture on Windows: $osArch")
}

osName.contains("mac") -> when {
osArch.contains("x86_64") || osArch.contains("amd64") -> Target.APPLE_X86_64
osArch.contains("aarch64") -> Target.APPLE_AARCH64
else -> throw UnsupportedOperationException("Unsupported architecture: $osArch")
osName.contains("mac") || osName.contains("darwin") || osName.contains("os x") -> when {
osArch.contains("x86_64") || osArch.contains("amd64") || osArch.contains("x64") ->
Target.APPLE_X86_64

osArch.contains("aarch64") || osArch.contains("arm64") ->
Target.APPLE_AARCH64

else -> throw UnsupportedOperationException("Unsupported architecture on macOS: $osArch")
}

osName.contains("nix") || osName.contains("nux") || osName.contains("aix") -> when {
osArch.contains("x86_64") || osArch.contains("amd64") -> Target.LINUX_X86_64
osArch.contains("aarch64") -> Target.LINUX_AARCH64
else -> throw UnsupportedOperationException("Unsupported architecture: $osArch")
osArch.contains("x86_64") || osArch.contains("amd64") || osArch.contains("x64") ->
Target.LINUX_X86_64

osArch.contains("aarch64") || osArch.contains("arm64") ->
Target.LINUX_AARCH64

else -> throw UnsupportedOperationException("Unsupported architecture on Linux/Unix: $osArch")
}

else -> throw UnsupportedOperationException("Unsupported platform: $osName")
Expand Down Expand Up @@ -108,7 +117,9 @@ internal actual object ZenohLoad {
}

private fun loadLibraryAsInputStream(target: Target): Result<InputStream> = runCatching {
val libUrl = ClassLoader.getSystemClassLoader().getResourceAsStream("$target/$target.zip")!!
val targetName = "$target/$target.zip"
val libUrl = ClassLoader.getSystemClassLoader().getResourceAsStream(targetName)
?: javaClass.classLoader.getResourceAsStream(targetName)!!
val uncompressedLibFile = unzipLibrary(libUrl)
return Result.success(FileInputStream(uncompressedLibFile.getOrThrow()))
}
Expand Down Expand Up @@ -145,6 +156,9 @@ internal actual object ZenohLoad {
*/
private fun tryLoadingLocalLibrary(): Result<Unit> = runCatching {
val lib = ClassLoader.getSystemClassLoader().findLibraryStream(ZENOH_LIB_NAME)
?: javaClass.classLoader.findLibraryStream(
ZENOH_LIB_NAME
)
if (lib != null) {
loadZenohJNI(lib)
} else {
Expand Down
Loading