Details
-
Bug
-
Status: Closed
-
Minor
-
Resolution: Fixed
-
2.0.5
-
None
-
None
-
Patch
Description
The problem appears in version 1.8.4 and in revision 4cf5263.. I
attached a one-line patch (patch.diff) that fixes it. I will also
post (in the "Comments" section) the URL for the github pull request.
The entire work performed in method
"ClassCompletionVerifier.checkMethodForWeakerAccessPrivileges"
produces no result when the parameter "MethodNode mn" represents a
public method, i.e., when "mn.isPublic()" is "true". This condition
can be evaluated right at the beginning of the
"checkMethodForWeakerAccessPrivileges" method body, thus avoiding the
entire method execution.
We can have this fast exist because the method
"checkMethodForWeakerAccessPrivileges" produces results only when this
condition (in the method code):
if ((mn.isPrivate() && !superMethod.isPrivate()) ||
(mn.isProtected() && superMethod.isPublic()))
evaluates to "true", which does not happen when "mn.isPublic()" is
"true" (i.e., when "!mn.isPrivate() && !mn.isProtected()" is "true").
I attached a second one-line patch (patchTwoCond.diff) where I use the
condition "!mn.isPrivate() && !mn.isProtected()" instead of
"mn.isPublic()", in case you prefer the longer condition.