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..

Community
  • 1
  • 1
Håkon Hægland
  • 39,012
  • 21
  • 81
  • 174

2 Answers2

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.

Holger
  • 285,553
  • 42
  • 434
  • 765
  • 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.. – Håkon Hægland Nov 18 '13 at 16:41
  • 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. – Holger Nov 18 '13 at 16:56
  • 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..) – Håkon Hægland Nov 18 '13 at 17:01
  • 1
    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. – Holger Nov 18 '13 at 17:08
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;
    }
}

}

Rhycce
  • 111
  • 1
  • 8