package omgrofl.jit;

import java.lang.reflect.InvocationTargetException;
import java.util.logging.Level;
import java.util.logging.Logger;

public class JavaBytecodeRunner extends ClassLoader {
    
    private JavaBytecodeRunner() { }
    
    public static void run(byte[] bytecode, String className) {
        try {
            JavaBytecodeRunner bytecodeRunner = new JavaBytecodeRunner();
            Class newClass = bytecodeRunner.defineClass(className, bytecode, 0, bytecode.length);
            newClass.getMethods()[0].invoke(null, new Object[] {null});
        } catch (IllegalAccessException ex) {
            Logger.getLogger(JavaBytecodeRunner.class.getName()).log(Level.SEVERE, null, ex);
        } catch (IllegalArgumentException ex) {
            Logger.getLogger(JavaBytecodeRunner.class.getName()).log(Level.SEVERE, null, ex);
        } catch (InvocationTargetException ex) {
            Logger.getLogger(JavaBytecodeRunner.class.getName()).log(Level.SEVERE, null, ex);
        }
    }
}

@@ -131,16 +131,49 @@
 .Logger;
+%0Aimport java.lang.reflect.Method;
 %0A%0Apublic
@@ -528,16 +528,35 @@
         
+ Method%5B%5D methods =
  newClas
@@ -573,46 +573,229 @@
 ds()
-%5B0%5D.invoke(null, new Object%5B%5D %7Bnull%7D);
+;%0A            for (Method method : methods) %7B%0A                if (%22main%22.equals(method.getName())) %7B%0A                    method.invoke(null, new Object%5B%5D %7Bnull%7D);%0A                    break;%0A                %7D%0A            %7D
 %0A   

Fix JavaBytecodeRunner