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
The problem is that it is often desirable to dispose of handles ASAP because you "know" that the instances won't be used anymore:
using (var typeface = Typeface.Create (...)) {
// use typeface
}
The problem is that the above code is making an assumption that Typeface.Create() will be returning a new, unique, instance. If it doesn't (as is actually the case), then the returned wrapper could be shared with other threads, and if the handle is Dispose()d while another thread is using it...Bad Things™ happen.
The first half involves adding another "primitive" operation: in addition to JavaVM.GetValue() (Issue #2), we should have JavaVM.CreateValue() methods which always create a new, possibly aliasing, wrapper instance (if a wrapper would be used, e.g. vm.CreateValue<int>(...) clearly doesn't involve a wrapper...).
We would thus have two ways to turn a JNI handle into a value:
JavaVM.GetValue() to maintain object identity semantics, maintaining a single wrapper instance per encountered Java instance.
JavaVM.CreateValue(), which always creates a new wrapper (when required), allowing the caller to alwaysDispose() of it.
Activity
[Java.Runtime.Environment] Don't Destroy the JVM by default.
[Java.Runtime.Environment] Don't Destroy the JVM by default. (#65)