When an event is announced in a recursive fashion, the *last* announce statement's body becomes the body for *all* event chains. This is due to using a single static variable to maintain body in the EventFrame. A test case follows.
public void event E { }
public class C {
public static void main(String[] args) {
new H();
new C().m();
}
public void m() {
announce E(){
System.out.println("first");
}
}
}
public class H {
public H() {
register(this);
}
static boolean again = true;
public void handler(E next) throws Throwable {
if (again) {
again = false;
announce E(){
System.out.println("second");
}
}
next.invoke();
System.out.println("handler");
}
when E do handler;
}
Expected output:
second
handler
first
handler
Observed output:
second
handler
second
handler
E.java
C.java
H.java