RFR: 8253385: annotation processors remove varargs information from record components [v2]

Vicente Romero vromero at openjdk.java.net
Wed Nov 4 17:13:07 UTC 2020

> Please review this fix for a corner case bug. Essentially for code like:
> import java.lang.annotation.*;
> @Target({ElementType.TYPE_USE})
> @interface Simple {}
> record R(@Simple int ...val) {
>     static void test() {
>         R rec = new R(10, 20);
>     }
> }
> assuming that there is an AP present, after the first annotation processing round, the record component's symbol is set to `null` and thus the flags info is lost. So once the symbols and their types are determined again after every annotation processing round, there is no recollection that the record component was a varargs. Remember that the AST for the record component declaration is not kept but it is used to extract information from it and to derive compiler generated code like fields, canonical constructor, etc. The proposed solution is to keep the information about the vararg-ness of the record component in a dedicated field in the record component so that this information can be recovered later on as needed.
> TIA,
> Vicente

Vicente Romero has updated the pull request incrementally with one additional commit since the last revision:

  addressing review comments


  - all: https://git.openjdk.java.net/jdk/pull/709/files
  - new: https://git.openjdk.java.net/jdk/pull/709/files/379ee616..21e26551

 - full: https://webrevs.openjdk.java.net/?repo=jdk&pr=709&range=01
 - incr: https://webrevs.openjdk.java.net/?repo=jdk&pr=709&range=00-01

  Stats: 3 lines in 2 files changed: 0 ins; 0 del; 3 mod
  Patch: https://git.openjdk.java.net/jdk/pull/709.diff
  Fetch: git fetch https://git.openjdk.java.net/jdk pull/709/head:pull/709

PR: https://git.openjdk.java.net/jdk/pull/709

More information about the compiler-dev mailing list