List of usage examples for java.lang StackTraceElement getClassName
public String getClassName()
From source file:com.atinternet.tracker.CrashDetectionHandler.java
/** * Get the class name where the exception thrown * * @param t Throwable// w w w.java 2s . c o m * @return String */ private String getClassNameException(Throwable t) { for (StackTraceElement element : t.getStackTrace()) { if (element.getClassName().contains(context.getApplicationContext().getPackageName())) { return element.getClassName(); } } return ""; }
From source file:org.codehaus.groovy.grails.exceptions.DefaultStackTraceFilterer.java
private List<StackTraceElement> filterTraceWithCutOff(StackTraceElement[] trace, String endPackage) { List<StackTraceElement> newTrace = new ArrayList<StackTraceElement>(); boolean foundGroovy = false; for (StackTraceElement stackTraceElement : trace) { String className = stackTraceElement.getClassName(); String fileName = stackTraceElement.getFileName(); if (!foundGroovy && fileName != null && fileName.endsWith(".groovy")) { foundGroovy = true;/* www . ja v a 2 s .c o m*/ } if (endPackage != null && className.startsWith(endPackage) && foundGroovy) break; if (isApplicationClass(className)) { if (stackTraceElement.getLineNumber() > -1) { newTrace.add(stackTraceElement); } } } return newTrace; }
From source file:CheckThreadViolationRepaintManager.java
private void checkThreadViolations(JComponent c) { if (!SwingUtilities.isEventDispatchThread() && (completeCheck || c.isShowing())) { boolean repaint = false; boolean fromSwing = false; boolean imageUpdate = false; StackTraceElement[] stackTrace = Thread.currentThread().getStackTrace(); for (StackTraceElement st : stackTrace) { if (repaint && st.getClassName().startsWith("javax.swing.")) { fromSwing = true;//from ww w . ja va 2s . c om } if (repaint && "imageUpdate".equals(st.getMethodName())) { imageUpdate = true; } if ("repaint".equals(st.getMethodName())) { repaint = true; fromSwing = false; } } if (imageUpdate) { // assuming it is java.awt.image.ImageObserver.imageUpdate(...) // image was asynchronously updated, that's ok return; } if (repaint && !fromSwing) { // no problems here, since repaint() is thread safe return; } // ignore the last processed component if (lastComponent != null && c == lastComponent.get()) { return; } lastComponent = new WeakReference<JComponent>(c); violationFound(c, stackTrace); } }
From source file:jext2.JextReentrantReadWriteLock.java
private String[] getElementsThatRequestedLock(StackTraceElement[] stack) { LinkedList<String> interresting = new LinkedList<String>(); for (StackTraceElement element : stack) { if (element.getClassName().contains("jext2") && !element.getClassName().contains("JextReentrantReadWriteLock")) { interresting.add(element.getFileName() + ":" + element.getLineNumber()); }//from w ww .j a v a2s .c o m } return interresting.toArray(new String[0]); }
From source file:net.ymate.platform.log.AbstractLogger.java
/** * ??/*w ww . j a va2s .c o m*/ * * @return ??className.methodName:lineNumber?NO_STACK_TRACE:-1 */ protected String __doMakeCallerInfo() { StackTraceElement[] _stacks = new Throwable().getStackTrace(); // ??? if (__depth >= 0 && _stacks.length > 1 + __depth) { StackTraceElement _element = _stacks[1 + __depth]; return StringUtils.substringBeforeLast(_element.getClassName(), ".").concat(".") .concat(_element.getMethodName()).concat(":") .concat(_element.getLineNumber() + StringUtils.EMPTY); } return "NO_STACK_TRACE:-1"; }
From source file:edu.cornell.mannlib.vitro.webapp.utils.developer.loggers.StackTraceUtility.java
public String format(boolean requested) { StringBuilder sb = new StringBuilder(); if (requested) { for (StackTraceElement ste : stackTrace) { sb.append(String.format(" %s.%s(%s:%d) \n", ste.getClassName(), ste.getMethodName(), ste.getFileName(), ste.getLineNumber())); }//from w ww . j a v a 2s. c om sb.append(" ...\n"); } return sb.toString(); }
From source file:org.mycore.common.content.MCRVFSContent.java
private String getDebugStacktrace() { StackTraceElement[] stackTrace = Thread.currentThread().getStackTrace(); int i = 0;//from w ww.jav a 2 s .com for (StackTraceElement se : stackTrace) { i++; if (se.getClassName().contains(getClass().getName()) && se.getMethodName().contains("close") || se.getMethodName().contains("getInputStream")) { break; } } return Stream.of(stackTrace).skip(i) .filter(s -> !(s.getClassName().equals(getClass()) && s.getMethodName().contains("Debug"))) .map(s -> "\tat " + s.toString()).collect(Collectors.joining(System.getProperty("line.separator"))); }
From source file:edu.cornell.mannlib.vitro.webapp.utils.developer.loggers.StackTraceUtility.java
private void trimStackTraceAtEnd(List<StackTraceElement> list) { ListIterator<StackTraceElement> iter = list.listIterator(); boolean trimming = false; while (iter.hasNext()) { StackTraceElement ste = iter.next(); if (trimming) { iter.remove();//from w w w . j a va 2 s .c om } else if (ste.getClassName().contains("ApplicationFilterChain")) { trimming = true; } } }
From source file:org.openbmp.Config.java
public void help() { HelpFormatter fmt = new HelpFormatter(); StackTraceElement[] stack = Thread.currentThread().getStackTrace(); StackTraceElement main = stack[stack.length - 1]; String mainClassName = main.getClassName(); fmt.printHelp(80, mainClassName, "\nOPTIONS:", options, "\n"); }
From source file:net.sf.jasperreports.engine.util.JdkGlyphFixTextMeasurer.java
protected boolean isJdkGlyphError(NullPointerException e) { StackTraceElement[] stackTrace = e.getStackTrace(); if (stackTrace.length == 0) { if (log.isDebugEnabled()) { log.debug("Caught exception with no stacktrace; " + (catchEmptyStacktrace ? "" : "not ") + "treating as JDK Glyph exception"); }/*from ww w .j ava 2s .c o m*/ return catchEmptyStacktrace; } StackTraceElement top = stackTrace[0]; return top.getClassName().startsWith(JDK_EXCEPTION_CLASS_PREFIX); }