1   package org.apache.commons.javaflow.bytecode.transformation.rewrite;
2   
3   import org.apache.commons.javaflow.Continuation;
4   
5   import java.io.Serializable;
6   
7   
8   /**
9    * Test for making sure that rstack works correctly. For this test we need to
10   * have a stack frame that goes through multiple objects of different types.
11   * 
12   * @author Kohsuke Kawaguchi
13   */
14  public final class BlackRed implements Runnable, Serializable {
15  
16    public void run() {
17      // new Black( new Red( new Black( new Suspend()))).run();
18      new Black( new Suspend()).run();
19    }
20  
21    
22    class Black implements Runnable {
23      final Runnable r;
24  
25      public Black( Runnable r) {
26        this.r = r;
27      }
28  
29      public void run() {
30        String s = "foo"; // have some random variable
31        r.run();
32      }
33    }
34  
35    
36    class Red implements Runnable {
37      final Runnable r;
38  
39      public Red( Runnable r) {
40        this.r = r;
41      }
42  
43      public void run() {
44        int i = 5; // have some random variable
45        r.run();
46      }
47    }
48  
49    
50    class Suspend implements Runnable {
51      public void run() {
52        Continuation.suspend();
53      }
54    }
55  
56  }
57