When I debug Eclipse, it often happens that the debugger crashes, causing the "Source not found" error message (under which there is a button with the text "Change source search path"). I previously searched the Internet for an explanation / solution to this problem, but found nothing to help me.
However, now I have figured out what happens in my case: an error occurs when passing code line by line, and then exiting the block of running code. I don’t know the terminology, but I think that many applications can go into “standby mode” at some point when none of its codes are currently working. One example is a graphical application waiting for a mouse click. Stopping at a breakpoint in the MouseListener method, and then exiting it (into "standby mode") will result in an error in my case.
I put MWE at the bottom of this question. An error occurs when I put a breakpoint on a line
System.out.println("You clicked!");
and exit the method line by line using F6 ("Step Over"). If I press F8 (Resume) instead of F6 on the last line of the listener, the debugger will not work, and everything will be fine.
My question is: why is Eclipse doing something so serious that it might crash in this case? I understand that in the source code there is no line about which it can be said that the program element “comes” after exiting the listener in the example below, but why not just go into “standby mode” without complaining? Can I somehow deactivate this error so that my debugging sessions are not so often encountered with their untimely termination? Or do I just need to remember to press F8 instead of F6 when the latter will fail?
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); } }
source share