Repository navigation
Model static and final modifiers for fields and nested types - #498
igel-devin-ai wants to merge 13 commits into
Conversation
…lpers#495) - ClassFieldDto: staticModifier/finalModifier with builder support — constants are static+final together, the only legal field kind in interfaces and annotation types - NestedTypeDto: staticModifier with builder support — static nested types no longer capture the outer instance; no effect inside interfaces/annotation types/records where member types are implicitly static - Roaster rendering: setStatic/setFinal on fields, static on nested types (via StaticCapableSource) - tests: constant rendering, static and non-static nested types
…d final, capability warnings
…extblock tests - isStatic/isFinal naming aligned with MethodDto (field, setter, builder helpers) - NestedTypeDto: isFinal added end-to-end — final nested types cannot be extended - warning logged when a nested type kind cannot carry static/final instead of silently dropping the modifier - the three new rendering tests compare full generated source textblocks
Setting a boolean modifier to true is the dominant use case — the no-arg variant expresses it directly, and the seldom false case stays covered by the boolean variant. Applied consistently to ClassFieldDtoBuilder, NestedTypeDtoBuilder, MethodDtoBuilder and the processor's BuilderMethodDtoBuilder
Codecov Report✅ All modified and coverable lines are covered by tests. 📢 Thoughts on this report? Let us know! |
Strict reviewblocking Reviewed head
Verification
Other-PR integration reviewRead bodies/file lists and ran read-only pairwise merge-tree checks against #430, #480, #482, #483, #484, #492, #497, #499, and #500.
Recheck at
|
| # | Original finding (short) | Status | Remaining action |
|---|---|---|---|
| 1 | Removed isStatic(BooleanSupplier) APIs |
accepted as breaking change — announced in #495 | Add the breaking-change PR label. |
| 2 | Interface constants rejected/omitted | fixed | — |
| 3 | Modifier/copy regression coverage | partially fixed — minor | Add independent static/final field and true/false/no-op-copy tests (DtoBuilderCopyTest.java:67–77,209–222). |
| 4 | Record member classes documented as static | not fixed — minor | Correct NestedTypeDto.java:140–142 and NestedTypeDtoBuilder.java:888–890. |
| 5 | Escaped source fixtures | not fixed — nit | Use text blocks (RoasterCodeGeneratorTest.java:857,887; GenerationTargetValidatorTest.java:357). |
Build: Java 17 module install — BUILD SUCCESS; interface-constant compilation and modifier-copy probes pass.
Recheck at 8770ac39 (2026-12-06)
Verdict: minor changes
| Severity | What is missing | Where (file:line) |
|---|---|---|
| note | Suggest breaking-change label; supplier removal accepted and announced in #495. |
MethodDtoBuilder.java:456–471; BuilderMethodDtoBuilder.java:404–419 |
| minor | Partial: static-only/final-only field-output assertions still missing; new copy contracts cover true/false. | RoasterCodeGeneratorTest.java:876–903; DtoBuilderCopyTest.java:127–168 |
…t redundant modifiers, regression tests
The validator stays generator-agnostic: other future generators may support generic records. RoasterCodeGenerator now raises a generation error for nested records with generic parameters (roaster limitation, forge/roaster#275). Also drops the isFinal usage in the enum test (modifier modeling belongs to java-helpers#498).
…xt blocks - Member types of records are NOT implicitly static (verified against javac) — the isStatic javadoc wrongly claimed they were; corrected in NestedTypeDto and its builder - Copy regressions: static/final flags survive copy-constructor copies in both true and false states, on fields and nested types, incl. no-op copies - Escaped-quote literal initializers converted to stripped text blocks
|
Recheck items addressed:
|
|
Recheck finding 5 done: the escaped literal-initializer fixtures ( |
appendNestedType exceeded cognitive complexity 15 — generics creation and the static/final capable-source handling are extracted into helpers, behavior unchanged
|



Fixes #495.
ClassFieldDto:staticModifier/finalModifierwith builder support (supplier + value variants, copy-constructor tracking) — constants are static+final together, the only legal field kind in interfaces and annotation typesNestedTypeDto:staticModifierwith builder support — static nested types don't capture the outer instance; ineffective (harmless) inside interfaces/annotation types/records where member types are implicitly staticsetStatic/setFinalon fields; static on nested types viaStaticCapableSourcepublic static final String X = "example"), static and non-static nested types — 26/26 roaster tests green, full reactor 1,262 greenScope note on validator rules: the issue's record-specific validation (static fields legal in Java but unsupported by Roaster, forge/roaster#279) needs kind-awareness that lands with #492 — it belongs there rather than in this PR since main's validator has no kind concept yet.