Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Annotation for GWT compiler to ignore method

Tags:

java

gwt

Is it possible to create an annotation (or some other way) to force the GWT compiler to not compile a method? I have a class that I also use on app-engine (in a shared folder) and one method in it requires a server side only function which causes GWT to not compile. I would like GWT to just ignore the method (while appengine does not).

I figured either an annotation, or a pre-compile script that erases the method prior to compilation. Both methods would work for me, it would be best if I could still compile through the eclipse IDE.

Anyone else thought of this or tried it?

like image 723
Michael Avatar asked Nov 01 '12 20:11

Michael


2 Answers

Not until now. Very recently such annotation was added @com.google.gwt.core.shared.GwtIncompatible("Description why..."). It is applicable on classes or methods.

But the patched code was not released yet! Official status is FixedNotReleased. And i can personally confirm, it is not in current GWT 2.5.1 version. I am hopeful for upcoming 2.5.2.

See:

http://code.google.com/p/google-web-toolkit/source/browse/trunk/user/src/com/google/gwt/core/shared/GwtIncompatible.java?spec=svn11570&r=11570

http://code.google.com/p/google-web-toolkit/issues/detail?id=3769

https://gwt-review.googlesource.com/#/c/2320/

Note, there is already similar annotation com.google.gwt.thirdparty.guava.common.annotations.GwtIncompatible in gwt-dev.jar, however it does not work, compiler still wants to compile my incompatible method in shared class.

like image 199
Espinosa Avatar answered Sep 20 '22 16:09

Espinosa


Prior to GWT version 2.6, there is no annotation to make the GWT compiler ignore a method. There is a requests for it in the GWT issue tracker, and apparently it is scheduled for the 2.6 release.

One workaround approach is to have the "offending" method in a class of its own and ignore that class in your .gwt.xml file:

<source path="gwtclient">
   <exclude name="AppEngineOnlyClass.java" />
   ...
</source>
...

Hope that helps a bit.

Cheers,

like image 44
Anders R. Bystrup Avatar answered Sep 23 '22 16:09

Anders R. Bystrup