RFR: 8319196: ExecutableElement.getReceiverType doesn't return receiver types for methods loaded from bytecode [v5]

Vicente Romero vromero at openjdk.org
Thu Nov 9 17:32:00 UTC 2023


On Mon, 6 Nov 2023 23:14:02 GMT, Liam Miller-Cushon <cushon at openjdk.org> wrote:

>> Hello,
>> 
>> Please consider this fix for [JDK-8319196: ExecutableElement.getReceiverType doesn't return receiver types for methods loaded from bytecode](https://bugs.openjdk.org/browse/JDK-8319196).
>> 
>> As discussed in [the accompanying CSR](https://bugs.openjdk.org/browse/JDK-8319330), `ExecutableElement.getReceiverType()` and `ExecutableType.getReceiverType()` currently returns `NoType` unless the receiver parameter syntax was present in source, which also means that `getReceiverType()` doesn't work for methods loaded from class files.
>> 
>> This fix updates the implementation to return the implicit receiver type of methods that do not explicitly declare a receiver parameter in source, including for methods that were loaded from class files.
>
> Liam Miller-Cushon has updated the pull request with a new target base due to a merge or a rebase. The incremental webrev excludes the unrelated changes brought in by the merge/rebase. The pull request contains seven additional commits since the last revision:
> 
>  - Merge branch 'master' into JDK-8319196
>  - Only infer receiver types during class reading if receiver type annotations are present
>  - Add a test for annotated receiver types
>  - Merge branch 'master' into JDK-8319196
>  - Update src/jdk.compiler/share/classes/com/sun/tools/javac/code/Symbol.java
>    
>    Co-authored-by: liach <7806504+liach at users.noreply.github.com>
>  - Add a null check, update affected tests
>  - 8319196: ExecutableElement.getReceiverType doesn't return receiver types for methods loaded from bytecode

looks good to me, just minor comments

src/jdk.compiler/share/classes/com/sun/tools/javac/code/Symbol.java line 84:

> 82: import static com.sun.tools.javac.jvm.ByteCodes.lushrl;
> 83: import static com.sun.tools.javac.jvm.ByteCodes.lxor;
> 84: import static com.sun.tools.javac.jvm.ByteCodes.ret;

this import doesn't seem to be used now

test/langtools/tools/javac/processing/model/element/TestExecutableReceiverType.java line 51:

> 49:             for (ExecutableElement e : ElementFilter.methodsIn(
> 50:                   roundEnv.getElementsAnnotatedWith(ReceiverTypeKind.class))) {
> 51:               count += testExecutable(e);

nit: indentation should be 4 spaces here, same issue below

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

Marked as reviewed by vromero (Reviewer).

PR Review: https://git.openjdk.org/jdk/pull/16482#pullrequestreview-1723109394
PR Review Comment: https://git.openjdk.org/jdk/pull/16482#discussion_r1388339579
PR Review Comment: https://git.openjdk.org/jdk/pull/16482#discussion_r1388319026


More information about the compiler-dev mailing list