RFR: 8266027: The diamond finder does not find diamond candidates in field initializers
Jan Lahoda
jlahoda at openjdk.java.net
Tue Apr 27 09:21:54 UTC 2021
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.
-------------
Commit messages:
- 8266027: The diamond finder does not find diamond candidates in field initializers
Changes: https://git.openjdk.java.net/jdk/pull/3713/files
Webrev: https://webrevs.openjdk.java.net/?repo=jdk&pr=3713&range=00
Issue: https://bugs.openjdk.java.net/browse/JDK-8266027
Stats: 63 lines in 3 files changed: 61 ins; 0 del; 2 mod
Patch: https://git.openjdk.java.net/jdk/pull/3713.diff
Fetch: git fetch https://git.openjdk.java.net/jdk pull/3713/head:pull/3713
PR: https://git.openjdk.java.net/jdk/pull/3713
More information about the compiler-dev
mailing list