A few things to note:
-logger is already an instance of log4j, which does pretty much everything anyway
-this code has been copied entirely from another source code file in the same directory
-I have no idea WTF is going on here.
public void warn(Object msg, Throwable t) {
logger.log(FQCN, Level.WARN, msg, t);
logNestedException(Level.WARN, msg, t);
}
void logNestedException(Level level, Object msg, Throwable t) {
if(t == null)
return;
try {
Class tC = t.getClass();
Method mA[] = tC.getMethods();
Method nextThrowableMethod = null;
for(int i=0; i < mA.length ; i++) {
if(("getCause".equals(mA[i].getName()) && !JDK14)
|| "getRootCause".equals(mA[i].getName())
|| "getNextException".equals( mA[i].getName())
|| "getException".equals( mA[i].getName())) {
// check param types
Class params[] = mA[i].getParameterTypes();
if(params==null || params.length==0) {
// just found the getter for the nested throwable
nextThrowableMethod=mA[i];
break; // no need to search further
}
}
}
if(nextThrowableMethod != null) {
// get the nested throwable and log it
Throwable nextT=(Throwable)nextThrowableMethod.invoke(t, new
Object[0]);
if(nextT != null) {
this.logger.log(FQCN, level, "Previous log CONTINUED: ", nextT);
}
}
} catch(Exception e) {
// do nothing
}
}