Android: Add string EValue input support in JNI execute path#19526
Android: Add string EValue input support in JNI execute path#19526psiddh wants to merge 2 commits into
Conversation
The JNI execute_method handles Tensor, Int, Double, and Bool input types but was missing String support. Java EValue supports String (TYPE_CODE_STRING = 2) and the C++ output path already handles string EValues, but passing a string input would fail with "Unsupported input EValue type code". String data and ArrayRef are heap-allocated via unique_ptr to ensure pointer stability as the vectors grow, since EValue stores a raw ArrayRef<char>* that must remain valid through execution. Co-authored-by: Claude <noreply@anthropic.com>
🔗 Helpful Links🧪 See artifacts and rendered test results at hud.pytorch.org/pr/pytorch/executorch/19526
Note: Links to docs will display an error until the docs builds have been completed. ❗ 1 Active SEVsThere are 1 currently active SEVs. If your PR is affected, please view them below: ❌ 5 New Failures, 3 Unrelated FailuresAs of commit f19e1a2 with merge base fe98297 ( NEW FAILURES - The following jobs have failed:
FLAKY - The following job failed but was likely due to flakiness present on trunk:
BROKEN TRUNK - The following jobs failed but was present on the merge base:👉 Rebase onto the `viable/strict` branch to avoid these failures
This comment was automatically generated by Dr. CI and updates every 15 minutes. |
This PR needs a
|
There was a problem hiding this comment.
Pull request overview
This PR adds support for passing Java EValue strings through the Android JNI execute_method input conversion path, bringing input handling in line with the already-supported string output path.
Changes:
- Adds JNI-side handling for
JEValue::kTypeCodeStringinputs by converting JavaStringto a nativeEValuestring (ArrayRef<char>*). - Introduces heap-backed keepalive storage (
unique_ptr) for string data andArrayRef<char>objects to maintain pointer stability during execution.
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
Address Copilot feedback: - Check for null jstring from toStr() before dereferencing - Add else branch that throws InvalidArgument for unrecognized EValue type codes instead of silently skipping them Co-authored-by: Claude <noreply@anthropic.com>
The JNI execute_method handles Tensor, Int, Double, and Bool input types but was missing String support. Java EValue supports String (TYPE_CODE_STRING = 2) and the C++ output path already handles string EValues, but passing a string input would fail with "Unsupported input EValue type code".
String data and ArrayRef are heap-allocated via unique_ptr to ensure pointer stability as the vectors grow, since EValue stores a raw ArrayRef* that must remain valid through execution.