getMethod() private method

private getMethod ( global par0, java par1 ) : global::java.lang.reflect.Method
par0 global
par1 java
return global::java.lang.reflect.Method
Exemplo n.º 1
0
		protected override string DetermineCallingFunction() {
			System.Exception e = new System.Exception ();
			java.lang.Class c = vmw.common.TypeUtils.ToClass (e);
			java.lang.reflect.Method m = c.getMethod ("getStackTrace",
				new java.lang.Class [0]);
			java.lang.StackTraceElement [] els = (java.lang.StackTraceElement [])
				m.invoke (e, new object [0]);
			java.lang.StackTraceElement el = els [4];
			return el.getClassName () + "." + _ownerClass + "." + el.getMethodName ();
		}
    public virtual bool hasSuiteMethod(Class testClass)
    {
      try
      {
        testClass.getMethod("suite", new Class[0], SuiteMethodBuilder.__\u003CGetCallerID\u003E());
        goto label_3;
      }
      catch (NoSuchMethodException ex)
      {
      }
      return false;
label_3:
      return true;
    }
Exemplo n.º 3
0
 public static Test testFromSuiteMethod(Class klass)
 {
   InvocationTargetException invocationTargetException;
   try
   {
     Method method = klass.getMethod("suite", new Class[0], SuiteMethod.__\u003CGetCallerID\u003E());
     if (Modifier.isStatic(method.getModifiers()))
       return (Test) method.invoke((object) null, new object[0], SuiteMethod.__\u003CGetCallerID\u003E());
     string str = new StringBuilder().append(klass.getName()).append(".suite() must be static").toString();
     Throwable.__\u003CsuppressFillInStackTrace\u003E();
     throw new Exception(str);
   }
   catch (InvocationTargetException ex)
   {
     int num = 1;
     invocationTargetException = (InvocationTargetException) ByteCodeHelper.MapException<InvocationTargetException>((Exception) ex, (ByteCodeHelper.MapFlags) num);
   }
   throw Throwable.__\u003Cunmap\u003E(invocationTargetException.getCause());
 }
Exemplo n.º 4
0
        private java.lang.ClassLoader createClassLoader()
        {
            java.io.File[] jarFiles = this.getGroovyClasspath();

            java.net.URL[] jarFilesAsURLs = new java.net.URL[jarFiles.Length];
            for (int i = 0; i < jarFiles.Length; i++)
            {
                jarFilesAsURLs[i] = jarFiles[i].toURI().toURL();
            }
            java.net.URLClassLoader urlClassLoader = new java.net.URLClassLoader(jarFilesAsURLs, java.lang.ClassLoader.getSystemClassLoader());

            java.lang.Class          groovyClassLoaderClass = java.lang.Class.forName("groovy.lang.GroovyClassLoader", true, urlClassLoader);
            java.lang.reflect.Method addClassPathMethod     = groovyClassLoaderClass.getMethod("addClasspath", java.lang.Class.forName("java.lang.String"));
            java.lang.ClassLoader    groovyClassLoader      = (java.lang.ClassLoader)groovyClassLoaderClass.newInstance();
            foreach (java.io.File file in jarFiles)
            {
                addClassPathMethod.invoke(groovyClassLoader, file.getAbsolutePath());
            }
            this._groovyClassLoaderClass = groovyClassLoaderClass;

            return(groovyClassLoader);
        }
Exemplo n.º 5
0
    static int Main(string[] args)
    {
        Tracer.EnableTraceConsoleListener();
        Tracer.EnableTraceForDebug();
        System.Collections.Hashtable props = new System.Collections.Hashtable();
        string classpath = Environment.GetEnvironmentVariable("CLASSPATH");

        if (classpath == null || classpath == "")
        {
            classpath = ".";
        }
        props["java.class.path"] = classpath;
        bool   jar           = false;
        bool   saveAssembly  = false;
        bool   saveAssemblyX = false;
        bool   waitOnExit    = false;
        bool   showVersion   = false;
        string mainClass     = null;
        int    vmargsIndex   = -1;
        bool   debug         = false;
        String debugArg      = null;
        bool   noglobbing    = false;

        for (int i = 0; i < args.Length; i++)
        {
            String arg = args[i];
            if (arg[0] == '-')
            {
                if (arg == "-help" || arg == "-?")
                {
                    PrintHelp();
                    return(1);
                }
                else if (arg == "-X")
                {
                    PrintXHelp();
                    return(1);
                }
                else if (arg == "-Xsave")
                {
                    saveAssembly = true;
                    IKVM.Internal.Starter.PrepareForSaveDebugImage();
                }
                else if (arg == "-XXsave")
                {
                    saveAssemblyX = true;
                    IKVM.Internal.Starter.PrepareForSaveDebugImage();
                }
                else if (arg == "-Xtime")
                {
                    new Timer();
                }
                else if (arg == "-Xwait")
                {
                    waitOnExit = true;
                }
                else if (arg == "-Xbreak")
                {
                    System.Diagnostics.Debugger.Break();
                }
                else if (arg == "-Xnoclassgc")
                {
                    IKVM.Internal.Starter.ClassUnloading = false;
                }
                else if (arg == "-Xverify")
                {
                    IKVM.Internal.Starter.RelaxedVerification = false;
                }
                else if (arg == "-jar")
                {
                    jar = true;
                }
                else if (arg == "-version")
                {
                    Console.WriteLine(Startup.getVersionAndCopyrightInfo());
                    Console.WriteLine();
                    Console.WriteLine("CLR version: {0} ({1} bit)", Environment.Version, IntPtr.Size * 8);
                    System.Type type = System.Type.GetType("Mono.Runtime");
                    if (type != null)
                    {
                        Console.WriteLine("Mono version: {0}", type.InvokeMember("GetDisplayName", BindingFlags.InvokeMethod | BindingFlags.Static | BindingFlags.NonPublic, null, null, new object[0]));
                    }
                    foreach (Assembly asm in AppDomain.CurrentDomain.GetAssemblies())
                    {
                        Console.WriteLine("{0}: {1}", asm.GetName().Name, asm.GetName().Version);
                    }
                    string ver = java.lang.System.getProperty("openjdk.version");
                    if (ver != null)
                    {
                        Console.WriteLine("OpenJDK version: {0}", ver);
                    }
                    return(0);
                }
                else if (arg == "-showversion")
                {
                    showVersion = true;
                }
                else if (arg.StartsWith("-D"))
                {
                    arg = arg.Substring(2);
                    string[] keyvalue = arg.Split('=');
                    string   value;
                    if (keyvalue.Length == 2)                    // -Dabc=x
                    {
                        value = keyvalue[1];
                    }
                    else if (keyvalue.Length == 1) // -Dabc
                    {
                        value = "";
                    }
                    else // -Dabc=x=y
                    {
                        value = arg.Substring(keyvalue[0].Length + 1);
                    }
                    props[keyvalue[0]] = value;
                }
                else if (arg == "-ea" || arg == "-enableassertions")
                {
                    IKVM.Runtime.Assertions.EnableAssertions();
                }
                else if (arg == "-da" || arg == "-disableassertions")
                {
                    IKVM.Runtime.Assertions.DisableAssertions();
                }
                else if (arg == "-esa" || arg == "-enablesystemassertions")
                {
                    IKVM.Runtime.Assertions.EnableSystemAssertions();
                }
                else if (arg == "-dsa" || arg == "-disablesystemassertions")
                {
                    IKVM.Runtime.Assertions.DisableSystemAssertions();
                }
                else if (arg.StartsWith("-ea:") || arg.StartsWith("-enableassertions:"))
                {
                    IKVM.Runtime.Assertions.EnableAssertions(arg.Substring(arg.IndexOf(':') + 1));
                }
                else if (arg.StartsWith("-da:") || arg.StartsWith("-disableassertions:"))
                {
                    IKVM.Runtime.Assertions.DisableAssertions(arg.Substring(arg.IndexOf(':') + 1));
                }
                else if (arg == "-cp" || arg == "-classpath")
                {
                    props["java.class.path"] = args[++i];
                }
                else if (arg.StartsWith("-Xtrace:"))
                {
                    Tracer.SetTraceLevel(arg.Substring(8));
                }
                else if (arg.StartsWith("-Xmethodtrace:"))
                {
                    Tracer.HandleMethodTrace(arg.Substring(14));
                }
                else if (arg == "-Xdebug")
                {
                    debug = true;
                }
                else if (arg == "-Xnoagent")
                {
                    //ignore it, disable support for oldjdb
                }
                else if (arg.StartsWith("-Xrunjdwp") || arg.StartsWith("-agentlib:jdwp"))
                {
                    debugArg = arg;
                    debug    = true;
                }
                else if (arg.StartsWith("-Xreference:"))
                {
                    Startup.addBootClassPathAssembly(Assembly.LoadFrom(arg.Substring(12)));
                }
                else if (arg == "-Xnoglobbing")
                {
                    noglobbing = true;
                }
                else if (arg == "-XX:+AllowNonVirtualCalls")
                {
                    IKVM.Internal.Starter.AllowNonVirtualCalls = true;
                }
                else if (arg.StartsWith("-Xms") ||
                         arg.StartsWith("-Xmx") ||
                         arg.StartsWith("-Xss") ||
                         arg == "-Xmixed" ||
                         arg == "-Xint" ||
                         arg == "-Xincgc" ||
                         arg == "-Xbatch" ||
                         arg == "-Xfuture" ||
                         arg == "-Xrs" ||
                         arg == "-Xcheck:jni" ||
                         arg == "-Xshare:off" ||
                         arg == "-Xshare:auto" ||
                         arg == "-Xshare:on"
                         )
                {
                    Console.Error.WriteLine("Unsupported option ignored: {0}", arg);
                }
                else
                {
                    Console.Error.WriteLine("{0}: illegal argument", arg);
                    break;
                }
            }
            else
            {
                mainClass   = arg;
                vmargsIndex = i + 1;
                break;
            }
        }
        if (mainClass == null || showVersion)
        {
            Console.Error.WriteLine(Startup.getVersionAndCopyrightInfo());
            Console.Error.WriteLine();
        }
        if (mainClass == null)
        {
            PrintHelp();
            return(1);
        }
        try
        {
            if (debug)
            {
                // Starting the debugger
                Assembly asm       = Assembly.GetExecutingAssembly();
                String   arguments = debugArg + " -pid:" + System.Diagnostics.Process.GetCurrentProcess().Id;
                String   program   = new FileInfo(asm.Location).DirectoryName + "\\debugger.exe";
                try
                {
                    ProcessStartInfo info = new ProcessStartInfo(program, arguments);
                    info.UseShellExecute = false;
                    Process debugger = new Process();
                    debugger.StartInfo = info;
                    debugger.Start();
                }
                catch (Exception ex)
                {
                    Console.Error.WriteLine(program + " " + arguments);
                    throw ex;
                }
            }
            if (jar)
            {
                props["java.class.path"] = mainClass;
            }
            // like the JDK we don't quote the args (even if they contain spaces)
            props["sun.java.command"]  = String.Join(" ", args, vmargsIndex - 1, args.Length - (vmargsIndex - 1));
            props["sun.java.launcher"] = "SUN_STANDARD";
            Startup.setProperties(props);
            Startup.enterMainThread();
            string[] vmargs;
            if (noglobbing)
            {
                vmargs = new string[args.Length - vmargsIndex];
                System.Array.Copy(args, vmargsIndex, vmargs, 0, vmargs.Length);
            }
            else
            {
                // Startup.glob() uses Java code, so we need to do this after we've initialized
                vmargs = Startup.glob(args, vmargsIndex);
            }
            try
            {
                java.lang.Class clazz = sun.launcher.LauncherHelper.checkAndLoadMain(true, jar ? 2 : 1, mainClass);
                // we don't need to do any checking on the main method, as that was already done by checkAndLoadMain
                Method method = clazz.getMethod("main", typeof(string[]));
                // if clazz isn't public, we can still call main
                method.setAccessible(true);
                if (saveAssembly)
                {
                    java.lang.Runtime.getRuntime().addShutdownHook(new SaveAssemblyShutdownHook(clazz));
                }
                if (waitOnExit)
                {
                    java.lang.Runtime.getRuntime().addShutdownHook(new WaitShutdownHook());
                }
                try
                {
                    method.invoke(null, new object[] { vmargs });
                    return(0);
                }
                catch (InvocationTargetException x)
                {
                    throw x.getCause();
                }
            }
            finally
            {
                if (saveAssemblyX)
                {
                    IKVM.Internal.Starter.SaveDebugImage();
                }
            }
        }
        catch (System.Exception x)
        {
            java.lang.Thread thread = java.lang.Thread.currentThread();
            thread.getThreadGroup().uncaughtException(thread, ikvm.runtime.Util.mapException(x));
        }
        finally
        {
            Startup.exitMainThread();
        }
        return(1);
    }