{"record":{"id":"3e72bc4adbec206d","repo":"java-native-access/jna","slug":"jna-unhandled-arg-conversion-type-d","errorCode":null,"errorMessage":"JNA: Unhandled arg conversion type %d\n","messagePattern":"JNA: Unhandled arg conversion type (.+?)\n","errorType":"console","errorClass":null,"httpStatus":null,"severity":"warning","filePath":"native/callback.c","lineNumber":462,"sourceCode":"        case CVT_CALLBACK:\n          *((void **)args[i+3]) = newJavaCallback(env, *(void **)cbargs[i], cb->arg_classes[i]);\n          break;\n        case CVT_FLOAT:\n\t  args[i+3] = alloca(sizeof(double));\n\t  *((double *)args[i+3]) = *(float*)cbargs[i];\n          break;\n        case CVT_SHORT:\n\t  args[i+3] = alloca(sizeof(int));\n\t  *((int *)args[i+3]) = *(short*)cbargs[i];\n          break;\n        case CVT_BYTE:\n\t  args[i+3] = alloca(sizeof(int));\n          *((int *)args[i+3]) = *(char*)cbargs[i];\n          break;\n        case CVT_DEFAULT:\n          break;\n        default:\n          fprintf(stderr, \"JNA: Unhandled arg conversion type %d\\n\", cb->conversion_flags[i]);\n          break;\n        }\n      }\n    }\n\n    if (cb->rflag == CVT_STRUCTURE_BYVAL) {\n      resp = alloca(sizeof(jobject));\n    }\n    else if (cb->cif.rtype->size > cif->rtype->size) {\n      resp = alloca(cb->cif.rtype->size);\n    }\n#define FPTR(ENV,OFFSET) (*(void **)((char *)(*(ENV)) + OFFSET))\n#define JNI_FN(X) ((void (*)(void))(X))\n    ffi_call(&cb->java_cif, JNI_FN(FPTR(env, cb->fptr_offset)), resp, args);\n    if ((*env)->ExceptionCheck(env)) {\n      jthrowable throwable = (*env)->ExceptionOccurred(env);\n      (*env)->ExceptionClear(env);\n      if (!handle_exception(env, self, throwable)) {","sourceCodeStart":444,"sourceCodeEnd":480,"githubUrl":"https://github.com/java-native-access/jna/blob/d036ad9781adad4b66693e8fa7098e4ac665e0a3/native/callback.c#L444-L480","documentation":"In invoke_callback's argument conversion loop, an unrecognized conversion flag (cb->conversion_flags[i]) hits the default case and JNA prints this diagnostic to stderr, skipping conversion for that argument. The Java callback will then receive an incorrectly or unconverted argument value.","triggerScenarios":"A callback declaration whose parameter type maps to a conversion flag the native layer does not handle (unsupported/unknown CVT_* flag) — typically from a mismatch between the Java callback signature and what native setup computed, or a JNA build/version mismatch.","commonSituations":"Mixed native library (libjnidispatch) and Java JNA jar versions; callback parameter types that aren't in the supported conversion set.","solutions":["Ensure the native jnidispatch binary version exactly matches the JNA jar version.","Change the callback parameter types to supported ones (primitives, Pointer, Structure, String/WString, NativeMapped).","Rebuild/refresh the native library if a custom or stale build is deployed."],"exampleFix":"// before\nvoid cb(CustomJavaType t); // no native conversion flag\n// after\nvoid cb(Pointer p); // supported conversion type","handlingStrategy":"validation","validationCode":"// Verify at startup that jnidispatch native version matches the JNA jar\nNative.getNativeVersion(); // compare against com.sun.jna.Version","typeGuard":null,"tryCatchPattern":null,"preventionTips":["Ship the jnidispatch native binary bundled from the exact JNA version used","Restrict callback parameters to supported conversion types","Rebuild/redeploy consistently when upgrading JNA","Watch stderr for 'Unhandled arg conversion type' during integration tests"],"tags":["jna","native","callback","argument-conversion"],"backgroundTag":"unsupported-operation","analyzedSha":"d036ad9781adad4b66693e8fa7098e4ac665e0a3","analyzedAt":"2026-09-12T06:50:59.239Z","contentChangedAt":"2026-09-12T06:50:59.239Z","schemaVersion":2},"datasetVersion":"2026-09-14T05:17:10.506Z"}