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

Maurizio Cimadamore mcimadamore at openjdk.org
Mon Apr 7 21:23:34 UTC 2025


`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.

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

Commit messages:
 - Cleanup code in CodeModelToAST

Changes: https://git.openjdk.org/babylon/pull/386/files
  Webrev: https://webrevs.openjdk.org/?repo=babylon&pr=386&range=00
  Stats: 84 lines in 2 files changed: 36 ins; 22 del; 26 mod
  Patch: https://git.openjdk.org/babylon/pull/386.diff
  Fetch: git fetch https://git.openjdk.org/babylon.git pull/386/head:pull/386

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


More information about the babylon-dev mailing list