# Create the JVM, returns its handle and store the a pointer to JniEnv in `env_ref`
#
# Unavailable on Android, where you cannot instanciate a new JVM.
- new(args: JavaVMInitArgs, env_ref: JniEnvRef) import jni_error, JniEnvRef.jni_env=, JniEnv as nullable `{
+ new(args: JavaVMInitArgs, env_ref: JniEnvRef) import jni_error, JniEnvRef.jni_env=, JniEnv.as nullable `{
#ifdef ANDROID
JavaVM_jni_error(NULL, "JVM creation not supported on Android", 0);
return (char*)(*recv)->GetStringUTFChars(recv, (jstring)jobj, NULL);
`}
- private fun convert_args_to_jni(args: nullable Array[nullable Object]): Pointer import Array[nullable Object] as not nullable, Array[nullable Object].[], Array[nullable Object].length, nullable Object.as(Int), nullable Object.as(Char), nullable Object.as(Bool), nullable Object.as(Float), nullable Object.as(JavaObject), nullable Object.as(String), String.to_cstring, String.length `{
+ private fun convert_args_to_jni(args: nullable Array[nullable Object]): Pointer import Array[nullable Object].as not nullable, Array[nullable Object].[], Array[nullable Object].length, nullable Object.as(Int), nullable Object.as(Char), nullable Object.as(Bool), nullable Object.as(Float), nullable Object.as(JavaObject), nullable Object.as(String), String.to_cstring, String.length `{
if(nullable_Array_of_nullable_Object_is_null(args)){
return NULL;
}
fun string_to_jobject(string: String): JavaObject `{
return (*recv)->NewStringUTF(recv, String_to_cstring(string));
`}
+
+ # Pushes a local reference frame on the JNI stack
+ fun push_local_frame(capacity: Int): Bool `{
+ return (*recv)->PushLocalFrame(recv, capacity);
+ `}
+
+ # Pops the current local reference frame on the JNI stack
+ fun pop_local_frame `{
+ (*recv)->PopLocalFrame(recv, NULL);
+ `}
end
# used to initialize a JavaVM
end
# Represens a jni jobject
-extern class JavaObject `{jobject`}
+extern class JavaObject in "Java" `{ java.lang.Object `}
end
# Represents a jni JNINNativeMethod