Eclipse debugging “source not found”

前端 未结 6 1872
南旧
南旧 2020-11-29 05:50

I just started using Eclipse so go easy on me ;). But when trying to debug a JUnit test case I get a dialog that states the the source is not found when I get to this line i

相关标签:
6条回答
  • 2020-11-29 06:20

    I had a similar problem. I fixed it by right clicking on the project folder in the package explorer and selecting refresh. The code source was out of sync with the debugger and this corrected it. The Transformer.IsRuntimeCode(ProtectionDomain) Source not found message no longer appears.

    0 讨论(0)
  • 2020-11-29 06:22

    I had a similar problem with another jar, even when I pointed to the source it would ask for it again. I was able to solve it by compiling the jar with debug="on" on ANT.

    0 讨论(0)
  • 2020-11-29 06:29

    Use the Step Filter to avoid stepping through the ...junit... packages. Right click on the stack trace and choose Filter Package. You may have to turn on filtering first with Use Step Filters. ~~~

    0 讨论(0)
  • 2020-11-29 06:35

    I had this very annoying problem for a long time but was finally able to solve it. In my case, a null pointer exception was being thrown somewhere in Java's Transformer.IsRuntimeCode(ProtectionDomain) function.

    I didn't really need to know about this since the exception was being caught and handled, but eclipse would pause debugging every time this happened and tell me that the source wasn't available. As a result, I constantly had to keep pressing the button to continue code execution.

    In order to prevent this from happening, I:

    1. Clicked on the "Breakpoints" window at the bottom of the debugging screen
    2. Right clicked "NullPointerException"
    3. Unchecked "Caught"

    This prevented the debugger from pausing program flow during a caught NullPointerException.


    (source: SharpDetail.com)

    0 讨论(0)
  • 2020-11-29 06:35

    The debug callstack will display a JUnit source code line when throwing an exception.
    But you should not need to worry about that, if you do not have the source code of JUnit.

    If you go back one line in the callstack, you should see the line (of your source code) which has caused the JUnit exception.
    That should be enough to debug your code.


    To associate the source with JUnit, you could add the junit.jar in the librairies of your project, and associates the junit-x.y.z-src.jar to the junit-x.y.z.jar, like so:

    http://web.archive.org/web/20130227201940/http://img241.i_mageshack.us/img241/1412/eclipsejunitsrc.png

    That will generate in the .classpath of your project a line like:

    <classpathentry kind="lib" path="junit-x.y.z.jar" sourcepath="junit-x.y.z-src.jar">
    

    Note: actually, there would be the full path of the junit[...].jar files in this classpathentry line. But you could also use Linked resources to avoid that fixed value (the full path) in your .classpath file.

    0 讨论(0)
  • 2020-11-29 06:39

    Calculate contents.size() on a separate line instead or set a breakpoint on the method.

    Also note the junit view in Eclipse allows you to navigate the stack trace.

    0 讨论(0)
提交回复
热议问题