Integrated: 8253385: annotation processors remove varargs information from record components

Vicente Romero vromero at openjdk.java.net
Wed Nov 4 23:34:00 UTC 2020


On Fri, 16 Oct 2020 19:50:31 GMT, Vicente Romero <vromero at openjdk.org> wrote:

> 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

This pull request has now been integrated.

Changeset: 97a81cee
Author:    Vicente Romero <vromero at openjdk.org>
URL:       https://git.openjdk.java.net/jdk/commit/97a81cee
Stats:     44 lines in 2 files changed: 43 ins; 0 del; 1 mod

8253385: annotation processors remove varargs information from record components

Reviewed-by: jjg

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

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


More information about the compiler-dev mailing list