Comments (2)
That looks correct.
I hacked together an example based on your code, and it seems to work fine. I tried it on Debian Linux Sid x86_64 with Java 17.0.9-ea, Clang 16.0.6, and Rust 1.71.1.
So, I'm not sure why it's crashing for you. Can you give some details about your platform, and prepare a minimal reproducible example of the problem you're having?
To run my example:
- Get a Linux machine with Rust and Clang installed.
- Unzip this archive on that machine.
cd c-jni-interop && sh ./run.sh
If successful, it will print the usual Cargo compilation messages, then Successfully got JNIEnv
(printed from the Rust function function
), then Hello, world!
(printed by Java code calling into C, after successfully loading the native library).
Note: the code in this example is platform-agnostic, but the run.sh
script assumes Linux, and will need to be adjusted for other platforms.
from jni-rs.
uh that's weird.
I clean the cache and recompile it and suddenly it works.
It was running on a Android device actually so maybe there was something wrong with ndk or gradle stuff.
Thanks for answering anyway
from jni-rs.
Related Issues (20)
- `JClass::from`, `JString::from`, `JThrowable::from`, etc. safety HOT 2
- Byte type confusion
- Feature request: JString from JChar slice via NewString
- How to return jobject as kotlin data class
- New release on crates.io
- Could not compile jni (build script) HOT 1
- JNIEnv::register_native_methods should be marked as unsafe
- JNIEnv::get_string should delete the local ref of string_class HOT 1
- Performance enhancement in get_string
- `new_object_unchecked` should accept`Desc<'local, JMethodID>`
- [Question]: How does one send a native rust function to java as a callback? HOT 2
- `JNIEnv::take_rust_field` seems meant for use with `java.lang.Object.finalize`, but that is deprecated
- Unsound usages of unsafe implementation from small size to large size HOT 2
- some samples for jni-rs
- Borrow multiple Rust fields (on different objects) on the same `env` concurrently? HOT 1
- JObject should implement Copy and/or Clone HOT 2
- already borrowed: BorrowMutError at jni-0.21.1/src/wrapper/java_vm/vm.rs:544 HOT 1
- How do I operate on a &JObject that I happen to know is an array ?
- attach_current_thread with thread name HOT 3
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from jni-rs.