Dead-code removal is an optimization ran *after* the first phases have 
completed. You can however annotate your method with @GwtIncompatible (in 
any package, only the annotation's simple-name matters; one is provided in 
com.google.gwt.core.shared in gwt-user and gwt-servlet, another exists in 
Guava in com.google.common.annotations, and you can create your own if you 
don't want a dependency on those libs) and it'll be ignored by the compile.

On Monday, March 7, 2016 at 11:59:51 AM UTC+1, Bruno Salmon wrote:
>
> Ok, great that GWT automatically removes dead code.
>
> I invoke the compiler using the maven plugin so I assume it is a 
> production compile (right?).
>
> But this simple code fails on compilation:
>
> public class MyEntryPoint implements EntryPoint {
>
>     @Override
>     public void onModuleLoad() {
>         methodCompileOk();
>     }
>
>     public void methodCompileOk() {
>         Logger.getLogger("").info("This compiles with GWT");
>     }
>
>     public void methodCompileNotOk() {
>         // Logger.getAnonymousLogger() is not emulated by GWT so this code 
> doesn't compile with GWT
>         Logger.getAnonymousLogger().warning("This doesn't compile with GWT");
>     }
>
> }
>
>
> I'm getting this error: The method getAnonymousLogger() is undefined for 
> the type Logger
> even if my code actually doesn't call the second method.
>
> Shouldn't the second method be considered as dead code and automatically 
> removed by GWT?
>
>

-- 
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+unsubscr...@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.

Reply via email to