Expand description
§jni-simple
This crate contains a simple dumb handwritten rust wrapper around the JNI (Java Native Interface) API. It does absolutely no magic around the JNI Calls and lets you just use it as you would in C.
If you are looking to start a jvm from rust then the entrypoints in this create are
init_dynamic_link
, load_jvm_from_library
, JNI_CreateJavaVM
and JNI_GetCreatedJavaVMs
.
If you are looking to write a jni library in rust then the types JNIEnv
and jclass, etc.
should be sufficient.
Macros§
- jtypes
- This macro is usefull for constructing jtype arrays. This is often needed when making upcalls into the jvm with many arguments using the ‘A’ type functions:
Structs§
Enums§
Constants§
- JNI_
ABORT - JNI_
COMMIT - JNI_
EDETACHED - JNI_
EEXIST - JNI_
EINVAL - JNI_
ENOMEM - JNI_ERR
- JNI_
EVERSION - JNI_OK
- JNI_
VERSION_ 9 - JNI_
VERSION_ 1_ 1 - JNI_
VERSION_ 1_ 2 - JNI_
VERSION_ 1_ 4 - JNI_
VERSION_ 1_ 6 - JNI_
VERSION_ 1_ 8 - JNI_
VERSION_ 10 - JNI_
VERSION_ 19 - JNI_
VERSION_ 20 - JNI_
VERSION_ 21
Traits§
- JType
- Marker trait for all types that are valid to use to make variadic JNI Up-calls with.
- UseC
String - Helper trait that converts rusts various strings into a zero terminated c string for use with a JNI method.
Functions§
- JNI_
Create ⚠JavaVM - Directly calls
JNI_CreateJavaVM
with the provided arguments. - JNI_
Create ⚠JavaVM_ with_ string_ args - Convenience function to call
JNI_CreateJavaVM
with a simple list of String arguments. - JNI_
GetCreated ⚠JavaV Ms - Returns the created
JavaVMs
. This will only ever return 1 (or 0)JavaVM
according to Oracle Documentation. - init_
dynamic_ link - Call this function to initialize the dynamic linking to the jvm to use the provided function pointers to create the jvm.
- is_
jvm_ loaded - Returns true if the jvm was loaded by either calling
load_jvm_from_library
orinit_dynamic_link
. - load_
jvm_ ⚠from_ java_ home - Convenience method to load the jvm from the
JAVA_HOME
environment variable that is commonly set on Windows by End-User Java Setups, or on linux by distribution package installers. - load_
jvm_ ⚠from_ library - Convenience method to load the jvm from a path to libjvm.so or jvm.dll.
Type Aliases§
- jarray
- jboolean
- jboolean
Array - jbyte
- jbyte
Array - jchar
- jchar
Array - jclass
- jdouble
- jdouble
Array - jfieldID
- jfloat
- jfloat
Array - jint
- jint
Array - jlong
- jlong
Array - jmethodID
- jobject
- jobject
Array - jshort
- jshort
Array - jsize
- jstring
- jthrowable
- jweak