[code-reflection] RFR: Super expressions [v2]

Maurizio Cimadamore mcimadamore at openjdk.org
Fri Sep 6 08:06:08 UTC 2024


On Fri, 6 Sep 2024 08:01:23 GMT, Maurizio Cimadamore <mcimadamore at openjdk.org> wrote:

>> Paul Sandoz has updated the pull request incrementally with one additional commit since the last revision:
>> 
>>   Remove comment.
>
> src/jdk.compiler/share/classes/com/sun/tools/javac/comp/ReflectMethods.java line 1023:
> 
>> 1021:                 switch (sym.getKind()) {
>> 1022:                     case FIELD, ENUM_CONSTANT -> {
>> 1023:                         if (sym.name.equals(names._this) || sym.name.equals(names._super)) {
> 
> Not sure: don't we need super also for field access? E.g.
> 
> 
> class A {
>    Object o;
> }
> class B extends A {
>     int o; // shadows A.o
>     Object superO() { return super.o; }
> }

I wonder if a modelling where `super` is its own expression would be beneficial. E.g. like some kind of "virtual field" on `this`. E.g. one would load `this` and then access `super` onto it (and maybe there's a core op for _that_). Then the result is used for either a method receiver, or field access expression.

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

PR Review Comment: https://git.openjdk.org/babylon/pull/221#discussion_r1746679296


More information about the babylon-dev mailing list