在 Eclipse 中调试 - ClassNotFoundException

声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow 原文地址: http://stackoverflow.com/questions/4525334/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me): StackOverFlow

提示:将鼠标放在中文语句上可以显示对应的英文。显示中英文
时间:2020-09-19 15:33:34  来源:igfitidea点击:

Debug in Eclipse - ClassNotFoundException

eclipsedebuggingclassnotfoundexception

提问by lmsasu

when i debug in Eclipse a simple console application, I get a lot of ClassNotFoundException lines in the debug Window. It is not an error, somewhat lower in another pane I get "Source not found.". I understand that it is because the source code of the required class is not available, buI would like to skip over these lines... I have to press a lot of times the "step over" or "step out" button to get out of these states.

当我在 Eclipse 中调试一个简单的控制台应用程序时,我在调试窗口中得到了很多 ClassNotFoundException 行。这不是错误,在另一个窗格中稍低一些我得到“找不到源。”。我明白是因为所需类的源代码不可用,但我想跳过这些行......我必须多次按下“跳过”或“步骤退出”按钮才能退出这些州。

What can I do in order to avoid these useless lines at all?

我该怎么做才能完全避免这些无用的线条?

Thanks

谢谢

回答by TimeTrap

I've been having this problem for a few months now. I'd be debugging a java app and every time I'd hit a constructor, eclipse would try to find matching java core library ClassNotFoundException's source code.

我已经有这个问题几个月了。我将调试一个 Java 应用程序,每次我遇到构造函数时,eclipse 都会尝试找到匹配的 Java 核心库 ClassNotFoundException 的源代码。

I solved this problem by right-clicking in Debug window on the ClassNotFoundException when I hit it, and clicking on Filter Type. I would then right-click in the debug window again and choose Edit Step Filters.... In the Edit Step Filters window I checked everything in the Defined Step Filters section and unchecked everything in the bottom of the window (Filter synthetic methods, Filter static initializers, etc).

当我点击 ClassNotFoundException 时,我通过在调试窗口中右键单击 ClassNotFoundException 并单击过滤器类型解决了这个问题。然后,我将再次在调试窗口中右键单击并选择 Edit Step Filters.... 在 Edit Step Filters 窗口中,我检查了 Defined Step Filters 部分中的所有内容,并取消选中窗口底部的所有内容(过滤合成方法、过滤器静态初始值设定项等)。

Hope this helps others in the future.

希望这可以帮助其他人在未来。

回答by numbers3567

After Launching Debug Mode.

启动调试模式后。

Go to Window → Show View → Break Points. Now you would be able to see Break Point tab in Debugging mode.

转到Window → Show View → Break Points。现在您将能够在调试模式下看到 Break Point 选项卡。

Uncheckthe option "ClassNotFoundException: caught and uncaught".

取消选中“ClassNotFoundException:已捕获和未捕获”选项。

回答by dimitrisli

While debugging try Step Return(F7 as shortcut) to get one level up at a time and thus out of the libs you don't have the source attached for.

在调试时尝试Step Return(F7 作为快捷方式)一次升级一个级别,从而摆脱您没有附加源的库。

回答by slartidan

In a normal application your own code (your java files) is mixed together with code of others (class files in libraries, runtime environment, etc.). Each time you step into a class file you will get this "Source not found"-Warning. (as you already mentioned in your question)

在普通应用程序中,您自己的代码(您的 java 文件)与其他代码(库中的类文件、运行时环境等)混合在一起。每次进入类文件时,您都会收到此“未找到源”-警告。(正如您在问题中已经提到的那样)

At first you could try to get the source codes for the libraries and link them to your libraries (for example in "project setup => Preferences.../Java Build Path/Libraries => unfold a jar-libraries => Source attachment").

首先,您可以尝试获取库的源代码并将它们链接到您的库(例如在“项目设置 => 首选项.../Java 构建路径/库 => 展开 jar-libraries => 源附件”中) )。

If no source code is available you have to use the debugger-comands to avoid jumping into that class files. "Step Out/Return" might help, but the "Debug View" (which can be found in the top left corner in your "Debug Perspective") could be even more helpful.

如果没有可用的源代码,您必须使用调试器命令来避免跳转到该类文件。“Step Out/Return”可能会有所帮助,但“Debug View”(可以在“Debug Perspective”的左上角找到)可能会更有帮助。

In the "Debug View" you can see each thread of your application. If you are currently debugging a thread you can there see the current stacktrace. Instead of clicking F6 and F7 all the time you can also navigate by clicking on an stacktrace-item there.

在“调试视图”中,您可以看到应用程序的每个线程。如果您当前正在调试一个线程,您可以在那里看到当前的堆栈跟踪。您也可以通过单击此处的堆栈跟踪项进行导航,而不是一直单击 F6 和 F7。

Tipp: I am using - (Rightclick->"run to line") a lot - this is quite helpful to run over loops, etc.

Tipp:我经常使用-(右键单击->“运行到行”)-这对于运行循环等非常有帮助。

回答by Lokesh Kumar

An occurence of ClassNotFoundException is most common in debugging in order to avoid these exceptions, In breakpoints window(Windows>Show View>BreakPoints) uncheck the "ClassNotFoundException: caught and uncaught" to continue with the normal debugging.

ClassNotFoundException 的发生在调试中最常见,为了避免这些异常,在断点窗口(Windows>Show View>BreakPoints)中取消选中“ClassNotFoundException:catch and uncaught”以继续正常调试。