Package edu.umd.cs.findbugs.ba

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


     * @param xmethod
     *            the method
     * @return a SourceLineAnnotation for the entire method
     */
    public static SourceLineAnnotation forEntireMethod(JavaClass javaClass, XMethod xmethod) {
        JavaClassAndMethod m = Hierarchy.findMethod(javaClass, xmethod.getName(), xmethod.getSignature());
        if (m == null) {
            return createUnknown(javaClass.getClassName(), javaClass.getSourceFileName());
        } else {
            return forEntireMethod(javaClass, m.getMethod());
        }
    }
View Full Code Here


    public boolean isSignificant() {
        return false;
    }

    static SourceLineAnnotation getSourceAnnotationForMethod(String className, String methodName, String methodSig) {
        JavaClassAndMethod targetMethod = null;
        Code code = null;

        try {
            JavaClass targetClass = AnalysisContext.currentAnalysisContext().lookupClass(className);
            targetMethod = Hierarchy.findMethod(targetClass, methodName, methodSig);
            if (targetMethod != null) {
                Method method = targetMethod.getMethod();
                if (method != null) {
                    code = method.getCode();
                }
            }

        } catch (ClassNotFoundException e) {
            AnalysisContext.reportMissingClass(e);
        }
        SourceInfoMap sourceInfoMap = AnalysisContext.currentAnalysisContext().getSourceInfoMap();
        SourceInfoMap.SourceLineRange range = sourceInfoMap.getMethodLine(className, methodName, methodSig);

        if (range != null) {
            return new SourceLineAnnotation(className, AnalysisContext.currentAnalysisContext().lookupSourceFile(className),
                    range.getStart(), range.getEnd(), 0, code == null ? -1 : code.getLength());
        }

        if (sourceInfoMap.fallBackToClassfile() && targetMethod != null) {
            return forEntireMethod(targetMethod.getJavaClass(), targetMethod.getMethod());
        }

        // If we couldn't find the source lines,
        // create an unknown source line annotation referencing
        // the class and source file.
View Full Code Here

        // Construct the CFG in its raw form
        MethodGen methodGen = analysisCache.getMethodAnalysis(MethodGen.class, descriptor);
        if (methodGen == null) {
            JavaClass jclass = analysisCache.getClassAnalysis(JavaClass.class, descriptor.getClassDescriptor());
            Method method = analysisCache.getMethodAnalysis(Method.class, descriptor);
            JavaClassAndMethod javaClassAndMethod = new JavaClassAndMethod(jclass, method);
            AnalysisContext.currentAnalysisContext().getLookupFailureCallback().reportSkippedAnalysis(descriptor);
            throw new MethodUnprofitableException(javaClassAndMethod);
        }
        CFGBuilder cfgBuilder = CFGBuilderFactory.create(descriptor, methodGen);
        cfgBuilder.build();
View Full Code Here

            String methodName = method.getName();
            int codeLength = method.getCode().getLength();
            String superclassName = jclass.getSuperclassName();
            if (codeLength > 6000 && methodName.equals("<clinit>") && superclassName.equals("java.lang.Enum")) {
                analysisContext.getLookupFailureCallback().reportSkippedAnalysis(
                        new JavaClassAndMethod(jclass, method).toMethodDescriptor());
                return null;
            }
            if (analysisContext.getBoolProperty(AnalysisFeatures.SKIP_HUGE_METHODS)) {
                if (codeLength > 6000 || (methodName.equals("<clinit>") || methodName.equals("getContents")) && codeLength > 2000) {
                    analysisContext.getLookupFailureCallback().reportSkippedAnalysis(
                            new JavaClassAndMethod(jclass, method).toMethodDescriptor());
                    return null;
                }
            }

            return new MethodGen(method, jclass.getClassName(), cpg);
View Full Code Here

        IsNullValueAnalysis invAnalysis = new IsNullValueAnalysis(descriptor, methodGen, cfg, vnaDataflow, typeDataflow, dfs,
                assertionMethods);

        // Set return value and parameter databases

        invAnalysis.setClassAndMethod(new JavaClassAndMethod(getJavaClass(analysisCache, descriptor.getClassDescriptor()),
                getMethod(analysisCache, descriptor)));

        IsNullValueDataflow invDataflow = new IsNullValueDataflow(cfg, invAnalysis);
        invDataflow.execute();
        if (ClassContext.DUMP_DATAFLOW_ANALYSIS) {
View Full Code Here

                System.out.println("Method invocation: " + location.getHandle());
                System.out.println("\tInvoking: "
                        + SignatureConverter.convertMethodSignature((InvokeInstruction) ins, classContext.getConstantPoolGen()));

                JavaClassAndMethod proto = Hierarchy.findInvocationLeastUpperBound((InvokeInstruction) ins,
                        classContext.getConstantPoolGen());
                if (proto == null) {
                    System.out.println("\tUnknown prototype method");
                } else {
                    System.out.println("\tPrototype method: class=" + proto.getJavaClass().getClassName() + ", method="
                            + proto.getMethod());
                }
                Set<JavaClassAndMethod> calledMethodSet = Hierarchy.resolveMethodCallTargets((InvokeInstruction) ins,
                        classContext.getTypeDataflow(method).getFactAtLocation(location), classContext.getConstantPoolGen());
                System.out.println("\tTarget method set: " + calledMethodSet);
            }
View Full Code Here

        }

        try {
            JavaClass[] superclassList = javaClass.getSuperClasses();
            if (superclassList != null) {
                JavaClassAndMethod match = Hierarchy.findMethod(superclassList, method.getName(), method.getSignature(),
                        Hierarchy.INSTANCE_METHOD);
                if (match != null) {
                    return true;
                }
            }

            JavaClass[] interfaceList = javaClass.getAllInterfaces();
            if (interfaceList != null) {
                JavaClassAndMethod match = Hierarchy.findMethod(interfaceList, method.getName(), method.getSignature(),
                        Hierarchy.INSTANCE_METHOD);
                if (match != null) {
                    return true;
                }
            }
View Full Code Here

TOP

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

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.