Comments (5)
Ah, this seems to work:
ptr::null_mut() as *mut _jobject
Maybe that could somehow be made more ergonomic? Via an Option
would be fantastic, but even a provided helper function creating such a null-jobject would be nice.
from jni-rs.
Do you mean that you're trying to return either a jobject
or a null pointer from an extern "C"
function? I think that the "Option
to represent a null ffi pointer" pattern is mainly used for function pointers. I'm pretty sure that returning an Option
to C-land doesn't work in the same manner, so it won't be possible to do that here. A helper should be pretty easy though.
from jni-rs.
Do you mean that you're trying to return either a jobject or a null pointer from an extern "C" function?
Exactly. In Java it would be something like this:
public MyObject foo() {
if (...) {
return new MyObject();
} else {
return null;
}
}
from jni-rs.
Going ahead and closing this since I'm like 95% sure that returning an option from an FFI function is not and likely will never be possible, and the helper for constructing a null object made its way into 0.6.1.
If you can find anything to the contrary on the option return, feel free to reopen!
from jni-rs.
Would something like that work? llogiq/optional#23
from jni-rs.
Related Issues (20)
- call_method overriding class reference (Classloader issue) HOT 5
- Feature request: LocalExecutor HOT 3
- How can I return an int array in a JNI call? HOT 4
- Better InvalidArgList Error HOT 3
- `Error::JavaException`, when `Display`ed, doesn't show the Java exception message HOT 1
- Reduce clone overhead for JavaType HOT 1
- `get_env` should accept JNI version as a parameter, like the C JNI function `GetEnv` does
- pass rust function as implementation for Java object HOT 5
- JavaVM should be Clone HOT 1
- `get_static_field_unchecked` was not updated to use ReturnType in #344
- `{get,set}[_static]_field_unchecked` should be `unsafe`
- How to add elements into an `JObjectArray`? HOT 2
- `JNIStr` should implement `to_str()` and not `Deref` directly to a `CStr`
- How to pass JavaVM from c to rust HOT 2
- `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
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.