0

我有一个仅在调试模式下调用的函数。如果我不添加:

@SuppressWarnings("unused")

我收到警告,因为在非调试模式下从未使用过该功能。如果我添加它会收到警告,因为对于Unnecessary @SuppressWarnings("unused"), 处于调试模式。

你通常会做什么来避免它?

4

2 回答 2

2

You can make the flag which checks for debug mode not statically determined.

static final boolean DEBUG = Boolean.getBoolean("debug");

or

static final boolean DEBUG = LOGGER.isDebugEnabled();

or

static final boolean DEBUG = Boolean.parseBoolean("true");

This will stop the static analysis being about to determine whether you have debug enabled or not.

于 2013-01-07T14:28:07.270 回答
0

您可以尝试使该方法受到保护,这应该会删除警告。另一种选择是更改首选项。

于 2013-01-07T14:12:28.853 回答