OSGi 版本注释的奇怪 javadoc 错误(使用 jdk12)

随着从 Java 11 到 Java 12 的更改,我们现在在包含 OSGi 版本注释的包信息文件上生成 Javadoc 时看到一个奇怪的错误。


源代码是:


@Version("1.3.0")

package org.apache.jackrabbit.oak.commons;


import org.osgi.annotation.versioning.Version;

错误是:


[ERROR] C:\projects\apache\oak\trunk\oak-commons\src\main\java\org\apache\jackrabbit\oak\commons\package-info.java:17: error: unknown tag: Version

[ERROR] @Version("1.3.0")

[ERROR] ^

(查看详细信息和上下文)


这是 Java 12 中的回归,还是注释的使用方式有问题,或者如何调用 Javadoc(通过 maven)?


偶然的你
浏览 117回答 2
2回答

智慧大石

可能是 Javadoc 错误,因为 Javadoc 将 Java Annotation 视为Javadoc Tag。解决方法 1: 禁用此 Javadoc 标记&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <plugin>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <groupId>org.apache.maven.plugins</groupId>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <artifactId>maven-javadoc-plugin</artifactId>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <version>3.1.0</version>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <configuration>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;&nbsp;&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <tags>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <tag>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <name>Version</name>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;&nbsp;&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <placement>X</placement>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;&nbsp;&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; </tag>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; </tags>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; </configuration>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; </plugin>解决方法 2: 在每个注释前添加一个空 Javadoc 块/** */@Version("1.3.0")package org.apache.jackrabbit.oak.commons;

慕姐8265434

简化复制:package p;import static java.lang.annotation.ElementType.PACKAGE;import java.lang.annotation.Target;@Target(PACKAGE)public @interface A {}@Apackage p;$ javadoc package-info.java A.java...package-info.java:1: error: unknown tag: A@A^看起来 javadoc 错误被分类为JDK-8223117,它被标记为JDK-8222091 的副本:Javadoc 在 package-info.java 上没有正确处理包注释,并在 JDK 13 中修复。同样的问题也会影响 OpenJDK 11.0.17,因为引入 javadoc 回归的更改最近被向后移植。这应该在即将发布的 JDK 11u 版本中修复:https ://bugs.openjdk.org/browse/JDK-8295850
打开App,查看更多内容
随时随地看视频慕课网APP

相关分类

Java