On Fri, Jun 8, 2012 at 12:15 AM, zorro <
jan....@gmail.com> wrote:
> I am getting, when compiled with TRACE
> Error, ... references to instance methods in overlay types are illegal; use
> a stronger type or a Java trampoline method
>
> From the compiler output I found out there is:
> gwt-2.4.0/doc/helpInfo/jsoRestrictions.html
>
> There is no link to this from
>
https://developers.google.com/web-toolkit/doc/latest/DevGuideCodingBasicsJSNI
Because JSOs have their own section in the Dev Guide:
https://developers.google.com/web-toolkit/doc/latest/DevGuideCodingBasicsOverlay
In this case, see
http://code.google.com/p/google-web-toolkit/wiki/OverlayTypes#Restrictions
(linked to at the bottom of the above-mentioned page):
“Native JSNI methods may not refer to instance methods within
@SingleJsoImpl types, just as they may not refer to instance methods
on overlay types.”
(note that @SingleJsoImpl doesn't actually exist, it was in an earlier
iteration, now the GWT Compiler infers it from how it's actually being
used)
What it means is that if you have a JavaScriptObject subclass
com.example.client.Foo with a "public final bar()" method (native or
not), you cannot write in JSNI:
someObj.@com.example.client.Foo::bar()();
This is due to how JSOs are handled by the compiler: all methods are
transformed into static methods, they're not instance methods on the
JavaScript object (a JSO is just a Java "view" of a JS object).
> btw, What is "trampoline method"? Sounds good;-)
public static void trampoline_to_bar(Foo foo) {
foo.bar();
}
Then you can use in JSNI:
@com.example.client.Trampoline::trampoline_to_bar(Lcom/example/client/Foo;)(someObj);