[java-inspections] ReflectionForUnavailableAnnotation: provide fix if the @Retention annotation is presented

(IJ-CR-14614)

GitOrigin-RevId: 39fe3f01bb989cfee948773cfabc748fbd0eeebd
This commit is contained in:
Andrey.Cherkasov
2021-10-18 13:22:44 +03:00
committed by intellij-monorepo-bot
parent 06369b2c81
commit 48d2830934
7 changed files with 61 additions and 18 deletions

View File

@@ -0,0 +1,17 @@
// "Annotate annotation 'Test' as @Retention(RetentionPolicy.RUNTIME)" "true"
import java.lang.annotation.ElementType;
import java.lang.annotation.Retention;
import java.lang.annotation.RetentionPolicy;
import java.lang.annotation.Target;
import java.lang.reflect.Method;
@Retention(RetentionPolicy.RUNTIME)
@Target(ElementType.METHOD)
@interface Test {
}
class Main {
private static boolean hasTestAnnotation(Method method) {
return method.getAnnotation(Test.class) != null;
}
}

View File

@@ -1,4 +1,4 @@
// "Annotate annotation 'Test' as @Retention" "true"
// "Annotate annotation 'Test' as @Retention(RetentionPolicy.RUNTIME)" "true"
import java.lang.annotation.ElementType;
import java.lang.annotation.Retention;
import java.lang.annotation.RetentionPolicy;

View File

@@ -1,4 +1,4 @@
// "Annotate annotation 'Test' as @Retention" "false"
// "Annotate annotation 'Test' as @Retention(RetentionPolicy.RUNTIME)" "true"
import java.lang.annotation.ElementType;
import java.lang.annotation.Retention;
import java.lang.annotation.RetentionPolicy;

View File

@@ -1,4 +1,4 @@
// "Annotate annotation 'NotNull' as @Retention" "false"
// "Annotate annotation 'NotNull' as @Retention(RetentionPolicy.RUNTIME)" "false"
import org.jetbrains.annotations.NotNull;
import java.lang.reflect.Method;

View File

@@ -1,4 +1,4 @@
// "Annotate annotation 'Test' as @Retention" "true"
// "Annotate annotation 'Test' as @Retention(RetentionPolicy.RUNTIME)" "true"
import java.lang.annotation.ElementType;
import java.lang.annotation.Target;
import java.lang.reflect.Method;

View File

@@ -1,4 +1,4 @@
// "Annotate annotation 'Subst' as @Retention" "false"
// "Annotate annotation 'Subst' as @Retention(RetentionPolicy.RUNTIME)" "false"
import org.intellij.lang.annotations.Subst;
import java.lang.reflect.Method;