mirror of
https://gitflic.ru/project/openide/openide.git
synced 2026-01-08 15:09:39 +07:00
[java-inspections] ReflectionForUnavailableAnnotation: fix NullPointerException
GitOrigin-RevId: 203ff77a14096913a4b9c8b07ee4eea9ea658cf6
This commit is contained in:
committed by
intellij-monorepo-bot
parent
25b1f21fb7
commit
06369b2c81
@@ -0,0 +1,10 @@
|
||||
// "Annotate annotation 'NotNull' as @Retention" "false"
|
||||
import org.jetbrains.annotations.NotNull;
|
||||
|
||||
import java.lang.reflect.Method;
|
||||
|
||||
class Foo {
|
||||
boolean bar(Method method) {
|
||||
return method.getAnnotation(NotNull.class<caret>) != null;
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,10 @@
|
||||
// "Annotate annotation 'Subst' as @Retention" "false"
|
||||
import org.intellij.lang.annotations.Subst;
|
||||
|
||||
import java.lang.reflect.Method;
|
||||
|
||||
class Foo {
|
||||
boolean bar(Method method) {
|
||||
return method.getAnnotation(Subst.class<caret>) != null;
|
||||
}
|
||||
}
|
||||
@@ -98,8 +98,12 @@ public class ReflectionForUnavailableAnnotationInspection extends BaseInspection
|
||||
return;
|
||||
}
|
||||
final PsiAnnotation retentionAnnotation = modifierList.findAnnotation(CommonClassNames.JAVA_LANG_ANNOTATION_RETENTION);
|
||||
if (retentionAnnotation == null && annotationClass.isWritable()) {
|
||||
registerError(arg, annotationClass);
|
||||
if (retentionAnnotation == null) {
|
||||
if (annotationClass.isWritable()) {
|
||||
registerError(arg, annotationClass);
|
||||
} else {
|
||||
registerError(arg);
|
||||
}
|
||||
return;
|
||||
}
|
||||
final PsiAnnotationParameterList parameters = retentionAnnotation.getParameterList();
|
||||
|
||||
Reference in New Issue
Block a user