{"action":"created","issue":{"url":"https://api.github.com/repos/xamarin/java.interop/issues/38","repository_url":"https://api.github.com/repos/xamarin/java.interop","labels_url":"https://api.github.com/repos/xamarin/java.interop/issues/38/labels{/name}","comments_url":"https://api.github.com/repos/xamarin/java.interop/issues/38/comments","events_url":"https://api.github.com/repos/xamarin/java.interop/issues/38/events","html_url":"https://github.com/xamarin/java.interop/pull/38","id":157240207,"number":38,"title":"[generator] Qualify Java.Lang.Object.Handle references","user":{"login":"jonpryor","id":155958,"avatar_url":"https://avatars.githubusercontent.com/u/155958?v=3","gravatar_id":"","url":"https://api.github.com/users/jonpryor","html_url":"https://github.com/jonpryor","followers_url":"https://api.github.com/users/jonpryor/followers","following_url":"https://api.github.com/users/jonpryor/following{/other_user}","gists_url":"https://api.github.com/users/jonpryor/gists{/gist_id}","starred_url":"https://api.github.com/users/jonpryor/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/jonpryor/subscriptions","organizations_url":"https://api.github.com/users/jonpryor/orgs","repos_url":"https://api.github.com/users/jonpryor/repos","events_url":"https://api.github.com/users/jonpryor/events{/privacy}","received_events_url":"https://api.github.com/users/jonpryor/received_events","type":"User","site_admin":false},"labels":[{"url":"https://api.github.com/repos/xamarin/java.interop/labels/cla-already-signed","name":"cla-already-signed","color":"009800"}],"state":"open","locked":false,"assignee":null,"milestone":null,"comments":1,"created_at":"2016-05-27T16:07:40Z","updated_at":"2016-05-30T03:20:51Z","closed_at":null,"pull_request":{"url":"https://api.github.com/repos/xamarin/java.interop/pulls/38","html_url":"https://github.com/xamarin/java.interop/pull/38","diff_url":"https://github.com/xamarin/java.interop/pull/38.diff","patch_url":"https://github.com/xamarin/java.interop/pull/38.patch"},"body":"Android N Preview 2 adds some methods named `handle()`, such as\r\n`java.util.concurrent.CompletableFuture.handle()`. This clashes with\r\nthe Java.Lang.Object.Handle property, resulting in C# compiler errors\r\nwithin the generated binding code:\r\n\r\n\tif (Handle != IntPtr.Zero)\r\n\t// Java.Util.Concurrent.CompletableFuture.cs(101,8): error CS0019: Operator `!=' cannot be applied to operands of type `method group' and `System.IntPtr'\r\n\r\n\t__args [0] = new JniArgumentValue ((other == null) ? IntPtr.Zero : other.Handle);\r\n\t// Java.Util.Concurrent.CompletableFuture.cs(254,65): error CS0173: Type of conditional expression cannot be determined because there is no implicit conversion between `System.IntPtr' and `method group'\r\n\r\nThere are two possible fixes:\r\n\r\n1. Forbid the name `Handle`, and *rename* any occurrences to something\r\n    else, such as `InvokeHandle`.\r\n\r\n2. *Qualify* the `Java.Lang.Object.Handle` property reference.\r\n\r\n(1) is kinda ugly.\r\n\r\n(2) is possible by using a cast: instead of `value.Handle`, use e.g.\r\n`((Java.Lang.Object) value).Handle`, which causes the compiler to use\r\nthe intended member, and not whatever may be hiding it in the current\r\nscope.\r\n\r\n(2) results in an arguably nicer API -- maybe? -- as the bound API\r\nmore closely mirrors the Java API.\r\n\r\n(2) also results in uglier binding code. However, who reads it?\r\n\r\nNote: Why cast to e.g. Java.Lang.Object and not IJavaObject? To avoid\r\nvirtual calls. `((Java.Lang.Object)value).Handle` results in a direct\r\ninvocation of the Object.get_Handle() method, avoiding a virtual call.\r\nCasting to IJavaObject would result in a virtual interface method\r\ninvocation, causing additional runtime overhead to lookup the value."},"comment":{"url":"https://api.github.com/repos/xamarin/java.interop/issues/comments/222404387","html_url":"https://github.com/xamarin/java.interop/pull/38#issuecomment-222404387","issue_url":"https://api.github.com/repos/xamarin/java.interop/issues/38","id":222404387,"user":{"login":"atsushieno","id":53929,"avatar_url":"https://avatars.githubusercontent.com/u/53929?v=3","gravatar_id":"","url":"https://api.github.com/users/atsushieno","html_url":"https://github.com/atsushieno","followers_url":"https://api.github.com/users/atsushieno/followers","following_url":"https://api.github.com/users/atsushieno/following{/other_user}","gists_url":"https://api.github.com/users/atsushieno/gists{/gist_id}","starred_url":"https://api.github.com/users/atsushieno/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/atsushieno/subscriptions","organizations_url":"https://api.github.com/users/atsushieno/orgs","repos_url":"https://api.github.com/users/atsushieno/repos","events_url":"https://api.github.com/users/atsushieno/events{/privacy}","received_events_url":"https://api.github.com/users/atsushieno/received_events","type":"User","site_admin":false},"created_at":"2016-05-30T03:20:51Z","updated_at":"2016-05-30T03:20:51Z","body":"I'm a bit scared of passing expression by string but we can add more arguments later if required."}}
{"actor":{"display_login":"atsushieno"}}