Created
October 28, 2010 17:21
-
-
Save boggle/651843 to your computer and use it in GitHub Desktop.
attempt at runtime type system breakage w exceptions
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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