[code-reflection] Integrated: Cleanup `CodeModelToAST` to use `Resolve`

Maurizio Cimadamore mcimadamore at openjdk.org
Tue Apr 8 16:56:44 UTC 2025


On Mon, 7 Apr 2025 17:46:52 GMT, Maurizio Cimadamore <mcimadamore at openjdk.org> wrote:

> `CodeModelToAST` needs to convert field/method references back into javac var and method symbols. In javac backend classes this is typically done by using `Resolve::resolveInternalField/Method`. The current approach is instead to create new symbol instances from the contents of the field/method references, which is problematic because the code has to figure out properties that are not encoded in the references -- such as flags and other hidden information (such as constant values) that might be left there by javac.
> 
> This PR rectifies that. I also cleaned up the code a bit by breaking very long lines and I have fixed an issue in the translation from TypeElement back to javac type as erased type (e.g. `Map`) were converted back to generic types (e.g. `Map<K, V>`) thus leading to issues when calling the internal resolution methods.
> 
> The only place left where we create a new symbol from scratch is with instance creation expressions -- to fix this we need to associate a `MethodRef` to `NewOp` nodes.

This pull request has now been integrated.

Changeset: 9cddb871
Author:    Maurizio Cimadamore <mcimadamore at openjdk.org>
URL:       https://git.openjdk.org/babylon/commit/9cddb871638b7590033c0127f26e5e8ae41294a6
Stats:     84 lines in 2 files changed: 36 ins; 22 del; 26 mod

Cleanup `CodeModelToAST` to use `Resolve`

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

PR: https://git.openjdk.org/babylon/pull/386


More information about the babylon-dev mailing list