Merge branch '6.1.x'

This commit is contained in:
Stéphane Nicoll
2024-07-25 16:29:07 +02:00
4 changed files with 52 additions and 9 deletions

View File

@@ -58,7 +58,7 @@ class CodeWarnings {
*/
public CodeWarnings detectDeprecation(AnnotatedElement... elements) {
for (AnnotatedElement element : elements) {
register(element.getAnnotation(Deprecated.class));
registerDeprecationIfNecessary(element);
}
return this;
}
@@ -112,6 +112,16 @@ class CodeWarnings {
return Collections.unmodifiableSet(this.warnings);
}
private void registerDeprecationIfNecessary(@Nullable AnnotatedElement element) {
if (element == null) {
return;
}
register(element.getAnnotation(Deprecated.class));
if (element instanceof Class<?> type) {
registerDeprecationIfNecessary(type.getEnclosingClass());
}
}
private void register(@Nullable Deprecated annotation) {
if (annotation != null) {
if (annotation.forRemoval()) {