You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Running Java.Interop.Dynamic-Tests would result in lots of
"Deleting JNI local reference handle <HANDLE> from wrong thread"
messages written to the JNI local reference log. These were coming
from all the various JniType instances involved ~everywhere:
* JniPeerMembers.JniPeerType
* JavaMethodInvokeInfo.ReturnType
* JavaMethodInvokeInfo.Arguments
* JavaMethodInvokeInfo.Method
Plus associated Jni*FieldID and Jni*MethodID values (though those
won't cause the above "Deleting..." messages.)
There are two plausible fixes:
1. Stop using JNI Local References for everything!
#6
JNI Handles would still need to be used, but by making them
*Global* references the GC can freely clean them up.
2. Add an explicit cleanup mechanism.
We're opting for (2) for now. :-)
((1) is later.)
That said, (2) is usually done by implementing IDisposable, which
we're doing for DynamicJavaClass. Why not have JniPeerMembers and
company implement IDisposable?
Because I don't want some asshole coming through and going:
var o = new JavaObject();
o.JniPeerMembers.Dispose();
...which would promptly blow up fucking everything.
Instead, we're adding a *static* JniPeerMembers.Dispose() method,
which won't show up in normal JniPeerMembers code completion, and will
prevent using JniPeerMembers instances in `using` blocks.
Once JniPeerMembers has a cleanup method, extend DynamicJavaClass to
implement IDispoable. This allows our tests to cleanup after
themselves, reducing spam to the LREF log.
0 commit comments