문서의 선택한 두 판 사이의 차이를 보여줍니다.
다음 판 | 이전 판 마지막 판 양쪽 다음 판 | ||
java:exception [2014/01/22 12:58] kwon37xi 새로 만듦 |
java:exception [2017/06/25 14:04] kwon37xi [Checked Exception] |
||
---|---|---|---|
줄 1: | 줄 1: | ||
====== Java Exception ====== | ====== Java Exception ====== | ||
+ | * [[http:// | ||
===== Checked Exception ===== | ===== Checked Exception ===== | ||
가능하면 사용하지 말 것. | 가능하면 사용하지 말 것. | ||
- | * [[http:// | + | * [[http:// |
- | class Thrower | + | * [[http:// |
- | public static void spit(final Throwable | + | public |
- | | + | private ExceptionThrower() {} |
- | @SuppressWarnings(" | + | |
- | private void sneakyThrow(Throwable exception) throws T { | + | public static void spit(final Throwable |
- | throw (T) exception; | + | |
- | } | + | |
- | | + | |
- | new EvilThrower().sneakyThrow(exception); | + | |
} | } | ||
- | } | ||
- | public class ThrowerSample { | + | @SuppressWarnings(" |
- | | + | |
- | | + | |
+ | // 실제 캐스팅은 발생하지 않는다. | ||
+ | throw (T) throwable; | ||
} | } | ||
} | } | ||
+ | |||
+ | ExceptionThrower.spit(new IOException(" | ||
</ | </ | ||
- | * [[http:// |