Can't breakpoint the last statement of a code block in Eclipse

前端 未结 4 1720
甜味超标
甜味超标 2020-12-16 17:05
if (true) {
    String a = \"foo\";
    String b = \"bar\";
}

If I set a breakpoint at String a = \"foo\"; eclipse will stop, and I ca

4条回答
  •  挽巷
    挽巷 (楼主)
    2020-12-16 18:06

    I'm honestly not sure what's going on in your Eclipse installation. I'm working in Java and just tried everything I can think of. I checked a static method for breakpoint on the last line that is not a } and it works just fine. I checked the same for a non-static method.

    It breaks down this way: you can't breakpoint on a curly brace end, but it will default to whatever is under the curly brace, line-wise. So if you have a nested function:

    public int DoesStuff(int x, int y) {
        if(x > y) {
            DoThing;
        }
        else {
            DoOtherThing;
        }
    }
    

    Then the last two braces cannot be break-pointed, but DoThing and DoOtherThing can. Make sense?

提交回复
热议问题