You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
MC_OVERRIDABLE_METHOD_CALL_IN_CONSTRUCTOR is reported for mere method references, without them being invoked. This happens with sb-contrib version 7.6.4 (current release).
Both predicate1 and predicate2 produce the bug. In case of predicate1, the method is clearly not called. In the case of predicate2, it might of course theoretically be called, but there are also a lot of use cases (like here) where the method reference is just passed to be stored for later use. (One of the actual use cases I have is a memoization wrapper for the overridable method, stored as a field.)
One issue is that this also cannot be worked around by adding @SuppressFBWarnings("MC_OVERRIDABLE_METHOD_CALL_IN_CONSTRUCTOR") to the field declaration.
Maybe, if the analysis cannot determine that the overridable method is being passed for immediate invocation (like when passed to well-known methods like Map::compute), this should instead map to a separate bug code.
The text was updated successfully, but these errors were encountered:
MC_OVERRIDABLE_METHOD_CALL_IN_CONSTRUCTOR is reported for mere method references, without them being invoked. This happens with sb-contrib version 7.6.4 (current release).
Example code:
Both
predicate1
andpredicate2
produce the bug. In case ofpredicate1
, the method is clearly not called. In the case ofpredicate2
, it might of course theoretically be called, but there are also a lot of use cases (like here) where the method reference is just passed to be stored for later use. (One of the actual use cases I have is a memoization wrapper for the overridable method, stored as a field.)One issue is that this also cannot be worked around by adding
@SuppressFBWarnings("MC_OVERRIDABLE_METHOD_CALL_IN_CONSTRUCTOR")
to the field declaration.Maybe, if the analysis cannot determine that the overridable method is being passed for immediate invocation (like when passed to well-known methods like
Map::compute
), this should instead map to a separate bug code.The text was updated successfully, but these errors were encountered: