I am fairly certain that the code below is valid Java 1.8 code:
import java.util.function.Consumer;
public class UnsolvableClass {
private Consumer<Object> func = (Object theErrorVariable) -> {};
public UnsolvableClass() {
return;
}
}
Now, you might be thinking: "Why do you have a return in the constructor?" Well, that's because it's minimal example code that I have come up with that produces this error.
Take note that it is perfectly legal to have a return statement in a constructor.
javac spits this error out when compiling it.
UnsolvableClass.java:10: error: variable theErrorVariable might not have been initialized
return;
^
1 error
I like how it thinks the error is happening on the "return" line when the error has to do with... the "theErrorVariable" variable not being initialized.
If I remove the "return" line, everything compiles fine. Also, if I remove the lambda statement, it also compiles fine.
Note: I have tried compiling this using Eclipse's java compiler and it compiles successfully.
Sounds like a very obscure bug in javac's lambda support. Am I missing something?
If I'm not and this is an actual bug, where would I go to report this to Oracle?