24 #define DEBUG_LOG(...) clib_warning(__VA_ARGS__) 26 #define DEBUG_LOG(...) 33 jclass callbackClass, jobject callbackObject,
34 jclass callbackExceptionClass) {
35 DEBUG_LOG(
"\nCallOnError : callback=%s, retval=%d, context=%d\n", callName,
36 clib_net_to_host_u32(retval), clib_net_to_host_u32(context));
39 DEBUG_LOG(
"CallOnError : jm->callbackClass is null!\n");
42 jmethodID excConstructor = (*env)->GetMethodID(env, callbackExceptionClass,
43 "<init>",
"(Ljava/lang/String;II)V");
44 if (!excConstructor) {
45 DEBUG_LOG(
"CallOnError : excConstructor is null!\n");
48 jmethodID callbackExcMethod = (*env)->GetMethodID(env, callbackClass,
49 "onError",
"(Lio/fd/vpp/jvpp/VppCallbackException;)V");
50 if (!callbackExcMethod) {
51 DEBUG_LOG(
"CallOnError : callbackExcMethod is null!\n");
55 jobject excObject = (*env)->NewObject(env, callbackExceptionClass,
56 excConstructor, (*env)->NewStringUTF(env, callName),
57 clib_net_to_host_u32(contextId), clib_net_to_host_u32(retval));
59 DEBUG_LOG(
"CallOnError : excObject is null!\n");
63 (*env)->CallVoidMethod(env, callbackObject, callbackExcMethod, excObject);
64 DEBUG_LOG(
"CallOnError : Response sent\n");
70 jclass exClass = (*env)->FindClass(env,
"java/lang/IllegalStateException");
72 strcpy(msgBuf,
"API mismatch detected: ");
74 strcat(msgBuf,
" is missing");
75 DEBUG_LOG(
"get_message_id : %s\n", msgBuf);
76 (*env)->ThrowNew(env, exClass, msgBuf);
u32 get_message_id(JNIEnv *env, const char *key)
Retrieves message id based on message name and crc (key format: name_crc).
static void clib_mem_free(void *p)
static void * clib_mem_alloc(uword size)
void call_on_error(const char *callName, int contextId, int retval, jclass callbackClass, jobject callbackObject, jclass callbackExceptionClass)
Calls onError callback on callbackObject reference.