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

Joel Borggrén-Franck jfranck at openjdk.java.net
Tue Apr 27 11:08:35 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 to me

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

Marked as reviewed by jfranck (Reviewer).

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


More information about the compiler-dev mailing list