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

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


On Fri, 6 Sep 2024 00:06:39 GMT, Paul Sandoz <psandoz at openjdk.org> wrote:

>> Support super expressions.
>> 
>> The work in the bytecode generator is not complete, and a disabled test has been added. Currently when it encounters an invoke super operation it will throw. We cannot generate invokespecial instructions as this will create invalid bytecode (the calling class is not related to the referenced class). Instead, in a subsequent PR, we need to dynamically generate method handles, pass them as class data to the defined hidden class, so they can be loaded as constants and invoked (and therefore emulating the invokespecial instruction). That subsequent PR should also address the lifting of invokespecial instructions.
>> 
>> This work has shown deficiencies in the modeling of invocation expressions and the resolution of `MethodRef`s. The latter has been partially addressed by providing additional information for resolution, namely the kind of invocation.
>> 
>> Invocation operations do not fully model invocation to vararg methods and this means we cannot reliably determine in all cases if the invocation has a receiver operand or not (a class or instance invocation). This should be fixed in a subsequent PR. The fix might require the following:
>> - explicit modeling of class and instance and invocation; and
>> - modeling var args as a prefix (sublist) of the operand list
>
> Paul Sandoz has updated the pull request incrementally with one additional commit since the last revision:
> 
>   Remove comment.

javac and model changes look solid. I've left some comments/questions for your consideration.

src/jdk.compiler/share/classes/com/sun/tools/javac/comp/ReflectMethods.java line 1095:

> 1093:                     if (!sym.isStatic()) {
> 1094:                         args.add(receiver);
> 1095:                         isSuper = switch (access.selected) {

Note for later - `expr.super(...)` for inner class super constructor calls. Perhaps add a `@@@` comment now?

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

Marked as reviewed by mcimadamore (Reviewer).

PR Review: https://git.openjdk.org/babylon/pull/221#pullrequestreview-2285340981
PR Review Comment: https://git.openjdk.org/babylon/pull/221#discussion_r1746683997


More information about the babylon-dev mailing list