Community
Participate
Working Groups
Build ID: 20090619-0625 Steps To Reproduce: Eclipse shows in a Java source file an indicator "dead code" for Java source code that is completely valid and has no dead code: /** * Get first node with a specific name. * * @param document Documentto search. * @param name Name of (first) node to return. * @return First node found or null if no node found. */ static public Node getFirstNode(final Document document, final String name) { Node result = null; if (document != null && name != null) { final NodeList nodeList = document.getElementsByTagName(name); final int count = nodeList.getLength(); for (int i = 0; i < count; i++) { result = nodeList.item(i); break; //only first node }//next node }//else: input unavailable return result; }//getFirstNode() The "i++" in the line for (int i = 0; i < count; i++) { is marked as "dead code" which is of course not true. Strangly, other similar code with such loops are not marked. More information: It always shows this marker - no matter if I restart Eclipse, compile, clean, etc.
It looks to me that this warning is appropriate due to the break; line in the loop. This line makes the i incrementation is never done, hence the compiler warning...
Verified for 3.6M1