Skip to content

Fix TypedPropertyPath caching using Kotlin - #3546

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

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.
christophstrobl pushed a commit that referenced this pull request Oct 9, 2026
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.

See: #3521
Original Pull Request: #3546
christophstrobl pushed a commit that referenced this pull request Oct 9, 2026
Add value semantics to KSinglePropertyReference and KIterablePropertyReference. Move off our own isLambdaClass(…) implementation in favor of Spring Framework's ClassUtils.isLambdaClass(…) utility method.

See: #3521
Original Pull Request: #3546
christophstrobl pushed a commit that referenced this pull request Oct 9, 2026
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.

See: #3521
Original Pull Request: #3546
christophstrobl pushed a commit that referenced this pull request Oct 9, 2026
christophstrobl added a commit that referenced this pull request Oct 9, 2026
christophstrobl pushed a commit that referenced this pull request Oct 9, 2026
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.

See: #3521
Original Pull Request: #3546
christophstrobl pushed a commit that referenced this pull request Oct 9, 2026
Add value semantics to KSinglePropertyReference and KIterablePropertyReference. Move off our own isLambdaClass(…) implementation in favor of Spring Framework's ClassUtils.isLambdaClass(…) utility method.

See: #3521
Original Pull Request: #3546
christophstrobl pushed a commit that referenced this pull request Oct 9, 2026
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.

See: #3521
Original Pull Request: #3546
christophstrobl pushed a commit that referenced this pull request Oct 9, 2026
christophstrobl added a commit that referenced this pull request Oct 9, 2026
@christophstrobl
christophstrobl deleted the issue/3521 branch October 9, 2026 13:19
@christophstrobl christophstrobl added this to the 4.1.2 (2026.0.2) milestone Oct 9, 2026
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

2 participants