Counts the number of duplicate stack frames, starting from the end of the stack. @param currentStack a stack to compare @param parentStack a stack to compare @return the number of duplicate stack frames.
(StackTraceElement[] currentStack,
StackTraceElement[] parentStack)
| 220 | * @return the number of duplicate stack frames. |
| 221 | */ |
| 222 | private static int countDuplicates(StackTraceElement[] currentStack, |
| 223 | StackTraceElement[] parentStack) { |
| 224 | int duplicates = 0; |
| 225 | int parentIndex = parentStack.length; |
| 226 | for (int i = currentStack.length; --i >= 0 && --parentIndex >= 0;) { |
| 227 | StackTraceElement parentFrame = parentStack[parentIndex]; |
| 228 | if (parentFrame.equals(currentStack[i])) { |
| 229 | duplicates++; |
| 230 | } else { |
| 231 | break; |
| 232 | } |
| 233 | } |
| 234 | return duplicates; |
| 235 | } |
| 236 | |
| 237 | /** |
| 238 | * Returns an array of StackTraceElements. Each StackTraceElement represents |