internal static void FreeArgs(JavaVMAttachArgs args) { args.Dispose(); }
internal static IntPtr AttachCurrentThread(JavaVMThreadAttachArguments arguments) { JavaVMAttachArgs attachArgs = new JavaVMAttachArgs(); if (arguments != null) { attachArgs = arguments.ToArgs(Instance.JvmConfiguration.Version); } try { unsafe { void** ppEnv = null; void* pArgs = null; if (arguments != null) { pArgs = &attachArgs; } int result = Instance.mInvokeInterface.AttachCurrentThread(Instance.mJavaVM, &ppEnv, pArgs); if (0 != result) { JniException.CheckVMErrorCode(result); } IntPtr environmentHandle = new IntPtr((void*)ppEnv); return environmentHandle; } } finally { if (arguments != null) { JavaVMThreadAttachArguments.FreeArgs(attachArgs); } } }