Esempio n. 1
0
        public jvmtiError GetClassMethods(JvmVirtualMachineRemoteHandle virtualMachine, JvmClassRemoteHandle @class, out JvmMethodRemoteHandle[] methods)
        {
            JavaVM machine = JavaVM.GetInstance(virtualMachine);

            List <JvmMethodRemoteHandle> methodsList = new List <JvmMethodRemoteHandle>();
            jvmtiError result = jvmtiError.Internal;

            machine.InvokeOnJvmThread(
                (environment) =>
            {
                jvmtiInterface rawInterface = environment.RawInterface;

                IntPtr methodsPtr = IntPtr.Zero;
                try
                {
                    int methodCount;
                    result = rawInterface.GetClassMethods(environment.Handle, @class, out methodCount, out methodsPtr);

                    unsafe
                    {
                        jmethodID *rawMethods = (jmethodID *)methodsPtr;
                        for (int i = 0; i < methodCount; i++)
                        {
                            methodsList.Add(new JvmMethodRemoteHandle(rawMethods[i]));
                        }
                    }
                }
                finally
                {
                    rawInterface.Deallocate(environment.Handle, methodsPtr);
                }
            });

            methods = methodsList.ToArray();
            return(result);
        }