This Bugzilla instance is a read-only archive of historic NetBeans bug reports. To report a bug in NetBeans please follow the project's instructions for reporting issues.

Bug 211286 - Java Debugger "line of execution" improperly displays when stepping through a simple loop.
Summary: Java Debugger "line of execution" improperly displays when stepping through a...
Status: RESOLVED WONTFIX
Alias: None
Product: debugger
Classification: Unclassified
Component: Java (show other bugs)
Version: 7.1.1
Hardware: PC Windows 7
: P3 normal (vote)
Assignee: Martin Entlicher
URL:
Keywords:
Depends on:
Blocks:
 
Reported: 2012-04-16 18:44 UTC by pekkle
Modified: 2012-05-09 14:37 UTC (History)
0 users

See Also:
Issue Type: DEFECT
Exception Reporter:


Attachments

Note You need to log in before you can comment on or make changes to this bug.
Description pekkle 2012-04-16 18:44:27 UTC
I accidentally ran across this issue, and I can't figure out what is going on.  Take this very simple code example:

public static void main( String[] args )
    {
        System.out.println( "Hello World!" );
        List<Integer> intList = new LinkedList<Integer>();
        intList.add(new Integer("0"));
        intList.add(new Integer("1"));
        intList.add(new Integer("2"));
        intList.add(new Integer("3"));
        intList.add(new Integer("4"));
        intList.add(new Integer("5"));
        Integer num = new Integer("5");
        for (Integer integer : intList) {
            if(num <= integer){
                System.out.println("hey I'm true!");
                
            }
        }
        
        
    }

If you put a breakpoint anywhere above the for each loop and you step over the lines of code you can see this odd behavior.  
When you get to the conditional in the for each loop the first 5 passes evaluate to false, but the "Green" line of execution makes it appear that the println is being executed.  It doesn't actually execute the statement, but the debugger appears that it does.

Can someone shed some light on this?
Comment 1 Martin Entlicher 2012-05-09 14:37:48 UTC
This is a compiler error.
It's reproducible for me on JDK 1.6.0, but not on JDK 1.7.0. Therefore this was likely fixed.

This is similar to http://bugs.sun.com/bugdatabase/view_bug.do?bug_id=6765597