I have noticed that following code does not compile with Neon.M5:
package tmp;
import java.util.ArrayList;
import java.util.List;
public class SomeClass {
private final List<Object> values;
public SomeClass() {
values = new ArrayList<>();
}
public SomeClass(Object arg) {
if(arg instanceof SomeClass) {
values = ((SomeClass)(arg)).values; //Compile error here.
} else {
throw new IllegalArgumentException("arg is not instance of SomeClass");
}
}
}
I get this error on the "values" variable after the cast "((SomeClass)(arg))":
Quote:The blank final field values may not have been initialized
This is a problem I do not have with the Mars.1 Version.
I can compile this class with javac:
> javac -version
javac 1.8.0_66
> javac SomeClass.java
The workaround is to assign the casted class to a variable:
package tmp;
import java.util.ArrayList;
import java.util.List;
public class SomeClass {
private final List<Object> values;
public SomeClass() {
values = new ArrayList<>();
}
public SomeClass(Object arg) {
if(arg instanceof SomeClass) {
SomeClass someClass = (SomeClass)(arg);
values = someClass.values;
} else {
throw new IllegalArgumentException("arg is not instance of SomeClass");
}
}
}
Is this an already known bug?
What is the proper way to report it?
Thank you in advance.
[Updated on: Tue, 16 February 2016 10:26]
Report message to a moderator