// retrieve the implementation Java class
java_class = Sys_load_jclass(sys, "{{{mmodule.impl_java_class_name}}}");
if (java_class == NULL) {
- fprintf(stderr, "Nit FFI with Java error: failed to load class.\\n");
+ PRINT_ERROR("Nit FFI with Java error: failed to load class.\\n");
(*nit_ffi_jni_env)->ExceptionDescribe(nit_ffi_jni_env);
exit(1);
}
// retreive the implementation static function
java_meth_id = (*nit_ffi_jni_env)->GetStaticMethodID(nit_ffi_jni_env, java_class, "{{{java_fun_name}}}", "{{{jni_format}}}");
if (java_meth_id == NULL) {
- fprintf(stderr, "Nit FFI with Java error: Java implementation not found.\\n");
+ PRINT_ERROR("Nit FFI with Java error: Java implementation not found.\\n");
(*nit_ffi_jni_env)->ExceptionDescribe(nit_ffi_jni_env);
exit(1);
}
// execute implementation code
{{{ccall}}}
if ((*nit_ffi_jni_env)->ExceptionCheck(nit_ffi_jni_env)) {
- fprintf(stderr, "Nit FFI with Java error: Exception after call.\\n");
+ PRINT_ERROR("Nit FFI with Java error: Exception after call.\\n");
(*nit_ffi_jni_env)->ExceptionDescribe(nit_ffi_jni_env);
exit(1);
}
};
jint res = (*env)->RegisterNatives(env, jclazz, methods, n_methods);
if (res != JNI_OK) {
- fprintf(stderr, "RegisterNatives failed\\n");
+ PRINT_ERROR("RegisterNatives failed\\n");
(*env)->ExceptionDescribe(env);
exit(1);
}
redef fun java_type
do
var ftype = mclass.ftype
- if ftype isa ForeignJavaType then return ftype.java_type
+ if ftype isa ForeignJavaType then return ftype.java_type.
+ replace('/', ".").replace('$', ".").replace(' ', "")
if mclass.name == "Bool" then return "boolean"
if mclass.name == "Char" then return "char"
if mclass.name == "Int" then return "int"