ARK-Builders / ARK-Builders/ark-core

Investigate returning Kotlin style `Result` type through JNI bindings.

Open
#74 0 comments 0 reactions 0 assignees View on GitHub
Dominant language
Rust
Stars
10
Forks
6
PR merge metrics
No merged PRs in 30d

Description

JNI does not support returning the generic types so `Result` cannot be returned from bindings. JNI bindings can only return Java values. The solution implemented in #61 throws exception when a result type is an error. However, there might be a way to return Kotlin/functional style Result values from JNI bindings which will give a more ergonomic API.

Since JNI only allows Java types a Kotlin Result type is not supported directly. However, it is possible to create a Java `Result` class that mimics a Kotlin `Result` type.[^1] To use this it will need to be defined and loaded into the JNIEnv[^2] so that the Java Result object can be created and filled with the appropriate value.

The result will be a more ergonomic and functional style Java bindings to the fs-storage crate.

[^1]: https://stackoverflow.com/q/60626607
[^2]: https://stackoverflow.com/q/67818417

Contributor guide

Open the contributing guide

Research direction

Review the JNI binding behavior implemented in #61 and the referenced JNI/Java Result material first; the issue names no repository files or tests. Define and validate a Java Result representation that can be loaded through JNIEnv and returned with the appropriate value, with ergonomic functional-style bindings as the completion target.

Written by the indexing model from the issue text.

Assessment

Tech stack
java, kotlin, rust
Domain
api
Issue type
Feature
Difficulty
5/5
Estimated time
Over a week
Activity status
Stale
Clarity
Needs clarification
Newbie friendliness
20/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.