Search code examples
javagwtgwt-2.7gwt-2.8

GWT Compiler : when is a compilation error fatal?


I'm trying to understand more about how GWT compilation works.

More specifically, I want to know how does GWT decide that a particular error is fatal, and the app compilation should fail because of it, and how does it decide that compilation is successful, even though there are compilation errors.

The reason I'm asking is that it's very difficult to distinguish legitimate errors in my log when doing a search, from ones that don't seem to cause any problem.

I'm talking about GWT 2.7 and GWT 2.8 (which I've seen they exhibit the same behavior). Also, I'm using GWTP 1.5.3, if this is relevant somewhat.

A concrete example: I have this error in my logs:

Tracing compile failure path for type 'myApp.ClientModule'
Errors in 'file:/E:/data/.../myApp/ClientModule.java'
   Line 24: No source code is available for type myApp.client.ServicesProvidersModuleGen; did you forget to inherit a required module?
Checked 1 dependencies for errors.

The error above does not make my app to fail compilation, and myApp works just fine (the class is something that registers some GIN bindings, which also work).

Why didn't GWT failed my compilation when it encountered that error?

Additionally, I also have other errors such as:

  Errors in 'com/google/gwt/validation/client/impl/AbstractGwtSpecificValidator.java'
 Line 102: No source code is available for type javax.validation.ValidationException; did you forget to inherit a required module?
 Line 177: No source code is available for type javax.validation.ConstraintValidator<A,T>; did you forget to inherit a required module?
 Line 153: No source code is available for type javax.validation.groups.Default; did you forget to inherit a required module?
 Line 302: No source code is available for type javax.validation.ConstraintViolation<T>; did you forget to inherit a required module?

These errors also don't fail my compilation. Why?

Edit1: forgot to add.

I'm tempted to guess that compilation fails when the error is in something directly reachable from an entry point, and that compilation is OK when that code is not reachable. However, I have the counter-example of code with annotations. I have code that IS reachable from the entry point, and has annotations whose source code is not available, and yet the compilation succeeds (although this is the only exception that I could find so far).


Solution

  • Your analysis is good.

    GWT will scan the entire classpath, ignoring everything not in the source path and "rebasing" super-sources. During that scan, it emits the kind of error you saw, but only when code will reach the missing sources (from entry points) the error will become fatal. Annotations are no exception, but code will never actually reach them as their just metadata (unless you implement an @interface, which Java allows). Annotations can be used by generators though, in which case they can fail the build.

    Note that if you use -failOnError (or -strict, which is an alias), then all errors are fatal. You should aim for turning this on IMO.