Fix KotlinReflectPropertyAccessStrategy to yield instead of throwing NPE - #4995
Draft
MateuszNaKodach wants to merge 1 commit into
Draft
Fix KotlinReflectPropertyAccessStrategy to yield instead of throwing NPE#4995MateuszNaKodach wants to merge 1 commit into
MateuszNaKodach wants to merge 1 commit into
Conversation
MateuszNaKodach
requested review from
hjohn,
jangalinski and
zambrovski
and removed request for
a team
September 1, 2026 09:39
MateuszNaKodach
force-pushed
the
bug/kotlin-property-access-value-class-id
branch
from
September 1, 2026 09:42
2c0563d to
7496cb0
Compare
zambrovski
reviewed
Sep 1, 2026
| return constructor.call(value) as V | ||
| // Unbox value classes to their underlying JVM representation, consistent with the default | ||
| // field/getter strategies and the type the framework resolves ids and @EventTag values against. | ||
| if (value != null && returnClass?.isValue == true) { |
Contributor
|
Just curious, do we also need one for conversion of Kotlin Types to Java Types? Like Int / Integer, etc... |
MateuszNaKodach
force-pushed
the
bug/kotlin-property-access-value-class-id
branch
from
September 1, 2026 10:05
7496cb0 to
2d0af57
Compare
KotlinReflectPropertyAccessStrategy registers with priority 1000, so PropertyAccessStrategy consults it first for every class. Its propertyFor used kProperty(...)!!, which throws NullPointerException when the target is not a Kotlin class, or when the name does not match exactly one member property. PropertyAccessStrategy.getProperty walks the registered strategies by priority and moves on when one returns null, which is the documented contract of propertyFor. Because this strategy is consulted first, that NPE broke resolution for every consumer instead of letting a lower-priority strategy handle it. propertyFor now returns null in those cases. To let the Kotlin override return null, the abstract PropertyAccessStrategy.propertyFor is annotated @nullable, making the existing "or null if the property could not be found" contract explicit. Adds tests: a non-Kotlin class falls through to another strategy, and an unknown property resolves to null.
MateuszNaKodach
force-pushed
the
bug/kotlin-property-access-value-class-id
branch
from
September 1, 2026 10:35
2d0af57 to
fcd62f6
Compare
MateuszNaKodach
marked this pull request as draft
September 1, 2026 10:41
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
WORK IN PROGRESS....
Summary
KotlinReflectPropertyAccessStrategyregisters with priority1000, soPropertyAccessStrategyconsults it first for every class. ItspropertyForusedkProperty(...)!!, which throwsNullPointerExceptionwhen the target is not a Kotlin class, or when the name does not match exactly one member property.PropertyAccessStrategy.getPropertywalks the registered strategies by priority and moves on when one returnsnull, which is the documented contract ofpropertyFor:Because this strategy is consulted first, that NPE broke resolution for every consumer instead of letting a lower-priority strategy handle it.
propertyFornow returnsnullin those cases so the chain falls through.To let the Kotlin override return
null, the abstractPropertyAccessStrategy.propertyForis annotated@Nullable, making the existing "or null if the property could not be found" contract explicit.Tests
RuntimeException) falls through so a lower-priority strategy resolvesmessage.null.All extension module tests and the
commonproperty tests pass.