Eclipse hangs when attempting to step into function
Eclipse freezes when I tried running the following code in debug mode:
public class LinkedListTest2 {
public static void main(String[] args) {
Node a = new Node(1); // Attach breakpoint here
Node b = new Node(2);
Node c = new Node(3);
a.next = b;
b.next = c;
c.next = null;
System.out.println(toString(a)); // Step into here
}
public static String toString(Node head) {
StringBuilder builder = new StringBuilder();
while (head != null) {
builder.append(head.data);
if (head.next != null) {
builder.append(", ");
}
head = head.next;
}
return "[" + builder.toString() + "]";
}
public static class Node {
public int data;
public Node next;
public Node(int data, Node next) {
this.data = data;
this.next = next;
}
public Node(int data) {
this(data, null);
}
}
}
To reproduce:
- Attach a breakpoint to line 3 and start debug mode.
- Press the "step over" button several times until you are highlighting the println on line 11
- Once you are on line 11, press the "step into" button to try and step into the "toString" function
- Eclipse will freeze instead of stepping into the function
It's unclear to me exactly why this is happening, but I did find that reducing the number of nodes in the main method to 1 or 2 made the error go away.