Skip to content

Fix TypedPropertyPath caching using Kotlin - #3546

Open
mp911de wants to merge 6 commits into
mainfrom
issue/3521
Open

mp911de wants to merge 6 commits into
mainfrom
issue/3521

Conversation

@mp911de

@mp911de mp911de commented Sep 22, 2026

Copy link
Copy Markdown
Member

We now introspect the property-path Lambda cache key for Kotlin lambdas as Kotlin creates an instance per invocation rendering our cache useless.

Also, move off own helpers to Spring Framework utils, avoid instantiation of capturing lambdas in TypedPropertyPathFeature and register reflection hints for SAM-converted Kotlin lambdas.

Closes #3521

We now pre-process the cache key for Kotlin typed path references as Kotlin creates a new lambda instance per invocation while non-capturing Java lambdas result in a single instance per declaration site.
Add value semantics to KSinglePropertyReference and KIterablePropertyReference. Move off our own isLambdaClass(…) implementation in favor of Spring Framework's ClassUtils.isLambdaClass(…) utility method.
Kotlin (SAM-converted Lambdas) and Java capturing lambdas declare constructors that require the capturing argument and thus cannot be instantiated with a zero-arg constructor. We skip capturing lambda registrations entirely. For SAM-converted Kotlin lambdas, we introspect their metadata and obtain model information through KPropertyReferenceDescriptor. This isn't ideal as this registers reflection for every reachable Kotlin property reference in the image.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

type: bug A general bug

Projects

None yet

Development

Successfully merging this pull request may close these issues.

TypedPropertyPaths cache grows linearly for Kotlin property references

3 participants