Содержание
- 2. VI. Исключения 2. Классы исключений
- 4. Класс Throwable public class Throwable implements Serializable { private String detailMessage; public Throwable() { fillInStackTrace(); }
- 5. Получение информации об исключении public class ExceptionMethodsDemo { public static void main(String[] args) { try {
- 6. Стек вызовов
- 8. Класс Throwable public class Throwable implements Serializable { private StackTraceElement[] stackTrace; public void printStackTrace() { printStackTrace(System.err);
- 9. Стек вызовов public class StackTraceDemo { static void methodA() throws Exception { throw new Exception(); }
- 10. Стек вызовов public class StackTraceDemo { ... public static void main(String[] args) { try { methodA();
- 11. Стек вызовов methodA main -------------------------------- methodA methodB main -------------------------------- methodA methodB methodC main
- 12. Стек вызовов public class AnotherStackTraceDemo { ... public static void main(String[] args) { try { methodA();
- 13. Стек вызовов java.lang.Exception at classes.AnotherStackTraceDemo.methodA(AnotherStackTraceDemo.java:6) at classes.AnotherStackTraceDemo.main(AnotherStackTraceDemo.java:19) -------------------------------- java.lang.Exception at classes.AnotherStackTraceDemo.methodA(AnotherStackTraceDemo.java:6) at classes.AnotherStackTraceDemo.methodB(AnotherStackTraceDemo.java:10) at classes.AnotherStackTraceDemo.main(AnotherStackTraceDemo.java:26) --------------------------------
- 14. Элемент стека вызовов
- 15. Класс Throwable public class Throwable implements Serializable { public void setStackTrace(StackTraceElement[] stackTrace) { StackTraceElement[] defensiveCopy =
- 16. Класс StackTraceElement public class StackTraceElement implements java.io.Serializable { private String declaringClass; private String methodName; private String
- 17. Элемент стека вызовов public class StackTraceElementDemo { public static void main(String[] args) { try { methodA();
- 18. Перебрасывание исключений из блока catch
- 20. Перебрасывание исключений public class RethrowingDemo { public static void methodA() throws Exception { System.out.println("Originating the exception
- 21. Перебрасывание исключений public class RethrowingDemo { public static void main(String[] args) { try { methodB(); }
- 22. Перебрасывание исключений Originating the exception in methodA() Inside methodB java.lang.Exception: Thrown from methodA() at classes.RethrowingDemo.methodA(RethrowingDemo.java:7) at
- 23. Сцепленные исключения
- 25. Не сцепленные исключения public class NoChainedExceptionDemo { public static void methodA() throws Exception { System.out.println("Originating the
- 26. Не сцепленные исключения Originating the exception in methodA() Throwing new exception in methodB() Throwing new exception
- 27. final final final Класс Throwable public class Throwable implements Serializable { private Throwable cause = this;
- 28. final final final Класс Throwable public class Throwable implements Serializable { public void printStackTrace(PrintStream s) {
- 29. Сцепленные исключения public class ChainedExceptionDemo { public static void methodA() throws Exception { System.out.println("Originating the exception
- 30. Сцепленные исключения Originating the exception in methodA() Throwing new exception in methodB() Throwing new exception in
- 32. Скачать презентацию