The 'unreachable code' error has its limits. The compiler checks for some cases of unreachable code, but it will not go and trace into the throwIt() method to see if there's something there that might make some code in main() unreachable. If the compiler would have to check all possible kinds of unreachable code, the compiler would have to be incredibly complicated - it would have to trace all kinds of strange code paths. What if your code looked like this:
Would you expect the compiler to check if method2 never returns normally, and to do that it have to check method1, etc. What if method1 was in a different class or somewhere else, probably in a JAR file in a third-party library? Would the compiler have to examine the compiled classes in that library to check if your println line was unreachable?
You can make up other arbitrarily complex examples:
[ April 11, 2007: Message edited by: Jesper Young ]