in stetho/src/main/java/com/facebook/stetho/dumpapp/plugins/CrashDumperPlugin.java [113:145]
private void doUncaughtException(Iterator<String> argsIter) throws DumpException {
String throwableClassString = ArgsHelper.nextOptionalArg(argsIter, OPTION_THROW_DEFAULT);
try {
Class<? extends Throwable> throwableClass =
(Class<? extends Throwable>)Class.forName(throwableClassString);
Throwable t;
Constructor<? extends Throwable> ctorWithMessage =
tryGetDeclaredConstructor(throwableClass, String.class);
if (ctorWithMessage != null) {
t = ctorWithMessage.newInstance("Uncaught exception triggered by Stetho");
} else {
Constructor<? extends Throwable> ctorParameterless =
throwableClass.getDeclaredConstructor();
t = ctorParameterless.newInstance();
}
Thread crashThread = new Thread(new ThrowRunnable(t));
crashThread.start();
Util.joinUninterruptibly(crashThread);
} catch (
ClassNotFoundException |
ClassCastException |
NoSuchMethodException |
IllegalAccessException |
InstantiationException e) {
throw new DumpException("Invalid supplied Throwable class: " + e);
} catch (InvocationTargetException e) {
// This means that the method invoked actually threw, independent of reflection. Best
// reflect that as a normal unchecked exception in dumpapp output.
throw ExceptionUtil.propagate(e.getCause());
}
}