{"record":{"id":"1462b0c62299fc37","repo":"java-native-access/jna","slug":"class-type-paramtypes-i-getname-not-mapped-to-primitive","errorCode":null,"errorMessage":"Class type <paramTypes[i].getName()> not mapped to primitive default value.","messagePattern":"Class type <paramTypes\\[i\\]\\.getName\\(\\)> not mapped to primitive default value\\.","errorType":"exception","errorClass":"java.lang.IllegalArgumentException","httpStatus":null,"severity":"error","filePath":"contrib/platform/src/com/sun/jna/platform/win32/COM/util/CallbackProxy.java","lineNumber":230,"sourceCode":"        // exception occurs while doing the call into the target method\n        for (int i = 0; i < params.length; i++) {\n            if (params[i] == null && paramTypes[i].isPrimitive()) {\n                if (paramTypes[i].equals(boolean.class)) {\n                    params[i] = DEFAULT_BOOLEAN;\n                } else if (paramTypes[i].equals(byte.class)) {\n                    params[i] = DEFAULT_BYTE;\n                } else if (paramTypes[i].equals(short.class)) {\n                    params[i] = DEFAULT_SHORT;\n                } else if (paramTypes[i].equals(int.class)) {\n                    params[i] = DEFAULT_INT;\n                } else if (paramTypes[i].equals(long.class)) {\n                    params[i] = DEFAULT_LONG;\n                } else if (paramTypes[i].equals(float.class)) {\n                    params[i] = DEFAULT_FLOAT;\n                } else if (paramTypes[i].equals(double.class)) {\n                    params[i] = DEFAULT_DOUBLE;\n                } else {\n                    throw new IllegalArgumentException(\"Class type \" + paramTypes[i].getName() + \" not mapped to primitive default value.\");\n                }\n            }\n        }\n\n        try {\n            eventMethod.invoke(comEventCallbackListener, params);\n        } catch (Exception e) {\n            List<String> decodedClassNames = new ArrayList<>(params.length);\n            for (Object o : params) {\n                if (o == null) {\n                    decodedClassNames.add(\"NULL\");\n                } else {\n                    decodedClassNames.add(o.getClass().getName());\n                }\n            }\n            CallbackProxy.this.comEventCallbackListener.errorReceivingCallbackEvent(\n                    \"Exception invoking method \" + eventMethod + \" supplied: \" + decodedClassNames.toString(), e);\n        }","sourceCodeStart":212,"sourceCodeEnd":248,"githubUrl":"https://github.com/java-native-access/jna/blob/d036ad9781adad4b66693e8fa7098e4ac665e0a3/contrib/platform/src/com/sun/jna/platform/win32/COM/util/CallbackProxy.java#L212-L248","documentation":"CallbackProxy builds a parameters array of default primitive values for the reflected event method; the chain of equals(...) checks only covers known primitives (boolean, int, long, float, double, etc.). If a parameter type is not in the map it throws this IllegalArgumentException. It indicates the callback method signature uses a type the proxy's default-value table does not handle.","triggerScenarios":"Defining an IComEventCallbackListener method whose parameters include an unmapped type (e.g. char, byte, or an object type) so CallbackProxy.invokeOnThread cannot synthesize default values for a discarded event call.","commonSituations":"Writing an event callback signature that does not match the actual COM dispinterface signature; using wrapper types (Integer, String[]) or custom objects where the proxy expects primitives; JNA version changes adding/removing supported primitive mappings.","solutions":["Change the callback method's parameter types to ones the proxy supports (matching the real event signature)","Check CallbackProxy.invokeOnThread for the exact list of supported primitive types in your JNA version","If you need the real values rather than defaults, ensure the dispId-to-Method mapping matches so actual VARIANT args are converted instead of defaults being filled","Upgrade/patch JNA if your primitive type should be supported by a newer version"],"exampleFix":"// before\nvoid onProgress(char stage);\n// after\nvoid onProgress(int stage);","handlingStrategy":"try-catch","validationCode":"for (Class<?> p : callbackMethod.getParameterTypes()) {\n    if (!p.isPrimitive() && p != String.class && !DISPATCHED_TYPES.contains(p))\n        throw new IllegalArgumentException(\"unsupported callback param: \" + p);\n}","typeGuard":null,"tryCatchPattern":"try { listenerMethod.invoke(target, args); } catch (IllegalArgumentException e) { if (e.getMessage().contains(\"not mapped to primitive default value\")) { log.error(\"fix callback signature: \" + e.getMessage()); } }","preventionTips":["Match callback method signatures exactly to the COM event signature","Use plain primitives (int, long, double, boolean, float) in event callbacks","Keep callbacks in sync with the type library"],"tags":["java","com","reflection","events","type-mismatch"],"backgroundTag":"type-mismatch","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"}