Add static bound for add_fd_with_callback
Open
Nobody has claimed this yet.
- Dominant language
- Rust
- Stars
- 1.3k
- Forks
- 125
- PR merge metrics
- No merged PRs in 30d
Description
Since the callback is leaking into memory, should we add a 'static constraint to it to make sure it's always valid, otherwise a JNIEnv <'local> is captured here, and it compiles. But the JNIEnv is only valid in the scope of the native method on_create
//native jni method
pub fn on_create(mut env: JNIEnv, jactivity: JObject) {
ThreadLooper::for_thread()
.unwrap()
.add_fd_with_callback(fd, FdEvent::INPUT, move || {
env.call_method(obj, name, sig, args);
})?;
}
Contributor guide
No contributing guide indexed for this repository
First steps
- Read the whole issue, then the project's contributing guide.
- Comment on the issue to say you are picking it up — it saves two people doing the same work.
- Fork the repository and make your change on a branch.
- Open a pull request that references the issue number.
Research direction
Search for add_fd_with_callback and inspect how its callback is stored and invoked. Confirm the shown on_create example cannot capture the scoped JNIEnv, then add coverage that verifies the callback requires a 'static lifetime and run the relevant Rust tests.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- rust
- Domain
- mobile-dev
- Issue type
- Bug
- Difficulty
- 2/5
- Estimated time
- 1-3 hours
- Activity status
- Stale
- Clarity
- Mostly clear
- Newbie friendliness
- 35/100