{"action":"created","issue":{"url":"https://api.github.com/repos/gwtproject/gwt/issues/9327","repository_url":"https://api.github.com/repos/gwtproject/gwt","labels_url":"https://api.github.com/repos/gwtproject/gwt/issues/9327/labels{/name}","comments_url":"https://api.github.com/repos/gwtproject/gwt/issues/9327/comments","events_url":"https://api.github.com/repos/gwtproject/gwt/issues/9327/events","html_url":"https://github.com/gwtproject/gwt/issues/9327","id":153078149,"number":9327,"title":"Relax JsInteorp restriction checking so one can perform feature check","user":{"login":"gkdn","id":4112632,"avatar_url":"https://avatars.githubusercontent.com/u/4112632?v=3","gravatar_id":"","url":"https://api.github.com/users/gkdn","html_url":"https://github.com/gkdn","followers_url":"https://api.github.com/users/gkdn/followers","following_url":"https://api.github.com/users/gkdn/following{/other_user}","gists_url":"https://api.github.com/users/gkdn/gists{/gist_id}","starred_url":"https://api.github.com/users/gkdn/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/gkdn/subscriptions","organizations_url":"https://api.github.com/users/gkdn/orgs","repos_url":"https://api.github.com/users/gkdn/repos","events_url":"https://api.github.com/users/gkdn/events{/privacy}","received_events_url":"https://api.github.com/users/gkdn/received_events","type":"User","site_admin":false},"labels":[],"state":"open","locked":false,"assignee":null,"milestone":{"url":"https://api.github.com/repos/gwtproject/gwt/milestones/1","html_url":"https://github.com/gwtproject/gwt/milestones/2.8","labels_url":"https://api.github.com/repos/gwtproject/gwt/milestones/1/labels","id":1173710,"number":1,"title":"2.8","description":"","creator":{"login":"tbroyer","id":173813,"avatar_url":"https://avatars.githubusercontent.com/u/173813?v=3","gravatar_id":"","url":"https://api.github.com/users/tbroyer","html_url":"https://github.com/tbroyer","followers_url":"https://api.github.com/users/tbroyer/followers","following_url":"https://api.github.com/users/tbroyer/following{/other_user}","gists_url":"https://api.github.com/users/tbroyer/gists{/gist_id}","starred_url":"https://api.github.com/users/tbroyer/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/tbroyer/subscriptions","organizations_url":"https://api.github.com/users/tbroyer/orgs","repos_url":"https://api.github.com/users/tbroyer/repos","events_url":"https://api.github.com/users/tbroyer/events{/privacy}","received_events_url":"https://api.github.com/users/tbroyer/received_events","type":"User","site_admin":false},"open_issues":16,"closed_issues":59,"state":"open","created_at":"2015-06-20T22:43:02Z","updated_at":"2016-05-04T18:30:23Z","due_on":null,"closed_at":null},"comments":4,"created_at":"2016-05-04T18:06:54Z","updated_at":"2016-05-05T20:55:37Z","closed_at":null,"body":"Relax JsInteorp restriction checking so one can perform feature check; like:\r\n\r\n```java\r\nclass Performance { \r\n  @JsMethod(namespace=\"performance\")\r\n  public static native double now();\r\n  public static boolean hasNow() { return getNow() != null; }\r\n  @JsProperty(namespace=\"performance\")\r\n  private static native Object getNow();\r\n}\r\n```\r\n\r\nAbove snippet fails due to name restriction checking.\r\n\r\nCurrent workaround:\r\n```java\r\nclass Performance { \r\n  @JsMethod(namespace=\"performance\")\r\n  public static native double now();\r\n  public static boolean hasNow() { return Helper.getNow() != null; }\r\n\r\n  private static class Helper {\r\n    @JsProperty(namespace=\"performance\")\r\n    public static native Object getNow();\r\n  }\r\n}\r\n```"},"comment":{"url":"https://api.github.com/repos/gwtproject/gwt/issues/comments/217277375","html_url":"https://github.com/gwtproject/gwt/issues/9327#issuecomment-217277375","issue_url":"https://api.github.com/repos/gwtproject/gwt/issues/9327","id":217277375,"user":{"login":"rluble","id":4175508,"avatar_url":"https://avatars.githubusercontent.com/u/4175508?v=3","gravatar_id":"","url":"https://api.github.com/users/rluble","html_url":"https://github.com/rluble","followers_url":"https://api.github.com/users/rluble/followers","following_url":"https://api.github.com/users/rluble/following{/other_user}","gists_url":"https://api.github.com/users/rluble/gists{/gist_id}","starred_url":"https://api.github.com/users/rluble/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/rluble/subscriptions","organizations_url":"https://api.github.com/users/rluble/orgs","repos_url":"https://api.github.com/users/rluble/repos","events_url":"https://api.github.com/users/rluble/events{/privacy}","received_events_url":"https://api.github.com/users/rluble/received_events","type":"User","site_admin":false},"created_at":"2016-05-05T20:55:37Z","updated_at":"2016-05-05T20:55:37Z","body":"@Ignacio, I think you misread the point. This is not about primitive types.\nThis is using JsInterop in an unusual way using a JsFunction type property\nto check for the existence of a instance method in a native type.\n\nOn Wed, May 4, 2016 at 11:48 PM, Ignacio Baca Moreno-Torres <\nnotifications@github.com> wrote:\n\n> Null primitives is quite annoying I hope GWT team will find good solution\n> (manolo already makes a comment in the NextGen doc, and you said that\n> Double and now Boolean can be used) but...\n> For example (easy to say, sorry... just ignore if makes no sense 😉):\n> @JsProperty(orElse=\"0\") double now(); where orElse is a literal string.\n> Or at least some primitive flag which if is true, all call will be handled\n> as similar as possible as java primitives so now() will be always\n> translated as (now||0), booleans now||false, etc.\n>\n> Other more weird idea:\n>\n> // field is substitude by the field name, this is useful to save the string as a constant somewhere else\n> @JsProperty(getter=“$field++”) int increment();// using a constant\n> @JsProperty(getter=INCREMENT) int increment();// even more weird example (not sure if this makes sense)\n> @JsProperty(\n>   getter=“var l=@java.util.ArrayList::new()();l.@java.util.ArrayList::array=$field;return l;”,\n>   setter=“$field = $set.@java.util.ArrayList::array”\n> ) ArrayList<String> tokens();// using a constant\n> @JsProperty(getter=ARRAY_LIST_GET, setter=ARRAY_LIST_SET) ArrayList<String> tokens();// and just because is so easy to say thing a do not implement them...\n> @JsProperty(getter=ARRAY_LIST_GET, setter=ARRAY_LIST_SET)\n> @Target(FIELD) @Retention(RUNTIME) @JsDefpublic @interface JsList {}// so can be used as javax.validation annotation composition, just to clean it up the code\n> @JsList ArrayList<String> tokens();\n>\n> —\n> You are receiving this because you are subscribed to this thread.\n> Reply to this email directly or view it on GitHub\n> <https://github.com/gwtproject/gwt/issues/9327#issuecomment-217087808>\n>\n"}}