summaryrefslogtreecommitdiffstats
path: root/runtime/src
diff options
context:
space:
mode:
authorwisberg <wisberg>2004-01-15 05:21:33 +0000
committerwisberg <wisberg>2004-01-15 05:21:33 +0000
commitad2fb7a583f7451f3101f8101b090999d6a43341 (patch)
tree9992a19e70f68b6c9a084322ad0f69b6e5449978 /runtime/src
parent9122ff2963909f54608b43cdb454a1282cbd9e16 (diff)
downloadaspectj-ad2fb7a583f7451f3101f8101b090999d6a43341.tar.gz
aspectj-ad2fb7a583f7451f3101f8101b090999d6a43341.zip
47952 fix: SoftException.printStackTrace(..) prints wrapped throwable (if not >= 1.4)
tested in 1.1, 1.3, 1.4 (but not in 1.1 release tests)
Diffstat (limited to 'runtime/src')
-rw-r--r--runtime/src/org/aspectj/lang/SoftException.java50
1 files changed, 47 insertions, 3 deletions
diff --git a/runtime/src/org/aspectj/lang/SoftException.java b/runtime/src/org/aspectj/lang/SoftException.java
index 406eb5272..b1ac84cb4 100644
--- a/runtime/src/org/aspectj/lang/SoftException.java
+++ b/runtime/src/org/aspectj/lang/SoftException.java
@@ -1,6 +1,7 @@
/* *******************************************************************
* Copyright (c) 1999-2001 Xerox Corporation,
- * 2002 Palo Alto Research Center, Incorporated (PARC).
+ * 2002 Palo Alto Research Center, Incorporated (PARC),
+ * 2004 Contributors.
* All rights reserved.
* This program and the accompanying materials are made available
* under the terms of the Common Public License v1.0
@@ -14,6 +15,9 @@
package org.aspectj.lang;
+import java.io.PrintStream;
+import java.io.PrintWriter;
+
/**
* Wrapper for checked exceptions matched by a 'declare soft'.
* You can soften checked exceptions at join points by using
@@ -21,10 +25,29 @@ package org.aspectj.lang;
* At the join points, any exceptions thrown which match
* TypePattern will be wrapped in <code>SoftException</code>
* and rethrown. You can get the original exception using
- * <code>getWrappedThrowable()</code>.
+ * <code>getWrappedThrowable()</code> or
+ * <code>getCause()</code>.
*/
public class SoftException extends RuntimeException {
- Throwable inner;
+
+ private static final boolean HAVE_JAVA_14;
+
+ static {
+ boolean java14 = false;
+ try {
+ Class.forName("java.nio.Buffer");
+ java14 = true;
+ } catch (Throwable t) {
+ // still false;
+ }
+ HAVE_JAVA_14 = java14;
+ }
+
+ // shouldn't field be private final, constructor default or private?
+ // but either would be a binary incompatible change.
+
+ Throwable inner;
+
public SoftException(Throwable inner) {
super();
this.inner = inner;
@@ -33,4 +56,25 @@ public class SoftException extends RuntimeException {
public Throwable getWrappedThrowable() { return inner; }
public Throwable getCause() { return inner; }
+ public void printStackTrace() {
+ printStackTrace(System.err);
+ }
+
+ public void printStackTrace(PrintStream stream) {
+ super.printStackTrace(stream);
+ final Throwable _inner = this.inner;
+ if (!HAVE_JAVA_14 && (null != _inner)) {
+ stream.print("Caused by: ");
+ _inner.printStackTrace(stream);
+ }
+ }
+
+ public void printStackTrace(PrintWriter stream) {
+ super.printStackTrace(stream);
+ final Throwable _inner = this.inner;
+ if (!HAVE_JAVA_14 && (null != _inner)) {
+ stream.print("Caused by: ");
+ _inner.printStackTrace(stream);
+ }
+ }
}