0

While debugging a relatively small program in Eclipse, I am seeing "Source not found" errors as I step through. Other questions state that this is usually an import/jar problem. In this case, I have no imported jar files, nothing fancy, just classes in the src/default package.

The specific behavior is this:

If the debugger is pointed at a line which instantiates a new object (e.g., "Foo foo = new Foo();") where the class, Foo, in question is in the same source directory and has a valid constructor, one of two things happens:

1) Either: Hitting F5 will take me into the class and onto the constructor signature; a subsequent F5 will take me to the dreaded "Source Not Found" error;

2) Or: Hitting F5 will take me immediately to the "Source Not Found" error

In either case, I can continue the debugging.... sort of. E.g., the debug session continues and stepping forward results in further steps through the program. (If I run this program without the debugger, or if there are no breakpoints at those locations, I see no problems. Hitting F8 and going to the next breakpoint will usually get me free of the problem.)

The Java Build Path source is set correctly (the src subdirectory of the project, which is where the default package is sitting.) The Java Build Path libraries has nothing but the JRE System Library, and as far as I know there are no name clashes. I can't think of anything else I'd need to do to the Java Build Path.

This is probably not related to the bug I am hunting with the debugger (NaN proliferation in numerical application) but it is distracting, and it is hampering my ability to get to the root of the problem.

Specific question: What is causing this behavior? Or is it expected behavior that I have not noticed before?

EDIT: Including Code

Loop2:  for (int depth = 0; depth < maxDepth; depth++) {
        for (int node = 0; node < policy.numMemory; node++) {
            Belief belief = new Belief(messages, node);
            nodeTraces[node] = new nodeTrace(policy, pomdp, messages, belief, depth);
            if (nodeTraces[node].bestGain > bestGain) {bestTrace = node; bestGain = nodeTraces[node].bestGain; }
        }
        if (bestGain > 0.01) { System.out.println("breaking"); break Loop2; }
    }

Setting a breakpoint at Belief belief = new Belief(messages, node); above, and hitting F5 will yield the Source Not Found message in the debugger. A code snippet from that class is:

public class Belief {

int numStates;
double[] belief;

public Belief(Messages messages, int node) {
    // do some stuff
}

I stress again that there are no included packages anywhere in this project. All classes are mine and reside in the project's own source directory, which is included in the Java Build Path's source tab. If the suggested link above explains what it going on here, I am just not seeing it even after reading it three times, and I will be grateful if someone explains it to me in small words.

Novak
  • 4,687
  • 2
  • 26
  • 64

1 Answers1

0

Eclipse may be missing the source of the standard library, i.e. the JDK.

This can be set via Preferences -> Java -> Installed JRE .

wool.in.silver
  • 547
  • 1
  • 3
  • 13
  • Changed the default from jdk1.7.0_40 to jre7 and back again; no change in behavior for either setting. – Novak Oct 13 '13 at 22:51
  • Is there a source attachment for that JDK? Can you, for example, open java.lang.Object as a type and see the source? – wool.in.silver Oct 13 '13 at 23:26