When I'm debugging in Eclipse, it often happens that the debugger crashes, displaying the error message "Source not found" (under which is a button with the text "Edit Source Lookup Path"). I have previously searched the web for an explanation/solution to this problem, but found nothing of help to me.
However, I've now figured out what is happening in my case: The error occurs when stepping through the code line by line, and then stepping out of a block of running code. I don't know the terminology, but I guess many applications might enter "standby mode" at some point, where none of its code is currently running. One example is a graphical application waiting for a mouse click. Stopping at a breakpoint in a MouseListener method, and then stepping out of it (into "standby mode") will cause the error in my case.
I've supplied an MWE at the bottom of this question. The error occurs when I place a breakpoint at the line
System.out.println("You clicked!");
and step out of the method line by line using F6 ("Step Over"). If I press F8 ("Resume") instead of F6 at the last line of the listener, the debugger doesn't crash and everything is fine.
My question is: why does Eclipse do something so severe as to crash in this case? I understand that there is no line in the source code that the program control can be said to "step to" after leaving the listener in the below example, but why not just go into "standby mode" without complaining? Can I deactivate this error somehow, to prevent my debugging sessions from so frequently meeting their untimely end? Or do I just have to remember to press F8 instead of F6 when the latter would cause a crash?
package app;
import java.awt.Dimension;
import java.awt.event.MouseAdapter;
import java.awt.event.MouseEvent;
import javax.swing.JFrame;
public class TestFrame extends JFrame {
public TestFrame() {
getContentPane().setPreferredSize(new Dimension(200, 200));
getContentPane().addMouseListener(new MouseAdapter() {
@Override
public void mouseClicked(MouseEvent e) {
System.out.println("You clicked!");
}
});
pack();
}
public static void main(String[] args) {
JFrame testFrame = new TestFrame();
testFrame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
testFrame.setVisible(true);
}
}