Skip to content

Instantly share code, notes, and snippets.

@boggle
Created October 28, 2010 17:21
Show Gist options
  • Save boggle/651843 to your computer and use it in GitHub Desktop.
Save boggle/651843 to your computer and use it in GitHub Desktop.
attempt at runtime type system breakage w exceptions
public final class EvilEx {
public final static class Complain extends Throwable {
}
private static Throwable[] _complain = { new Complain() };
static void complain() throws Exception {
System.out.println("I fart in your general direction");
throw ((Exception[])_complain)[0];
}
public static void main(String[] args) {
growl();
System.out.println("Type-safety... fail!");
}
public static void growl() {
System.out.println("The duke will puke");
try {
complain();
System.out.println("Heeha");
System.exit(0);
}
catch (Exception e) {
System.out.println("Type-safety... check!");
}
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment