diff options
-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); - } - } } |