Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
141 commits
Select commit Hold shift + click to select a range
57304da
initial code generation
milyin May 23, 2026
c4b5aee
templates in separate files in prebindgen-ext
milyin May 23, 2026
b69f61b
mangle harness
milyin May 23, 2026
4415c8d
dependency on zenoh-flat-jni added
milyin May 23, 2026
3631ce3
switch to keyexprValidate, package support
milyin May 23, 2026
45d6c82
zenoh-jni reexported by zenoh-flat-jni
milyin May 23, 2026
9e09d5a
No load generator
milyin May 23, 2026
b0ec4f3
Merge branch 'main' into zenoh-flat-jni
milyin May 24, 2026
d1dae5a
output only declared in prebindgen-ext
milyin May 24, 2026
417f8a8
better error reporting
milyin May 24, 2026
51b3c1f
reporting fix
milyin May 24, 2026
24d108b
report unresolved descendants from required roots
milyin May 24, 2026
7d3a449
refactored, test added
milyin May 25, 2026
79d6ccf
ptr class added
milyin May 25, 2026
caacadb
qualify non-fqn types
milyin May 25, 2026
804e49f
filter undeclared fns out of JNINative/JNIOrphaned emit
milyin May 25, 2026
6dae2dd
drop JNIOrphaned bucket; reuse declared_functions trait method
milyin May 25, 2026
9cd677a
missing functions added to autogeneration
milyin May 25, 2026
f3b6ee5
into in build.rs
milyin May 25, 2026
7c5522e
universal post-emit qualification via VisitMut visitor
milyin May 25, 2026
045771c
transition to zenoh-flat keyexpr for zenoh-java
milyin May 25, 2026
e78bcda
ZKeyExpr improved
milyin May 25, 2026
c348133
closeable data classes
milyin May 25, 2026
2ead434
universa close for data classes
milyin May 25, 2026
31fbe85
throwable data class
milyin May 25, 2026
bb56ce0
config in zenoh-flat
milyin May 25, 2026
5d57dfa
scouting api
milyin May 26, 2026
2b64a24
JNIScout removed
milyin May 26, 2026
2ebdf6a
whatami from jni
milyin May 26, 2026
975f3f8
value type
milyin May 26, 2026
fe7f34b
zenoh id is a wrapper
milyin May 26, 2026
bcbcf97
&str as input parameter
milyin May 26, 2026
e73189f
logging api
milyin May 26, 2026
82dae1e
structured methods
milyin May 26, 2026
8d466c6
buildrs api renamr
milyin May 26, 2026
6de95ae
scouting package
milyin May 26, 2026
1abc2fe
packaging fixes
milyin May 26, 2026
99ee3d8
set intersection level
milyin May 26, 2026
14b2b60
zenoh-flat as mods
milyin May 26, 2026
c847149
qos enums ported
milyin May 26, 2026
31b1792
enum validation in prebindgen
milyin May 26, 2026
fe80524
wrap enums
milyin May 26, 2026
ef73ea2
bytearray in zenoh-flat
milyin May 26, 2026
f0c10c6
zenoh-java zbytes
milyin May 26, 2026
f550778
jni synchronized
milyin May 28, 2026
00a9591
enum return fix
milyin May 28, 2026
8bead46
take and ptr wraper in callback
milyin May 28, 2026
648bdfc
manually implemented serialization
milyin May 28, 2026
a362086
publisher ported
milyin May 28, 2026
0a73496
attachment into
milyin May 28, 2026
6ddfd4c
encoding in zenoh-flat
milyin May 28, 2026
f200f98
encoding constants
milyin May 28, 2026
8a968f0
renaming, fromstring added
milyin May 28, 2026
09a4552
zencoding
milyin May 28, 2026
8f03769
subscriber ported
milyin May 28, 2026
6ebbfba
querier/queriable ported
milyin May 28, 2026
2b58526
query and reply methods ported
milyin May 28, 2026
86ac53f
query structure
milyin May 28, 2026
f69428a
renaming
milyin May 28, 2026
e234338
get and corresponding structures
milyin May 28, 2026
83bcf75
full timestamp representation in zenoh-flat
milyin May 28, 2026
f267c41
old log init removed
milyin May 28, 2026
5c03b5c
liveliness migrated, codegenerator fixed
milyin May 28, 2026
6cb3fec
value type return fix
milyin May 29, 2026
fe33837
sesstion migrated
milyin May 29, 2026
d380b96
valur type handling fix
milyin May 29, 2026
248f645
niche fix
milyin May 29, 2026
a1a720d
wrappers directly in Session and. Liveliness
milyin May 29, 2026
3e8abcf
bytes form zenoh_id to string added
milyin May 29, 2026
ffe23b0
zenoh-jni removed
milyin May 29, 2026
ec29e8e
jni generator and zenoh-flat moved out
milyin Jun 3, 2026
3d7e18b
wrapper lock function
milyin Jun 3, 2026
02d4bce
blob type
milyin Jun 3, 2026
b166472
vlaue blob zzenohid
milyin Jun 3, 2026
7977d6a
missing api surface added
milyin Jun 3, 2026
22162ca
switch to wrapped functions
milyin Jun 4, 2026
4b5963e
single into
milyin Jun 4, 2026
d95146c
gtom struct from callback
milyin Jun 4, 2026
8a6d040
recursive call
milyin Jun 4, 2026
1fb65e6
flatten callbacks
milyin Jun 4, 2026
609b830
create java object directly
milyin Jun 4, 2026
53c2089
flatten input
milyin Jun 5, 2026
bcef560
no array for locks
milyin Jun 5, 2026
8416964
removed expanded code
milyin Jun 7, 2026
c82b879
expand constructor support
milyin Jun 7, 2026
d7f6741
types expanded
milyin Jun 7, 2026
eb737db
use accessors
milyin Jun 7, 2026
c5a5353
sample attachment accessor
milyin Jun 7, 2026
f885561
nested output
milyin Jun 8, 2026
9438d2b
vec unfold
milyin Jun 8, 2026
f484202
comment added
milyin Jun 8, 2026
f04fb26
naming shortened
milyin Jun 8, 2026
92e5530
converter, renamings
milyin Jun 8, 2026
86ce22c
process error as normal type
milyin Jun 8, 2026
8576c2b
zerror declared
milyin Jun 8, 2026
154d361
keyexpr default constructor
milyin Jun 8, 2026
1a5e7b0
accessor_fun
milyin Jun 8, 2026
5f5fb71
full expand
milyin Jun 8, 2026
f3e855f
recursive expamd demo
milyin Jun 8, 2026
43638af
new api migration
milyin Jun 8, 2026
f2f9b6f
zbytes support callback error interface
milyin Jun 9, 2026
cb840a1
expand callbacks
milyin Jun 10, 2026
bdadc0f
output kotlin one file per package
milyin Jun 10, 2026
5fd208d
flattened structure
milyin Jun 10, 2026
50a307b
named callback parameters
milyin Jun 10, 2026
03a3dd7
regenrate kotlin code
milyin Jun 10, 2026
2fbf841
generated files reformatted
milyin Jun 10, 2026
ff54477
cargo fmt
milyin Jun 10, 2026
af8b73d
callback formatting
milyin Jun 10, 2026
8876e88
no throws in generated code
milyin Jun 10, 2026
9fa0f23
hello and query unwrap
milyin Jun 11, 2026
bc29435
tests fixed
milyin Jun 11, 2026
b15d7d3
query close in reply operations
milyin Jun 11, 2026
ae008df
reply unwrap
milyin Jun 11, 2026
c37a4b0
multiline long calls
milyin Jun 11, 2026
01374ca
sample attributes added
milyin Jun 11, 2026
33b74e0
typed interface callback
milyin Jun 12, 2026
3b406c3
generated code insignificant change
milyin Jun 12, 2026
127f717
derfaults in error
milyin Jun 12, 2026
63a1f4a
proxy interface
milyin Jun 13, 2026
c7fcbd0
accelerated onerror handler
milyin Jun 13, 2026
660973f
unfold encoding for acceleration
milyin Jun 13, 2026
1d27ecb
renamings in builder
milyin Jun 14, 2026
272aafd
refactor: Remove local zenoh-flat-jni subproject, consume as Maven de…
milyin Jun 15, 2026
1cf4b7e
build: Enable Gradle composite build for local zenoh-flat-jni develop…
milyin Jun 15, 2026
8e5c1b5
chore: Remove zenoh-flat-jni directory from zenoh-java
milyin Jun 15, 2026
d742ed4
api change ported
milyin Jun 16, 2026
aa7d490
serialize fixes
milyin Jun 16, 2026
f164b94
loading in zenoh-flat-jni
milyin Jun 16, 2026
7e6157a
import predefined encodings as consts
milyin Jul 10, 2026
97363ec
Use typed zenoh-flat-jni key expression overloads
milyin Jul 15, 2026
213f8c9
Install CI lint components for the pinned Rust toolchain
milyin Jul 15, 2026
1de085d
Run flat JNI clippy without a tracked lockfile
milyin Jul 15, 2026
1ee4c25
Merge remote-tracking branch 'origin/main' into prebindgen-split-api
milyin Jul 15, 2026
834a51c
Preserve consuming Rust API semantics
milyin Jul 15, 2026
03fa790
Limit rustfmt CI to the JNI crate
milyin Jul 15, 2026
434db4d
Remove stale local task lock
milyin Jul 15, 2026
7c7d2c4
Use generated JNI receiver methods
milyin Jul 15, 2026
d507066
Pin receiver-style JNI bindings in CI
milyin Jul 15, 2026
8461c29
Track de-prefixed zenoh-flat type names in JNI bindings
milyin Jul 16, 2026
0f227f1
Use derived JNI factory and getter names
milyin Jul 16, 2026
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
51 changes: 38 additions & 13 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,34 @@ jobs:
os: [ubuntu-latest, macos-latest]

steps:
- uses: actions/checkout@v4
- name: Check out zenoh-java
uses: actions/checkout@v4
with:
path: zenoh-java

- name: Check out zenoh-flat-jni
uses: actions/checkout@v4
with:
repository: ZettaScaleLabs/zenoh-flat-jni
ref: c82656b2f41093d04921ead50516219ae74c7e96
path: zenoh-flat-jni

- name: Check out zenoh-flat
uses: actions/checkout@v4
with:
repository: ZettaScaleLabs/zenoh-flat
ref: 7b151d7808583ed15884fada2fd40d5db387c982
path: zenoh-flat

- name: Use prebindgen from GitHub main
shell: bash
working-directory: zenoh-flat-jni
run: |
sed -i.bak \
-e 's|prebindgen = { path = "../prebindgen/prebindgen" }|prebindgen = { git = "https://github.com/milyin/prebindgen.git", branch = "main" }|g' \
-e 's|prebindgen-proc-macro = { path = "../prebindgen/prebindgen-proc-macro",|prebindgen-proc-macro = { git = "https://github.com/milyin/prebindgen.git", branch = "main",|g' \
Cargo.toml ../zenoh-flat/Cargo.toml
rm Cargo.toml.bak ../zenoh-flat/Cargo.toml.bak

- uses: actions/setup-java@v4
with:
Expand All @@ -32,31 +59,29 @@ jobs:
- name: Install Rust toolchain
run: |
rustup show
rustup component add rustfmt clippy
rustup component add rustfmt clippy --toolchain 1.93.0

- name: Cargo Format
working-directory: zenoh-jni
run: cargo fmt --all --check
working-directory: zenoh-flat-jni
run: cargo fmt --check

- name: Clippy Check without Cargo.lock
working-directory: zenoh-jni
run: |
rm Cargo.lock
cargo clippy --all-targets --all-features -- -D warnings
git restore Cargo.lock
- name: Clippy Check
working-directory: zenoh-flat-jni
run: cargo clippy --all-targets --all-features -- -D warnings

- name: Check for feature leaks
working-directory: zenoh-jni
working-directory: zenoh-flat-jni
run: cargo test --no-default-features

- name: Build Zenoh-JNI
working-directory: zenoh-jni
- name: Build zenoh-flat-jni
working-directory: zenoh-flat-jni
run: cargo build

- name: Setup Gradle
uses: gradle/actions/setup-gradle@v4

- name: Gradle Test
working-directory: zenoh-java
run: ./gradlew jvmTest --info

markdown_lint:
Expand Down
10 changes: 2 additions & 8 deletions examples/build.gradle.kts
Original file line number Diff line number Diff line change
Expand Up @@ -78,19 +78,13 @@ tasks {

examples.forEach { example ->
register(example, JavaExec::class) {
dependsOn("CompileZenohJNI")
dependsOn(":zenoh-java:buildZenohFlatJni")
description = "Run the $example example"
mainClass.set("io.zenoh.$example")
classpath(sourceSets["main"].runtimeClasspath)
val zenohPaths = "../zenoh-jni/target/release"
val zenohPaths = "../zenoh-flat-jni/target/release"
val defaultJvmArgs = arrayListOf("-Djava.library.path=$zenohPaths")
jvmArgs(defaultJvmArgs)
}
}
}

tasks.register("CompileZenohJNI") {
project.exec {
commandLine("cargo", "build", "--release", "--manifest-path", "../zenoh-jni/Cargo.toml")
}
}
15 changes: 11 additions & 4 deletions examples/src/main/java/io/zenoh/ZSubThr.java
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@
import io.zenoh.exceptions.ZError;
import io.zenoh.keyexpr.KeyExpr;
import io.zenoh.pubsub.Subscriber;
import io.zenoh.sample.Sample;
import picocli.CommandLine;

import java.util.List;
Expand All @@ -40,7 +41,7 @@ public Integer call() throws Exception {
System.out.println("Opening Session");
try (Session session = Zenoh.open(config)) {
try (KeyExpr keyExpr = KeyExpr.tryFrom("test/thr")) {
subscriber = session.declareSubscriber(keyExpr, sample -> listener(number));
subscriber = session.declareSubscriber(keyExpr, sample -> listener(sample, number));
System.out.println("Press CTRL-C to quit...");

while (subscriber.isValid()) {
Expand All @@ -51,7 +52,12 @@ public Integer call() throws Exception {
return 0;
}

private void listener(long number) {
private void listener(Sample sample, long number) {
// Touch the delivered data so it actually reaches the Java surface
// (payload bytes + key-expression string): keeps lazy bindings honest
// and prevents either side from skipping materialization costs.
dataSink += sample.getPayload().toBytes().length
+ sample.getKeyExpr().toString().length();
if (batchCount > samples) {
closeSubscriber();
report();
Expand Down Expand Up @@ -86,8 +92,8 @@ private void report() {
double elapsedTimeSecs = (double) (end - globalStartTimestampNs) / NANOS_TO_SEC;
double averageMessagesPerSec = totalMessages / elapsedTimeSecs;

System.out.printf("Received %d messages in %.2f seconds: averaged %.2f msgs/sec%n",
totalMessages, elapsedTimeSecs, averageMessagesPerSec);
System.out.printf("Received %d messages in %.2f seconds: averaged %.2f msgs/sec (sink %d)%n",
totalMessages, elapsedTimeSecs, averageMessagesPerSec, dataSink);
}

private void closeSubscriber() {
Expand All @@ -114,6 +120,7 @@ private void closeSubscriber() {
private static final long NANOS_TO_SEC = 1_000_000_000L;
private long batchCount = 0;
private long count = 0;
private long dataSink = 0;
private long startTimestampNs = 0;
private long globalStartTimestampNs = 0;

Expand Down
6 changes: 5 additions & 1 deletion settings.gradle.kts
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,11 @@ rootProject.name = "zenoh-java"

include(":zenoh-java")
include(":examples")
include(":zenoh-jni")

// zenoh-flat-jni is now a separate repository (https://github.com/ZettaScaleLabs/zenoh-flat-jni)
// and is consumed as a Maven artifact: org.eclipse.zenoh:zenoh-flat-jni:VERSION
// For local development with coordinated changes, use Gradle composite build:
includeBuild("../zenoh-flat-jni")

plugins {
id("org.gradle.toolchains.foojay-resolver-convention") version("0.4.0")
Expand Down
103 changes: 5 additions & 98 deletions zenoh-java/build.gradle.kts
Original file line number Diff line number Diff line change
Expand Up @@ -12,8 +12,6 @@
// ZettaScale Zenoh Team, <zenoh@zettascale.tech>
//

import com.nishtahir.CargoExtension

plugins {
kotlin("multiplatform")
kotlin("plugin.serialization")
Expand All @@ -30,26 +28,21 @@ val release = project.findProperty("release")?.toString()?.toBoolean() == true
// Modifying this property will affect the release workflows!
val isRemotePublication = project.findProperty("remotePublication")?.toString()?.toBoolean() == true

var buildMode = if (release) BuildMode.RELEASE else BuildMode.DEBUG
// zenoh-flat-jni is now consumed as a Maven artifact: org.eclipse.zenoh:zenoh-flat-jni:VERSION
// Native libraries are bundled in the JAR by the zenoh-flat-jni module

if (androidEnabled) {
apply(plugin = "com.android.library")
apply(plugin = "org.mozilla.rust-android-gradle.rust-android")

configureCargo()
configureAndroid()
}


kotlin {
jvmToolchain(11)
jvm {
compilations.all {
kotlinOptions.jvmTarget = "11"
}
testRuns["test"].executionTask.configure {
val zenohPaths = "../zenoh-jni/target/$buildMode"
jvmArgs("-Djava.library.path=$zenohPaths")
}
if (!androidEnabled) {
withJava() // Adding java to a kotlin lib targeting android is incompatible
// The java code is only meant for testing and is non-critical for the android publication.
Expand All @@ -66,6 +59,8 @@ kotlin {
sourceSets {
val commonMain by getting {
dependencies {
// Zenoh Flat JNI - includes Kotlin sources and native libraries
implementation("org.eclipse.zenoh:zenoh-flat-jni:1.9.0")
implementation("commons-net:commons-net:3.9.0")
implementation("com.google.guava:guava:33.3.1-jre")
}
Expand All @@ -82,18 +77,6 @@ kotlin {
}
}
}
val jvmMain by getting {
if (isRemotePublication) {
// The line below is intended to load the native libraries that are crosscompiled on GitHub actions when publishing a JVM package.
resources.srcDir("../jni-libs").include("*/**")
} else {
resources.srcDir("../zenoh-jni/target/$buildMode").include(arrayListOf("*.dylib", "*.so", "*.dll"))
}
}

val jvmTest by getting {
resources.srcDir("../zenoh-jni/target/$buildMode").include(arrayListOf("*.dylib", "*.so", "*.dll"))
}
}

val javadocJar by tasks.registering(Jar::class) {
Expand Down Expand Up @@ -153,65 +136,6 @@ tasks.withType<PublishToMavenRepository>().configureEach {
dependsOn(tasks.withType<Sign>())
}

tasks.withType<Test> {
doFirst {
// The line below is added for the Android Unit tests which are equivalent to the JVM tests.
// For them to work we need to specify the path to the native library as a system property and not as a jvmArg.
systemProperty("java.library.path", "../zenoh-jni/target/$buildMode")
}
}

tasks.whenObjectAdded {
if ((this.name == "mergeDebugJniLibFolders" || this.name == "mergeReleaseJniLibFolders")) {
this.dependsOn("cargoBuild")
}
}

tasks.named("compileKotlinJvm") {
dependsOn("buildZenohJni")
}

tasks.register("buildZenohJni") {
doLast {
if (!isRemotePublication) {
// This is intended for local publications. For publications done through GitHub workflows,
// the zenoh-jni build is achieved and loaded differently from the CI
buildZenohJNI(buildMode)
}
}
}

fun buildZenohJNI(mode: BuildMode = BuildMode.DEBUG) {
val cargoCommand = mutableListOf("cargo", "build")

if (mode == BuildMode.RELEASE) {
cargoCommand.add("--release")
}

val result = project.exec {
commandLine(*(cargoCommand.toTypedArray()), "--manifest-path", "../zenoh-jni/Cargo.toml")
}

if (result.exitValue != 0) {
throw GradleException("Failed to build Zenoh-JNI.")
}

Thread.sleep(1000)
}

enum class BuildMode {
DEBUG {
override fun toString(): String {
return "debug"
}
},
RELEASE {
override fun toString(): String {
return "release"
}
}
}

fun Project.configureAndroid() {
extensions.configure<com.android.build.gradle.LibraryExtension>("android") {
namespace = "io.zenoh"
Expand Down Expand Up @@ -249,20 +173,3 @@ fun Project.configureAndroid() {
}
}
}

fun Project.configureCargo() {
extensions.configure<CargoExtension>("cargo") {
pythonCommand = "python3"
module = "../zenoh-jni"
libname = "zenoh-jni"
targetIncludes = arrayOf("libzenoh_jni.so")
targetDirectory = "../zenoh-jni/target/"
profile = "release"
targets = arrayListOf(
"arm",
"arm64",
"x86",
"x86_64",
)
}
}
27 changes: 0 additions & 27 deletions zenoh-java/src/androidMain/kotlin/io.zenoh/Zenoh.kt

This file was deleted.

Loading
Loading