1/4 Added @Nullable to return type of org.springframework.asm.AnnotationVisitor::visitAnnotation

Reasons: 1. On inspection, the method may return null 2. The method is overridden by methods with nullable annotation (violating LSP indicating that return types should not be generalised in overridden methods, assuming that most static null checkers will use the nonull-by-default assumption):

  • org.springframework.core.type.classreading.MergedAnnotationReadingVisitor::visitAnnotation
  • org.springframework.core.type.classreading.MergedAnnotationReadingVisitor$ArrayVisitor::visitAnnotation

2/4 Added @Nullable to return type of org.springframework.asm.ClassVisitor::visitMethod

Reasons: 1. On inspection, the method may return null 2. The method is overridden by methods with nullable annotation (violating LSP indicating that return types should not be generalised in overridden methods, assuming that most static null checkers will use the nonull-by-default assumption):

  • org.springframework.core.type.classreading.SimpleAnnotationMetadataReadingVisitor::visitMethod
  • org.springframework.core.LocalVariableTableParameterNameDiscoverer$ParameterNameDiscoveringVisitor::visitMethod

3/4 Added @Nullable to return type of org.springframework.asm.ClassVisitor::visitAnnotation

Reasons: 1. On inspection, the method may return null 2. The method is overridden by methods with nullable annotation (violating LSP indicating that return types should not be generalised in overridden methods, assuming that most static null checkers will use the nonull-by-default assumption):

  • org.springframework.core.type.classreading.SimpleAnnotationMetadataReadingVisitor::visitAnnotation

4/4 Added @Nullable to return type of org.springframework.asm.MethodVisitor::visitAnnotation

Reasons: 1. On inspection, the method may return null 2. The method is overridden by methods with nullable annotation (violating LSP indicating that return types should not be generalised in overridden methods, assuming that most static null checkers will use the nonull-by-default assumption):

  • org.springframework.core.type.classreading.SimpleMethodMetadataReadingVisitor::visitAnnotation

Note that there are similar methods in those classes that could also be annotated as @Nullable based on code inspection. This PR is conservative as it only adds @Nullable to methods where there are multiple reasons. If this gets accepted, I can create a separate PR for those.

Comment From: pivotal-cla

@jensdietrich Please sign the Contributor License Agreement!

Click here to manually synchronize the status of this Pull Request.

See the FAQ for frequently asked questions.

Comment From: pivotal-cla

@jensdietrich Thank you for signing the Contributor License Agreement!

Comment From: snicoll

@jensdietrich thanks for the PR but ASM is a 3rd party lib we shade and we don't want to modify them.

Comment From: jensdietrich

Makes sense, I should have checked for shading.