Tuesday, September 13, 2016

Re: Strange (BAD?) code generated


On Tuesday, September 13, 2016 at 4:08:38 PM UTC+2, Kirill Prazdnikov wrote:

You must be missing an isNative=true on ClientRect 

Ok, but what does it mean when a type has a @JsProperty but it is not "isNative=true" ?

Must each class with JsProperties be "isNative=true" ?

See comments on the linked issue: if it's not isNative=true, then from the PoV of GWT it's a normal Java type and will be pruned if it's never instantiated; unless you -generateJsInteropExports in which case you expose its constructor to the JS world (and GWT can no longer tell if it's ever instantiated, so it doesn't prune it; if I'm not mistaken).
Because GWT can tell here (you didn't use -generateJsInteropExports, right?) that you never instantiate the ClientRect, it prunes it, which means that anything that returns it from JS must be returning 'null' or 'undefined' (remember: you don't instantiate it, and you don't expose a way for JS to instantiate it, so it cannot ever be instantiated and it's then safe to assume that it can only be null); which leads to this code calling null.$_nullMethod(), which is GWT's way of representing NullPointerExceptions in JS.

ClientRect here represents/maps an object that comes from the JS world, so it should be isNative=true. If you don't use isNative=true, it means it's an object from your app that you'll expose for consumption by JS (iff you use -generateJsInteropExports; otherwise jsinterop annotations are just ignored).

--
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 google-web-toolkit+unsubscribe@googlegroups.com.
To post to this group, send email to google-web-toolkit@googlegroups.com.
Visit this group at https://groups.google.com/group/google-web-toolkit.
For more options, visit https://groups.google.com/d/optout.

No comments:

Post a Comment