[code-reflection] RFR: Beef up reference resolution code and test

Maurizio Cimadamore mcimadamore at openjdk.org
Thu Nov 13 18:36:20 UTC 2025


On Thu, 13 Nov 2025 17:13:31 GMT, Maurizio Cimadamore <mcimadamore at openjdk.org> wrote:

> This PR improves the code for method/field/constructor resolution. To resolve fields and methods we have to perform two MH lookups, and find if any of them succeds. Since to code to do this is a bit convoluted, I have reimplemented the resolution support to use a more functional style (inspired by `Either` type).
> 
> I have also added several tests to make sure we test several lookup combinations, for instance/static method/fields, and also for super method resolution.
> 
> We will probably need more tests to cover the entire spectrum, but this should be at least a start.
> 
> I found 2 (!!) JDK issues when writing these tests, so some of the new tests contain workarounds.

Btw, now that I worked on this some more... perhaps I see the appeal for dropping support for array constructors, and encode the "shape" of the array factory as a _type_ in the new array op. The reason is that, while field/constructor/methods can indeed be _resolved_ to their corresponding declarations, an array constructor can't really... sure, we can create a MH that creates a new instance of the array, but there's no underlying Constructor we can really resolve back to.

-------------

PR Comment: https://git.openjdk.org/babylon/pull/682#issuecomment-3529156144


More information about the babylon-dev mailing list