Debugger shows incorrect variable values [message #1076008] |
Tue, 30 July 2013 14:07 |
Jim Anderson Messages: 109 Registered: October 2014 |
Senior Member |
|
|
I am debugging some code and have found that Eclipse is not always staying up to date with the source code. I verified this by putting some print statements in my source code. If I run the program in a batch mode, the output values are correct, but in Eclipse the values are not correct.
My *.class files are co-located with the *.java files, so I would expect that
Eclipse would update each .class file when changes are made to the source files,
but this does not seem to be the case. When I make changes to the source file, the
source window in the debug perspective reflects the change, but when I run the code,
the object file has not been updated in Eclipse.
I suspect the problem may be that I have linked my workspace source to an external
source. This link points to the area on disk where I maintain my CVS controlled
source code. When I look at my workspace, I see that under my java project there
is a 'bin' directory that has jar files matching up to the jar files that I normally
build when in batch mode. By 'matching up' I mean that the jar files in the workspace
match up to the jar files in the CVS area and are in the same relative directory.
When I change a source file and do a build, the jar files in both areas get rebuilt.
My best guess is that Eclipse is not updating the version of xxx.class when
xxx.java is changed. I experimented and changed the source code for my xxx.java.
The jar file in my workspace was automatically updated by Eclipse, but the xxx.class file remained out of date. I can only guess that Eclipse is using the out
of date .class file. It should either be using the up to date jar file or
updating the .class file, if I am correct.
I did some additional checking in Eclipse and found that there is a
window --> preferences --> java --> build path --> 'source and output folder'
preference. For my project this was set to 'folders' and the values were
'src' and 'bin' for the source and output folders. This explains why
there is a 'bin' directory for my project. Under the 'bin' directory, I
find the same relative paths as in my 'src' directory. I find that my
xxx.class file is getting updated under the 'bin' directory, and not
under the 'src' directory.
Is there a 'preference' that can be set to instruct Eclipse to use the xxx.class
file in my 'src' directory, not the xxx.class file in the subdirectory
under 'bin' or the jar file?
Thank you in advance.
Jim Anderson
[Updated on: Tue, 30 July 2013 15:14] by Moderator Report message to a moderator
|
|
|
|
|
|
Re: Debugger shows incorrect variable values [message #1076083 is a reply to message #1076051] |
Tue, 30 July 2013 17:26 |
Jim Anderson Messages: 109 Registered: October 2014 |
Senior Member |
|
|
Ideally, what I want to do is use the same source code for both Eclipse and for my batch processing outside of Eclipse and then
do my builds of .class files for Eclipse in my Eclipse workspace and for my external builds in another sandbox.
To accomplish this, I tried to build my Eclipse project so that Eclipse will direct output to a separate directory, not the
linked source directory. Eclipse allows me to do this which is great. However, the problem is that when I try to debug, Eclipse
is not building a new class file in the output directory when the source code changes. I think this is a bug in my configuration
or in the JDT.
What I am trying to do worked fine until my disk got full and I had to relocate data, including my Eclipse
workspace, to another disk. I know Eclipse can handle what I want to do, but I don't know how to configure the
JDT to look at (linked) source directory .java files to know when to update the .class files in my output
directory. I know it knows about the output .class files because it creates them. And I know it knows the
source file locations because I can view them in the JDT.
It is not clear to me, if there is a setting or preference in the JDT which tells the JDT where to look
for the .class file. As far as I know, there are no plugins, unless some plugins are included with the
downloaded tar.gz file I used to install Kepler.
Thanks for the comments so far. I'm still experimenting, trying to get things to work, but so far, no luck.
Jim
|
|
|
|
Powered by
FUDForum. Page generated in 0.03486 seconds