gpt4 book ai didi

java - 如何在 Eclipse-Helios JDT 中专门抑制 "Comparing identical expressions"

转载 作者:太空狗 更新时间:2023-10-29 22:56:12 31 4
gpt4 key购买 nike

我尝试用注释封闭方法

    @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 的“警告选项”表中得到了“compareIdentical”字符串(当然是冰雹玛丽通行证)。

谢谢!

最佳答案

根据 standard $9.6.4.5 的规定,@SuppressWarnings() 只有 3 个受支持的参数:

  • Unchecked warnings (§4.8, §5.1.6, §5.1.9, §8.4.1, §8.4.8.3, §15.12.4.2, §15.13.2, §15.27.3) are specified by the string "unchecked".
  • Deprecation warnings (§9.6.4.6) are specified by the string "deprecation".
  • Removal warnings (§9.6.4.6) are specified by the string "removal".

但是,在小文本中,标准提到了对额外类型的支持:

For other kinds of warnings, compiler vendors should document the strings they support for @SuppressWarnings. Vendors are encouraged to cooperate to ensure that the same names work across multiple compilers.

一些编译器支持这些:

  • all 抑制所有警告
  • 装箱 以抑制与装箱/拆箱操作相关的警告
  • cast 以抑制与强制转换操作相关的警告
  • dep-ann 抑制与弃用注释相关的警告
  • deprecation 抑制与弃用相关的警告
  • fallthrough 以抑制与 switch 语句中缺少中断相关的警告
  • finally 抑制与不返回的 finally block 相关的警告
  • 隐藏 以抑制与隐藏变量的局部变量相关的警告
  • incomplete-switch 用于抑制与 switch 语句中缺失条目相关的警告(枚举大小写)
  • nls 抑制与非 nls 字符串文字相关的警告
  • null 抑制与 null 分析相关的警告
  • raw 抑制与使用原始类型相关的警告
  • restriction 以抑制与使用不鼓励或禁止的引用相关的警告
  • serial 抑制与可序列化类缺少 serialVersionUID 字段相关的警告
  • static-access 抑制与不正确的静态访问相关的警告
  • super 用于抑制与覆盖没有 super 调用的方法相关的警告
  • synthetic-access 抑制与来自内部类的未优化访问相关的警告
  • unchecked 抑制与未检查操作相关的警告
  • unqualified-field-access 抑制与字段访问不合格相关的警告
  • unused 抑制与未使用代码和死代码相关的警告

所以,没有什么可以帮助您的。

关于java - 如何在 Eclipse-Helios JDT 中专门抑制 "Comparing identical expressions",我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/6996631/

31 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com