Exemple #1
0
        public jvmtiError GetSourceFileName(JvmVirtualMachineRemoteHandle virtualMachine, JvmClassRemoteHandle @class, out string sourceName)
        {
            JavaVM machine = JavaVM.GetInstance(virtualMachine);

            string     sourceNameResult = null;
            jvmtiError result           = jvmtiError.Internal;

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

                IntPtr sourceNamePtr = IntPtr.Zero;
                try
                {
                    result = rawInterface.GetSourceFileName(environment.Handle, @class, out sourceNamePtr);

                    unsafe
                    {
                        if (sourceNamePtr != IntPtr.Zero)
                        {
                            sourceNameResult = ModifiedUTF8Encoding.GetString((byte *)sourceNamePtr);
                        }
                    }
                }
                finally
                {
                    rawInterface.Deallocate(environment.Handle, sourceNamePtr);
                }
            });

            sourceName = sourceNameResult;
            return(result);
        }