Eclipse 调试“找不到源" [英] Eclipse debugging "source not found"

查看:46
本文介绍了Eclipse 调试“找不到源"的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我刚开始使用 Eclipse,所以请放轻松;).但是,在尝试调试 JUnit 测试用例时,我收到一个对话框,指出当我在测试方法的代码中到达这一行时,找不到源代码:

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 in the code in my test method:

Assert.assertEquals(1, contents.size());

我知道我可能应该去尝试从某个地方下载源代码,但我真的不想这样做,因为我对进入 JUnit 代码没有兴趣.我有 JUnit 运行时 jar,那么为什么 Eclipse 要求我拥有所有引用的工具源代码以调试我自己的代码(似乎有些愚蠢)?

I know I should probably go and try and download the source from somewhere, but I really don't want to because I have no interest in stepping into the JUnit code. I have the JUnit runtime jar so Why does Eclipse expect me to have all the referenced tools source code in order to debug my own code (seems somewhat silly)?

我的主要问题是,当源不可用时,我如何告诉 Eclipse 跳过此对话框并允许我继续调试我自己的代码?

My main question is though, how can I tell Eclipse to skip this dialog when the source is not available and allow me to continue to debug my own code?

我已经查明了这个原因.当内部 JUnit 代码抛出异常时,Eclipse 似乎认为它需要源.一般来说,无论如何要告诉它它没有,而只是让它抛出某种错误对话框?

I've isolated the cause of this. It seems that Eclipse seems to think it needs the source when an exception is thrown by the internal JUnit code. In general is there anyway to tell it that it doesn't and just have it throw up an error dialog of some kind instead?

推荐答案

这个很烦人的问题困扰了我很久,但最终还是解决了.就我而言,在 Java 的 Transformer.IsRuntimeCode(ProtectionDomain) 函数中的某处抛出了一个空指针异常.

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.

我真的不需要知道这件事,因为异常正在被捕获和处理,但是每次发生这种情况时 eclipse 都会暂停调试并告诉我源不可用.结果,我不得不不断按下按钮才能继续执行代码.

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. 点击Breakpoints"窗​​口在调试的底部屏幕
  2. 右键单击NullPointerException"
  3. 未选中的已捕获"

这阻止了调试器在捕获 NullPointerException 期间暂停程序流.

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


(来源:SharpDetail.com)

这篇关于Eclipse 调试“找不到源"的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆