Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

@JsProperty method access is optimised to function call in abstract native jstype #9358

Closed
mbarkley opened this issue Jun 6, 2016 · 8 comments
Assignees

Comments

@mbarkley
Copy link

mbarkley commented Jun 6, 2016

In some cases, methods annotated with @JsProperty on a native @JsType are optimized to obfuscated function calls in a full compile.

Here is a reproducer for the problem. To see the issue, checkout the linked project and do a full compile (mvn clean package), then deploy the war file, and load the host page in Chrome. When you load the host page, you should see the message that calling getTextContent has failed and see a stack trace in the console where an obfuscated function was called rather than a property access to textContent. If you compile the project with optimization level 0, the property access works as expected.

Strangely enough, the problem goes away if I add a call to getTextContent on an Anchor field (see here).

I spent some time trying to simplify this project, but was unable to reproduce the problem in a project without Errai.

@gkdn
Copy link
Contributor

gkdn commented Jun 6, 2016

Passing --generateJsInteropExports?

@mbarkley
Copy link
Author

mbarkley commented Jun 7, 2016

No but all of the types involved have isNative=true so that shouldn't be necessary, right?

@gkdn
Copy link
Contributor

gkdn commented Jun 7, 2016

That's correct you shouldn't need it if you are calling a isNative=true method from Java.
You need send a smaller repro code snippet. Are you using latest snapshot?

@mbarkley
Copy link
Author

mbarkley commented Jun 7, 2016

Yes, that example uses the latest snapshots. There are really only these two classes + Errai, but I will try and make a smaller reproducer.

@mbarkley
Copy link
Author

mbarkley commented Jun 7, 2016

@gkdn I have made a new reproducer without Errai.

Here is the failing case. Here is the workaround.

As before you must build the failing case with mvn clean package to observe the problem.

@gkdn
Copy link
Contributor

gkdn commented Jun 8, 2016

Thanks for the smaller repro.

@rluble This might be something around accident overrides; not sure.

@rluble
Copy link
Contributor

rluble commented Jun 8, 2016

I'll have a look but I think your diagnostic is spot on. Because it is declared abstract the explicit stub created by the accidental override is probably not inheriting JsInfo.

@rluble rluble changed the title @JsPropery method access is optimised to function call @JsProperty method access is optimised to function call in abstract native jstype Jun 8, 2016
@rluble
Copy link
Contributor

rluble commented Jun 8, 2016

A sketch of a fix is in https://gwt-review.googlesource.com/#/c/15093.

@rluble rluble closed this as completed Jun 17, 2016
bauna pushed a commit to bauna/gwt that referenced this issue Jun 30, 2016
JsMember information is inherited from overriden methods
and pruning any of these overridden methods might cause the
compiler to "forget" that a JsMethod/JsProperty is a
JsMethod/JsProperty.

This is the correct behaviour in most cases (as only if
-nogenerateJsInteropExports those overriden members are pruned),
except for the case of native JsMethods.

This patch makes methods and fields that can be implemented
externally live.

Bug: gwtproject#9358
Bug-Link: http://github.com/gwtproject/gwt/issues/9358
Change-Id: I80637883849af5d99542f8d0bc35c3e5b895a9e1
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants