Beispiel #1
0
        public jvmtiError GetClassSignature(JvmVirtualMachineRemoteHandle virtualMachine, JvmClassRemoteHandle @class, out string signature, out string generic)
        {
            JavaVM machine = JavaVM.GetInstance(virtualMachine);

            string     signatureResult = null;
            string     genericResult   = null;
            jvmtiError result          = jvmtiError.Internal;

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

                IntPtr signaturePtr = IntPtr.Zero;
                IntPtr genericPtr   = IntPtr.Zero;
                try
                {
                    result = rawInterface.GetClassSignature(environment.Handle, @class, out signaturePtr, out genericPtr);

                    unsafe
                    {
                        if (signaturePtr != IntPtr.Zero)
                        {
                            signatureResult = ModifiedUTF8Encoding.GetString((byte *)signaturePtr);
                        }
                        if (genericPtr != IntPtr.Zero)
                        {
                            genericResult = ModifiedUTF8Encoding.GetString((byte *)genericPtr);
                        }
                    }
                }
                finally
                {
                    rawInterface.Deallocate(environment.Handle, signaturePtr);
                    rawInterface.Deallocate(environment.Handle, genericPtr);
                }
            });

            signature = signatureResult;
            generic   = genericResult;
            return(result);
        }