private static void ReleaseJavaObject(int jvmid, JOBJECT64 handle, bool isLegacy) { Debug.Assert(handle.Value != 0); // Note: We need the "ReleaseXxx" method to be static, as we can't depend // on any other managed object for calling into the WindowsAccessBridge // DLL. Also, we depend on the fact the CLR tries to load the method from // the DLL only when the method is actually called. This allows us to work // correctly on either a 64-bit or 32-bit. if (isLegacy) { ReleaseJavaObjectFP_Legacy(jvmid, (int)handle.Value); } else { if (IntPtr.Size == 4) { ReleaseJavaObjectFP_32(jvmid, handle.Value); } else { ReleaseJavaObjectFP_64(jvmid, handle.Value); } } }
private static void RecordDeactivation(JOBJECT64 handle) { if (handle.Value != 0) { Interlocked.Decrement(ref _activeCount); } }
public JavaObjectHandle(int jvmId, JOBJECT64 handle) { _jvmId = jvmId; _handle = handle; _isLegacy = false; if (handle.Value == 0) { GC.SuppressFinalize(this); } RecordActivation(handle); }
private static void EnqueueRelease(int jvmid, JOBJECT64 handle, bool isLegacy) { // Skip NULL handles, they don't need to be released. if (handle.Value == 0) { return; } lock (_releaseQueue) { _releaseQueue.Add(new ReleaseData { JvmId = jvmid, Handle = handle, IsLegacy = isLegacy }); } }