Integrated: 8266027: The diamond finder does not find diamond candidates in field initializers

Jan Lahoda jlahoda at openjdk.java.net
Thu Apr 29 14:58:53 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.

This pull request has now been integrated.

Changeset: f0f6b0d9
Author:    Jan Lahoda <jlahoda at openjdk.org>
URL:       https://git.openjdk.java.net/jdk/commit/f0f6b0d919266b90bd91971f3cdb915f4e8c5300
Stats:     63 lines in 3 files changed: 61 ins; 0 del; 2 mod

8266027: The diamond finder does not find diamond candidates in field initializers

Reviewed-by: jfranck, vromero

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

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


More information about the compiler-dev mailing list