Package edu.umd.cs.findbugs.ba

Examples of edu.umd.cs.findbugs.ba.XMethod


        Location location = new Location(handle, basicBlock);

        Instruction i = handle.getInstruction();
        if (i instanceof InvokeInstruction) {
            InvokeInstruction ii = (InvokeInstruction) i;
            XMethod m = XFactory.createXMethod(ii, cpg);
            if (TypeQualifierDataflowAnalysis.isIdentifyFunctionForTypeQualifiers(m)) {
                ValueNumberFrame vnaFrameAtLocation = vnaDataflow.getFactAtLocation(location);
                ValueNumberFrame vnaFrameAfterInstruction = vnaDataflow.getFactAfterLocation(location);
                ValueNumber in = vnaFrameAtLocation.getStackValue(0);
                ValueNumber out = vnaFrameAfterInstruction.getStackValue(0);
View Full Code Here


            }
            // AnalysisContext.logError("Error adding built-in nullness annotation",
            // e);
            return null;
        }
        XMethod xmethod = xclass.findMethod(mName, sig, isStatic);

        if (xmethod == null) {
            xmethod = XFactory.createXMethod(cName, mName, sig, isStatic);
        }
        return xmethod;
View Full Code Here

    @Override
    public void addMethodAnnotation(String cName, String mName, String sig, boolean isStatic, NullnessAnnotation annotation) {
        if (DEBUG) {
            System.out.println("addMethodAnnotation: annotate " + cName + "." + mName + " with " + annotation);
        }
        XMethod xmethod = getXMethod(cName, mName, sig, isStatic);
        if (xmethod == null) {
            return;
        }
        // Get JSR-305 nullness annotation type
        ClassDescriptor nullnessAnnotationType = getNullnessAnnotationClassDescriptor(annotation);

        // Create an AnnotationValue
        AnnotationValue annotationValue = new AnnotationValue(nullnessAnnotationType);

        // Destructively add the annotation to the MethodInfo object
        xmethod.addAnnotation(annotationValue);
    }
View Full Code Here

            int param, NullnessAnnotation annotation) {
        if (DEBUG) {
            System.out.println("addMethodParameterAnnotation: annotate " + cName + "." + mName + " param " + param + " with "
                    + annotation);
        }
        XMethod xmethod = getXMethod(cName, mName, sig, isStatic);
        if (xmethod == null) {
            return;
        }
        // Get JSR-305 nullness annotation type
        ClassDescriptor nullnessAnnotationType = getNullnessAnnotationClassDescriptor(annotation);

        // Create an AnnotationValue
        AnnotationValue annotationValue = new AnnotationValue(nullnessAnnotationType);

        if (!xmethod.getClassName().equals(cName)) {
            if (SystemProperties.ASSERTIONS_ENABLED) {
                AnalysisContext.logError("Could not fully resolve method " + cName + "." + mName + sig + " to apply annotation "
                        + annotation);
            }
            return;
        }

        if (SystemProperties.ASSERTIONS_ENABLED) {
            SignatureParser parser = new SignatureParser(sig);
            int numParams = parser.getNumParameters();
            assert param < numParams;
        }


        // Destructively add the annotation to the MethodInfo object
        xmethod.addParameterAnnotation(param, annotationValue);
    }
View Full Code Here

     */
    @Override
    public boolean visitClass(ClassDescriptor classDescriptor, XClass xclass) {
        assert xclass != null;
        String methodSignature;
        XMethod bridgedFrom = xmethod.bridgeFrom();
        if (bridgedFrom != null && !classDescriptor.equals(xmethod.getClassDescriptor())) {
            methodSignature = bridgedFrom.getSignature();
        } else {
            methodSignature = xmethod.getSignature();
        }
        // See if this class has an overridden method
        XMethod xm = xclass.findMethod(xmethod.getName(), methodSignature, false);
        if (xm == null && bridgedFrom != null && xclass.isInterface()) {
            // if the method is bridged and the superclass is an interface,
            // check the exact signature as well
            xm = xclass.findMethod(xmethod.getName(), xmethod.getSignature(), false);
        }
View Full Code Here

    }

    private void modelArguments(Location location) throws DataflowAnalysisException {
        // Model arguments to called method
        InvokeInstruction inv = (InvokeInstruction) location.getHandle().getInstruction();
        XMethod calledMethod = XFactory.createXMethod(inv, cpg);

        SignatureParser sigParser = new SignatureParser(calledMethod.getSignature());
        if (sigParser.getNumParameters() == 0) {
            return;
        }
        ValueNumberFrame vnaFrame = vnaDataflow.getFactAtLocation(location);

        if (!vnaFrame.isValid()) {
            // AnalysisContext.logError("bad vna frame  in " + xmethod +
            // " at location " + location.getHandle().getPosition() +
            // " calling " + calledMethod);
            return;
        }

        if (TypeQualifierDataflowAnalysis.isIdentifyFunctionForTypeQualifiers(calledMethod)) {
            return;
        }

        for (int param = 0; param < calledMethod.getNumParams(); param++) {
            TypeQualifierAnnotation tqa = TypeQualifierApplications.getEffectiveTypeQualifierAnnotation(calledMethod, param,
                    typeQualifierValue);

            boolean interproc = false;
            if (TypeQualifierDatabase.USE_DATABASE && tqa == null) {
                // See if there's an entry for this parameter
                // in the interprocedural type qualifier database.
                TypeQualifierDatabase tqdb = Global.getAnalysisCache().getDatabase(TypeQualifierDatabase.class);
                tqa = tqdb.getParameter(calledMethod.getMethodDescriptor(), param, typeQualifierValue);
                if (tqa != null) {
                    interproc = true;
                }
            }
View Full Code Here

            // Annotation elements appear as abstract methods in the annotation
            // class (interface).
            // So, if the type qualifier annotation has specified a default When
            // value,
            // it will appear as an abstract method called "when".
            XMethod whenMethod = xclass.findMethod("when", "()Ljavax/annotation/meta/When;", false);
            if (whenMethod == null) {
                isStrict1 = true;
            }
            for (XMethod xmethod : xclass.getXMethods()) {
                if (xmethod.getName().equals("value") && xmethod.getSignature().startsWith("()")) {
View Full Code Here

        if (CHECK_ANNOTATIONS && instruction instanceof InvokeInstruction) {
            checkNonNullParams(location, vnaFrame, fact);
        }

        if (CHECK_ANNOTATIONS && instruction instanceof ARETURN) {
            XMethod thisMethod = XFactory.createXMethod(methodGen);
            checkNonNullReturnValue(thisMethod, location, vnaFrame, fact);
        }

        if (CHECK_ANNOTATIONS && (instruction instanceof PUTFIELD || instruction instanceof PUTSTATIC)) {
            checkNonNullPutField(location, vnaFrame, fact);
View Full Code Here

            return Collections.emptySet();
        }
        INullnessAnnotationDatabase database = AnalysisContext.currentAnalysisContext().getNullnessAnnotationDatabase();

        InvokeInstruction inv = (InvokeInstruction) location.getHandle().getInstruction();
        XMethod called = XFactory.createXMethod(inv, constantPool);
        SignatureParser sigParser = new SignatureParser(called.getSignature());
        int numParams = sigParser.getNumParameters();

        Set<ValueNumber> result = new HashSet<ValueNumber>();
        Iterator<String> parameterIterator = sigParser.parameterSignatureIterator();
        for (int i = 0; i < numParams; i++) {
            String parameterSignature = parameterIterator.next();
            char firstChar = parameterSignature.charAt(0);
            if (firstChar != 'L' && firstChar != '[') {
                continue;
            }
            int offset = sigParser.getSlotsFromTopOfStackForParameter(i);
            if (invFrame != null) {
                int slot = invFrame.getStackLocation(offset);
                if (!reportDereference(invFrame, slot)) {
                    continue;
                }
            }
            if (database.parameterMustBeNonNull(called, i)) {
                int catchSizeNPE = Util.getSizeOfSurroundingTryBlock(method, "java/lang/NullPointerException", location
                        .getHandle().getPosition());
                int catchSizeNFE = Util.getSizeOfSurroundingTryBlock(method, "java/lang/NumberFormatException", location
                        .getHandle().getPosition());
                if (catchSizeNPE == Integer.MAX_VALUE
                        && (!called.getClassName().equals("java.lang.Integer") || catchSizeNFE == Integer.MAX_VALUE)) {
                    // Get the corresponding value number
                    ValueNumber vn = vnaFrame.getArgument(inv, constantPool, i, sigParser);
                    result.add(vn);
                }
            }
View Full Code Here

     *         effective TypeQualifierAnnotation on this AnnotatedObject
     */
    public static TypeQualifierAnnotation getEffectiveTypeQualifierAnnotation(AnnotatedObject o,
            TypeQualifierValue<?> typeQualifierValue) {
        if (o instanceof XMethod) {
            XMethod m = (XMethod) o;
            if (m.getName().startsWith("access$")) {
                InnerClassAccessMap icam = AnalysisContext.currentAnalysisContext().getInnerClassAccessMap();
                try {
                    InnerClassAccess ica = icam.getInnerClassAccess(m.getClassName(), m.getName());
                    if (ica != null && ica.isLoad()) {
                        o = ica.getField();
                    }
                } catch (ClassNotFoundException e) {
                    AnalysisContext.reportMissingClass(e);
View Full Code Here

TOP

Related Classes of edu.umd.cs.findbugs.ba.XMethod

Copyright © 2018 www.massapicom. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.