use of co.paralleluniverse.common.util.ExtendedStackTrace in project quasar by puniverse.
the class Fiber method checkInstrumentation.
@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) && first.getDeclaringClass().getName().startsWith("co.paralleluniverse.fibers")))
return true;
}
boolean ok = true;
StringBuilder stackTrace = null;
final ExtendedStackTraceElement[] stes = st.get();
for (int i = 0; i < stes.length; i++) {
final ExtendedStackTraceElement ste = stes[i];
if (ste.getClassName().equals(Thread.class.getName()) && ste.getMethodName().equals("getStackTrace"))
continue;
if (ste.getClassName().equals(ExtendedStackTrace.class.getName()))
continue;
if (!ok)
printTraceLine(stackTrace, ste);
if (ste.getClassName().contains("$$Lambda$"))
continue;
if (!ste.getClassName().equals(Fiber.class.getName()) && !ste.getClassName().startsWith(Fiber.class.getName() + '$') && !ste.getClassName().equals(Stack.class.getName()) && !SuspendableHelper.isWaiver(ste.getClassName(), ste.getMethodName())) {
final Class<?> clazz = ste.getDeclaringClass();
final boolean classInstrumented = SuspendableHelper.isInstrumented(clazz);
final Member /*Executable*/
m = SuspendableHelper.lookupMethod(ste);
if (m != null) {
final boolean methodInstrumented = SuspendableHelper.isInstrumented(m);
final Pair<Boolean, Instrumented> callSiteInstrumented = SuspendableHelper.isCallSiteInstrumented(m, ste.getLineNumber(), ste.getBytecodeIndex(), stes, i);
if (!classInstrumented || !methodInstrumented || !callSiteInstrumented.getFirst()) {
if (ok)
stackTrace = initTrace(i, stes);
if (!classInstrumented || !methodInstrumented)
stackTrace.append(" **");
else if (!callSiteInstrumented.getFirst())
stackTrace.append(" !! (instrumented suspendable calls at: ").append(callSitesString(callSiteInstrumented.getSecond())).append(")");
ok = false;
}
} else {
if (ok)
stackTrace = initTrace(i, stes);
// Methods can only be found via source lines in @Instrumented annotations
stackTrace.append(" **");
ok = false;
}
} else if (ste.getClassName().equals(Fiber.class.getName()) && ste.getMethodName().equals("run1")) {
if (!ok) {
final String str = "Uninstrumented whole methods ('**') or single calls ('!!') detected: " + stackTrace;
if (Debug.isUnitTest())
throw new VerifyInstrumentationException(str);
System.err.println("WARNING: " + str);
}
return ok;
}
}
throw new IllegalStateException("Not run through Fiber.exec(). (trace: " + Arrays.toString(stes) + ")");
}
Aggregations