[code-reflection] RFR: Further cleanup of `CodeModelToAST` and regularize support for varargs instance creation expressions [v2]

Maurizio Cimadamore mcimadamore at openjdk.org
Fri Apr 11 17:36:31 UTC 2025


> This PR makes the code in `CodeModelToAST` that deal with instance creation expression (`NewOp`) a bit closer to the code that deals with method calls (`InvokeOp`). I've added a method, called `constructorTypeToSymbol` which takes the constructor type of a `NewOp` and looks up the constructor symbol with that type.
> 
> Then I moved the logic that sets `varargElements` on the created `JCMethodInvocation` nodes into a separate, reusable routine. This is now called also for varargs instance creation expression.
> 
> Of course, to do that I had to add support for a new varargs attribute in the `NewOp` class -- which closely follows the one used by `InvokeOp`. This means that in `ReflectMethod` we can now reify in the model as to whether a constructor call was varargs or not.
> 
> I've also added some arg count validation in `NewOp`, very similar to the one that appears in `InvokeOp`.

Maurizio Cimadamore has updated the pull request incrementally with one additional commit since the last revision:

  Address review comments

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

Changes:
  - all: https://git.openjdk.org/babylon/pull/393/files
  - new: https://git.openjdk.org/babylon/pull/393/files/1d1056c9..9fe9b812

Webrevs:
 - full: https://webrevs.openjdk.org/?repo=babylon&pr=393&range=01
 - incr: https://webrevs.openjdk.org/?repo=babylon&pr=393&range=00-01

  Stats: 3 lines in 1 file changed: 0 ins; 3 del; 0 mod
  Patch: https://git.openjdk.org/babylon/pull/393.diff
  Fetch: git fetch https://git.openjdk.org/babylon.git pull/393/head:pull/393

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


More information about the babylon-dev mailing list