eclipse-jdt / eclipse-jdt/eclipse.jdt.ui
AddMissingMethodDeclarationFixCore makes unsafe call to getFunctionalInterfaceMethod() - NPE
- Dominant language
- Java
- Stars
- 59
- Forks
- 127
- Avg merge
- 21h 41m
- Merged PRs (30d)
- 31
Description
QuickAssistProcessorUtil has the following code,calling `getFunctionalInterfaceMethod` but checking the result for null:
```
public static IMethodBinding getFunctionalMethodForMethodReference(MethodReference methodReference) {
ITypeBinding targetTypeBinding= ASTNodes.getTargetType(methodReference);
if (targetTypeBinding == null)
return null;
IMethodBinding functionalMethod= targetTypeBinding.getFunctionalInterfaceMethod();
if (functionalMethod != null && functionalMethod.isSynthetic()) {
functionalMethod= Bindings.findOverriddenMethodInType(functionalMethod.getDeclaringClass(), functionalMethod);
}
return functionalMethod;
}
```
However similar code in `AddMissingMethodDeclarationFixCore` does not proceed in a null-safe fashion:
```
ITypeBinding[] parameterTypes= methodBinding.getParameterTypes();
ITypeBinding[] typeArguments= methodBinding.getTypeArguments();
ITypeBinding[] parameterTypesFunctionalInterface= parameterTypes[index].getFunctionalInterfaceMethod().getParameterTypes();
ITypeBinding returnTypeBindingFunctionalInterface= parameterTypes[index].getFunctionalInterfaceMethod().getReturnType();
```
Contributor guide
Assessment
This issue has not been assessed yet.