如何修复 Javadoc 注释有解析错误,详细信息:在解析 JAVADOC_TAG [NonEmptyAtClauseDescription] 时在输入“*”处没有可行的替代方案
How to fix Javadoc comment has parse error, Details: no viable alternative at input ' *' while parsing JAVADOC_TAG [NonEmptyAtClauseDescription]
/**
* This method is used for ABC.
* @return
* @throw IOException when this exceptional condition occurs
*/
[Error]:line:4- Javadoc comment at column 0 has parse error. Details:
no viable alternative at input ' *' while parsing JAVADOC_TAG
[NonEmptyAtClauseDescription]
知道为什么我会在 Javadoc 的 @throw 行中收到此错误吗?如何解决这个问题?
如上所述,向 return 标签添加描述或完全删除它以解决错误。
$ cat TestClass.java
public class TestClass {
/**
* This method is used for ABC.
* @return desc
* @throw IOException when this exceptional condition occurs
*/
int method() throws IOException {
return 0;
}
}
$ cat TestConfig.xml
<?xml version="1.0"?>
<!DOCTYPE module PUBLIC
"-//Puppy Crawl//DTD Check Configuration 1.3//EN"
"https://checkstyle.org/dtds/configuration_1_3.dtd">
<module name="Checker">
<property name="charset" value="UTF-8"/>
<module name="TreeWalker">
<module name="NonEmptyAtclauseDescriptionCheck" />
</module>
</module>
$ java -jar checkstyle-9.0.1-all.jar -c TestConfig.xml TestClass.java
Starting audit...
Audit done.
/**
* This method is used for ABC.
* @return
* @throw IOException when this exceptional condition occurs
*/
[Error]:line:4- Javadoc comment at column 0 has parse error. Details: no viable alternative at input ' *' while parsing JAVADOC_TAG [NonEmptyAtClauseDescription]
知道为什么我会在 Javadoc 的 @throw 行中收到此错误吗?如何解决这个问题?
如上所述,向 return 标签添加描述或完全删除它以解决错误。
$ cat TestClass.java
public class TestClass {
/**
* This method is used for ABC.
* @return desc
* @throw IOException when this exceptional condition occurs
*/
int method() throws IOException {
return 0;
}
}
$ cat TestConfig.xml
<?xml version="1.0"?>
<!DOCTYPE module PUBLIC
"-//Puppy Crawl//DTD Check Configuration 1.3//EN"
"https://checkstyle.org/dtds/configuration_1_3.dtd">
<module name="Checker">
<property name="charset" value="UTF-8"/>
<module name="TreeWalker">
<module name="NonEmptyAtclauseDescriptionCheck" />
</module>
</module>
$ java -jar checkstyle-9.0.1-all.jar -c TestConfig.xml TestClass.java
Starting audit...
Audit done.