Usually problems that you describe are solved with custom data structures to reflect path + some annotation processing for generating metamodels with methods that yield this paths. This also involves a pretty high level of generics juggling, with various numbers of generics depending on strictness of constraints you want to enforce (my query framework over hibernate, for example, has Path<ROOT, PARENT, TARGET> as base, with number of params reaching 5 for some of the most specialized paths. This is complex and not pretty, but is a most common solution for your problem
On Mon, Dec 1, 2025, 21:59 Bruno Eberhard <[email protected]> wrote: > Am 01.12.2025 um 20:37 schrieb Ethan McCue: > > One more question: How does the code today work around things like the > > small integer cache? > It allocates for each field a "new Integer(0)". As long as Integer have > an identity two of these values are distinguishable and can serve as > different keys in a IdentityHashMap . >
