Commit 5a82f37
committed
fix(jvm): ADR-0039 — resolving accessors are the default (Java + Kotlin port)
extends is a super-REFERENCE, not a flatten: inherited attrs/children/isArray
live on the parent, reachable only through the resolving accessors. Reading a
field/node's effective property or member set through an own-only accessor
silently dropped everything inherited via extends — corrupting codegen (an
entity inheriting its source.rdb emitted NOTHING), effective serialization,
and loader validation. Mirrors the TS reference.
The isArray resolver
- MetaField.isArrayType() now FULLY resolves: it walks the extends super chain
for the native isArray flag (resolvedNativeIsArray) as well as the @isarray
attr, so a concrete field extending an abstract array field is array-typed.
isArray() stays the own-only raw flag; all codegen array reads route through
isArrayType().
Metadata core
- MetaObject.getSources() no-arg now RESOLVES (getSources(true)), matching
getMetaFields()/getIdentities()/getRelationships(). The declaration-layer
one-primary-source validation keeps own-only via explicit getSources(false).
- ValidationPhase: field.object @objectRef/@storage and field.map
@valueType/@objectref reads flipped own→resolving (fixed the shared fixture's
false ERR_OBJECT_FIELD_WITHOUT_OBJECT_REF for a field.object extending an
abstract AddressBag). @dbColumnType stays own-only (commented).
- CanonicalJsonSerializer: effective mode now inlines inherited array-ness
(getNativeIsArray resolves via isArrayType in effective mode; own mode keeps
the raw flag so the authored form round-trips).
Java codegen (codegen-spring)
- SpringTypeMapper / SpringPayloadGenerator / OutputFormatSpecEmitter: raw
field.isArray() → resolving isArrayType(); OutputFormatSpecEmitter
@enumDoc/@example/@Instruction flipped own→resolving (consistent with the
already-resolving @values/@required).
Kotlin codegen (codegen-kotlin)
- New resolving source lookup KotlinGenUtil.firstRdbSource/hasRdbSource
(getSources(true)); routed ALL 8 generators' own-only
entity.children.filterIsInstance<RdbSource>() reads through it — an entity
inheriting its source.rdb via extends now emits its table/controller/etc.
- KotlinTypeMapper: intAttr (@precision/@scale) and stringAttr default
(@valueType) flipped own→resolving (consistent with stringMaxLength).
- KotlinExtractSchemaEmitter / KotlinOutputFormatSpecEmitter: raw .isArray →
isArrayType(); @enumDoc/@example/@Instruction → resolving.
- KotlinEntityGenerator.validator(): raw field.children →
getChildren(MetaValidator, true).
Kept own-only (each commented): @dbColumnType (never inherited by policy);
one-primary-source validation (declaration-layer); @isAbstract/@discriminator/
@provided/@kind/template-ref reads; origin.* reads (origin never inherits).
Tests
- New KotlinAbstractFieldExtendsInheritanceTest gates the two ADR-0039 shapes:
a concrete entity inheriting its source.rdb via extends emits an Exposed
table, and concrete fields extending an abstract array field / abstract
decimal field inherit isArray / @precision+@scale. Verified it FAILS on
pre-fix code.
- Shared fixtures/conformance/extends-abstract-field-inheritance now passes in
the Java conformance runner (loader + effective serializer). Fixture unchanged.
All green: Java metadata+codegen-spring 158, Java conformance 394, Kotlin
codegen 266, Kotlin integration (Testcontainers) 92, Java integration
(Testcontainers) 86. No existing goldens/snapshots changed.
Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01GF9xLEQZaPus5Y6opk398n1 parent d62aab5 commit 5a82f37
20 files changed
Lines changed: 232 additions & 52 deletions
File tree
- server/java
- codegen-kotlin/src
- main/kotlin/com/metaobjects/generator/kotlin
- apidocs
- test/kotlin/com/metaobjects/generator/kotlin
- codegen-spring/src/main/java/com/metaobjects/generator/spring
- metadata/src/main/java/com/metaobjects
- field
- io/json
- loader
- object
Lines changed: 4 additions & 1 deletion
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
371 | 371 | | |
372 | 372 | | |
373 | 373 | | |
374 | | - | |
| 374 | + | |
| 375 | + | |
| 376 | + | |
| 377 | + | |
375 | 378 | | |
376 | 379 | | |
377 | 380 | | |
| |||
Lines changed: 7 additions & 3 deletions
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
81 | 81 | | |
82 | 82 | | |
83 | 83 | | |
84 | | - | |
| 84 | + | |
| 85 | + | |
| 86 | + | |
85 | 87 | | |
86 | 88 | | |
87 | 89 | | |
| |||
927 | 929 | | |
928 | 930 | | |
929 | 931 | | |
930 | | - | |
| 932 | + | |
| 933 | + | |
931 | 934 | | |
932 | 935 | | |
933 | 936 | | |
| |||
1027 | 1030 | | |
1028 | 1031 | | |
1029 | 1032 | | |
1030 | | - | |
| 1033 | + | |
| 1034 | + | |
1031 | 1035 | | |
1032 | 1036 | | |
1033 | 1037 | | |
| |||
Lines changed: 2 additions & 1 deletion
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
143 | 143 | | |
144 | 144 | | |
145 | 145 | | |
146 | | - | |
| 146 | + | |
| 147 | + | |
147 | 148 | | |
148 | 149 | | |
149 | 150 | | |
| |||
Lines changed: 2 additions & 1 deletion
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
55 | 55 | | |
56 | 56 | | |
57 | 57 | | |
58 | | - | |
| 58 | + | |
| 59 | + | |
59 | 60 | | |
60 | 61 | | |
61 | 62 | | |
| |||
Lines changed: 18 additions & 0 deletions
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
4 | 4 | | |
5 | 5 | | |
6 | 6 | | |
| 7 | + | |
7 | 8 | | |
8 | 9 | | |
9 | 10 | | |
| |||
23 | 24 | | |
24 | 25 | | |
25 | 26 | | |
| 27 | + | |
| 28 | + | |
| 29 | + | |
| 30 | + | |
| 31 | + | |
| 32 | + | |
| 33 | + | |
| 34 | + | |
| 35 | + | |
| 36 | + | |
| 37 | + | |
| 38 | + | |
| 39 | + | |
| 40 | + | |
| 41 | + | |
| 42 | + | |
| 43 | + | |
26 | 44 | | |
27 | 45 | | |
28 | 46 | | |
| |||
Lines changed: 9 additions & 5 deletions
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
102 | 102 | | |
103 | 103 | | |
104 | 104 | | |
105 | | - | |
| 105 | + | |
| 106 | + | |
106 | 107 | | |
107 | 108 | | |
108 | 109 | | |
| |||
138 | 139 | | |
139 | 140 | | |
140 | 141 | | |
| 142 | + | |
141 | 143 | | |
142 | | - | |
143 | | - | |
| 144 | + | |
| 145 | + | |
144 | 146 | | |
145 | 147 | | |
146 | 148 | | |
| |||
160 | 162 | | |
161 | 163 | | |
162 | 164 | | |
163 | | - | |
164 | | - | |
| 165 | + | |
| 166 | + | |
| 167 | + | |
| 168 | + | |
165 | 169 | | |
166 | 170 | | |
167 | 171 | | |
| |||
Lines changed: 2 additions & 2 deletions
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
8 | 8 | | |
9 | 9 | | |
10 | 10 | | |
11 | | - | |
12 | 11 | | |
13 | 12 | | |
14 | 13 | | |
| |||
68 | 67 | | |
69 | 68 | | |
70 | 69 | | |
71 | | - | |
| 70 | + | |
| 71 | + | |
72 | 72 | | |
73 | 73 | | |
74 | 74 | | |
| |||
Lines changed: 2 additions & 1 deletion
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
91 | 91 | | |
92 | 92 | | |
93 | 93 | | |
94 | | - | |
| 94 | + | |
| 95 | + | |
95 | 96 | | |
96 | 97 | | |
97 | 98 | | |
| |||
Lines changed: 2 additions & 1 deletion
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
76 | 76 | | |
77 | 77 | | |
78 | 78 | | |
79 | | - | |
| 79 | + | |
| 80 | + | |
80 | 81 | | |
81 | 82 | | |
82 | 83 | | |
| |||
Lines changed: 13 additions & 5 deletions
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
321 | 321 | | |
322 | 322 | | |
323 | 323 | | |
324 | | - | |
| 324 | + | |
| 325 | + | |
325 | 326 | | |
326 | 327 | | |
327 | 328 | | |
| |||
583 | 584 | | |
584 | 585 | | |
585 | 586 | | |
| 587 | + | |
| 588 | + | |
586 | 589 | | |
587 | | - | |
| 590 | + | |
588 | 591 | | |
589 | 592 | | |
590 | 593 | | |
| |||
610 | 613 | | |
611 | 614 | | |
612 | 615 | | |
613 | | - | |
| 616 | + | |
| 617 | + | |
| 618 | + | |
| 619 | + | |
| 620 | + | |
| 621 | + | |
614 | 622 | | |
615 | | - | |
616 | | - | |
| 623 | + | |
| 624 | + | |
617 | 625 | | |
618 | 626 | | |
619 | 627 | | |
| |||
0 commit comments