public static ExtendedStackTrace of(Throwable t) { try { return new ExtendedStackTraceHotSpot(t); } catch (Throwable e) { return new ExtendedStackTrace(t); } }
@Override public Iterator<ExtendedStackTraceElement> iterator() { return Arrays.asList(get()).iterator(); }
@Override public Member getMethod() { if (method == null) { method = ExtendedStackTrace.this.getMethod(this); if (method != null && !getMethodName().equals(getName(method))) { throw new IllegalStateException("Method name mismatch: " + getMethodName() + ", " + method.getName()); // method = null; } } return method; }
protected /*Executable*/ Member getMethod(final ExtendedStackTraceElement este) { if (este.getDeclaringClass() == null) return null; Member[] ms = getMethods(este.getDeclaringClass()); Member method = null; final String desc = descriptor.get(); for (Member m : ms) { if (este.getMethodName().equals(getName(m)) && desc.equals(getDescriptor(m))) { method = m; break;
private static boolean checkInstrumentation() { return checkInstrumentation(ExtendedStackTrace.here()); }
@Override public void uncaughtException(Strand s, Throwable e) { System.err.print("Exception in Fiber \"" + s.getName() + "\" "); if (e instanceof NullPointerException || e instanceof ClassCastException || Exceptions.unwrap(e) instanceof NullPointerException || Exceptions.unwrap(e) instanceof ClassCastException) System.err.println("If this exception looks strange, perhaps you've forgotten to instrument a blocking method. Run your program with -Dco.paralleluniverse.fibers.verifyInstrumentation to catch the culprit!"); System.err.println(e); Strand.printStackTrace(threadToFiberStack(e.getStackTrace()), System.err); checkInstrumentation(ExtendedStackTrace.of(e), true); } };
@SuppressWarnings("null") private static boolean checkInstrumentation(ExtendedStackTrace st, boolean fromUncaughtExc) { if (fromUncaughtExc && st.get().length > 0 && st.get()[0] != null) { final ExtendedStackTraceElement first = st.get()[0]; if (!first.getDeclaringClass().equals(ClassCastException.class) && !(first.getDeclaringClass().equals(NullPointerException.class) && StringBuilder stackTrace = null; final ExtendedStackTraceElement[] stes = st.get(); for (int i = 0; i < stes.length; i++) { final ExtendedStackTraceElement ste = stes[i];