From c7fc97ad85993956a5e76c2ea69dbd90b34360ac Mon Sep 17 00:00:00 2001 From: Marek Gradzki Date: Mon, 16 Oct 2017 12:33:12 +0200 Subject: jvpp: stop plugin intialization on first mismatch Java bindings use get_message_id from jvpp-common to detect if messages known at compile time are avaliable at runtime. In case of missing entry, Java exception is propagated via JNI using (*env)->ThrowNew. But this function does not end code execution so, in order to prevent unexpected behaviour (e.g. calling vl_msg_api_set_handlers with id == 0), get_message_id caller should do it manually. Change-Id: I2edb5013fd3658dcdd77a867b5cdf62e559ee071 Signed-off-by: Marek Gradzki --- src/vpp-api/java/jvpp-common/jvpp_common.c | 9 ++++++--- 1 file changed, 6 insertions(+), 3 deletions(-) (limited to 'src/vpp-api/java/jvpp-common') diff --git a/src/vpp-api/java/jvpp-common/jvpp_common.c b/src/vpp-api/java/jvpp-common/jvpp_common.c index c00298bfa81..2425607c582 100644 --- a/src/vpp-api/java/jvpp-common/jvpp_common.c +++ b/src/vpp-api/java/jvpp-common/jvpp_common.c @@ -83,11 +83,14 @@ u32 get_message_id(JNIEnv *env, const char *key) { uword *p = hash_get(jvpp_main.messages_hash, key); if (!p) { jclass exClass = (*env)->FindClass(env, "java/lang/IllegalStateException"); - char *msgBuf = clib_mem_alloc(strlen(key) + 40); + char *msgBuf = clib_mem_alloc(strlen(key) + 70); strcpy(msgBuf, "API mismatch detected: "); strcat(msgBuf, key); - strcat(msgBuf, " is missing"); - DEBUG_LOG("get_message_id : %s\n", msgBuf); + strcat(msgBuf, " is missing in global name_crc hash table."); + DEBUG_LOG("%s", msgBuf); + DEBUG_LOG("Possible reasons:"); + DEBUG_LOG("1) incompatible VPP version used"); + DEBUG_LOG("2) message present in JSON file but not in global name_crc table"); (*env)->ThrowNew(env, exClass, msgBuf); clib_mem_free(msgBuf); return 0; -- cgit 1.2.3-korg