PageRenderTime 27ms CodeModel.GetById 18ms app.highlight 7ms RepoModel.GetById 1ms app.codeStats 0ms

/test/kilim/test/ex/ExBasicBlock.java

http://github.com/kilim/kilim
Java | 75 lines | 67 code | 8 blank | 0 comment | 7 complexity | 7436b354d0968046db237799565a3e62 MD5 | raw file
 1package kilim.test.ex;
 2
 3import kilim.Pausable;
 4import kilim.Task;
 5
 6public class ExBasicBlock {
 7    void noop() throws ArrayIndexOutOfBoundsException {
 8    }
 9    
10    static void pausable() throws Pausable {
11        "afakflkaflakd".getBytes();
12    }
13    
14    static int testFiber(Object testArgs1, Object[] testArgs) throws Pausable {
15      Task.getCurrentTask();
16      int a = 0, b = 0, c = 0, d = 0, e = 0, f = 0, g = 0;
17      for (int i = 0; i < g; i++) {
18        g = a + b + c + d + e + f;
19      }
20      return g;
21    }
22    
23    int loop() throws Pausable {
24        int sum = 0;
25        for (int i = 0; i < 10; i++) {
26            sum++;
27        }
28        return sum;
29    }
30
31    void nestedloop() throws Pausable {
32        for (int i = 0; i < 100; i++) {
33            while (i > 10) {
34                i--;
35            }
36        }
37    }
38    
39    void exception() throws Pausable {
40        try {
41            try {
42                pausable();
43            } catch (ArrayIndexOutOfBoundsException e) {
44                try {
45                    e.printStackTrace();
46                } catch (Throwable t) {
47                    noop();
48                }
49            }
50        } finally {
51            noop();
52        }
53    }
54    
55    void complex() throws Pausable {
56        double d = 10.0;
57        Object o = new Object();
58        for (int i = 0; i < 100; i++) {
59            try {
60                if (d > 10.3 && d < 10.5) {
61                    d = 20.0;
62                    try {
63                        synchronized(o) {
64                            o.hashCode();
65                        }
66                    } catch (RuntimeException re) {
67                        throw new Error(re.toString());
68                    }
69                }
70            } finally {
71                d = 100.0;
72            }
73        }
74    }
75}