Ви не можете вибрати більше 25 тем Теми мають розпочинатися з літери або цифри, можуть містити дефіси (-) і не повинні перевищувати 35 символів.

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980
  1. /* *******************************************************************
  2. * Copyright (c) 1999-2001 Xerox Corporation,
  3. * 2002 Palo Alto Research Center, Incorporated (PARC),
  4. * 2004 Contributors.
  5. * All rights reserved.
  6. * This program and the accompanying materials are made available
  7. * under the terms of the Eclipse Public License v1.0
  8. * which accompanies this distribution and is available at
  9. * http://www.eclipse.org/legal/epl-v10.html
  10. *
  11. * Contributors:
  12. * Xerox/PARC initial implementation
  13. * ******************************************************************/
  14. package org.aspectj.lang;
  15. import java.io.PrintStream;
  16. import java.io.PrintWriter;
  17. /**
  18. * Wrapper for checked exceptions matched by a 'declare soft'.
  19. * You can soften checked exceptions at join points by using
  20. * the form <code>declare soft: TypePattern: Pointcut</code>.
  21. * At the join points, any exceptions thrown which match
  22. * TypePattern will be wrapped in <code>SoftException</code>
  23. * and rethrown. You can get the original exception using
  24. * <code>getWrappedThrowable()</code> or
  25. * <code>getCause()</code>.
  26. */
  27. public class SoftException extends RuntimeException {
  28. private static final boolean HAVE_JAVA_14;
  29. static {
  30. boolean java14 = false;
  31. try {
  32. Class.forName("java.nio.Buffer");
  33. java14 = true;
  34. } catch (Throwable t) {
  35. // still false;
  36. }
  37. HAVE_JAVA_14 = java14;
  38. }
  39. // shouldn't field be private final, constructor default or private?
  40. // but either would be a binary incompatible change.
  41. Throwable inner;
  42. public SoftException(Throwable inner) {
  43. super();
  44. this.inner = inner;
  45. }
  46. public Throwable getWrappedThrowable() { return inner; }
  47. public Throwable getCause() { return inner; }
  48. public void printStackTrace() {
  49. printStackTrace(System.err);
  50. }
  51. public void printStackTrace(PrintStream stream) {
  52. super.printStackTrace(stream);
  53. final Throwable _inner = this.inner;
  54. if (!HAVE_JAVA_14 && (null != _inner)) {
  55. stream.print("Caused by: ");
  56. _inner.printStackTrace(stream);
  57. }
  58. }
  59. public void printStackTrace(PrintWriter stream) {
  60. super.printStackTrace(stream);
  61. final Throwable _inner = this.inner;
  62. if (!HAVE_JAVA_14 && (null != _inner)) {
  63. stream.print("Caused by: ");
  64. _inner.printStackTrace(stream);
  65. }
  66. }
  67. }