Consider this code:
---
import java.util.*;
public class Test {
private void test() {
List<String> ll = Collections.synchronizedList(new ArrayList<String>());
}
}
---
Running javac (tip: 558fe98d1ac0) as follows:
$ javac -XDfindDiamond -source 8 Test.java
Does not produce any "type argument is unnecessary" warning, even though the type argument of the new ArrayList is unnecessary with -source 8, as the following is compilable with -source 8:
---
import java.util.*;
public class Test {
private void test() {
List<String> ll = Collections.synchronizedList(new ArrayList<>());
}
}
---
---
import java.util.*;
public class Test {
private void test() {
List<String> ll = Collections.synchronizedList(new ArrayList<String>());
}
}
---
Running javac (tip: 558fe98d1ac0) as follows:
$ javac -XDfindDiamond -source 8 Test.java
Does not produce any "type argument is unnecessary" warning, even though the type argument of the new ArrayList is unnecessary with -source 8, as the following is compilable with -source 8:
---
import java.util.*;
public class Test {
private void test() {
List<String> ll = Collections.synchronizedList(new ArrayList<>());
}
}
---
- relates to
-
JDK-8021338 Diamond finder may mark a required type argument as unnecessary
- Closed