Okay, so I use your suggestion with the private native method.
We only use the JSNI in some cases where we have to use it. In a bridge to
a JavaScript lib for example.
Switching to GWT 2.8 is not possible atm, because I run into some problems
and these need to be investigated a first.
Thx a lot,
Norbert
Am Freitag, 27. Januar 2017 11:38:04 UTC+1 schrieb Thomas Broyer:
>
> I would say it's a bug (have you tried in 2.8, maybe it's fixed?).
> I'd also say one should try to keep JSNI as small as possible; your method
> could be rewritten as:
> public static void doSomethingWithMarker() {
> nativeDoSomethingWithMarker(SPECIAL_MARKER);
> }
> private static native void nativeDoSomethingWithMarker(String cm) /*-{
> $wnd.alert(cm);
> }-*/;
>
> In legacy devmode, JSNI boundaries used to be a performance issue, but
> this is no longer the case with SuperDevMode, so there's no reason to write
> big JSNI methods (or even JSNI at all: use JsInterop; there are still a few
> cases that need JSNI, but one can do almost everything with JsInterop
> nowadays).
>
> On Friday, January 27, 2017 at 11:23:35 AM UTC+1, Norbert Bartels wrote:
>>
>> Hi all,
>>
>> during development I ran into a problem and I had to dig a bit deeper to
>> find the root cause. Perhaps someone can explain why this happens.
>>
>> I use GWT 2.7. And I have a class with some constants. For example
>> something like this:
>>
>> public class MyConstants {
>>
>> public static final String SPECIAL_MARKER = "marker";
>>
>> }
>>
>> Now I try to use this in a JSNI method in another class, for example in
>> this way:
>>
>> ...
>> public static native void doSomethingWithMarker() /*-{
>> var cm = @my.package.MyConstants::SPECIAL_MARKER
>> $wnd.alert(cm);
>> }-*/;
>>
>> ...
>>
>> In classic dev mode and in the compiled version this is working. In
>> SuperDevMode cm is undefined.
>>
>> Now, I remove the final and voila, it even works in SuperDevMode.
>> So obviously the final is a problem. But why is it working in classic
>> and compiled mode? Is this simply a bug or is there a better way to use
>> such constants?
>>
>> Cheers,
>> Norbert
>>
>>
>
--
You received this message because you are subscribed to the Google Groups "GWT
Users" 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 https://groups.google.com/group/google-web-toolkit.
For more options, visit https://groups.google.com/d/optout.