|
25 | 25 |
|
26 | 26 | package java.lang.reflect; |
27 | 27 |
|
| 28 | +import org.checkerframework.checker.nullness.qual.Nullable; |
| 29 | +import org.checkerframework.framework.qual.AnnotatedFor; |
| 30 | +import org.checkerframework.framework.qual.CFComment; |
| 31 | + |
28 | 32 | import java.lang.annotation.Annotation; |
29 | 33 | import java.lang.invoke.MethodHandle; |
30 | 34 | import java.security.AccessController; |
|
72 | 76 | * @revised 9 |
73 | 77 | * @spec JPMS |
74 | 78 | */ |
| 79 | +@AnnotatedFor({"nullness"}) |
75 | 80 | public class AccessibleObject implements AnnotatedElement { |
76 | 81 |
|
77 | 82 | static void checkPermission() { |
@@ -444,6 +449,7 @@ public boolean isAccessible() { |
444 | 449 | * @see #setAccessible(boolean) |
445 | 450 | */ |
446 | 451 | @CallerSensitive |
| 452 | + @CFComment("Sometimes null is forbidden; other times, it is required") |
447 | 453 | public final boolean canAccess(Object obj) { |
448 | 454 | if (!Member.class.isInstance(this)) { |
449 | 455 | return override; |
@@ -503,7 +509,7 @@ protected AccessibleObject() {} |
503 | 509 | * @throws NullPointerException {@inheritDoc} |
504 | 510 | * @since 1.5 |
505 | 511 | */ |
506 | | - public <T extends Annotation> T getAnnotation(Class<T> annotationClass) { |
| 512 | + public <T extends Annotation> @Nullable T getAnnotation(Class<T> annotationClass) { |
507 | 513 | throw new AssertionError("All subclasses should override this method"); |
508 | 514 | } |
509 | 515 |
|
@@ -538,7 +544,7 @@ public Annotation[] getAnnotations() { |
538 | 544 | * @since 1.8 |
539 | 545 | */ |
540 | 546 | @Override |
541 | | - public <T extends Annotation> T getDeclaredAnnotation(Class<T> annotationClass) { |
| 547 | + public <T extends Annotation> @Nullable T getDeclaredAnnotation(Class<T> annotationClass) { |
542 | 548 | // Only annotations on classes are inherited, for all other |
543 | 549 | // objects getDeclaredAnnotation is the same as |
544 | 550 | // getAnnotation. |
|
0 commit comments