package org.moe;

import org.moe.natj.objc.ObjCRuntime;

import java.lang.reflect.InvocationTargetException;
import java.lang.reflect.Method;
import java.util.Arrays;

/**
 * A launcher class that allows us run extra code before running the actual application.
 *
 * This is mainly used for registering the crash hook on main thread.
 */
public class IOSLauncher {
    public static void main(String[] args) throws InvocationTargetException, IllegalAccessException {
        // Register the crash hook for main thread
        ObjCRuntime.crashAppWhenExceptionUncaught();

        // Get the user main class
        String mainClassName = args[0];

        // Args that need to be passed to user main
        String[] realArgs = Arrays.copyOfRange(args, 1, args.length);

        // Invoke main method
        Method mainMethod;
        try {
            Class<?> c = Class.forName(mainClassName);
            mainMethod = c.getDeclaredMethod("main", String[].class);
        } catch (ClassNotFoundException | NoSuchMethodException e) {
            throw new RuntimeException("Cannot execute main method from class " + mainClassName, e);
        }
        mainMethod.invoke(null, (Object) realArgs);
    }
}

@@ -412,57 +412,17 @@
 ows 
-InvocationTargetException, IllegalAccessException
+Throwable
  %7B%0A 
@@ -1100,16 +1100,34 @@
       %7D%0A
+        try %7B%0A    
         
@@ -1166,20 +1166,166 @@
  realArgs);%0A
+        %7D catch (InvocationTargetException e) %7B%0A            // Thrown out the wrapped exception instead%0A            throw e.getCause();%0A        %7D%0A
     %7D%0A%7D%0A

Fix exception name in crash report (multi-os-engine/multi-os-engine#139)