{"record":{"id":"0125b8e9153187cb","repo":"quarkusio/quarkus","slug":"wrong-number-of-parameters-method-has-arrays","errorCode":null,"errorMessage":"Wrong number of parameters - method has \" + Arrays.toString(parameterTypes) + \", attempting to set \" + Arrays.toString(params)","messagePattern":"Wrong number of parameters - method has \" \\+ Arrays\\.toString\\(parameterTypes\\) \\+ \", attempting to set \" \\+ Arrays\\.toString\\(params\\)","errorType":"exception","errorClass":"IllegalArgumentException","httpStatus":null,"severity":"error","filePath":"independent-projects/arc/runtime/src/main/java/io/quarkus/arc/impl/AbstractInvocationContext.java","lineNumber":62,"sourceCode":"    }\n\n    @SuppressWarnings(\"unchecked\")\n    @Override\n    public <T extends Annotation> List<T> findIterceptorBindings(Class<T> annotationType) {\n        List<T> found = new ArrayList<>();\n        for (Annotation annotation : (Set<Annotation>) getInterceptorBindings()) {\n            if (annotation.annotationType().equals(annotationType)) {\n                found.add((T) annotation);\n            }\n        }\n        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","sourceCodeStart":44,"sourceCodeEnd":80,"githubUrl":"https://github.com/quarkusio/quarkus/blob/e1c734241f34c7919086ceb4c9262b4a58f6de44/independent-projects/arc/runtime/src/main/java/io/quarkus/arc/impl/AbstractInvocationContext.java#L44-L80","documentation":"AbstractInvocationContext.validateParameters() throws IllegalArgumentException when the number of parameters supplied does not equal the executable's declared parameter count. This validates arguments before invoking a dynamically-invoked bean method (interceptor/invocation context).","triggerScenarios":"Calling InvocationContext.setParameters(Object[]) (or the internal invocation path) with an array whose length differs from the target method's parameter count, including passing null params.","commonSituations":"Miswired interceptors or synthetic invocations (e.g. in Dev UI or generated code) passing wrong-sized argument arrays; reflection-based callers constructing parameter arrays by hand; signature change after refactoring where callers weren't updated.","solutions":["Ensure the Object[] passed to setParameters/invoke matches the target method's exact parameter count","Check for reflection code that builds the args array and align it with the current method signature","Verify interceptors/decorators pass through the original parameters instead of rebuilding them","Log Arrays.toString of both arrays (as the exception does) to compare positions"],"exampleFix":"// before\nctx.setParameters(new Object[] { id }); // method has 2 params\n// after\nctx.setParameters(new Object[] { id, name }); // match declared signature","handlingStrategy":"validation","validationCode":"Object[] p = ...; if (p.length != method.getParameterCount()) throw new IllegalArgumentException(\"expected \" + method.getParameterCount() + \" args\");","typeGuard":null,"tryCatchPattern":"try { ctx.setParameters(args); } catch (IllegalArgumentException e) { log.warnf(\"Param mismatch: %s\", e.getMessage()); }","preventionTips":["Derive parameter arrays from the method's ParameterCount","Update reflection callers when method signatures change","Add unit tests for interceptor invocation paths"],"tags":["cdi","reflection","invocation"],"backgroundTag":"parameter-count-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"}