I\'m trying to understand local variable type inference in Java 10.
The code below works perfectly during compilation and runtime:
List list1 =
This is a bug in Java 10 compiler: https://bugs.openjdk.java.net/browse/JDK-8199910
It is only reproduced when javac is called with a -g flag.
Possible workarounds:
-g flag
var with intersection types (use explicit types):
List<Object> list = Arrays.asList(1L, 2.0F, "3");var list = Arrays.<Object> asList(1L, 2.0F, "3");The bug was fixed in JDK 10.0.2.
This is a bug of openjdk, see this:
Javac should skip non-denotable types in the LocalVariableTypeTable attribute