Path: blob/master/test/jdk/com/sun/jdi/ControlFlow.java
41149 views
/* /nodynamiccopyright/ */ // hard coded linenumbers in other tests - DO NOT CHANGE1/*2* Debuggee which exercises various types of control flow3*/45class ControlFlow {6boolean b = true;7int n = 22;89public static void main(String args[]) throws Exception {10(new ControlFlow()).go();11}1213void go() throws Exception {14if (b) {15System.out.println("if, no else");16}1718if (b) {19System.out.println("if branch");20} else {21throw new Exception("Wrong branch!?");22}2324if (!b) {25throw new Exception("Wrong branch!?");26} else {27System.out.println("else branch");28}2930try {31throw new Exception();32} catch (Exception e) {33System.out.println("caught exception");34} finally {35System.out.println("finally");36}3738// This isn't control flow at the source level, but it is at the bytecode level39synchronized (this) {40System.out.println("synchronized");41}424344for (int i = 0; i < n; i++) {45System.out.println("Loop iteration: " + (i+1) + "/" + n);46}4748switch (n) {49case 0:50throw new Exception("Wrong branch!?");51case 1:52throw new Exception("Wrong branch!?");53case 2:54throw new Exception("Wrong branch!?");55case 3:56throw new Exception("Wrong branch!?");57case 22:58System.out.println("switch case");59break;60default:61throw new Exception("Wrong branch!?");62}6364switch (n) {65case 0:66throw new Exception("Wrong branch!?");67case 1:68throw new Exception("Wrong branch!?");69case 2:70throw new Exception("Wrong branch!?");71case 3:72throw new Exception("Wrong branch!?");73default:74System.out.println("switch default");75break;76}77}78}798081