Skip to main content


Eclipse Community Forums
Forum Search:

Search      Help    Register    Login    Home
Home » Language IDEs » Java Development Tools (JDT) » Java Inspector ignores static imports(Problem with commands Display and Inspect during debugging.)
icon13.gif  Java Inspector ignores static imports [message #839915] Mon, 09 April 2012 12:07 Go to next message
Thomas Guckenbiehl is currently offline Thomas GuckenbiehlFriend
Messages: 3
Registered: April 2012
Junior Member
Hi,

I have a problem with debugging Java code with Eclipse Indigo 3.7 SR2. For demonstration purposes consider the following simple program:

package eu.guckenbiehl.test;

import eu.guckenbiehl.utils.MyConstants;

public class MyTest {
  public static void main(String[] args) {
      System.out.println(MyConstants.SOME_CONSTANT); // <-- Breakpoint here
      System.out.println("Done.");
  }
}


If I debug this program, I can stop at a breakpoint on the first line of main(). But if I then mark "MyConstants.SOME_CONSTANT" and try to evaluate it using the "Display" command in the context menu, I get the error "MyConstants cannot be resolved to a variable". The same happens if I use the Inspect command from the context menu.

However, if I go on with debugging and step over that line, the value of MyConstants.SOME_CONSTANT is printed to the console without any errors. Hence, the classpath of the debugger seems to be alright. Also, if I explicitly specify the package of MyConstants writing

System.out.println(eu.guckenbiehl.utils.MyConstants.SOME_CONSTANT);

the Display and Inspect commands work fine.

This happens whenever I try to apply Display and Inspect to expressions that refer to static variables or functions. If the expression refers only to variables or functions of instances, then Display and Inspect work as I expect. I also seem to remember, that in Eclipse 3.4 it was possible to display/inspect static expressions.

So, what am I missing? Do I have to set some particular option?

Thanks for any help,
Thomas


Re: Java Inspector ignores static imports [message #840024 is a reply to message #839915] Mon, 09 April 2012 15:20 Go to previous messageGo to next message
David Wegener is currently offline David WegenerFriend
Messages: 1445
Registered: July 2009
Senior Member
Have you tried just selecting SOME_CONSTANT and performing the Display on that? I'm not sure if this works, but the actual variable name is SOME_CONSTANT.
Re: Java Inspector ignores static imports [message #840025 is a reply to message #839915] Mon, 09 April 2012 15:22 Go to previous messageGo to next message
Michael Rennie is currently offline Michael RennieFriend
Messages: 67
Registered: July 2009
Location: Canada
Member
This should be working just fine. I ran your test code in:

Version: 4.2.0
Build id: I20120321-0610

and it worked just fine (no errors / exceptions).

In your test is the eu.guckenbiehl.utils package in the same project as your test class?
Re: Java Inspector ignores static imports [message #840130 is a reply to message #839915] Mon, 09 April 2012 17:56 Go to previous messageGo to next message
Thomas Guckenbiehl is currently offline Thomas GuckenbiehlFriend
Messages: 3
Registered: April 2012
Junior Member
@Michael: The problems occur with

Version: Indigo Service Release 2
Build id: 20120216-1857
JVM: Java HotSpot(TM) Client VM (20.6-b01, mixed mode)
Java: version 1.6.0_31, vendor Sun Microsystems Inc.

They also occured with
Version: Indigo Service Release 1
Build id: 20110916-0149.

The configuration is in the file "eclipse-configuration.txt" attached to this message.
I have a clean workspace with just that project. The project is also attached to this message.

I start the application by selecting "Debug as > Java Application" in the context menu of the editor (if this makes any difference).

@David: I tried to select and inspect just "SOME_CONSTANT", but it says "SOME_CONSTANT cannot resoved to a variable" (which is what I would expect, since it belongs to a different class).

Greetings and Thanks,
Thomas
Re: Java Inspector ignores static imports [message #841416 is a reply to message #840130] Wed, 11 April 2012 09:18 Go to previous messageGo to next message
Hresde dfsds is currently offline Hresde dfsdsFriend
Messages: 1
Registered: April 2012
Junior Member
Hi, does anyone know of a code inspector like SAP has for webdynpro abap but than for the java version?

61designstreet.com
Re: Java Inspector ignores static imports [message #916103 is a reply to message #841416] Tue, 18 September 2012 14:33 Go to previous messageGo to next message
Stanislav Rohac is currently offline Stanislav RohacFriend
Messages: 1
Registered: September 2012
Junior Member
Hi, I have the same problem after upgrading to version 3.7

Until I have had 3.4, everything works fine.

Found anybody solution how to fix this problem?
Re: Java Inspector ignores static imports [message #996291 is a reply to message #839915] Tue, 01 January 2013 17:42 Go to previous messageGo to next message
Thomas Guckenbiehl is currently offline Thomas GuckenbiehlFriend
Messages: 3
Registered: April 2012
Junior Member
This error also happens with Juno Service Release 1
Build id: 20121004-1855
Java HotSpot(TM) Client VM 1.7.0_10
Java(TM) SE Runtime Environment (build 1.7.0_10-b18)

I was finally able to simplify the example program:

package test;

import java.util.Date;
//
public class MyTest {
  public static void main(String[] args) {
      System.out.println(new Date()); // <-- Breakpoint here
  }
}



Please note the (for demonstration purposes: empty) comment in line 4 !

Now I put a breakpoint in line 7 and start the debugger. When it breaks in main(), I mark "new Date()" and try to evaluate it using the "Display" command in the context menu. This results in the error "Date cannot be resolved to a type". The same happens if I use the Inspect command from the context menu.

The same error occurs, if I put the comment slashes in line 9 after the closing bracket.

However the error does NOT occur, if I

  • remove the comment in line 4
  • move the comment to line 10
  • move the comment inside the class body


Any ideas?

Best regards,
Thomas
Re: Java Inspector ignores static imports [message #997415 is a reply to message #839915] Mon, 07 January 2013 11:21 Go to previous message
Anna Harris is currently offline Anna HarrisFriend
Messages: 1
Registered: January 2013
Junior Member
I tried your code in my editor and working quite fine. I think that there's noting wrong with your code.
Previous Topic:Howto Link all projects to same code formatter rules file
Next Topic:Addon's installed in firefox are not recognized by Eclipse during runtime.
Goto Forum:
  


Current Time: Thu Apr 25 16:04:35 GMT 2024

Powered by FUDForum. Page generated in 0.03607 seconds
.:: Contact :: Home ::.

Powered by: FUDforum 3.0.2.
Copyright ©2001-2010 FUDforum Bulletin Board Software

Back to the top