문서의 선택한 두 판 사이의 차이를 보여줍니다.
양쪽 이전 판 이전 판 | 다음 판 양쪽 다음 판 | ||
java:exception [2014/01/22 13:06] kwon37xi [Checked Exception] |
java:exception [2014/01/22 13:20] kwon37xi [Checked Exception] |
||
---|---|---|---|
줄 3: | 줄 3: | ||
===== 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< | + | |
} | } | ||
- | } | ||
- | public class ThrowerSample { | + | @SuppressWarnings(" |
- | | + | |
- | | + | |
+ | // 실제 캐스팅은 발생하지 않는다. | ||
+ | throw (T) throwable; | ||
} | } | ||
} | } | ||
- | </ | + | |
- | * [[http:// | + | |
public final class UncheckedThrow { | public final class UncheckedThrow { | ||
private UncheckedThrow(){} | private UncheckedThrow(){} |