Skip to content

Commit

Permalink
Fix reporting of failures to load Java interoperability module
Browse files Browse the repository at this point in the history
  • Loading branch information
nberth committed Nov 6, 2024
1 parent 5aaa4a9 commit d5ed5c3
Showing 1 changed file with 24 additions and 22 deletions.
46 changes: 24 additions & 22 deletions libcob/call.c
Original file line number Diff line number Diff line change
Expand Up @@ -2074,7 +2074,7 @@ cob_init_java (void) {

java_api = cob_malloc (sizeof (cob_java_api));
if (java_api == NULL) {
return 1;
goto error;
}

module_errmsg[0] = 0;
Expand All @@ -2092,10 +2092,15 @@ cob_init_java (void) {
should follow. */
cob_free (java_api);
java_api = NULL;
return 1;
goto error;
}
jinit (java_api);
return 0;

error:
cob_runtime_error (_("Java interoperability module cannot be loaded: %s"),
module_errmsg);
return 1;
}

#endif /* WITH_JNI */
Expand All @@ -2116,31 +2121,28 @@ cob_resolve_java (const char *class_name,

void
cob_call_java (const cob_java_handle *method_handle) {
if (method_handle == NULL) {
cob_runtime_error(_("Invalid Java method handle: NULL"));
cob_add_exception(COB_EC_ARGUMENT);
return;
}
if (method_handle == NULL) {
cob_runtime_error (_("Invalid Java method handle: NULL"));
cob_add_exception (COB_EC_ARGUMENT);
return;
}
#if WITH_JNI
if (java_api == NULL) {
cob_runtime_error (_("Java interoperability module cannot be loaded: %s"),
module_errmsg);
if (java_api == NULL && cob_init_java ()) {
return;
}
return java_api->cob_call (method_handle);
java_api->cob_call (method_handle);
#else
{
static int first_java = 1;

if (first_java) {
first_java = 0;
cob_runtime_warning (_("runtime is not configured to support %s"),
"JNI");
}
{
static int first_java = 1;
if (first_java) {
first_java = 0;
cob_runtime_warning (_("runtime is not configured to support %s"),
"JNI");
}
#if 0 /* TODO: if there is a register in Java-interop, then set it */
set_json_exception (JSON_INTERNAL_ERROR);
set_json_exception (JSON_INTERNAL_ERROR);
#endif
cob_add_exception (COB_EC_IMP_FEATURE_DISABLED);
}
cob_add_exception (COB_EC_IMP_FEATURE_DISABLED);
}
#endif
}

0 comments on commit d5ed5c3

Please sign in to comment.