capnproto / capnproto-java

Cap'n Proto in pure Java
Other
390 stars 86 forks source link

Questions about cross-language data exchange and Android support #138

Open WhiredPlanck opened 6 months ago

WhiredPlanck commented 6 months ago

There is a C++ native library I used for my Android app and it's able to provide data in Cap'n Proto. Naturally I want to utilize the ability to speed up the data exchanging, especially get data from C++ to Java/Kotlin, because common JNI object converting is really slow (ranges in ~40,000 µs to ~120,000 µs). So is there anyway to properly deal with this, like some Gradle plugins or any else example?

dwrensha commented 6 months ago

Yes, you should be able to compile your .capnp schemas with capnpc-java and then use the capnproto-java runtime library. The Addressbook example shows one way to set up a pom.xml to achieve this: https://github.com/capnproto/capnproto-java/blob/ed9a67c5fcd46604a88593625a9e38496b83d3ab/examples/pom.xml#L52-L71

There is also this maven plugin (but I've never used it): https://github.com/expretio/capnp-maven-plugin

One annoying bit about all this is that capnpc-java is still written in C++: #111

WhiredPlanck commented 5 months ago

@dwrensha No bad. I'll give it a try.