Reply
 
LinkBack Thread Tools Display Modes
  #1 (permalink)  
Old 07-05-2009, 05:51 AM
Member
 
Join Date: Mar 2009
Posts: 5
Rep Power: 0
bizso is on a distinguished road
Default watch expression in debug mode
Hi,
I'm new to eclipse and trying to get hang of debugging. When I execute my code in debug mode this is what I see at local variables:

num = 45632

when I right click on "num" in the variables view and select inspect, I see "num" and "45632" in the expressions view. However, when I right click there and select Convert to Watch Expression I get this message:

"Evaluations must contain either an expression or a block of well-formed statements"

Similarly, when I highlight "num" in the editor and right click inpsect, I get the same error message. I tried to use the display view, typed in num without a semicolon, but that didn't work either. Any help?
Bookmark Post in Technorati
Reply With Quote
  #2 (permalink)  
Old 07-05-2009, 05:31 PM
Eranga's Avatar
Moderator
 
Join Date: Jul 2007
Location: Colombo, Sri Lanka
Posts: 7,256
Rep Power: 11
Eranga has a spectacular aura aboutEranga has a spectacular aura about
Send a message via Yahoo to Eranga
Default
At what time you check the value, before debugger comes to that line, or after the execution. May be a garbage collection it is. What exactly num holds, type? Can you show a code segment here related to this?
__________________
Use an appropriate Subject. "Help, urgent!" isn't one.
Someone helped you? their helpful post.
Help:Forums FAQ|How To Ask Questions The Smart WayResources:The Java Tutorials|Glossary for Java|NetBeans IDE|Sun DownloadsWeb:WritOnceTips:Is your IDE the best?|Which Application Server?
Bookmark Post in Technorati
Reply With Quote
  #3 (permalink)  
Old 07-06-2009, 12:02 AM
Member
 
Join Date: Mar 2009
Posts: 5
Rep Power: 0
bizso is on a distinguished road
Default
Originally Posted by Eranga View Post
At what time you check the value, before debugger comes to that line, or after the execution. May be a garbage collection it is. What exactly num holds, type? Can you show a code segment here related to this?
This is what's happening:

Code:
import org.junit.Test;

public class AClassTest extends TestCase{
  @Test
  public void testTest(){
    AClass aClass = new AClass();
    int num = aClass.getTest();
    
  }
}
public class AClass {
  public int getTest() {
     return 45632;
  }
}
After
Code:
int num = aClass.getTest();
has been executed. I am able to see num in the variables field, and also able to see the value when I hover above it in debug mode. But when I highlight it and click inspect, or add to watch expression, I get that strange error message.

However, if I write

Code:
public class AClassTest extends TestCase{
  @Test
  public void testTest(){
    AClass aClass = new AClass();
    int num = 45632;
    
  }
}
Then everything is fine... ??
Bookmark Post in Technorati
Reply With Quote
  #4 (permalink)  
Old 07-06-2009, 06:20 AM
Eranga's Avatar
Moderator
 
Join Date: Jul 2007
Location: Colombo, Sri Lanka
Posts: 7,256
Rep Power: 11
Eranga has a spectacular aura aboutEranga has a spectacular aura about
Send a message via Yahoo to Eranga
Default
Hmmm, interesting. I'm not an Eclipse user. However I test your code in NetBeans and I didn't get any error message as you said. There is nothing wrong in your code, seems to me that's the ways debugger deals with.

We'll see is anyone comes with the same issue. If someone, Eclipse user, able to test this code and let us know really helpful.
__________________
Use an appropriate Subject. "Help, urgent!" isn't one.
Someone helped you? their helpful post.
Help:Forums FAQ|How To Ask Questions The Smart WayResources:The Java Tutorials|Glossary for Java|NetBeans IDE|Sun DownloadsWeb:WritOnceTips:Is your IDE the best?|Which Application Server?
Bookmark Post in Technorati
Reply With Quote
  #5 (permalink)  
Old 07-06-2009, 06:20 AM
Eranga's Avatar
Moderator
 
Join Date: Jul 2007
Location: Colombo, Sri Lanka
Posts: 7,256
Rep Power: 11
Eranga has a spectacular aura aboutEranga has a spectacular aura about
Send a message via Yahoo to Eranga
Default
Hmmm, interesting. I'm not an Eclipse user. However I test your code in NetBeans and I didn't get any error message as you said. There is nothing wrong in your code, seems to me that's the ways debugger deals with.

We'll see is anyone comes with the same issue. If someone, Eclipse user, able to test this code and let us know really helpful.
__________________
Use an appropriate Subject. "Help, urgent!" isn't one.
Someone helped you? their helpful post.
Help:Forums FAQ|How To Ask Questions The Smart WayResources:The Java Tutorials|Glossary for Java|NetBeans IDE|Sun DownloadsWeb:WritOnceTips:Is your IDE the best?|Which Application Server?
Bookmark Post in Technorati
Reply With Quote
  #6 (permalink)  
Old 07-06-2009, 07:25 PM
Member
 
Join Date: Mar 2009
Posts: 5
Rep Power: 0
bizso is on a distinguished road
Default
update...

I have tried out the same JUnit test case debugging in NetBeans 6.7 and everything works fine there (it correctly evaluates the watch expressions). So it would appear that this is an Eclipse specific problem...
Bookmark Post in Technorati
Reply With Quote
  #7 (permalink)  
Old 07-08-2009, 09:07 AM
Eranga's Avatar
Moderator
 
Join Date: Jul 2007
Location: Colombo, Sri Lanka
Posts: 7,256
Rep Power: 11
Eranga has a spectacular aura aboutEranga has a spectacular aura about
Send a message via Yahoo to Eranga
Default
Yes, seems like that. Not NetBeans it works fine. That's why I say if another Eclipse user able to test the same code, and let us know, to narrow down the exact scenario.
__________________
Use an appropriate Subject. "Help, urgent!" isn't one.
Someone helped you? their helpful post.
Help:Forums FAQ|How To Ask Questions The Smart WayResources:The Java Tutorials|Glossary for Java|NetBeans IDE|Sun DownloadsWeb:WritOnceTips:Is your IDE the best?|Which Application Server?
Bookmark Post in Technorati
Reply With Quote
Reply

Bookmarks

Tags
debug, expression, inspect, view, watch

Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On


Similar Threads
Thread Thread Starter Forum Replies Last Post
Debug challenge: how do you debug a Java program? CJSLMAN New To Java 60 07-04-2009 11:28 AM
How to enable debug mode in eclipse msgbharath New To Java 3 01-10-2009 03:20 AM
Watch TV on PC - 12,000 TV Channels and Movies, save money Get $10 rebate. arturmoniswork Reviews / Advertising 0 12-30-2008 06:56 AM
[SOLVED] Folder watch Issue jazz2k8 New To Java 13 07-24-2008 06:46 AM


All times are GMT +2. The time now is 07:19 PM.



VBulletin, Copyright ©2000 - 2010, Jelsoft Enterprises Ltd.
Content Relevant URLs by vBSEO ©2009, Crawlability, Inc.
Copyright ©2006 - 2007, www.java-forums.org