-
Notifications
You must be signed in to change notification settings - Fork 54
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Make IJavaPeerable
implementable
#17
Comments
IJavaObject
implementableIJavaPeerable
implementable
A closely related problem is Xamarin.Android's The only way I can think of to make it work without an So that's a bit of a non-starter. |
At present, I can't think of a way to satisfy the goal of having a sanely designed API (no interfaces that can't actually be implemented) which is also usable and fulfills known compatibility and integration points. Keeping this open (for now) should a brain storm occur, but I don't see how it can happen. |
Related: https://bugzilla.xamarin.com/show_bug.cgi?id=37560 People see an interface, and try to manually implement, and shit breaks. Film at 11. Even if the interface were implementable...they'd probably implement it wrong, because they're clearly already trying to implement the interface even when the documentation explicitly says not to. |
Closing, as this seems unlikely at this point. |
After discussion with @jpobst, we can probably:
These changes would allow this to compile and work as expected: class MyRunnable : Java.Lang.IRunnable {
public void Run() { /* … */ }
} Doing this would require use of |
After some further thought… Can we implement var list = new Java.Util.ArrayList ();
lits.Add (new MyRunnable());
var r = (MyRunnable) list.Get (0); The problem is, this overlooks the GC bridge:
On Mono, the GC bridge currently requires that the type provide 4 fields ( var list = new Java.Util.ArrayList ();
lits.Add (new MyRunnable());
/* Do Something to cause the `MyRunnable` to be collected; GC.Collect(), etc. */
var r = (MyRunnable) list.Get (0);
// throws a `NotSupportedException` as there isn't an "activation constructor"
// for `MyRunnable` This can be "solved" by not using the existing GC bridge, a'la https://github.com/jonpryor/Java.Interop/commits/jonp-registration-scope , or by otherwise rethinking how cross-VM object references work. |
https://twitter.com/sh4na/status/600662831017676800
What's the problem with
IJavaPeerable
? It shouldn't be implemented by developers. Ever. (In theory it could be properly implemented. In practice, I wouldn't want to try to do so.)We should nuke the
IJavaPeerable
interface from the public API.Problem:
JniPeerMethods
and other types make use ofIJavaObject
, which would need to be fixed. Perhaps we could refactor things to remove the problematic members, e.g.IJavaPeerable.PeerReference
?The text was updated successfully, but these errors were encountered: