Re: Setting breakpoint on the end of the method in Eclipse
Lew, thanks for a reply.
Well, that certainly is an opinion.
Certainly.
There is no instruction on '}' so there is no place to stop. You whine that
the IDE does not add a "nop" (is there even such an instruction in the JVM?).
There is NOP in Java VM:
http://java.sun.com/docs/books/jvms/second_edition/html/Instructions2.doc.html
I would whine if the IDE changed my code. I prefer breakpoints to exist
only where there is a place to stop, so /my/ opinion is that it does not suck.
I agree with the "code change" part. I disagree that the method exit
is not a place at which you would like to stop.
Put the breakpoint on the "while ( b )" line.
Right before the first instruction of a loop is the same spot as right after
the last.
Not true. Try this code in Eclipse:
public void breakpointTest() {
int a = 0;
while(a < 100) {
a++;
if(a == 1)
break;
}
}
and try to put a breakpoint on while - it will be reached once (the
one time you list as "one extra stop") and that's it. To be honest,
even NetBeans doesn't stop here. I don't know about the other IDEs
(e.g. VisualStudio for C# or so), but if I test them, I'll report it.
You get one extra stop, which can be eliminated with a conditional breakpoint
if it bothers you that much.
It's far from one extra stop:
public void breakpointTest() {
int a = 0;
while(a < 100) {
a++;
if(a == 10)
break;
}
}
If you put a breakpoint at while, it will stop 11 times. Conditional
breakpoints are a good solution to this, but you need much more time
to set them up then a non-conditional breakpoint which would do the
same thing, if it was present.
Since you want to guarantee at least one iteration for the "b" loop, couldn't
a better idiom be the do ... while() loop?
The example I gave is not an example of what I want to do, but the
example on which Eclipse fails to allow me do what I want to do. Yes,
for the above examples your code transformation is correct - that
wasn't the point, though.
To restrict the scope of the booleans you could use for ( ... ).
void test()
{
for ( boolean a = true; a; )
{
a = ! otherMethodReturningBoolean();
doOtherStuff();
for ( boolean b = true; b; )
{
b = ! yetAnotherMethodReturningBoolean();
doStillOtherStuff();
}
}
}
Now your breakpoints are on the "for" lines.
Agree with this. Again, the above were only the examples to explain
the problem and this also poses another problem with all the solutions
- I am not in the position to change all the code I debug. It's team
play. I need a debugger that can debug any code, not requiring me to
change it to allow debugging. If the only problem was to allow
debugging, adding simple "int nop1 = 0;", "int nop2 = 0;" and so on
just after the while loops end would allow me to do what I want.
Briefly put - it's possible, but it's a pain to do it that way.
I respect your opinion, but it still sucks. I still think this is like
using a hand crank to start the car in the era where keys are normal
thing. What would you say if I told you something like this: hey, on
our new XYZ car model MMNN you really cannot use the ABS system
everywhere, only where "there is a place to stop". Why? OK, I agree
that adding code (nops) is bad, but a) I am not sure NetBeans does it
and still allows this (albeit partially) and b) even if that is the
only way to do it, let's make a switch to compile the code with nops.
I am asking too much from free software and I should not complain this
much at least because of that reason. As I said, let's cut to the real
work and leave the philosophy to someone with more respect to how the
things really are. Again, sorry if I offended anyone - I'll retreat
now.
In fact, let me add one more thing. When I look it from another
perspective, it doesn't suck that much. I cannot say it sucks that
much, because someone else might just come and say "well, I
desperately need this ABC thing in Eclipse and it's not there". Well,
dude, it ain't there, so shut up and work with what is there. People
did a great job building Eclipse, it works marvelously, it has 100s of
features - what else do you want?! It sucks for me only, because I
needed this feature. I still would like it to be a part of Eclipse.
Guess I just wanted too much.