Eclipse ide, cannot resolve variables in newly written functions
I have a strange problem that I never encountered before, with debugging in Eclipse. while debugging, when I break in new code, the variables in the function are not displayed in the "variables" window. The ones that are displayed are only those which were passed to the function as arguments, and they are displayed as arg(0), arg(1) etc, and not 开发者_如何学Goby thier names. when I want to watch or inspect a variable in the function, I get the message "such and such cannot be resolved". Some facts: 1. When I rome in the debug stack and look at other functions, the variables are displayed properly 2. The debug run is synchronised with my written code 3. The project that I work in is compiled with external tools (that are using ant). None of my fellow workers ever encountered such a problem although all of them compile with the external tool. 4. The eclipse is 3.2.1 version
This is a typical behaviour if you compile code without the -g
option.
In eclipse: right-click on the Project, select 'Properties' from the context menue and "Java Compiler". Check if "project specific settings" is enabled.
If it is enabled, check if all checkboxes in the lower area are selected, especially "Add variable attributes to generates class files".
If this checkbox is enabled but not selected, check it (press apply), if it is not enabled not selected, select "Configure Workspace Settings" and enable the missing functionality globally (my advice).
External tool - the javac
command needs the -g
option. Default behaviour (no -g) is not having local variable information. (Reference)
Make sure you have the 'Debug Perspective' open before running the code. That solved a similar issue for me once.
Looks like you discard debug information during compiling. Check the command line parameters of your Ant-Task.
When compiling with ant please ensure that you have these instruction passed on to javac options.
javac **debug="true" debuglevel="lines,vars,source"** target="1.6" source="1.6" srcdir="${project.src.dir}" destdir="${project.build.dir}" classpathref="classpath">
Another couple things.
- Make sure the JDKs you're compiling with and debugging with are the same
- If it's a genuine Eclipse error (e.g. Not one of the solutions posted above) you might get some joy out of upgrading.
精彩评论