-
Bug
-
Resolution: Unresolved
-
P4
-
8-pool, 11, 16, 17, 18
-
generic
-
generic
ADDITIONAL SYSTEM INFORMATION :
OS: Windows 10 20H2 (build 19042.1348)
Java runtime:
openjdk version "18-beta" 2022-03-22
OpenJDK Runtime Environment Temurin-18+26-202112030041 (build 18-beta+26-202112030041)
OpenJDK 64-Bit Server VM Temurin-18+26-202112030041 (build 18-beta+26-202112030041, mixed mode, sharing)
A DESCRIPTION OF THE PROBLEM :
Documented annotations that combine target TYPE_USE and other valid targets such as PARAMETER, are duplicated in the class data, and so on documentation too
The duplication also happens if any other target type which is valid to the context is present, this causes annotations such as JetBrains's @NotNull and @Nullable to be duplicated in the class data, as well as on the javadocs, on return types or on parameters for example
The bug is reproducible on :
JDK 8u265
JDK 11.0.6+10
JDK 16.0.2+7
JDK 18-EA+26
Related issues:
https://bugs.openjdk.java.net/browse/JDK-8175533
Seems to be related:
https://bugs.openjdk.java.net/browse/JDK-8006775
Other issues caused by the bug:
https://github.com/JetBrains/java-annotations/issues/37 : "I.e. overlapping scopes lead to tools such as Javadoc recognizing both targets as matched thus leading to issues such as duplication of the annotation in documentation"
REGRESSION : Last worked in version 8
STEPS TO FOLLOW TO REPRODUCE THE PROBLEM :
1. Make any class with an annotated element that is allowed by two targets (TYPE_USE and PARAMETER here)
API.java:
@Documented
@Retention(RetentionPolicy.RUNTIME)
@Target({ElementType.PARAMETER, ElementType.TYPE_USE})
@interface TypeUseAnnot {}
public class API {
public static void doSomething(@TypeUseAnnot Object obj) { }
}
Generating the docs:
javadoc -d docs API.java
EXPECTED VERSUS ACTUAL BEHAVIOR :
EXPECTED -
The @TypeUseAnnot annotation should only appear once in the class data and also in the method detail section javadoc
ACTUAL -
The @TypeUseAnnot annotation is duplicated on the "obj" parameter
---------- BEGIN SOURCE ----------
@Documented
@Retention(RetentionPolicy.RUNTIME)
@Target({ElementType.PARAMETER, ElementType.TYPE_USE})
@interface TypeUseAnnot {}
public class API {
public static void doSomething(@TypeUseAnnot Object obj) { }
}
---------- END SOURCE ----------
FREQUENCY : always
OS: Windows 10 20H2 (build 19042.1348)
Java runtime:
openjdk version "18-beta" 2022-03-22
OpenJDK Runtime Environment Temurin-18+26-202112030041 (build 18-beta+26-202112030041)
OpenJDK 64-Bit Server VM Temurin-18+26-202112030041 (build 18-beta+26-202112030041, mixed mode, sharing)
A DESCRIPTION OF THE PROBLEM :
Documented annotations that combine target TYPE_USE and other valid targets such as PARAMETER, are duplicated in the class data, and so on documentation too
The duplication also happens if any other target type which is valid to the context is present, this causes annotations such as JetBrains's @NotNull and @Nullable to be duplicated in the class data, as well as on the javadocs, on return types or on parameters for example
The bug is reproducible on :
JDK 8u265
JDK 11.0.6+10
JDK 16.0.2+7
JDK 18-EA+26
Related issues:
https://bugs.openjdk.java.net/browse/JDK-8175533
Seems to be related:
https://bugs.openjdk.java.net/browse/JDK-8006775
Other issues caused by the bug:
https://github.com/JetBrains/java-annotations/issues/37 : "I.e. overlapping scopes lead to tools such as Javadoc recognizing both targets as matched thus leading to issues such as duplication of the annotation in documentation"
REGRESSION : Last worked in version 8
STEPS TO FOLLOW TO REPRODUCE THE PROBLEM :
1. Make any class with an annotated element that is allowed by two targets (TYPE_USE and PARAMETER here)
API.java:
@Documented
@Retention(RetentionPolicy.RUNTIME)
@Target({ElementType.PARAMETER, ElementType.TYPE_USE})
@interface TypeUseAnnot {}
public class API {
public static void doSomething(@TypeUseAnnot Object obj) { }
}
Generating the docs:
javadoc -d docs API.java
EXPECTED VERSUS ACTUAL BEHAVIOR :
EXPECTED -
The @TypeUseAnnot annotation should only appear once in the class data and also in the method detail section javadoc
ACTUAL -
The @TypeUseAnnot annotation is duplicated on the "obj" parameter
---------- BEGIN SOURCE ----------
@Documented
@Retention(RetentionPolicy.RUNTIME)
@Target({ElementType.PARAMETER, ElementType.TYPE_USE})
@interface TypeUseAnnot {}
public class API {
public static void doSomething(@TypeUseAnnot Object obj) { }
}
---------- END SOURCE ----------
FREQUENCY : always
- relates to
-
JDK-8175533 Documented annotations show up twice in Javadoc for fields and parameters
- Open
-
JDK-8006775 JSR 308: Compiler changes in JDK8
- Closed