Commit 285d422
Add VarHandle-based accessor generator for runtime mapper mode (#4194)
Introduces VarHandleAccessorGenerator, which generates PropertyAccessor
implementations using VarHandle (fields) and MethodHandle (method-based
properties) instead of delegating to __readXxx/__writeXxx synthetic methods.
This enables runtime-mode mapping without modifying entity bytecode on the
classpath, as required by CritterMapper (Phase 4).
- VarHandleAccessorGenerator: Gizmo-based generator using MethodHandles.privateLookupIn()
to create VarHandle/MethodHandle fields in the constructor; entity class loaded
via TCCL to avoid CritterClassLoader classloader mismatch
- PropertyFinder: runtimeMode flag skips entity bytecode registration and routes
to VarHandleAccessorGenerator instead of PropertyAccessorGenerator
- CritterGizmoGenerator: runtimeMode param threaded through to PropertyFinder;
varHandleAccessor() factory methods added
- TestVarHandleAccessor: covers String, int primitive, Long boxed fields;
verifies entity class is not modified in runtime mode
Co-authored-by: Claude Sonnet 4.6 <noreply@anthropic.com>1 parent fa7c7b2 commit 285d422
File tree
4 files changed
+535
-6
lines changed- critter/core/src
- main/kotlin/dev/morphia/critter/parser
- gizmo
- test/kotlin/dev/morphia/critter/parser
4 files changed
+535
-6
lines changedLines changed: 16 additions & 5 deletions
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
5 | 5 | | |
6 | 6 | | |
7 | 7 | | |
| 8 | + | |
8 | 9 | | |
9 | 10 | | |
10 | 11 | | |
| |||
14 | 15 | | |
15 | 16 | | |
16 | 17 | | |
17 | | - | |
| 18 | + | |
| 19 | + | |
| 20 | + | |
| 21 | + | |
| 22 | + | |
18 | 23 | | |
19 | 24 | | |
20 | 25 | | |
| |||
23 | 28 | | |
24 | 29 | | |
25 | 30 | | |
26 | | - | |
| 31 | + | |
| 32 | + | |
| 33 | + | |
27 | 34 | | |
28 | | - | |
| 35 | + | |
| 36 | + | |
29 | 37 | | |
30 | 38 | | |
31 | 39 | | |
32 | | - | |
| 40 | + | |
| 41 | + | |
| 42 | + | |
33 | 43 | | |
34 | | - | |
| 44 | + | |
| 45 | + | |
35 | 46 | | |
36 | 47 | | |
37 | 48 | | |
| |||
Lines changed: 14 additions & 1 deletion
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
14 | 14 | | |
15 | 15 | | |
16 | 16 | | |
| 17 | + | |
17 | 18 | | |
18 | 19 | | |
19 | 20 | | |
20 | 21 | | |
21 | 22 | | |
22 | 23 | | |
23 | 24 | | |
24 | | - | |
| 25 | + | |
25 | 26 | | |
26 | 27 | | |
27 | 28 | | |
| |||
43 | 44 | | |
44 | 45 | | |
45 | 46 | | |
| 47 | + | |
| 48 | + | |
| 49 | + | |
| 50 | + | |
| 51 | + | |
| 52 | + | |
| 53 | + | |
| 54 | + | |
| 55 | + | |
| 56 | + | |
| 57 | + | |
| 58 | + | |
46 | 59 | | |
47 | 60 | | |
48 | 61 | | |
| |||
0 commit comments