{"record":{"id":"a6fbb3242a271979","repo":"junit-team/junit5","slug":"unsupported-parameter-kind-parameter-getkind","errorCode":null,"errorMessage":"Unsupported parameter kind: ${parameter.getKind()}","messagePattern":"Unsupported parameter kind: (.+?)","errorType":"exception","errorClass":"JUnitException","httpStatus":null,"severity":"error","filePath":"junit-platform-commons/src/main/java/org/junit/platform/commons/util/KotlinFunctionUtils.java","lineNumber":123,"sourceCode":"\t\t\t}\n\t\t\tcatch (Exception e) {\n\t\t\t\tthrow throwAsUncheckedException(getUnderlyingCause(e));\n\t\t\t}\n\t\t});\n\t}\n\n\tprivate static Map<KParameter, @Nullable Object> toArgumentMap(@Nullable Object target, @Nullable Object[] args,\n\t\t\tKFunction<?> function) {\n\t\tMap<KParameter, @Nullable Object> arguments = new HashMap<>(args.length + 1);\n\t\tint index = 0;\n\t\tfor (KParameter parameter : function.getParameters()) {\n\t\t\tswitch (parameter.getKind()) {\n\t\t\t\tcase INSTANCE -> arguments.put(parameter, target);\n\t\t\t\tcase VALUE, EXTENSION_RECEIVER -> {\n\t\t\t\t\targuments.put(parameter, args[index]);\n\t\t\t\t\tindex++;\n\t\t\t\t}\n\t\t\t\tdefault -> throw new JUnitException(\"Unsupported parameter kind: \" + parameter.getKind());\n\t\t\t}\n\t\t}\n\t\treturn arguments;\n\t}\n\n\tprivate static KFunction<?> getKotlinFunction(Method method) {\n\t\treturn Preconditions.notNull(ReflectJvmMapping.getKotlinFunction(method),\n\t\t\t() -> \"Failed to get Kotlin function for method: \" + method);\n\t}\n\n\tprivate KotlinFunctionUtils() {\n\t}\n}\n","sourceCodeStart":105,"sourceCodeEnd":137,"githubUrl":"https://github.com/junit-team/junit5/blob/f070c699a08b5d8393df9afd147af5c5e90bb21b/junit-platform-commons/src/main/java/org/junit/platform/commons/util/KotlinFunctionUtils.java#L105-L137","documentation":"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.","triggerScenarios":"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.","commonSituations":"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.","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"],"exampleFix":null,"handlingStrategy":"validation","validationCode":null,"typeGuard":"static boolean supportsKotlinParam(kotlin.reflect.KParameter p) {\n    var k = p.getKind();\n    return k == KParameter.Kind.INSTANCE\n        || k == KParameter.Kind.VALUE\n        || k == KParameter.Kind.EXTENSION_RECEIVER;\n}","tryCatchPattern":null,"preventionTips":["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"],"tags":["kotlin","reflection","parameter-binding"],"backgroundTag":null,"analyzedSha":"f070c699a08b5d8393df9afd147af5c5e90bb21b","analyzedAt":"2026-08-11T20:31:00.530Z","contentChangedAt":null,"schemaVersion":2},"datasetVersion":"2026-09-23T08:17:48.524Z"}