spring-projects / spring-projects/spring-framework

KotlinReflectionParameterNameDiscoverer doesn't support Kotlin Context Parameters

Open
#35,134 9 comments 2 reactions 1 assignee View on GitHub

@sdeleuze is already working on this.

Since Jun 30, 2025.

in: core status: feedback-provided theme: kotlin type: enhancement
Dominant language
Java
Stars
60.2k
Forks
38.8k
Avg merge
5d 2h
Merged PRs (30d)
27

Description

Background

Context Parameters were introduced in Kotlin 2.1.20 and are currently in Beta status in Kotlin 2.2.0 under the flag -Xcontext-parameters (announcement)

Issue

Spring's KotlinReflectionParameterNameDiscoverer cannot detect Context Parameters in Kotlin methods. The kotlinFunction property returns incomplete results - context parameters are completely absent from the reflection data.

Use Case

I'm migrating from Context Receivers to Context Parameters for implementing security via HandlerMethodArgumentResolver. My implementation:

  • Uses a custom UserContext class as a context parameter
  • Injects it into controller handler methods
  • Propagates it through service method calls

Technical Details

Expected

  1. Track support for Context Parameters in Spring Framework (if KT-78752 will be resolved)
  2. Add support for the new parameter kind coming in Kotlin 2.2.20 when reflection API is available

Contributor guide

Open the contributing guide

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

Assessment

This issue has not been assessed yet.

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.