1

I have similar problem to the one described here: Eclipse and Java - source not found

I also looked at the following question: Eclipse java debugging: source not found but I could not see how that it applied to my case..

I have just started using Eclipse and its debugger. Here is how to reproduce the problem using Eclipse 3.7.2 on Ubuntu 12.04 with java and javac version 7.

  • Start Eclipse and select workspace, e.g., "Test" in home folder.
  • Open java perspective
  • Open new java project with project name "Test"
  • Add a new java class "Test"

I now have the following screenshot:

enter image description here

  • Add the following code to the source file Test.java

enter image description here

  • set a breakpoint at new Test2(1)
  • open debug perspective
  • start debugging:

enter image description here

  • choose Step Into (F5)

Now the error is reported:

enter image description here

Any help on this issue is appreciated..

asked Nov 18, 2013 at 16:24
2
  • Have you tried cleaning the project? (Project->Clean... and select your project) Commented Nov 18, 2013 at 16:26
  • I tried cleaning now, it did not help.. I still get the same error.. Commented Nov 18, 2013 at 16:29

2 Answers 2

2

The class Launcher$AppClassLoader belongs to the JRE and is about to load your class. It has nothing to do with the source code of your own classes. If you step further you will reach your own class Test2. If you go to the end of your debug button bar (four buttons right to the "step into" button), there’s a "Use step filters" button. Activate it to avoid unnecessary steps into the JRE classes.

answered Nov 18, 2013 at 16:36
Sign up to request clarification or add additional context in comments.

4 Comments

Thanks.. it seems you are right. I can step over it and after some more stepping I finally enter the constructor in the Test2 class.. I will try your advice regarding the step filters..
Maybe you have to configure your filters. You can right-click on a stacktrace entry and chose "filter type" or "filter package" to add the particular code to the filter.
Yes that seems to work.. What if I just open Preferences->Java->Debug->Step Filtering and select all the packages.. Is this adviceable? (I tried it now, and it also seems to work.. but I am not sure if it is the correct approach in general..)
I don’t know what predefined list you have there, but I guess Eclipse will provide useful suggestions. The only thing you have to be aware of is that this list exists. So once you are debugging and need to step in one of these packages you have to either turn filtering temporarily off or switch off that particular package for the debug session, whatever you prefer.
0

I believe you have to create an instance of Test before you can access the nested class Test2 in Test. Eclipse should have thrown an error in yours saying something like "No instance of Test2 is accessible" or something like that. Change your code to look like this and see if it works.

public class Test {
/**
 * @param args
 */
public static void main(String[] args) {
 // TODO Auto-generated method stub
 Test mTest = new Test();
 Test2 nTest = mTest.new Test2(1);
}
class Test2{
 int i;
 Test2(int i){
 this.i = i;
 }
}

}

answered Nov 18, 2013 at 16:35

2 Comments

Test2 isn't a nested class in the OP's screenshot. It's defined outside the scope of Test.
Sorry, my bad...I didnt see the final enclosing braces

Your Answer

Draft saved
Draft discarded

Sign up or log in

Sign up using Google
Sign up using Email and Password

Post as a guest

Required, but never shown

Post as a guest

Required, but never shown

By clicking "Post Your Answer", you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.