I work on a application 100% automatically transcoded from Cobol to Java. In many places, the COBOL have taken shortcuts to eliminate some codes: they code a which generates a return statement while there are other statements after the return.
The problem is the following: those "return" in Java means "unreachable statement" errors for all what's coming after the return in the same method.
I am fine with those errors, but my question: the compiler (OpenJDK) stops at the 1st one (while there many of those + others...). So, it's painful because I have to remove those errors one after the other and rerun the compile each time. Pretty painful !
Is there a way to tell to the compiler "don't stop at 1st error but discover them all" ?
PS: I run it via the ant . Does it make any difference than running the bare compiler from com
Thanks a lot in advanc开发者_如何学编程e !
didier
You could use a static code checker such as findBugs. It will report any problems like this (and a lot more) with your code.
http://findbugs.sourceforge.net/
PS: I run it via the ant . Does it make any difference than running the bare compiler from com
Shouldn't be a difference, ant is just doing the same.
You can use the Eclipse compiler from within Ant - http://www.ant4eclipse.org/node/55 - which in turn can be configured.
The samples on the page shows how to use the Eclipse settings (ant4eclipse is a project to allow compilation of existing eclipse projects with ant).
I have done some work with ant4eclipse but found that it did not scale well for us.
Also note you can add annotations to the generated source to turn off compiler warnings. See Java: How to @SuppressWarnings unreachable code?
精彩评论