简体   繁体   English

GWT编译器:编译错误何时致命?

[英]GWT Compiler : when is a compilation error fatal?

I'm trying to understand more about how GWT compilation works. 我试图更多地了解GWT编译的工作方式。

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. 更具体地说,我想知道GWT如何确定某个特定的错误是致命的,并且应用程序编译应因此而失败,并且即使存在编译错误,它也如何确定编译成功。

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). 我说的是GWT 2.7和GWT 2.8(我已经看到它们表现出相同的行为)。 Also, I'm using GWTP 1.5.3, if this is relevant somewhat. 另外,如果这有点相关,我正在使用GWTP 1.5.3。

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). 上面的错误不会使我的应用程序编译失败,并且myApp可以正常工作(该类注册了一些GIN绑定,这也可以工作)。

Why didn't GWT failed my compilation when it encountered that error? 为什么GWT在遇到该错误时没有使我的编译失败?

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. Edit1:忘记添加。

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). 我有从入口点就可以到达的代码,并且有注释,这些注释的源代码不可用,但是编译成功了(尽管这是迄今为止我所能找到的唯一例外)。

Your analysis is good. 您的分析很好。

GWT will scan the entire classpath, ignoring everything not in the source path and "rebasing" super-sources. GWT将扫描整个类路径,而忽略源路径中未包含的所有内容并“重新设置”超级源。 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). 注释也不例外,但是代码实际上不会真正到达它们的唯一元数据(除非您实现Java允许的@interface )。 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. 请注意,如果使用-failOnError (或-strict ,这是别名),则所有错误都是致命的。 You should aim for turning this on IMO. 您应该以将其设置为IMO为目标。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM