[code-reflection] RFR: JavaRef extends TypeElement [v2]
Paul Sandoz
psandoz at openjdk.org
Thu May 1 15:40:04 UTC 2025
On Wed, 30 Apr 2025 21:15:49 GMT, Maurizio Cimadamore <mcimadamore at openjdk.org> wrote:
>> Yes!
>
> Question - if Java code calls a method on a record... is the "ref" attached to the invoke operation a record type ref? I don't think that is the case, as I don't remember any special logic in javac to emit a record type ref when generating field/method references?
No, it's an invocation operation to the method whose name is the same as the component name. When we lower a record pattern we emit the invocation using the detail in the record ref, see [here](https://github.com/openjdk/babylon/blob/5238a40d11397b9896756a674158378223405388/src/jdk.incubator.code/share/classes/jdk/incubator/code/op/ExtendedOp.java#L3141):
Value nestedTarget = currentBlock.op(CoreOp.invoke(rpOp.recordDescriptor().methodForComponent(i), target));
where
@Override
public MethodRef methodForComponent(int i) {
if (i < 0 || i >= components.size()) {
throw new IndexOutOfBoundsException();
}
ComponentRef c = components.get(i);
return MethodRef.method(recordType, c.name(), c.type());
}
-------------
PR Review Comment: https://git.openjdk.org/babylon/pull/416#discussion_r2070420230
More information about the babylon-dev
mailing list