List of usage examples for java.lang Throwable Throwable
public Throwable()
From source file:de.micromata.genome.logging.LogStacktraceAttribute.java
/** * Instantiates a new log stacktrace attribute. *//* ww w. j av a 2 s . c om*/ public LogStacktraceAttribute() { super(GenomeAttributeType.Stacktrace, ""); stackTraceElements = new Throwable().getStackTrace(); skipLeadingStacktraces = new String[] { "de.micromata.genome.logging.LogStacktraceAttribute" }; }
From source file:Alias2.java
public Test() { // Discover the name of the class this // object was created within: className = new Throwable().getStackTrace()[1].getClassName(); testStream = new TestStream(className); }
From source file:com.meterware.httpunit.HttpUnitUtils.java
/** * are we running in the Eclipse IDE?/* w ww .j av a2 s.c om*/ * @return whether we are running in the Eclipse environment */ public static boolean isEclipse() { StackTraceElement[] ste = new Throwable().getStackTrace(); return (ste[ste.length - 1].getClassName().startsWith("org.eclipse.jdt")); }
From source file:com.asakusafw.testdriver.TestDriverTestToolsBase.java
private static Method findCaller() { StackTraceElement[] trace = new Throwable().getStackTrace(); for (StackTraceElement element : trace) { try {/* www . j a v a2 s . c o m*/ Class<?> aClass = Class.forName(element.getClassName()); if (TestDriverTestToolsBase.class.isAssignableFrom(aClass)) { continue; } Method method = aClass.getDeclaredMethod(element.getMethodName()); return method; } catch (Exception e) { continue; } } throw new IllegalStateException( "?????????????"); }
From source file:com.zimbra.common.auth.twofactor.TOTPAuthenticator.java
private byte[] decode(String secret, Encoding encoding) throws ServiceException { byte[] decoded; switch (encoding) { case BASE32://from w w w .java 2 s.c om decoded = new Base32().decode(secret); break; case BASE64: decoded = Base64.decodeBase64(secret); break; default: throw ServiceException.FAILURE("unknown encoding", new Throwable()); } return decoded; }
From source file:jetbrains.exodus.query.BinaryOperator.java
BinaryOperator(@NotNull final NodeBase left, @NotNull final NodeBase right) { this.left = getUnderRoot(left); this.right = getUnderRoot(right); this.left.setParent(this); this.right.setParent(this); final int leftDepth = left instanceof BinaryOperator ? ((BinaryOperator) left).depth : 1; final int rightDepth = right instanceof BinaryOperator ? ((BinaryOperator) right).depth : 1; depth = leftDepth < rightDepth ? rightDepth + 1 : leftDepth + 1; if (isWarnEnabled && depth >= MAXIMUM_LEGAL_DEPTH && (depth % MAXIMUM_LEGAL_DEPTH) == 0) { final long millis = System.currentTimeMillis(); if (millis - lastLoggedMillis > LARGE_DEPTH_LOGGING_FREQ) { lastLoggedMillis = millis;/*from www. ja v a 2 s.c om*/ log.warn("Binary operator of too great depth", new Throwable()); } } }
From source file:org.eclipse.vjet.dsf.common.trace.DefaultTracer.java
public void enterMethod(final Object caller) { if (!m_traceEnabled) { return;//from w ww .j a v a 2s . c o m } if (caller == null) { return; } final Throwable t = new Throwable(); t.fillInStackTrace(); final String clsName = getClassName(caller); final String methodName = getMethodName(caller, t); push(clsName + DOT + methodName); dispatch(new WriterInvoker() { public void process(ITraceWriter w) { w.handleEnterMethod(m_traceDepth, clsName, methodName); } }); }
From source file:com.krawler.portal.util.ByteArrayMaker.java
public ByteArrayMaker() { super(defaultInitSize); if (collect) { _getInfo(new Throwable()); } }
From source file:net.ymate.platform.log.AbstractLogger.java
/** * ??//from ww w.ja v a 2s.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:com.krawler.portal.util.ByteArrayMaker.java
public ByteArrayMaker(int size) { super(size); if (collect) { _getInfo(new Throwable()); } }