2323@ AutoService (BugChecker .class )
2424@ BugPattern (
2525 summary =
26- "This public internal class doesn't end with the javadoc disclaimer: \" "
27- + OtelInternalJavadoc .EXPECTED_INTERNAL_COMMENT
26+ "This public internal class doesn't end with any of the applicable javadoc disclaimers: \" "
27+ + OtelInternalJavadoc .EXPECTED_INTERNAL_COMMENT_V1
28+ + "\" , or \" "
29+ + OtelInternalJavadoc .EXPECTED_INTERNAL_COMMENT_V2
2830 + "\" " ,
2931 severity = WARNING )
3032public class OtelInternalJavadoc extends BugChecker implements BugChecker .ClassTreeMatcher {
@@ -36,17 +38,24 @@ public class OtelInternalJavadoc extends BugChecker implements BugChecker.ClassT
3638 private static final Pattern EXCLUDE_PACKAGE_PATTERN =
3739 Pattern .compile ("^io\\ .opentelemetry\\ .javaagent\\ .instrumentation\\ .internal\\ ." );
3840
39- static final String EXPECTED_INTERNAL_COMMENT =
41+ static final String EXPECTED_INTERNAL_COMMENT_V1 =
4042 "This class is internal and is hence not for public use."
4143 + " Its APIs are unstable and can change at any time." ;
4244
45+ static final String EXPECTED_INTERNAL_COMMENT_V2 =
46+ "This class is internal and experimental. Its APIs are unstable and can change at any time."
47+ + " Its APIs (or a version of them) may be promoted to the public stable API in the"
48+ + " future, but no guarantees are made." ;
49+
4350 @ Override
4451 public Description matchClass (ClassTree tree , VisitorState state ) {
4552 if (!isPublic (tree ) || !isInternal (state ) || tree .getSimpleName ().toString ().endsWith ("Test" )) {
4653 return Description .NO_MATCH ;
4754 }
4855 String javadoc = getJavadoc (state );
49- if (javadoc != null && javadoc .endsWith (EXPECTED_INTERNAL_COMMENT )) {
56+ if (javadoc != null
57+ && (javadoc .contains (EXPECTED_INTERNAL_COMMENT_V1 )
58+ || javadoc .contains (EXPECTED_INTERNAL_COMMENT_V2 ))) {
5059 return Description .NO_MATCH ;
5160 }
5261 return describeMatch (tree );
0 commit comments