Class CheckRelaxingNullnessAnnotation
java.lang.Object
org.objectweb.asm.ClassVisitor
org.objectweb.asm.tree.ClassNode
edu.umd.cs.findbugs.asm.ClassNodeDetector
edu.umd.cs.findbugs.detect.CheckRelaxingNullnessAnnotation
- All Implemented Interfaces:
Detector2, Priorities
Checks that overriding methods do not relax
NonNull (made
Nullable) on return values or Nullable (made
NonNull) on parameters.
The code accepts also old (deprecated) nullness annotations from
edu.umd.cs.findbugs.annotations package.-
Nested Class Summary
Nested ClassesModifier and TypeClassDescriptionprivate final classprivate class -
Field Summary
Fields inherited from class ClassNodeDetector
bugReporter, xclassFields inherited from class org.objectweb.asm.tree.ClassNode
access, attrs, fields, innerClasses, interfaces, invisibleAnnotations, invisibleTypeAnnotations, methods, module, name, nestHostClass, nestMembers, outerClass, outerMethod, outerMethodDesc, permittedSubclasses, recordComponents, signature, sourceDebug, sourceFile, superName, version, visibleAnnotations, visibleTypeAnnotationsFields inherited from class org.objectweb.asm.ClassVisitor
api, cvFields inherited from interface Priorities
EXP_PRIORITY, HIGH_PRIORITY, IGNORE_PRIORITY, LOW_PRIORITY, NORMAL_PRIORITY -
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescription(package private) static booleanareRelated(String sig, String superSig) (package private) static booleancompatibleParameters(String signature, String superSignature) (package private) static booleancontainsNullness(Collection<AnnotationValue> annotations, NullnessAnnotation nullness) (package private) static booleancontainsRelaxedNonNull(@Nullable List<org.objectweb.asm.tree.AnnotationNode> methodAnnotations) (package private) static booleancontainsRelaxedNonNullTypeUse(@Nullable List<org.objectweb.asm.tree.TypeAnnotationNode> typeAnnotations) (package private) static Map<Integer, NullnessAnnotation> getNonnullOrNullableParams(@Nullable List<org.objectweb.asm.tree.AnnotationNode> @Nullable [] parameterAnnotations) Extracts nullness annotations from parameter declaration annotations.(package private) static Map<Integer, NullnessAnnotation> getNonnullOrNullableParamsFromTypeAnnotations(@Nullable List<org.objectweb.asm.tree.TypeAnnotationNode> typeAnnotations) Extracts nullness annotations from method type annotations on formal parameters.(package private) static @Nullable NullnessAnnotationgetNullness(String annotationDesc) org.objectweb.asm.MethodVisitorvisitMethod(int methodAccess, String methodName, String desc, String methodSignature, String[] exceptions) Methods inherited from class ClassNodeDetector
finishPass, getClassInfo, visitClassMethods inherited from class org.objectweb.asm.tree.ClassNode
accept, check, visit, visitAnnotation, visitAttribute, visitEnd, visitField, visitInnerClass, visitModule, visitNestHost, visitNestMember, visitOuterClass, visitPermittedSubclass, visitRecordComponent, visitSource, visitTypeAnnotationMethods inherited from class org.objectweb.asm.ClassVisitor
getDelegateMethods inherited from class Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, waitMethods inherited from interface Detector2
getDetectorClassName
-
Constructor Details
-
CheckRelaxingNullnessAnnotation
-
-
Method Details
-
visitMethod
-
containsRelaxedNonNull
static boolean containsRelaxedNonNull(@Nullable List<org.objectweb.asm.tree.AnnotationNode> methodAnnotations) -
containsRelaxedNonNullTypeUse
static boolean containsRelaxedNonNullTypeUse(@Nullable List<org.objectweb.asm.tree.TypeAnnotationNode> typeAnnotations) -
getNonnullOrNullableParams
static Map<Integer, NullnessAnnotation> getNonnullOrNullableParams(@Nullable List<org.objectweb.asm.tree.AnnotationNode> @Nullable [] parameterAnnotations) Extracts nullness annotations from parameter declaration annotations.The map keys are the zero-based formal parameter indices, derived from each parameter's position in the parameter-annotation array. Annotations classified as
NullnessAnnotation.CHECK_FOR_NULLare ignored.- Parameters:
parameterAnnotations- the parameter declaration annotations, ornull- Returns:
- a map from formal parameter indices to their nullness annotations,
or an empty map if the parameter-annotation array is
nullor contains no relevant nullness annotations
-
getNonnullOrNullableParamsFromTypeAnnotations
static Map<Integer, NullnessAnnotation> getNonnullOrNullableParamsFromTypeAnnotations(@Nullable List<org.objectweb.asm.tree.TypeAnnotationNode> typeAnnotations) Extracts nullness annotations from method type annotations on formal parameters.Only annotations targeting
TypeReference.METHOD_FORMAL_PARAMETERare considered. The map keys are the zero-based formal parameter indices encoded in the type references, rather than positions in the type-annotation list, which may contain annotations for other targets. Annotations classified asNullnessAnnotation.CHECK_FOR_NULLare ignored.- Parameters:
typeAnnotations- the method's visible or invisible type annotations, ornull- Returns:
- a map from formal parameter indices to their nullness annotations,
or an empty map if the type-annotation list is
nullor contains no relevant nullness annotations
-
getNullness
-
containsNullness
static boolean containsNullness(Collection<AnnotationValue> annotations, NullnessAnnotation nullness) -
compatibleParameters
-
areRelated
-