Thor
Thor

Reputation: 10058

can't step into java source code. "step into" somehow act like "step over"

I'm trying to studying how a method in java String class works, so I created some customised code that calls that String class method.

As you can see, I have set a break point in my own code and I have set another break point in the java String class source code.

While I'm in debug mode and is on line 7 of my code, I pressed step into.

However, rather than stepping into the String class method indexOf, eclipse instead moved onto line 8 of my code.

Why is this happening? how can I step into the java string method source code?

enter image description here

public class TestingIndexOfMethod {
    public static void main(String[] args) {
        final String stringToBeSearchedThrough = "hello world";
        final String substringToLookFor = "ll";
        int a = stringToBeSearchedThrough.indexOf(substringToLookFor, 0);
        System.out.println(a);
    }
}

Edit 1:

I have already check to see, if "use step filter" is activated before asking this question on SO, and it is not activated. So I dont think "use step filter" is the problem here.

enter image description here

Edit 2:

step into works fine with methods I defined myself

Upvotes: 2

Views: 1410

Answers (1)

SubOptimal
SubOptimal

Reputation: 22963

Most probably there is a step filter which instructs the debugger to skip certain classes.

In the preferences dialog (menu Window -> Preferences) check the step filtering settings.

Either deactivate Use Step Fitlers which deactivates all step filters or deactivate the filter for the classes java.* only.

Eclipse step filtering

edit Another reason might be that your project is using a JRE instead of a JDK for the execution. Find below an example using a Java 8 JRE respective a Java 8 JDK.

project build path using a JRE (pay attention to jre1.8.0_112) project runtime JRE

project build path using a JDK (pay attention to JavaSE-1.8) project runtime JDK

edit 2 To determine the used Java runtime library add following statement in your code and run it in debug mode.

...
public static void main(String[] args) {
    Stream.of(System.getProperty("sun.boot.class.path")
            .split(File.pathSeparator))
            .filter(s -> s.endsWith("rt.jar"))
            .forEach(System.out::println);
    ...

Upvotes: 3

Related Questions