2

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).

4

1 回答 1

4

你的分析很好。

GWT 将扫描整个类路径,忽略不在源路径中的所有内容并“重新定位”超级源。在该扫描期间,它会发出您看到的那种错误,但只有当代码到达丢失的源(从入口点)时,错误才会变得致命。注释也不例外,但代码永远不会真正将它们作为它们的元数据(除非您实现@interfaceJava 允许的 )。但是,生成器可以使用注释,在这种情况下,它们可能会导致构建失败。

请注意,如果您使用-failOnError(或-strict,这是一个别名),那么所有错误都是致命的。您的目标应该是在 IMO 上启用此功能。

于 2017-02-13T20:21:03.233 回答