Class FindUnrelatedTypesInGenericContainer

  • All Implemented Interfaces:
    Detector, Priorities

    public class FindUnrelatedTypesInGenericContainer
    extends java.lang.Object
    implements Detector
    • Field Detail

      • DEBUG

        private static final boolean DEBUG
      • callMap

        private final MultiMap<java.lang.String,​FindUnrelatedTypesInGenericContainer.Info> callMap
        Map classname, methodname and signature to an int []. Each position in the int [] corresponds to an argument in the methodSignature. For each argument i, the value at position i corresponds to the index of the corresponding type in the class type parameters. If the argument has no correspondence, then the value is -1.

        Get the String key by calling getCollectionsMapKey()

      • baseGenericTypes

        @StaticConstant
        static final java.util.Set<java.lang.String> baseGenericTypes
    • Constructor Detail

      • FindUnrelatedTypesInGenericContainer

        public FindUnrelatedTypesInGenericContainer​(BugReporter bugReporter)
    • Method Detail

      • addCheckedCall

        private void addCheckedCall​(@DottedClassName
                                    java.lang.String className,
                                    java.lang.String methodName,
                                    java.lang.String sig,
                                    int argumentParameterIndex,
                                    int typeParameterIndex)
      • addCheckedCall

        private void addCheckedCall​(@DottedClassName
                                    java.lang.String className,
                                    java.lang.String methodName,
                                    int typeParameterIndex)
      • prescreen

        public boolean prescreen​(ClassContext classContext,
                                 org.apache.bcel.classfile.Method method)
        Use this to screen out methods that do not contain invocations.
      • isSynthetic

        private boolean isSynthetic​(org.apache.bcel.classfile.Method m)
        Methods marked with the "Synthetic" attribute do not appear in the source code
      • isGenericCollection

        private boolean isGenericCollection​(ClassDescriptor operandClass)
      • compareTypes

        private IncompatibleTypes compareTypes​(org.apache.bcel.generic.Type expectedType,
                                               org.apache.bcel.generic.Type actualType,
                                               boolean ignoreBaseType)
        Compare to see if the argument argType passed to the method matches the type of the corresponding parameter. The simplest case is when both are equal.

        This is a conservative comparison - returns true if it cannot decide. If the parameter type is a type variable (e.g. T) then we don't know enough (yet) to decide if they do not match so return true.

        Parameters:
        ignoreBaseType - TODO
      • compareTypesOld

        private boolean compareTypesOld​(org.apache.bcel.generic.Type parmType,
                                        org.apache.bcel.generic.Type argType)