RFR: 8266027: The diamond finder does not find diamond candidates in field initializers
Vicente Romero
vromero at openjdk.java.net
Tue Apr 27 21:31:06 UTC 2021
On Tue, 27 Apr 2021 09:13:46 GMT, Jan Lahoda <jlahoda at openjdk.org> wrote:
> Consider code like:
>
> public class Test {
> private List<String> f2 = new LinkedList<String>();
> }
>
>
> Running with javac with `-XDfind=diamond` will not produce any warning about a possible diamond use. The reason is that the field:
>
> private List<String> f2 = new LinkedList<String>();
>
>
> will get wrapped by a block, and attributed as a block, but since it has the `private` modifier, an error will be produced, and the transformation will be deemed impossible.
>
> The proposed solution is to clear the modifiers when/if wrapping fields with blocks.
looks good
-------------
Marked as reviewed by vromero (Reviewer).
PR: https://git.openjdk.java.net/jdk/pull/3713
More information about the compiler-dev
mailing list