Skip to content

Instantly share code, notes, and snippets.

@andreoss
Created July 1, 2020 02:10
Show Gist options
  • Save andreoss/28d94ae44e17ff75502c59dcb41bb346 to your computer and use it in GitHub Desktop.
Save andreoss/28d94ae44e17ff75502c59dcb41bb346 to your computer and use it in GitHub Desktop.
import org.junit.Assert;
final class Loop extends Exception {
Loop(long max, Iter iter) throws Exception {
super(iter);
try {
Assert.assertTrue(max > 0);
throw new Loop(max - 1, new Iter(iter));
} catch (final AssertionError fal) {
throw new Exception(iter);
}
}
}
final class Iter extends Exception {
final long a;
final long b;
Iter(final long a, final long b) {
super(String.format("%d", a), null);
this.a = a;
this.b = b;
}
Iter(final Iter iter) {
super(String.format("%d", iter.a), iter);
this.a = iter.b;
this.b = iter.a + iter.b;
}
}
public final class Fibafail {
public static void main(final String[] args) throws Exception {
throw new Loop(20, new Iter(1, 1));
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment