[code-reflection] RFR: Replace opField with opMethod for identified methods

Maurizio Cimadamore mcimadamore at openjdk.org
Thu Dec 19 13:42:57 UTC 2024


On Thu, 19 Dec 2024 02:34:19 GMT, Mourad Abbay <mabbay at openjdk.org> wrote:

> In this PR, instead of creating a field that will holds the textual representation of an identified method, we create a method (let's call it opMethod) that will returns the op of that method.

After this, we need another PR to fix lambda metafactory for `Quotable`. In that case we also pass a reference to a _field_ containing the op text to the `LambdaMetafactory` class. If we switch from field to methods, we should do so uniformly.

src/jdk.incubator.code/share/classes/jdk/incubator/code/internal/ReflectMethods.java line 415:

> 413: 
> 414:         var opVarInit = make.App(make.Ident(crSyms.opParserFromString), com.sun.tools.javac.util.List.of(make.Literal(op.toText())));
> 415:         var opVar = make.VarDef(new VarSymbol(0, names.fromString("op"), crSyms.opType, ms), opVarInit);

I believe you can skip the intermediate var? E.g. just cast the result of calling the op parser method?

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

PR Review: https://git.openjdk.org/babylon/pull/299#pullrequestreview-2514732789
PR Review Comment: https://git.openjdk.org/babylon/pull/299#discussion_r1892122033


More information about the babylon-dev mailing list