Unreachable statement compile error in Java

The compiler is also able to make that conclusion, and assumes you are making a mistake. And yes, the Java compiler does a pretty good amount of “Data-Flow Analysis”. The most common related message is the one about variables not initialized. The second most frequent is, I believe, precisely this one, about code not reachable.