Goal
Integrate critter-core into morphia-core to provide a modern Mapper architecture using bytecode generation, replacing legacy reflection-based implementation. Users get a config-driven choice between mappers with automatic fallback.
Implementation Phases
Planning Document
Full implementation plan with code samples, file references, verification steps, and risk mitigation:
docs/critter-integration-plan.md
Design Decisions
| Decision |
Choice |
| Generation strategy |
Hybrid: check classpath for pre-generated models (critter-maven AOT) → runtime generation (Gizmo + VarHandle) → reflection fallback |
| Runtime accessors |
VarHandle-based — no synthetic __read/__write methods needed at runtime |
| Language |
Convert to Java — convert critter Kotlin source before moving into morphia-core |
| Mapper interface |
@MorphiaInternal only — not exposed on any public API |
| Fallback granularity |
Entity-type level — all-or-nothing per type |
copy() semantics |
Share immutable CritterEntityModel references |
| Dependencies |
Optional + fail-fast — Gizmo/ASM/ByteBuddy marked <optional>, clear error if missing when CRITTER selected |
| Classloader |
Uses configured classloader as parent; build-time classes are permanent, runtime classes regenerated per JVM start |
| Module removal |
Last step — only after full test matrix is green |
Goal
Integrate critter-core into morphia-core to provide a modern Mapper architecture using bytecode generation, replacing legacy reflection-based implementation. Users get a config-driven choice between mappers with automatic fallback.
Implementation Phases
Planning Document
Full implementation plan with code samples, file references, verification steps, and risk mitigation:
docs/critter-integration-plan.md
Design Decisions
__read/__writemethods needed at runtime@MorphiaInternalonly — not exposed on any public APIcopy()semantics<optional>, clear error if missing when CRITTER selected