From 88fcc59f206b84ca29e1fb0ffc13d20671d4a1a7 Mon Sep 17 00:00:00 2001 From: Simon Sobisch Date: Thu, 11 Jul 2024 12:27:37 +0200 Subject: [PATCH] Update java.c first update to handle the case of --without-jni * always define externalized functions (we later need to add the delay-load part - likely these two functions are moved to call.c, then call into java.c after delay-loading - but that can come much later) * minor adjustment to header inclusion --- libcob/java.c | 67 ++++++++++++++++++++++++++++++++++++++++++--------- 1 file changed, 55 insertions(+), 12 deletions(-) diff --git a/libcob/java.c b/libcob/java.c index 002427d3b..1442e3c99 100644 --- a/libcob/java.c +++ b/libcob/java.c @@ -14,11 +14,20 @@ along with GnuCOBOL. If not, see . */ -#include +#include + #include #include #include -#include + +/* Force symbol exports */ +#define COB_LIB_EXPIMP +#include "libcob.h" +#include "coblocal.h" + +#if WITH_JNI + +#include /* Declarations */ static JavaVM *jvm = NULL; @@ -91,15 +100,49 @@ cob_resolve_java (const char *class_name, return handle; } +#else /* !WITH_JNI */ + +typedef struct __cob_java_static_method { + void *; + void *; +} cob_java_handle; + +cob_java_handle * +cob_resolve_java (const char *class_name, + const char* method_name, + const char *type_signature) +{ + return NULL; +} + +#endif + void -cob_call_java (const cob_java_handle *method_handle) { - if (method_handle == NULL) { - return; - } - (*env)->CallStaticVoidMethod(env, method_handle->cls, +cob_call_java (const cob_java_handle *method_handle) +{ +#if WITH_JNI + if (method_handle == NULL) { + return; + } + (*env)->CallStaticVoidMethod(env, method_handle->cls, method_handle->mid, NULL); - if ((*env)->ExceptionCheck(env)) { - (*env)->ExceptionDescribe(env); - (*env)->ExceptionClear(env); - } -} \ No newline at end of file + if ((*env)->ExceptionCheck(env)) { + (*env)->ExceptionDescribe(env); + (*env)->ExceptionClear(env); + } +#else + static int first_java = 1; + + COB_UNUSED (method_handle); + + 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); +#endif + cob_add_exception (COB_EC_IMP_FEATURE_DISABLED); +#endif +}