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 <mgradzki@cisco.com>
// verify API has not changed since jar generation
#define _(N) \
// verify API has not changed since jar generation
#define _(N) \
- get_message_id(env, #N); \
+ if (get_message_id(env, #N) == 0) return;
foreach_supported_api_message;
#undef _
foreach_supported_api_message;
#undef _
uword *p = hash_get(jvpp_main.messages_hash, key);
if (!p) {
jclass exClass = (*env)->FindClass(env, "java/lang/IllegalStateException");
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);
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;
(*env)->ThrowNew(env, exClass, msgBuf);
clib_mem_free(msgBuf);
return 0;
plugin_main->callbackObject = (*env)->NewGlobalRef(env, callback);
plugin_main->callbackClass = (jclass)(*env)->NewGlobalRef(env, (*env)->GetObjectClass(env, callback));
plugin_main->callbackObject = (*env)->NewGlobalRef(env, callback);
plugin_main->callbackClass = (jclass)(*env)->NewGlobalRef(env, (*env)->GetObjectClass(env, callback));
- // verify API has not changed since jar generation
+ // verify API has not changed since jar generation (exit on mismatch)
- get_message_id(env, #N); \
+ if (get_message_id(env, #N) == 0) return;
foreach_supported_api_message;
#undef _
foreach_supported_api_message;
#undef _
// verify API has not changed since jar generation
#define _(N) \
// verify API has not changed since jar generation
#define _(N) \
- get_message_id(env, #N); \
+ if (get_message_id(env, #N) == 0) return;
foreach_supported_api_message;
#undef _
foreach_supported_api_message;
#undef _
// verify API has not changed since jar generation
#define _(N) \
// verify API has not changed since jar generation
#define _(N) \
- get_message_id(env, #N);
+ if (get_message_id(env, #N) == 0) return;
foreach_supported_api_message;
#undef _
foreach_supported_api_message;
#undef _
// verify API has not changed since jar generation
#define _(N) \
// verify API has not changed since jar generation
#define _(N) \
- get_message_id(env, #N);
+ if (get_message_id(env, #N) == 0) return;
foreach_supported_api_message;
#undef _
foreach_supported_api_message;
#undef _
// verify API has not changed since jar generation
#define _(N) \
// verify API has not changed since jar generation
#define _(N) \
- get_message_id(env, #N);
+ if (get_message_id(env, #N) == 0) return;
foreach_supported_api_message;
#undef _
foreach_supported_api_message;
#undef _
// verify API has not changed since jar generation
#define _(N) \
// verify API has not changed since jar generation
#define _(N) \
- get_message_id(env, #N);
+ if (get_message_id(env, #N) == 0) return;
foreach_supported_api_message;
#undef _
foreach_supported_api_message;
#undef _
// verify API has not changed since jar generation
#define _(N) \
// verify API has not changed since jar generation
#define _(N) \
- get_message_id(env, #N); \
+ if (get_message_id(env, #N) == 0) return;
foreach_supported_api_message;
#undef _
foreach_supported_api_message;
#undef _