简体   繁体   中英

Eclipse cannot debug a newly created class in a package

In Eclipse, I have a Java package in a project that I can debug. I added a new class called Clothing by right-clicking on the package and hitting New->Class.

Now, this code works. It builds and runs successfully and I can successfully use the Open Declaration function on the window that pops up when I hover over Clothing-related constructors and methods.

However, when I try to debug it by stepping into Clothing, I get a "Source Not Found" and a prompt to edit the Source Lookup Path. The code still works when I step over it.

I'm sure there's a simple setting that I need to turn on or off but how do I debug this class?

Edit: I have cleaned this project, the code is all in one project in my workspace and I have restarted Eclipse multiple times.

This is not because of package/location of your project class, but because you are stepping into constructor while instantiating class for the first time.
Even if your class was declared in the same file - you'd likely have same problem.

When you instantiate your class for the first time, the class itself is loaded by java.lang.ClassLoader first, so your debugger is likely trying to step in ClassLoader's code, which you don't have.

Solution:
You can tell your debugger to skip ClassLoader part with Eclipse debug filter preferences and it should work.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM