Created
June 3, 2015 07:25
-
-
Save frankkienl/06f4ba0da8e38e553258 to your computer and use it in GitHub Desktop.
Java Exceptions Testing. Finding out how re-throwing affects the stacktrace.
This file contains hidden or 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
//Java Exceptions Testing. Finding out how re-throwing affects the stacktrace. | |
//Tested in: http://www.compilejava.net/ | |
public class HelloWorld | |
{ | |
public static void main(String[] args) throws Exception | |
{ | |
testThrowUp(); | |
} | |
public static void testThrowUp(){ | |
testThrowUp1(); | |
} | |
public static void testThrowUp1(){ | |
testThrowUp2(); | |
} | |
public static void testThrowUp2(){ | |
testThrowUp3(); | |
} | |
public static void testThrowUp3(){ | |
testThrowUp4(); | |
} | |
public static void testThrowUp4(){ | |
throw new RuntimeException("Some Message"); | |
} | |
} | |
///////////////////////////////////////////////////// | |
public class HelloWorld | |
{ | |
public static void main(String[] args) throws Exception | |
{ | |
testThrowUp(); | |
} | |
public static void testThrowUp(){ | |
try {testThrowUp1();} catch (Exception up){ | |
throw up; | |
} | |
} | |
public static void testThrowUp1(){ | |
try {testThrowUp2();} catch (Exception up){ | |
throw up; | |
} | |
} | |
public static void testThrowUp2(){ | |
try {testThrowUp3(); } catch (Exception up){ | |
throw up; | |
} | |
} | |
public static void testThrowUp3(){ | |
try { | |
testThrowUp4(); | |
} catch (Exception up){ | |
throw up; | |
} | |
} | |
public static void testThrowUp4(){ | |
throw new RuntimeException("Some Message"); | |
} | |
} | |
/////////////////////////////////// | |
public class HelloWorld | |
{ | |
public static void main(String[] args) throws Exception | |
{ | |
testThrowUp(); | |
} | |
public static void testThrowUp(){ | |
try {testThrowUp1();} catch (Exception up){ | |
throw up; | |
} | |
} | |
public static void testThrowUp1(){ | |
try {testThrowUp2();} catch (Exception up){ | |
throw up; | |
} | |
} | |
public static void testThrowUp2(){ | |
try {testThrowUp3(); } catch (Exception up){ | |
throw up; | |
} | |
} | |
public static void testThrowUp3() { | |
try { | |
testThrowUp4(); | |
} catch (Exception up){ | |
throw new RuntimeException(up); | |
} | |
} | |
public static void testThrowUp4(){ | |
throw new RuntimeException("Some Message"); | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment