1 8 package org.codehaus.aspectwerkz.util; 9 10 import java.util.List ; 11 import java.util.ArrayList ; 12 import java.util.Iterator ; 13 14 19 public final class StackTraceHelper { 20 21 27 public static void hideFrameworkSpecificStackTrace(final Throwable exception, final String className) { 28 if (exception == null) { 29 throw new IllegalArgumentException ("exception can not be null"); 30 } 31 if (className == null) { 32 throw new IllegalArgumentException ("class name can not be null"); 33 } 34 final List newStackTraceList = new ArrayList (); 35 final StackTraceElement [] stackTrace = exception.getStackTrace(); 36 int i; 37 for (i = 1; i < stackTrace.length; i++) { 38 if (stackTrace[i].getClassName().equals(className)) { 39 break; 40 } 41 } 42 for (int j = i; j < stackTrace.length; j++) { 43 newStackTraceList.add(stackTrace[j]); 44 } 45 final StackTraceElement [] newStackTrace = new StackTraceElement [newStackTraceList.size()]; 46 int k = 0; 47 for (Iterator it = newStackTraceList.iterator(); it.hasNext(); k++) { 48 final StackTraceElement element = (StackTraceElement ) it.next(); 49 newStackTrace[k] = element; 50 } 51 exception.setStackTrace(newStackTrace); 52 } 53 } | Popular Tags |