views:

95

answers:

3

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 NcoBusinessProgramException("Error Writing To Sequence File!");
  } 
 }
A: 

For what it worth, lineBuilder isn't defined (at least in the given code portion)

Flo.
A: 

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.)

Mike Baranczak
A: 

Are you sure it is ? It might be an artefact, try to close and reopen the file, or save all and rebuild.

Samuel_xL