Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

When stepping into class instantiation, eclipse debugger goes to native code

I recently upgraded to helios and now every time I step into a constructor for a class (e.g. Cat myCat = new Cat();), eclipse debugger shows the stack as

java stack trace entering instantiation:

To get to the actual constructor code, I have to step out several times which is annoying. This is happening with every class and despite the stack I never see any error messages in the console. How do I fix this so it directly steps into the constructor for my class?

This only happens the first time the class is used, and even for classes that are in the same src file as the current one.

like image 641
cplusplus Avatar asked May 09 '12 05:05

cplusplus


People also ask

How do I change the default debug in Eclipse?

Goto Windows - > preference -> General -> perspectives -> make default your perspective or press reset to default to forget the previous settings. Save this answer.

How do you run a class in debug mode?

Set a breakpoint in your main class by clicking in the left margin of the line where you want to set the breakpoint. The line with the breakpoint is highlighted in pink. Right-click the project's node again and choose Debug Project. The target should run and start execution of the program.

How do I debug a specific class in Eclipse?

A Java program can be debugged simply by right clicking on the Java editor class file from Package explorer. Select Debug As → Java Application or use the shortcut Alt + Shift + D, J instead. Either actions mentioned above creates a new Debug Launch Configuration and uses it to start the Java application.


2 Answers

Eclipse has a step filter preference in the Java debugger preferences. Its default preference filters out java.lang.ClassLoader, however this wasn't working. This might have something to do with recently having installed and switched to using jre7. To solve my problem I added a filter to step through any code in the java.lang package.

enter image description here

like image 81
cplusplus Avatar answered Sep 19 '22 08:09

cplusplus


I think the ClassNotFoundException is just happening as a part of class loading -- the problem is that you have a breakpoint set to trigger when those exceptions are thrown. My guess is that your version of Eclipse has this breakpoint on by default, whereas the old one didn't.

Check out this link, which reports a similar problem and provides the solution, which is just to disable that breakpoint.

(In the interest of teaching to fish and all that, the google search term was "eclipse debugger launcher$appclassloader".)

like image 38
yshavit Avatar answered Sep 17 '22 08:09

yshavit