On Friday, February 15, 2013 11:15:40 PM UTC+1, Thomas Broyer wrote:

> String is a special beast, as it's emulated by a JS String. It wouldn't 
> surprise me if that use case weren't supported. I grep'ed the source code 
> of GWT and didn't find any such use.
>
Yeah. I found this in the docs for the emulated string:

For efficiency we handle String in a specialized way, in fact, a
java.lang.String is actually implemented as a native JavaScript String. Then
we just load up the prototype of the JavaScript String object with the
appropriate instance methods.

So it should be possible to use the instance methods but not with the 
[email protected]... notation. Any ideas on what could be used 
instead?

On Friday, February 15, 2013 11:53:58 AM UTC+1, alucard wrote:
>>
>> This does not work:
>>
>> private static native int test(String str) /*-{
>>    return [email protected]::compareTo(Ljava/lang/String;)("test");
>> }-*/;
>>
>> It dies with the following exception:
>>
>> com.google.gwt.core.client.JavaScriptException: (Error) 
>> @test.client.Test::test(Ljava/lang/String;)([string: 'hello']): Error 
>> calling method on NPObject.
>> at 
>> com.google.gwt.dev.shell.BrowserChannelServer.invokeJavascript(BrowserChannelServer.java:249)
>> at 
>> com.google.gwt.dev.shell.ModuleSpaceOOPHM.doInvoke(ModuleSpaceOOPHM.java:136)
>> at com.google.gwt.dev.shell.ModuleSpace.invokeNative(ModuleSpace.java:571)
>>
>> Is it possible (if yes please write how) to invoke String methods from 
>> JSNI?
>>
>> Thanks for the help.
>>
>>

-- 
You received this message because you are subscribed to the Google Groups 
"Google Web Toolkit" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to [email protected].
To post to this group, send email to [email protected].
Visit this group at http://groups.google.com/group/google-web-toolkit?hl=en.
For more options, visit https://groups.google.com/groups/opt_out.


Reply via email to