Consider code like:
---
public class Test {
public static void main(String... args) {
new Test().test("a");
}
private void test(String s) {
if (s != null) {
switch (s) {
case "a":
System.out.println("a"); //breakpoint here, and continue with step-over
break;
default:
System.out.println("default"); //the program counter will be shown here eventually
}
} else {
System.out.println("null");
}
}
}
---
Place a breakpoint at the marked line, and continue with step-over. After a few steps, the current program counter marker will be at the line:
System.out.println("default");
The line will not be executed, but it will appear as if it would in the debugger.
---
public class Test {
public static void main(String... args) {
new Test().test("a");
}
private void test(String s) {
if (s != null) {
switch (s) {
case "a":
System.out.println("a"); //breakpoint here, and continue with step-over
break;
default:
System.out.println("default"); //the program counter will be shown here eventually
}
} else {
System.out.println("null");
}
}
}
---
Place a breakpoint at the marked line, and continue with step-over. After a few steps, the current program counter marker will be at the line:
System.out.println("default");
The line will not be executed, but it will appear as if it would in the debugger.
- relates to
-
JDK-6906748 Project Coin: Minor strings in switch cleanup
- Closed
-
JDK-8314275 Incorrect stepping in switch
- Resolved
-
JDK-6827009 Project Coin: Strings in Switch
- Closed