quarkusio/quarkus · error · IllegalArgumentException
The parameter type [" + params[i].getClass() + "] can not…
Error message
The parameter type [" + params[i].getClass() + "] can not be assigned to the type for the target method [" + parameterTypes[i] + "]
What it means
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.
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
Example fix
// before
ctx.setParameters(new Object[] { "42" }); // param is Integer
// after
ctx.setParameters(new Object[] { Integer.valueOf("42") }); Defensive patterns
Strategy: validation
Validate before calling
for (int i = 0; i < params.length; i++) {
Class<?> declared = Types.boxedClass(method.getParameterTypes()[i]);
if (params[i] != null && !declared.isAssignableFrom(Types.boxedClass(params[i].getClass()))) params[i] = convert(params[i], declared);
} Try / catch
try { ctx.setParameters(args); } catch (IllegalArgumentException e) { log.warnf("Type mismatch: %s", e.getMessage()); } Prevention
- 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
When it happens
Trigger: 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.
Common situations: 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.
Related errors
- Cache key generator instantiation failed
- Cannot instantiate JSON-B component:
- Cannot invoke constructor
- Cannot invoke method
- Cannot read field value
AI-assisted analysis of quarkusio/quarkus@e1c734241f (2026-09-05).
Data as JSON: /api/errors/f3ad1571093e584d.
Report an issue: GitHub.
Appendix: source
Thrown at independent-projects/arc/runtime/src/main/java/io/quarkus/arc/impl/AbstractInvocationContext.java:73
return found;
}
static void validateParameters(Executable executable, Object[] params) {
int newParametersCount = Objects.requireNonNull(params).length;
Class<?>[] parameterTypes = executable.getParameterTypes();
if (parameterTypes.length != newParametersCount) {
throw new IllegalArgumentException(
"Wrong number of parameters - method has " + Arrays.toString(parameterTypes) + ", attempting to set "
+ Arrays.toString(params));
}
for (int i = 0; i < params.length; i++) {
if (parameterTypes[i].isPrimitive() && params[i] == null) {
throw new IllegalArgumentException("Trying to set a null value to a primitive parameter [position: " + i
+ ", type: " + parameterTypes[i] + "]");
}
if (params[i] != null) {
if (!Types.boxedClass(parameterTypes[i]).isAssignableFrom(Types.boxedClass(params[i].getClass()))) {
throw new IllegalArgumentException("The parameter type [" + params[i].getClass()
+ "] can not be assigned to the type for the target method [" + parameterTypes[i] + "]");
}
}
}
}
@Override
public Method getMethod() {
return null;
}
@Override
public Object getTarget() {
return target;
}
@Override
public Object getTimer() {View on GitHub (pinned to e1c734241f)