Same also applies to JSOs. (i.e. You cannot call JSO methods with JSNI). On Mon, Mar 30, 2015 at 9:06 AM, 'Roberto Lublinerman' via GWT Contributors <[email protected]> wrote:
> GWT strings and arrays are JS native strings and arrays (no prototype > monkey patching), in Java code calls to Object, String, Array and > Comparable methods are devirtualized if applied to instances typed at one > of those types. > > So the answer is yes: You wont be able to call instance methods this way > for strings and arrays. At least, we should emit an error if you try to get > a JSNI reference to a String or array method, and probably a warning if you > make a jsni reference to a Object or Comparable method. Getting a jsni > reference to Object or Comparable method works fine on every object as long > as it is not a String or Array. > > > On Sun, Mar 29, 2015 at 5:42 PM, James Nelson <[email protected]> > wrote: > >> I'm not sure if this is intended, but I've noticed that JSNI methods on >> string do not work. >> I tried equals, compareTo, compareToIgnoreCase and charAt, but none of >> them worked. >> I used my fork and the pristine 2.7, and in super dev + regular compile; >> in all cases, the functions come back undefined. >> >> native char jsni(String s) >> /*-{ >> var fn = [email protected]::charAt(I); >> // fn is undefined >> return fn(0); // doom >> }-*/; >> >> In compiled code, it looks something like: >> var fn = string_0_g$.charAt_3_g$; >> >> >> So, my question, is this expected behaviour? >> >> If so, are there other types I need to guard against JSNI failures? >> >> If not, should I file a bug and look into a patch? >> (Assuming a patch would be a rewrite static method visitor that can >> replace jsni method refs with a staticified version). >> >> For my reflection support, I'm going to guard against this by making >> public methods not use JSNI, >> but if there are other types or gotchas I should be aware of, it would be >> nice to know about them. >> >> >> Thanks! >> >> -- >> You received this message because you are subscribed to the Google Groups >> "GWT Contributors" group. >> To unsubscribe from this group and stop receiving emails from it, send an >> email to [email protected]. >> To view this discussion on the web visit >> https://groups.google.com/d/msgid/google-web-toolkit-contributors/996e0a45-0048-4a61-abdd-3bff209df09d%40googlegroups.com >> <https://groups.google.com/d/msgid/google-web-toolkit-contributors/996e0a45-0048-4a61-abdd-3bff209df09d%40googlegroups.com?utm_medium=email&utm_source=footer> >> . >> For more options, visit https://groups.google.com/d/optout. >> > > -- > You received this message because you are subscribed to the Google Groups > "GWT Contributors" group. > To unsubscribe from this group and stop receiving emails from it, send an > email to [email protected]. > To view this discussion on the web visit > https://groups.google.com/d/msgid/google-web-toolkit-contributors/CAC7T7g%3D1RED4t2_ZJN9skhPM85UzkTBks-Xo3MAtsvqJ%2BrJruw%40mail.gmail.com > <https://groups.google.com/d/msgid/google-web-toolkit-contributors/CAC7T7g%3D1RED4t2_ZJN9skhPM85UzkTBks-Xo3MAtsvqJ%2BrJruw%40mail.gmail.com?utm_medium=email&utm_source=footer> > . > > For more options, visit https://groups.google.com/d/optout. > -- You received this message because you are subscribed to the Google Groups "GWT Contributors" group. To unsubscribe from this group and stop receiving emails from it, send an email to [email protected]. To view this discussion on the web visit https://groups.google.com/d/msgid/google-web-toolkit-contributors/CAN%3DyUA18_OtO5E-n99LrhAg-yYG5ptDDwtAHu9mZYk72RrO1NA%40mail.gmail.com. For more options, visit https://groups.google.com/d/optout.
