Skip to content

Support Java record component properties - #1349

Open
alloutflo wants to merge 1 commit into
HubSpot:masterfrom
alloutflo:fix/1163-record-properties
Open

alloutflo wants to merge 1 commit into
HubSpot:masterfrom
alloutflo:fix/1163-record-properties

Conversation

@alloutflo

Copy link
Copy Markdown

For a Java record such as record Person(String name) {}, {{ person.name }} currently renders an empty string with an unknown-property warning, even though {{ person.name() }} works. This adds missing record-component properties to the existing bean resolver so dot and bracket access can use the component accessor without requiring an extra JavaBean getter.

The same descriptor discovery is used for property resolution and feature descriptors. Existing JavaBean properties retain precedence, including write-only properties. Newly added component properties have no setter; method and return-type allowlists and existing reflection rules remain unchanged. No public API, configuration, or dependency changes.

Validation

  • Confirmed the original rendering regression fails before the fix and passes afterward.
  • Added 12 tests covering rendering, primitive/null/nested values, snake-case names, custom/private accessors, existing getter and write-only precedence, type/feature metadata, write rejection, allowlist rejection, and eager/deferred evaluation. All 68 tests in the three affected test classes pass.
  • Full CI-equivalent Maven verify passes with Temurin 17, 21, and 25 (Maven running on Java 25): 2,250 tests per run, 0 failures, 0 errors, 23 skipped. Spotless, Checkstyle, Duplicate Finder, SpotBugs, and PMD pass.
  • Used -Duser.language=en -Duser.country=US for the full suite because an existing FormatNumberFilterTest locale failure was separately reproduced on unmodified master under de_AT.
  • Independent diff review completed; git diff --check passes.

AI assistance: This change and its tests were developed with OpenAI Codex and checked through automated tests and an independent Codex review.

Fixes #1163

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Add support for java records

1 participant