如何专门抑制“比较相同的表达式”在 Eclipse-Helios JDT 中
我尝试用注释封闭方法,
@SuppressWarnings("compareIdentical")
但这不起作用(更糟糕的是,注释会导致其自己的 Unsupported @SuppressWarnings("compareIdentical")
警告!)
我知道我总是可以使用,
@SuppressWarnings("all")
但是'警告抑制会比我想要的更多。
FWIW,我从 http://help.eclipse.org/helios/index.jsp?topic=/org.eclipse.jdt.doc.isv/guide/jdt_api_compile.htm(万岁玛丽通行证,可以肯定的是)。
谢谢!
I tried annotating the enclosing method with
@SuppressWarnings("compareIdentical")
but this does not work (worse yet, the annotation results in its own Unsupported @SuppressWarnings("compareIdentical")
warning!)
I know that I can always use
@SuppressWarnings("all")
but that'd be more warning-suppression than I want.
FWIW, I got the "compareIdentical" string from the "Warning Options" table in http://help.eclipse.org/helios/index.jsp?topic=/org.eclipse.jdt.doc.isv/guide/jdt_api_compile.htm (a hail-mary pass, to be sure).
Thanks!
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
正式而言,
@SuppressWarnings()
仅支持 3 个参数,如 标准 $9.6.4.5:但是,在小文本中,该标准提到了对额外类型的支持:
一些编译器支持这些:
all
抑制所有警告boxing
抑制与装箱/拆箱操作相关的警告cast
抑制与强制类型转换相关的警告操作dep-ann
抑制与已弃用注释相关的警告deprecation
抑制与弃用相关的警告fallthrough
抑制与 switch 语句中缺少中断相关的警告finally
抑制与不返回的finally 块相关的警告hiding
抑制与隐藏变量incomplete-switch
的局部变量相关的警告incomplete-switch
抑制警告相对于 switch 语句中缺失的条目(枚举情况)nls
抑制与非 nls 字符串文字相关的警告null
抑制与 null 分析相关的警告raw< /code> 抑制与使用相关的警告原始类型
restriction
用于抑制与使用不鼓励或禁止的引用相关的警告serial
用于抑制与可序列化类缺少 serialVersionUID 字段相关的警告static-access
> 抑制与不正确的静态访问相关的警告super
抑制与在没有 super 调用的情况下重写方法相关的警告synthetic-access
抑制与内部类的未优化访问相关的警告unchecked
用于抑制与未检查操作相关的警告unqualified-field-access
用于抑制与字段访问相关的警告 unqualifiedunused
用于抑制与未使用代码相关的警告和死代码所以,没有什么可以帮助你。
Officially, there are only 3 supported arguments to
@SuppressWarnings()
, as specified by the standard $9.6.4.5:But, in small text, the standard mentions support for extra types:
These are supported by some compilers:
all
to suppress all warningsboxing
to suppress warnings relative to boxing/unboxing operationscast
to suppress warnings relative to cast operationsdep-ann
to suppress warnings relative to deprecated annotationdeprecation
to suppress warnings relative to deprecationfallthrough
to suppress warnings relative to missing breaks in switch statementsfinally
to suppress warnings relative to finally block that don't returnhiding
to suppress warnings relative to locals that hide variableincomplete-switch
to suppress warnings relative to missing entries in a switch statement (enum case)nls
to suppress warnings relative to non-nls string literalsnull
to suppress warnings relative to null analysisraw
to suppress warnings relative to usage of raw typesrestriction
to suppress warnings relative to usage of discouraged or forbidden referencesserial
to suppress warnings relative to missing serialVersionUID field for a serializable classstatic-access
to suppress warnings relative to incorrect static accesssuper
to suppress warnings relative to overriding a method without super invocationssynthetic-access
to suppress warnings relative to unoptimized access from inner classesunchecked
to suppress warnings relative to unchecked operationsunqualified-field-access
to suppress warnings relative to field access unqualifiedunused
to suppress warnings relative to unused code and dead codeSo, there is nothing which might help you.
这样就可以了(至少在 Eclipse 中):
This does it (in Eclipse at least):