Commit d81b3b4
fix: Fix JNI signature mismatches caused by bind_java_type! JObject mapping
bind_java_type! maps JObject to Ljava/lang/Object; in JNI signatures, but
Java methods using domain-specific types (UUID, Future, Stream, ScanResult,
byte[], List, Map, etc.) require exact signature matches. This caused runtime
"Method not found" errors and a SIGSEGV in the scan callback.
Changes:
- objects.rs: Move all methods with domain-typed params/returns out of
bind_java_type! into manual env.call_method() with correct JNI signatures.
Keep bind_java_type! for class definitions and primitive-only methods.
- future.rs: Move JFuture::poll to manual impl with correct Waker/PollResult sigs
- stream.rs: Move JStream::poll_next to manual impl with correct Waker/PollResult sigs
- mod.rs: Fix reportScanResult to use extern "C" + EnvUnowned + with_env for
raw JNI ABI compatibility (from_raw_parts requires raw C calling convention).
Add env.get_java_vm() to seed JavaVM singleton during init.
- peripheral_finder.rs: Add catch_unwind and logging to adapter background thread
for Android debugging (silent thread death caused confusing RecvError)
Verified: 28/29 Android integration tests pass on Pixel 9a. The single failure
(testPropertiesContainPeripheralInfo TX power) is a test-peripheral issue.
Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>1 parent c3ac72b commit d81b3b4
5 files changed
Lines changed: 167 additions & 99 deletions
File tree
- src/droidplug
- jni_utils
- jni
- tests/common
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
1 | 1 | | |
2 | 2 | | |
3 | | - | |
| 3 | + | |
4 | 4 | | |
5 | 5 | | |
6 | 6 | | |
| |||
18 | 18 | | |
19 | 19 | | |
20 | 20 | | |
| 21 | + | |
| 22 | + | |
21 | 23 | | |
22 | 24 | | |
23 | 25 | | |
24 | 26 | | |
25 | 27 | | |
26 | 28 | | |
27 | | - | |
28 | | - | |
29 | | - | |
30 | | - | |
31 | | - | |
| 29 | + | |
| 30 | + | |
| 31 | + | |
| 32 | + | |
| 33 | + | |
| 34 | + | |
| 35 | + | |
32 | 36 | | |
33 | 37 | | |
34 | 38 | | |
| |||
96 | 100 | | |
97 | 101 | | |
98 | 102 | | |
99 | | - | |
100 | | - | |
| 103 | + | |
| 104 | + | |
101 | 105 | | |
102 | 106 | | |
103 | | - | |
104 | | - | |
105 | | - | |
| 107 | + | |
| 108 | + | |
| 109 | + | |
| 110 | + | |
| 111 | + | |
| 112 | + | |
106 | 113 | | |
107 | 114 | | |
108 | 115 | | |
| |||
0 commit comments