How to work with Kotlin nullable type like 'Long?', 'String?' etc. on JNI? JNI type signatures represent the following information:
Signature |Java Type
-----------|----------------
Z | boolean
B | byte
C | char
S | short
I | int
J | long
F | float
D | double
L | fully-qualified-class;
[ type | type[]
(arg-types)| ret-type method type
But how I can use nullable 'var value:Long?' from JNI?
Kotlin Code
class KtClass
{
var value:Long? = null
}
JNI
jclass ktclass = env->FindClass("package/KtClass");
jmethodID ctorktID = env->GetMethodID(ktclass, "<init>", "()V");
env->NewObject(ktclass, ctorktID);
//J - mean Kotlin Long, but it not nullable 'Long?'
jfieldID valueID = env->GetFieldID(ktclass, "value", "J");
env->SetLongField(ktclass, valueID, NULL); //Error