저는 매우 간단한 클래스와 Immutables 라이브러리를 사용합니다. 정의하는 자동 생성 된 코드는 방법과 같이 동일 :Immutables lib는 @Nullable을 equals() 메소드에 추가합니다.
@Nullable 주석이 다음 FindBugs 오류가 발생@Override
public boolean equals(@Nullable Object another) {
:
NP_METHOD_PARAMETER_TIGHTENS_ANNOTATION: Method tightens nullness annotation on parameter
A method should always implement the contract of a method it overrides. Thus, if a method takes a parameter that is marked as @Nullable, you shouldn't override that method in a subclass with a method where that parameter is @Nonnull. Doing so violates the contract that the method should handle a null parameter.
내가 Immutables 값-2.5.6.jar
을 사용하고를이 오류를 본 사람이 있습니까? 내가 추가하여이 문제를 일시적으로 완화 한
다음 Immutables 클래스에
@SuppressFBWarnings
. 그러나 이것이 장기적인 해결책이라고 생각하지 않습니다. 내가 잃어버린 뭔가가있을거야.
생성 된 코드의 하위 클래스가 있는데, 아마도 'equals'을 재정의하고 주석을 추가하지 않습니까? – ThrawnCA
이 경우에 발생하므로 무시 클래스가 받아들이는 입력을 확장하면 좋다고 생각합니다. '@ Nullable'에서'@ Nonnull'으로가는 것은 분명히 계약 위반 일 것이고, 다른 길은 단순히 계약의 연장 일뿐입니다. 이 경우 FB가 잘못되었습니다. – Henrik