{"record":{"id":"f3ad1571093e584d","repo":"quarkusio/quarkus","slug":"the-parameter-type-params-i-getclass","errorCode":null,"errorMessage":"The parameter type [\" + params[i].getClass() + \"] can not be assigned to the type for the target method [\" + parameterTypes[i] + \"]","messagePattern":"The parameter type \\[\" \\+ params\\[i\\]\\.getClass\\(\\) \\+ \"\\] can not be assigned to the type for the target method \\[\" \\+ parameterTypes\\[i\\] \\+ \"\\]","errorType":"exception","errorClass":"IllegalArgumentException","httpStatus":null,"severity":"error","filePath":"independent-projects/arc/runtime/src/main/java/io/quarkus/arc/impl/AbstractInvocationContext.java","lineNumber":73,"sourceCode":"        return found;\n    }\n\n    static void validateParameters(Executable executable, Object[] params) {\n        int newParametersCount = Objects.requireNonNull(params).length;\n        Class<?>[] parameterTypes = executable.getParameterTypes();\n        if (parameterTypes.length != newParametersCount) {\n            throw new IllegalArgumentException(\n                    \"Wrong number of parameters - method has \" + Arrays.toString(parameterTypes) + \", attempting to set \"\n                            + Arrays.toString(params));\n        }\n        for (int i = 0; i < params.length; i++) {\n            if (parameterTypes[i].isPrimitive() && params[i] == null) {\n                throw new IllegalArgumentException(\"Trying to set a null value to a primitive parameter [position: \" + i\n                        + \", type: \" + parameterTypes[i] + \"]\");\n            }\n            if (params[i] != null) {\n                if (!Types.boxedClass(parameterTypes[i]).isAssignableFrom(Types.boxedClass(params[i].getClass()))) {\n                    throw new IllegalArgumentException(\"The parameter type [\" + params[i].getClass()\n                            + \"] can not be assigned to the type for the target method [\" + parameterTypes[i] + \"]\");\n                }\n            }\n        }\n    }\n\n    @Override\n    public Method getMethod() {\n        return null;\n    }\n\n    @Override\n    public Object getTarget() {\n        return target;\n    }\n\n    @Override\n    public Object getTimer() {","sourceCodeStart":55,"sourceCodeEnd":91,"githubUrl":"https://github.com/quarkusio/quarkus/blob/e1c734241f34c7919086ceb4c9262b4a58f6de44/independent-projects/arc/runtime/src/main/java/io/quarkus/arc/impl/AbstractInvocationContext.java#L55-L91","documentation":"validateParameters() throws IllegalArgumentException when a supplied argument's type is not assignable to the declared parameter type (compared via boxed types). It enforces type safety for reflectively invoked methods before the actual call.","triggerScenarios":"Passing an argument whose runtime class cannot be assigned to the declared parameter's boxed class — e.g. passing String where Integer is expected, or an unrelated subtype not in the hierarchy.","commonSituations":"Hand-built invocation arrays from deserialized JSON (numbers become String or BigDecimal); generic Object wiring in interceptors; changed method signature with stale callers; int vs long confusion.","solutions":["Cast/convert the argument to the declared parameter type before invocation","Use converters (e.g. Number conversion) when values come from text/config sources","Verify the method signature hasn't changed and callers pass matching types","Validate assignability with Types.boxedClass(paramType).isInstance(value) beforehand"],"exampleFix":"// before\nctx.setParameters(new Object[] { \"42\" }); // param is Integer\n// after\nctx.setParameters(new Object[] { Integer.valueOf(\"42\") });","handlingStrategy":"validation","validationCode":"for (int i = 0; i < params.length; i++) {\n  Class<?> declared = Types.boxedClass(method.getParameterTypes()[i]);\n  if (params[i] != null && !declared.isAssignableFrom(Types.boxedClass(params[i].getClass()))) params[i] = convert(params[i], declared);\n}","typeGuard":null,"tryCatchPattern":"try { ctx.setParameters(args); } catch (IllegalArgumentException e) { log.warnf(\"Type mismatch: %s\", e.getMessage()); }","preventionTips":["Convert JSON/text-sourced values to declared types before invocation","Use boxedClass assignability checks for generic wiring","Keep signatures and callers in sync with compiler-checked paths where possible"],"tags":["cdi","reflection","type-safety"],"backgroundTag":"parameter-type-mismatch","analyzedSha":"e1c734241f34c7919086ceb4c9262b4a58f6de44","analyzedAt":"2026-09-05T17:01:29.979Z","contentChangedAt":"2026-09-05T17:01:29.979Z","schemaVersion":2},"datasetVersion":"2026-09-14T00:17:10.932Z"}