Migrate a bug fix for printStackTrace which was done before the JAXP 1.3 integration

back to the head.


git-svn-id: https://svn.apache.org/repos/asf/xml/commons/trunk@226231 13f79535-47bb-0310-9956-ffa450edef68
This commit is contained in:
mkwan 2005-06-14 19:13:40 +00:00
parent c3fa88a3b2
commit 57c5a282f3

View File

@ -312,49 +312,62 @@ public class TransformerException extends Exception {
super.printStackTrace(s);
} catch (Throwable e) {}
Throwable exception = getException();
boolean isJdk14OrHigher = false;
try {
Throwable.class.getMethod("getCause",null);
isJdk14OrHigher = true;
} catch (NoSuchMethodException nsme) {
// do nothing
}
for (int i = 0; (i < 10) && (null != exception); i++) {
s.println("---------");
// The printStackTrace method of the Throwable class in jdk 1.4
// and higher will include the cause when printing the backtrace.
// The following code is only required when using jdk 1.3 or lower
if (!isJdk14OrHigher) {
Throwable exception = getException();
try {
if (exception instanceof TransformerException) {
String locInfo =
((TransformerException) exception)
for (int i = 0; (i < 10) && (null != exception); i++) {
s.println("---------");
try {
if (exception instanceof TransformerException) {
String locInfo =
((TransformerException) exception)
.getLocationAsString();
if (null != locInfo) {
s.println(locInfo);
if (null != locInfo) {
s.println(locInfo);
}
}
exception.printStackTrace(s);
} catch (Throwable e) {
s.println("Could not print stack trace...");
}
exception.printStackTrace(s);
} catch (Throwable e) {
s.println("Could not print stack trace...");
}
try {
Method meth =
((Object) exception).getClass().getMethod("getException",
try {
Method meth =
((Object) exception).getClass().getMethod("getException",
null);
if (null != meth) {
Throwable prev = exception;
if (null != meth) {
Throwable prev = exception;
exception = (Throwable) meth.invoke(exception, null);
exception = (Throwable) meth.invoke(exception, null);
if (prev == exception) {
break;
if (prev == exception) {
break;
}
} else {
exception = null;
}
} else {
} catch (InvocationTargetException ite) {
exception = null;
} catch (IllegalAccessException iae) {
exception = null;
} catch (NoSuchMethodException nsme) {
exception = null;
}
} catch (InvocationTargetException ite) {
exception = null;
} catch (IllegalAccessException iae) {
exception = null;
} catch (NoSuchMethodException nsme) {
exception = null;
}
}
// insure output is written