简体   繁体   English

Java编译器警告严重性

[英]Java compiler warnings severity

Intro 介绍
Some continuous-integration tools (say, Hudson) assume compilers generate warnings of different severity (aka priority): high, normal and low. 一些连续集成工具(例如Hudson)假定编译器生成不同严重程度(高优先级)的警告:高,正常和低。
Depending on number and severity of compiler warnings, the tool can mark a build as unstable . 根据编译器警告的数量和严重性,该工具可以将构建标记为不稳定
I want my builds unstable if compiler generates high priority warnings. 如果编译器生成高优先级警告,我希望构建不稳定。

I never seen any high (and low) priority warnings on our project -- only normal, so I'm a bit suspicious if they really exist. 我从未在我们的项目中看到任何高(或低)优先级警告-仅是正常情况,因此如果它们确实存在,我会有点怀疑。

Question
Where can I look at a list of high priority compiler warnings generated by javac and/or ecj. 在哪里可以看到由javac和/或ecj生成的高优先级编译器警告列表
Or maybe you can provide some examples of high priority warnings. 或者,您可以提供一些高优先级警告的示例。

Other 其他
Related, but maybe different question: I suspect high priority compiler warnings are actually errors and there can't be actually a situation you have source code compiled with high priority warnings (build will be broken in that case). 相关的,但也许是不同的问题:我怀疑高优先级编译器警告实际上是错误,并且实际上不会出现源代码具有高优先级警告编译的情况(在这种情况下,构建将被破坏)。

You can get a list of all compiler warnings by typing: 您可以通过键入以下内容获取所有编译器警告的列表:

javac -X javac -X

and looking at the list given for the -Xlint option. 并查看为-Xlint选项提供的列表。

Java doesn't really have a notion of "high" vs "low" priority, and arguably shouldn't-- which particuarly warnings are likely to indicate a problem with your project is really specific to your particular mode of development. Java实际上并没有“高”优先级与“低”优先级的概念,并且可以说不应该-尤其是警告可能表明您的项目中的问题确实是特定于您的特定开发模式的。

If you want to see high and low priority warning you could use PMD, FindBug and/or checkstyle. 如果要查看高优先级和低优先级警告,可以使用PMD,FindBug和/或checkstyle。 Checkstyle is particularly good at producing a lot of very low priority warning. Checkstyle特别擅长产生很多非常低优先级的警告。 ;) ;)

Referring to Hudson specifically, it looks like the "Scan log files for compiler warnings" option is meant to be generic across compilers, and the options for high priority vs medium vs low is probably intended for compilers capable of generating these severity levels (such as gcc or PC-Lint or (maybe) the Eclipse Java compiler). 特别是指Hudson,“扫描日志文件以查看编译器警告”选项似乎在各个编译器中通用,并且高优先级与中级与低级选项可能适用于能够生成这些严重性级别的编译器(例如gcc或PC-Lint或(也许是Eclipse Java编译器)。 I don't believe that javac is capable of this. 我不相信javac能够做到这一点。

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

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