junit-team/junit5 · error · JUnitException
Unsupported parameter kind
Error message
Unsupported parameter kind: ${parameter.getKind()} What it means
JUnitException thrown by KotlinFunctionUtils.toArgumentMap when a Kotlin KParameter's kind is not INSTANCE, VALUE, or EXTENSION_RECEIVER. JUnit only knows how to bind those three kinds when invoking Kotlin functions reflectively; any other kind (e.g. HEADER from inline-class metadata, or kinds introduced by newer Kotlin compilers) is rejected.
Solutions
- Restructure the Kotlin test method to use standard VALUE parameters
- Upgrade JUnit to a version with broader Kotlin kind support
- Avoid inline/value classes as direct test method parameters
- Report the case to JUnit with the Kotlin compiler version and a reproducer
Defensive patterns
Strategy: validation
Type guard
static boolean supportsKotlinParam(kotlin.reflect.KParameter p) {
var k = p.getKind();
return k == KParameter.Kind.INSTANCE
|| k == KParameter.Kind.VALUE
|| k == KParameter.Kind.EXTENSION_RECEIVER;
} Prevention
- Keep Kotlin test method parameters to plain VALUE kinds
- Match JUnit and Kotlin compiler versions per the JUnit compatibility matrix
- Avoid inline/value classes as direct test method parameters
When it happens
Trigger: Reflective invocation of a Kotlin @Test method or lifecycle method whose Kotlin metadata declares a parameter kind JUnit does not handle - e.g. a value parameter of an inline class exposed with HEADER kind, or a kind introduced by a newer kotlin-compiler version.
Common situations: Using Kotlin inline/value classes as direct test method parameters; new Kotlin compiler version emitting metadata kinds JUnit does not yet recognize; Kotlin suspend functions routed through the non-suspend invocation path.
Related errors
- Could not instantiate TimeZoneProvider because of exception
- Detected cycle in inner class hierarchy between
- Failed to find constructor for
- Failed to inject parameter value into field
- LocaleProvider instance could not be constructed because of…
AI-assisted analysis of junit-team/junit5@f070c699a0 (2026-08-11).
Data as JSON: /api/errors/a6fbb3242a271979.
Report an issue: GitHub.
Appendix: source
Thrown at junit-platform-commons/src/main/java/org/junit/platform/commons/util/KotlinFunctionUtils.java:123
}
catch (Exception e) {
throw throwAsUncheckedException(getUnderlyingCause(e));
}
});
}
private static Map<KParameter, @Nullable Object> toArgumentMap(@Nullable Object target, @Nullable Object[] args,
KFunction<?> function) {
Map<KParameter, @Nullable Object> arguments = new HashMap<>(args.length + 1);
int index = 0;
for (KParameter parameter : function.getParameters()) {
switch (parameter.getKind()) {
case INSTANCE -> arguments.put(parameter, target);
case VALUE, EXTENSION_RECEIVER -> {
arguments.put(parameter, args[index]);
index++;
}
default -> throw new JUnitException("Unsupported parameter kind: " + parameter.getKind());
}
}
return arguments;
}
private static KFunction<?> getKotlinFunction(Method method) {
return Preconditions.notNull(ReflectJvmMapping.getKotlinFunction(method),
() -> "Failed to get Kotlin function for method: " + method);
}
private KotlinFunctionUtils() {
}
}
View on GitHub (pinned to f070c699a0)