Bug 283123 - Errors/Warnings indicator shows wrong "dead code"!
Summary: Errors/Warnings indicator shows wrong "dead code"!
Status: VERIFIED INVALID
Alias: None
Product: JDT
Classification: Eclipse Project
Component: Core (show other bugs)
Version: 3.5   Edit
Hardware: PC Windows XP
: P3 normal (vote)
Target Milestone: 3.6 M1   Edit
Assignee: JDT-Core-Inbox CLA
QA Contact:
URL:
Whiteboard:
Keywords:
Depends on:
Blocks:
 
Reported: 2009-07-10 05:37 EDT by MH CLA
Modified: 2009-08-04 06:01 EDT (History)
2 users (show)

See Also:


Attachments

Note You need to log in before you can comment on or make changes to this bug.
Description MH CLA 2009-07-10 05:37:28 EDT
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.
Comment 1 Frederic Fusier CLA 2009-07-10 09:26:03 EDT
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...
Comment 2 Srikanth Sankaran CLA 2009-08-04 06:01:16 EDT
Verified for 3.6M1