public static void printSite(Site s, StringBuilder out) { if (s == null) { out.append("(null)"); return; } StackTraceElement[] st = s.site(); int interestingSitesPrinted = 0; for (int i = s.offset; i < st.length; i++) { StackTraceElement e = st[i]; String fileName = e.getFileName(); if (THIS_FILE_NAME.equals(fileName)) { continue; } out.append(" " + e.getMethodName() + "(" + e.getFileName() + ":" + e.getLineNumber() + ")"); interestingSitesPrinted++; if (interestingSitesPrinted <= SITES_TO_PRINT) { continue; } if (fileName == null || "View.java".equals(fileName)) { continue; } String methodName = e.getMethodName(); if (skipMethods.contains(methodName)) { continue; } break; } }
public static void printElement(Site s, int index) { if (s == null || index >= s.site().length) { ps.print("(null)"); } else { StackTraceElement e = s.site()[index]; ps.print(e.getMethodName() + " (" + e.getFileName() + ":" + e.getLineNumber() + ")"); } }
public static void printElements(Site s, int index, int nelems) { if (s == null || index >= s.site().length) { ps.print("(null)"); } else { for (int i = 0; i < nelems; i++) { int j = index + i; if (j >= s.site().length) { break; } if (i > 0) { ps.print(", "); } StackTraceElement e = s.site()[j]; ps.print(e.getMethodName() + " (" + e.getFileName() + ":" + e.getLineNumber() + ")"); } } }
protected static boolean wasCalledDuringClassLoading() { if (LOCK.isHeldByCurrentThread()) return true; LOCK.lock(); try { StackTrace st = new StackTrace(new Throwable()); int n = st.getDepth(); for (int i = 3; i < n; i++) { StackTraceElement ste = st.getElement(i); if ("ClassLoader.java".equals(ste.getFileName()) && "loadClass".equals(ste.getMethodName())) { return true; } } return false; } finally { LOCK.unlock(); } }