Home | Contact Us | FAQ | Search & Site Map | Link to Us
Sign In | Join | Other 45 Sites in Network
HomeAnnouncementsWhite Papers
Discussion GroupsFirst AidDatabasesJavaBeansGUIJava 3DVirtual MachineCORBASecurityToolsGeneral
Java DirectoryOpen Source ProjectsSample Book ChaptersUser GroupsWeb Resources
Related Topics
Databases.NETMore Topics ...

Java Forum / First Aid / July 2008

Tip: Looking for answers? Try searching our database.

Cannot set Breakpoint on Netbeans 6.1

Thread view: 
Global667 - 04 Jul 2008 16:37 GMT
Hello,

its a bug or I am blind $) ?

for (int i = 1; i < 20; i++) {
for (int j = 1; j < 20; j++) {
    c = new Coor(i, j);
    if (!Game.hasLiberties(c)) {
        f = 0;                /***** BREAKPOINT WHICH DOESNT WORK */
    }
    if (!Game.hasLiberties(c)) {
        g.Board[coorToInt(c)] = ".";     /**** SAME LIKE ABOVE BUT WORKS */
    } else {
        g.Board[coorToInt(c)] = Game.Board[coorToInt(c)];
    }
}
}

Hope there is an answer.

Best regards,
Wolf S. Kappesser
Lew - 04 Jul 2008 18:10 GMT
> its [sic] a bug or I am blind $) ?
>
[quoted text clipped - 13 lines]
>
> Hope there is an answer.

There's always an answer.   In your case, I think the answer is that it's not
a bug and neither are you blind.

The only time I've seen behavior like this is when the source has not yet been
recompiled.  Obviously we have waaaaaaaay too little information to give you a
definitive explanation for the phenomenon in your scenario.

Had you recently edited the source before attempting to debug?  Are you sure
you rebuilt the project?  Are you sure that the execution is using the newer
version of the compiled code?

Signature

Lew
This post contained three requests for information.  You will know if you
answered them if you provide three answers.

Mark Space - 04 Jul 2008 20:28 GMT
> Hello,
>
[quoted text clipped - 5 lines]
>     if (!Game.hasLiberties(c)) {
>         f = 0;                /***** BREAKPOINT WHICH DOESNT WORK */

I assume you mean that you ran the code in debug mode, and the IDE told
you that it was unable to submit a breakpoint.

That's a message coming from the JVM to NetBeans.  NetBeans has no
control over which breakpoints the JVM will accept.  NB just submits
them and waits for the response.

I don't have an exact explanation, but in my experience, this line was
optimized away by the compiler (is there a chance f is always 0?).
You'll just have to set the breakpoint nearby, or figure out why the
code is being compiled the way it is and change it so the line is
executed. (Set f to 1 before the loop starts, for example.)
Global667 - 04 Jul 2008 22:45 GMT
@Lew
> Obviously we have waaaaaaaay too little information to give you a  
> definitive explanation for the phenomenon in your scenario.
Answer and more explanation see below.

@Mark
> this line was optimized away by the compiler (is there a chance f is  
> always 0?). You'll just have to set the breakpoint nearby, or figure out  
> why the code is being compiled the way it is and change it so the line  
> is executed. (Set f to 1 before the loop starts, for example.)

Oh yes I think that will be the answer. The sense of the line

f = 0;

only means to provide a breakpoint ( in theorie...;) ) to catch the "if"  
line before (or after):

if (!Game.hasLiberties(c)) {        // same condition like ...
    f = 0;                // should catch the condition; bp is set here
}
if (!Game.hasLiberties(c)) {        // ...this; step-in mode on debugger go into  
the function
    g.Board[coorToInt(c)] = ".";     //
} else {

Thanks to all for the quick answer/reaktion.

Greets
gloabl667
Lew - 04 Jul 2008 23:39 GMT
>  The sense of the line
>
> f = 0;
>
> only means to provide a breakpoint ( in theorie...;) ) to catch the "if"
> line before (or after):

I would not do that.  Setting different code for debug purposes is an
antipattern.  You should debug the code as it will be deployed, only.

> if (!Game.hasLiberties(c)) {        // same condition like ...
>     f = 0;                // should catch the condition; bp is set here
> }

Mark Space might have something there, then.  You don't show complete code so
we cannot tell from your original question how 'f' is declared (int?  double?
 Long?) or whether it is a useless call that will be optimized away.  That
last seems to be the case, based on the skimpy information you have deigned to
offer thus far.

> if (!Game.hasLiberties(c)) {        // ...this; step-in mode on debugger

This 'if' is where I would recommend you set the breakpoint.

>     g.Board[coorToInt(c)] = ".";     //
> } else {

Signature

Lew

Global667 - 05 Jul 2008 12:03 GMT
The hole function:

The game of go:
http://www.nihonkiin.or.jp/howto/htm-e/howto1.htm

Board (one times static, one times local) is an array which represents a  
goboard (states could be: ".", "w", "b").
hasLiberties returns the number of liberties one element of Board has.

CODE:
==========================================================================================================
@SuppressWarnings("static-access")
        static public void updateBoard() {
            Coor c;
            int f = 0;
            Game g = new Game();
            for (int k = 0; k < 361; k++) {
                visited[k] = false;
            }

       // 19x19 check for every boardpoint. Should the point cleared  
(hasLiberties < 1) ?
            for (int i = 1; i < 20; i++) {
                for (int j = 1; j < 20; j++) {
                    c = new Coor(i, j);
                    if (Game.hasLiberties(c, Game.getColor(c.x,c.y)) < 1)  
{        // same condition like ...
                       f = 0;                              // should catch the condition; bp is  
set here
           }
                    if (Game.hasLiberties(c, Game.getColor(c.x, c.y)) < 1)  
{        // ...this; step-in mode on debugger go into the
                                          //function
                        g.Board[coorToInt(c)] = ".";
                    } else {
                        g.Board[coorToInt(c)] = Game.Board[coorToInt(c)];
                    }
                }
            }
            Game.Board = g.Board;
        }
===========================================================================================================
:EDOC

Best regards,
global667

Am 05.07.2008, 00:39 Uhr, schrieb Lew <lew@lewscanon.com>:

>>  The sense of the line
>>  f = 0;
[quoted text clipped - 20 lines]
>>     g.Board[coorToInt(c)] = ".";     //
>> } else {
Lew - 05 Jul 2008 15:18 GMT
Please, please, please, please do not top-post.

Do not use TAB indentation in Usenet posts.  Use (roughly) two spaces per
indent level.

Do not use TAB indentation in Usenet posts.

> The hole function:
>
> The game of go:
> http://www.nihonkiin.or.jp/howto/htm-e/howto1.htm
>
> Board (one times static, one times local) is an array which represents a

What does "one times static, one times local" mean?

> goboard (states could be: ".", "w", "b").
> hasLiberties returns the number of liberties one element of Board has.

Is this homework?

> CODE:
> ==========================================================================================================
>
> @SuppressWarnings("static-access")

Why are you suppressing instead of fixing this warning?

Nearly always, use of @SuppressWarnings is a dodge to avoid fixing something
that needs to be fixed.  Suppressing the warning means leaving a bug in the
code on purpose.

Do you really want to leave a bug in your code on purpose?

>         static public void updateBoard() {

Why are you doing this as a static method?  It would be much better as an
instance method.

>             Coor c;
>             int f = 0;

Throw 'f' away.  Don't use it.

>             Game g = new Game();

You start a new Game every time you update the Board?

'g' is a lousy variable name here.  It communicates absolutely nothing about
the nature of the variable.

>             for (int k = 0; k < 361; k++) {
>                 visited[k] = false;

What is 'visited'?

You need very badly to read <http://pscode.org/sscce.html> and study its lesson.

>             }
>
[quoted text clipped - 7 lines]
>                        f = 0;                               // should
> catch the condition; bp is set here

Throw away this entire 'if' clause.

>             }
>                     if (Game.hasLiberties(c, Game.getColor(c.x, c.y)) <
> 1) {         // ...this; step-in mode on debugger go into the

Since you just created an instance of Game, why are you now ignoring that
instance and using static methods?

>                                            //function
>                         g.Board[coorToInt(c)] = ".";

Now, hey, presto! you are using 'g', the instance.  How in blazes will 'Board'
(which should be spelled with a lower-case first letter!) ever contain a
meaningful value?

The method 'coorToInt()'
<http://pscode.org/sscce.html>
is not shown, although if its name is accurate we know what it intends to do.

>                     } else {
>                         g.Board[coorToInt(c)] = Game.Board[coorToInt(c)];

There's a useful assignment!  Not.

Another thing, that shouldn't be 'coorToInt(c)', that should be set up so you
call 'c.toInt()'.

>                     }
>                 }
>             }
>             Game.Board = g.Board;

This is wrong, wrong, wrong.  You should never name a static variable and an
instance variable the same.

And spell your variables correctly.
<http://java.sun.com/docs/codeconv/index.html>

>         }
> ===========================================================================================================
>
> :EDOC

Signature

Lew
This post contains nine questions.  You will know that you answered all of
them by whether you gave nine answers.

Lew - 05 Jul 2008 15:28 GMT
Global667 wrote:
>>             Coor c;
...
>>             for (int i = 1; i < 20; i++) {
>>                 for (int j = 1; j < 20; j++) {
>>                     c = new Coor(i, j);

I recommend this idiom instead:

 for (int i = 1; i < 20; i++)
 {
  for (int j = 1; j < 20; j++)
  {
    Coor c = new Coor(i, j);

Signature

Lew

Mark Space - 05 Jul 2008 01:22 GMT
> only means to provide a breakpoint ( in theorie...;) ) to catch the "if"
> line before (or after):
[quoted text clipped - 6 lines]
>     g.Board[coorToInt(c)] = ".";     //
> } else {

If you want to break before the second "if" is execute, I believe that
is what a breakpoint does already.  Setting a breakpoint at the line
number of the second "if" will break before the expression or the if is
evaluated.

I just did a quick test on some code with a "for" and that's the way it
seems to work.  Give it a test.


Free Magazines

Get these publications absolutely FREE for up to 12 months. There are no hidden fees and no obligation. Simply choose a title, complete the application form and submit it. Read more ...

Oracle MagazineNetwork ComputingComputer WorldBio-IT WorldeWeekInformation WeekInfosecurity
 
Sign In
Join
My Latest Posts
My Monitored Threads
My Blog
My Photo Gallery
My Profile
My Homepage

Start New Thread
Enable EMail Alerts
Rate this Thread



©2008 Advenet LLC   Privacy Policy - Terms of Use
This website includes both content owned or controlled by Advenet as well as content owned or controlled by third parties.