Re: [gwt-contrib] Jsni on String methods in GWT 2.7

2015-03-30 Thread 'Roberto Lublinerman' via GWT Contributors
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  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 = s...@java.lang.String::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 google-web-toolkit-contributors+unsubscr...@googlegroups.com.
> 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
> 
> .
> 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 google-web-toolkit-contributors+unsubscr...@googlegroups.com.
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.
For more options, visit https://groups.google.com/d/optout.


Re: [gwt-contrib] Jsni on String methods in GWT 2.7

2015-03-30 Thread 'Roberto Lublinerman' via GWT Contributors
Please file an issue to keep track.

On Mon, Mar 30, 2015 at 9:06 AM, Roberto Lublinerman 
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 
> 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 = s...@java.lang.String::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 google-web-toolkit-contributors+unsubscr...@googlegroups.com.
>> 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
>> 
>> .
>> 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 google-web-toolkit-contributors+unsubscr...@googlegroups.com.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/google-web-toolkit-contributors/CAC7T7g%3DAH1hEa8GbirmOfgiK%2BfYWbEi_oCJ5SD7CwJZNkR%2Bm8Q%40mail.gmail.com.
For more options, visit https://groups.google.com/d/optout.


Re: [gwt-contrib] Jsni on String methods in GWT 2.7

2015-03-30 Thread 'Goktug Gokdogan' via GWT Contributors
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
 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 
> 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 = s...@java.lang.String::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 google-web-toolkit-contributors+unsubscr...@googlegroups.com.
>> 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
>> 
>> .
>> 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 google-web-toolkit-contributors+unsubscr...@googlegroups.com.
> 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
> 
> .
>
> 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 google-web-toolkit-contributors+unsubscr...@googlegroups.com.
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.


Re: [gwt-contrib] Jsni on String methods in GWT 2.7

2015-03-30 Thread James Nelson
Ok, great.  Thanks for the heads up.  I was pretty sure that Strings had 
become native first-class objects.

Since JSOs will all have public methods, I will be safe with the same fix 
for String (not using JSNI if not necessary).
Given that java arrays only have one field, and that field does not work in 
JVM reflection, nor do any of the Object methods, I'll leave them alone
(that's what java.lang.reflect.Array is for)...

Added 
issue https://code.google.com/p/google-web-toolkit/issues/detail?id=9166 to 
track this.

For posterity and search indexing, if anyone tries to use hashCode, equals 
or compareTo on String or Array in JSNI and are getting undefined reference 
errors, use a static method instead.

-- 
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 google-web-toolkit-contributors+unsubscr...@googlegroups.com.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/google-web-toolkit-contributors/9bbd9127-65c9-4fa1-9743-a94fcd4f3bf4%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.