Struct java_spaghetti::VM
source · pub struct VM(/* private fields */);
Expand description
FFI: Use &VM instead of *const JavaVM. This represents a global, process-wide Java exection environment.
On Android, there is only one VM per-process, although on desktop it’s possible (if rare) to have multiple VMs within the same process. This library does not support having multiple VMs active simultaniously.
This is a “safe” alternative to jni_sys::JavaVM raw pointers, with the following caveats:
-
A null vm will result in undefined behavior. Java should not be invoking your native functions with a null *mut JavaVM, however, so I don’t believe this is a problem in practice unless you’ve bindgened the C header definitions elsewhere, calling them (requiring
unsafe
), and passing null pointers (generally UB for JNI functions anyways, so can be seen as a caller soundness issue.) -
Allowing the underlying JavaVM to be modified is undefined behavior. I don’t believe the JNI libraries modify the JavaVM, so as long as you’re not accepting a *mut JavaVM elsewhere, using unsafe to dereference it, and mucking with the methods on it yourself, I believe this “should” be fine.
Implementations§
Trait Implementations§
source§impl Ord for VM
impl Ord for VM
source§impl PartialOrd for VM
impl PartialOrd for VM
1.0.0 · source§fn le(&self, other: &Rhs) -> bool
fn le(&self, other: &Rhs) -> bool
self
and other
) and is used by the <=
operator. Read more