Take this example for a specific purpose, taken from JLS:
{ int k; int n = 5; if (n > 2) k = 3; System.out.println(k); }
We can say that the compiler knows that execution will certainly reach inside the if block, as a result of which the value k will be assigned, so it should compile fine, but it is not.
I think this is a decision made by the java authors, how reasonable they want to be a compiler, given the acceptable compile-time values and / or other factors.
source share