Class UnnecessaryLongToIntConversion

All Implemented Interfaces:
BugChecker.MethodInvocationTreeMatcher, Suppressible, Serializable

public class UnnecessaryLongToIntConversion
extends BugChecker
implements BugChecker.MethodInvocationTreeMatcher
A BugChecker; see the associated BugPattern annotation for details.
See Also:
Serialized Form
  • Constructor Details

    • UnnecessaryLongToIntConversion

      public UnnecessaryLongToIntConversion()
  • Method Details

    • matchMethodInvocation

      public Description matchMethodInvocation​(com.sun.source.tree.MethodInvocationTree tree, VisitorState state)
      Matches if a long or Long is converted to an int for a long parameter in a method invocation.

      Does **not** match if the method parameter is a Long, because passing an int or Integer for a Long parameter produces an incompatible types error. Does **not** match when a long or Long is converted to an Integer because this requires first converting to an int and then to an Integer. This is awkwardly complex and out of scope. Does **not** match when the conversion occurs in a separate statement prior the method invocation.

      Specified by:
      matchMethodInvocation in interface BugChecker.MethodInvocationTreeMatcher