diff options
author | chiba <chiba@30ef5769-5b8d-40dd-aea6-55b5d6557bb3> | 2005-08-26 06:48:26 +0000 |
---|---|---|
committer | chiba <chiba@30ef5769-5b8d-40dd-aea6-55b5d6557bb3> | 2005-08-26 06:48:26 +0000 |
commit | 57f386402fe50fd195c3469fc008727f1b66980c (patch) | |
tree | dd91fc88273cbd79d006d4f573e1a073c4607f3b | |
parent | 5e191f7f297bfbd53c4f65ffc66074572e6b5ac2 (diff) | |
download | javassist-57f386402fe50fd195c3469fc008727f1b66980c.tar.gz javassist-57f386402fe50fd195c3469fc008727f1b66980c.zip |
improved the compatibility with respect to chained exceptions.
git-svn-id: http://anonsvn.jboss.org/repos/javassist/trunk@199 30ef5769-5b8d-40dd-aea6-55b5d6557bb3
-rw-r--r-- | src/main/javassist/CannotCompileException.java | 51 |
1 files changed, 25 insertions, 26 deletions
diff --git a/src/main/javassist/CannotCompileException.java b/src/main/javassist/CannotCompileException.java index 6151a0f2..a16a4e5e 100644 --- a/src/main/javassist/CannotCompileException.java +++ b/src/main/javassist/CannotCompileException.java @@ -21,9 +21,30 @@ import javassist.compiler.CompileError; * Thrown when bytecode transformation has failed. */ public class CannotCompileException extends Exception { + private Throwable myCause; + + /** + * Gets the cause of this throwable. + * It is for JDK 1.3 compatibility. + */ + public Throwable getCause() { + return (myCause == this ? null : myCause); + } + + /** + * Initializes the cause of this throwable. + * It is for JDK 1.3 compatibility. + */ + public synchronized Throwable initCause(Throwable cause) { + myCause = cause; + return this; + } + private String message; - private Throwable cause; + /** + * Gets a long message if it is available. + */ public String getReason() { if (message != null) return message; @@ -39,7 +60,7 @@ public class CannotCompileException extends Exception { public CannotCompileException(String msg) { super(msg); message = msg; - cause = null; + initCause(null); } /** @@ -51,7 +72,7 @@ public class CannotCompileException extends Exception { public CannotCompileException(Throwable e) { super("by " + e.toString()); message = null; - cause = e; + initCause(e); } /** @@ -63,7 +84,7 @@ public class CannotCompileException extends Exception { */ public CannotCompileException(String msg, Throwable e) { this(msg); - cause = e; + initCause(e); } /** @@ -95,26 +116,4 @@ public class CannotCompileException extends Exception { public CannotCompileException(ClassFormatError e, String name) { this("invalid class format: " + name, e); } - - /** - * Prints this exception and its backtrace. - */ - public void printStackTrace(java.io.PrintWriter w) { - super.printStackTrace(w); - if (cause != null) { - w.println("Caused by:"); - cause.printStackTrace(w); - } - } - - /** - * Prints this exception and its backtrace. - */ - public void printStackTrace(java.io.PrintStream w) { - super.printStackTrace(w); - if (cause != null) { - w.println("Caused by:"); - cause.printStackTrace(w); - } - } } |