Search code examples
gwt

How to get rid of this useless GWT compiler warning?


There is an option in GWT to obfuscate enum names:

<set-configuration-property name="compiler.enum.obfuscate.names" value="true" />

When I use this option, my compiles produce a warning:

[WARN] Call to Enum method name when enum obfuscation is enabled:
com/google/gwt/dom/client/DataTransfer.java:127

Looking at the DataTransfer source code, I can see that it has an enum DropEffect and the enum names are used in one of the methods (setDropEffect).

I'm using modern JsInterop-oriented GWT, so I'm not using this DataTransfer class (or anything in gwt-user.jar). It's annoying to have a useless warning. Is there an easy way to get rid of it?

I know how to exclude files in my own source folders.

Is it possible to exclude source folders from gwt-user? (Other than by physically deleting files from the jar!)


Solution

  • That looks like a bug - unfortunate too that the compiler doesn't remove this class. This should be easy to fix with a patch to GWT, adding a field to DropEffect for the name, since it must never be removed even when that compiler flag is enabled.

    Is it possible to exclude source folders from gwt-user? (Other than by physically deleting files from the jar!)

    What you must do is exclude the .gwt.xml file itself, by not inheriting it at all, even transitively. So, for example, if you do avoid all JSNI including Widget types in the User module, your .gwt.xml shouldn't reference the Dom module, or User, or anything else which references Dom. But once a module has been inherited, there is no way to "uninherit" it. And once a module is inherited, its sources are added, and cannot be un-added.