user1722361
user1722361

Reputation: 427

How can I step into a core java class method in Eclipse?

Hi I am going to dig a little more in Java so I would like to see how the program executed in the core class. For example, I would like to know how String.chatAt() is implemented, so I set breakpoint and tried to step into with debug mode. But I failed, I set bp at the second line when the program hit it, I used step into it still continue to the third line.

String a = "1231231241241";
char b = a.charAt(0);
System.out.println(b);

I think it should go into the source and show "no source found" and then give me a chance to attach the source file, right? But why it cannot get in? I can only use ctrl+right click on a method to get into source and attach.

Upvotes: 6

Views: 4399

Answers (5)

user3526053
user3526053

Reputation: 1

for example in this System.out.println("test") piece of code if you want to step into System class just click on System and click F3 you will be redirected to attach the source code if you haven't already attached.Just attached the src folder of the jdk

Upvotes: 0

Alderath
Alderath

Reputation: 3874

Most likely, you have the "Step filtering" functionality activated.

When debugging, it can sometimes be a bit annoying when the debugger steps into trivial classes whose internals you were not really interested in. Because of this, you can configure "Step filters". Classes or packages that are added as step filters will be ignored by the "Step into" operation.

If you want to configure which classes/packages should be included in the step filter, you can go to:
Window --> Preferences --> Java --> Debug --> Step Filtering
My guess is that you have a java.* package filter defined there, meaning that the debugger will never step into any class within a package which starts with "java". Uncheck this package filter if you want to be able to step into java.lang.String

Alternatively, if you want to activate/deactivate step filtering completely, you can do this by clicking the Use step filtering button in the debug view, as shown below:

Toggling step filtering

Upvotes: 5

s-hoff
s-hoff

Reputation: 196

Seems like you dont have the "Source Attachment" set. Go to Preferences -> Java -> Installed JREs. Select the JRE you use and click "Edit", then set the Source Attachment to the src.zip that comes with the jdk by selecting the jars and clicking "Source Attachment" :). You can do this with all of the jars at the same time by selecting them via shift-click.

Upvotes: 0

To be able to look at the code of libriaries you are using in your project you should configure your build path by attaching the soruces and JavaDoc.

Source Lookup

Upvotes: 2

Less
Less

Reputation: 3207

It might be that your Eclipse is not setup to run with JDK, it might run with JRE instead.
Check this link.
Also, I might suggest you to try and use Maven for your Java projects management, it makes the life so much easier, when you get a grasp of it.

Upvotes: 5

Related Questions