Bug 177686 - [compiler] Breakpoints set on break statements are never hit
Summary: [compiler] Breakpoints set on break statements are never hit
Status: RESOLVED WONTFIX
Alias: None
Product: JDT
Classification: Eclipse Project
Component: Core (show other bugs)
Version: 3.3   Edit
Hardware: PC Windows XP
: P3 normal (vote)
Target Milestone: 3.3 RC1   Edit
Assignee: Philipe Mulet CLA
QA Contact:
URL:
Whiteboard:
Keywords:
Depends on:
Blocks:
 
Reported: 2007-03-15 20:49 EDT by Paul Cowan CLA
Modified: 2007-05-07 09:06 EDT (History)
0 users

See Also:


Attachments

Note You need to log in before you can comment on or make changes to this bug.
Description Paul Cowan CLA 2007-03-15 20:49:38 EDT
Build ID: I20070222-0951

Steps To Reproduce:
1. Create a new class with the following code:
    public static void main(String[] args) {
        int i = 0;
        while (true) {
            i++;
            if (i == 1000) {
                System.out.println("Breaking"); // *A*
                break; // *B*
            }
        }
        System.out.println("Broken"); // *C*
    }

2. Set breakpoints on the lines marked *B* and *C*
3. Debug the class; only the breakpoint at line *C* will be hit
4. If a breakpoint is added at line *A*, that will be hit. It is only the break statement itself where the breakpoint fails to be triggered.

This could obviously make it difficult to debug some loops, where adding an additional 'dummy' statement (like *A* above) may not be an option (e.g. debugging a remote application).
Comment 1 Olivier Thomann CLA 2007-03-16 11:23:28 EDT
The problem for us is that the break doesn't end up generating any bytecode since it would be a goto to the next bytecode.
So we optimize it out and therefore there is no position to reach.

Philippe,

I don't see how we can get a line entry for the break statement if we optimize it out.
Comment 2 Philipe Mulet CLA 2007-05-07 08:00:01 EDT
I don't think we would de-optimize the compiler to address this scenario.
Comment 3 Philipe Mulet CLA 2007-05-07 09:06:45 EDT
No action planned. Closing as Won't fix.