Eclipse's Dead Code warning when it is reachable?
Why Eclipse gives me a dead code warning in the fourth line of the following method? How can it not be reachable?
private void writeToSequenceFile() {
try {
CustomFileWriter nBatchWriter = new CustomFileWriter(sequeneceFileName, CONFIG_RESOURCE_NAME, "outputFile");
// The line below is a dead code?
lineBuilder.setString("Line", fileSequenceDate.concat(" ").concat(fileSequenceNo));
lineBuilder.setString("LineFeed", "\r");
nBatchWriter.writeRecord(lineBuilder.toRecord());
nBatchWriter.close();
} catch (Exception ex){
throw new NcoBusines开发者_StackOverflow中文版sProgramException("Error Writing To Sequence File!");
}
}
Does it compile?
The only possible way that I can imagine for that line to be unreachable would be if the CustomFileWriter constructor called writeToSequenceFile(), causing infinite recursion, so the next line would never be reached. (Or if the constructor always threw an exception, but that would be a pretty silly way to write it.)
Are you sure it is ? It might be an artefact, try to close and reopen the file, or save all and rebuild.
精彩评论