• 如果您觉得本站非常有看点,那么赶紧使用Ctrl+D 收藏吧

Java Dataflow类的典型用法和代码示例

java 2次浏览

本文整理汇总了Java中edu.umd.cs.findbugs.ba.Dataflow的典型用法代码示例。如果您正苦于以下问题:Java Dataflow类的具体用法?Java Dataflow怎么用?Java Dataflow使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。

Dataflow类属于edu.umd.cs.findbugs.ba包,在下文中一共展示了Dataflow类的9个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的Java代码示例。

示例1: inspectResult

点赞 2

import edu.umd.cs.findbugs.ba.Dataflow; //导入依赖的package包/类
@Override
public void inspectResult(ClassContext classContext, MethodGen methodGen, CFG cfg,
        Dataflow<ResourceValueFrame, ResourceValueAnalysis<Lock>> dataflow, Lock resource) {

    JavaClass javaClass = classContext.getJavaClass();

    ResourceValueFrame exitFrame = dataflow.getResultFact(cfg.getExit());
    if (DEBUG) {
        System.out.println("Resource value at exit: " + exitFrame);
    }
    int exitStatus = exitFrame.getStatus();

    if (exitStatus == ResourceValueFrame.OPEN || exitStatus == ResourceValueFrame.OPEN_ON_EXCEPTION_PATH) {
        String bugType;
        int priority;
        if (exitStatus == ResourceValueFrame.OPEN) {
            bugType = "UL_UNRELEASED_LOCK";
            priority = HIGH_PRIORITY;
        } else {
            bugType = "UL_UNRELEASED_LOCK_EXCEPTION_PATH";
            priority = NORMAL_PRIORITY;
        }

        String sourceFile = javaClass.getSourceFileName();
        Location location = resource.getLocation();
        InstructionHandle handle = location.getHandle();
        InstructionHandle nextInstruction = handle.getNext();
        if (nextInstruction.getInstruction() instanceof RETURN)
            return; // don't report as error; intentional
        bugAccumulator.accumulateBug(new BugInstance(this, bugType, priority).addClassAndMethod(methodGen, sourceFile),
                SourceLineAnnotation.fromVisitedInstruction(classContext, methodGen, sourceFile, handle));
    }
}
 

开发者ID:ytus,
项目名称:findbugs-all-the-bugs,
代码行数:34,
代码来源:FindUnreleasedLock.java

示例2: inspectResult

点赞 2

import edu.umd.cs.findbugs.ba.Dataflow; //导入依赖的package包/类
@Override
public void inspectResult(ClassContext classContext, MethodGen methodGen, CFG cfg,
        Dataflow<ResourceValueFrame, ResourceValueAnalysis<Stream>> dataflow, Stream stream) {

    if (DEBUG) {
        System.out.printf("Result for %s in %s%n", stream, methodGen);
        dataflow.dumpDataflow(dataflow.getAnalysis());
        
    }
    ResourceValueFrame exitFrame = dataflow.getResultFact(cfg.getExit());

    int exitStatus = exitFrame.getStatus();
    if (exitStatus == ResourceValueFrame.OPEN || exitStatus == ResourceValueFrame.OPEN_ON_EXCEPTION_PATH) {

        // FIXME: Stream object should be queried for the
        // priority.

        String bugType = stream.getBugType();
        int priority = NORMAL_PRIORITY;
        if (exitStatus == ResourceValueFrame.OPEN_ON_EXCEPTION_PATH) {
            bugType += "_EXCEPTION_PATH";
            priority = LOW_PRIORITY;
        }

        potentialOpenStreamList.add(new PotentialOpenStream(bugType, priority, stream));
    } else if (exitStatus == ResourceValueFrame.CLOSED) {
        // Remember that this stream was closed on all paths.
        // Later, we will mark all of the streams in its equivalence class
        // as having been closed.
        stream.setClosed();
    }
}
 

开发者ID:ytus,
项目名称:findbugs-all-the-bugs,
代码行数:33,
代码来源:FindOpenStream.java

示例3: analyzeMethod

点赞 2

import edu.umd.cs.findbugs.ba.Dataflow; //导入依赖的package包/类
public void analyzeMethod(ClassContext classContext, Method method, ResourceTrackerType resourceTracker,
        ResourceCollection<Resource> resourceCollection) throws CFGBuilderException, DataflowAnalysisException {

    MethodGen methodGen = classContext.getMethodGen(method);
    if (methodGen == null)
        return;
    try {
        CFG cfg = classContext.getCFG(method);
        DepthFirstSearch dfs = classContext.getDepthFirstSearch(method);

        if (DEBUG)
            System.out.println(SignatureConverter.convertMethodSignature(methodGen));

        for (Iterator<Resource> i = resourceCollection.resourceIterator(); i.hasNext();) {
            Resource resource = i.next();

            ResourceValueAnalysis<Resource> analysis = new ResourceValueAnalysis<Resource>(methodGen, cfg, dfs,
                    resourceTracker, resource);
            Dataflow<ResourceValueFrame, ResourceValueAnalysis<Resource>> dataflow = new Dataflow<ResourceValueFrame, ResourceValueAnalysis<Resource>>(
                    cfg, analysis);

            Profiler profiler = Global.getAnalysisCache().getProfiler();
            profiler.start(resourceTracker.getClass());
            try {
                dataflow.execute();
            } finally {
                profiler.end(resourceTracker.getClass());
            }
            inspectResult(classContext, methodGen, cfg, dataflow, resource);
        }
    } catch (RuntimeException e) {
        AnalysisContext.logError("Exception while analyzing " + methodGen.getClassName() + "." + methodGen.getName() + ":"
                + methodGen.getSignature(), e);
    }
}
 

开发者ID:ytus,
项目名称:findbugs-all-the-bugs,
代码行数:36,
代码来源:ResourceTrackingDetector.java

示例4: analyze

点赞 2

import edu.umd.cs.findbugs.ba.Dataflow; //导入依赖的package包/类
public DominatorsAnalysis analyze(IAnalysisCache analysisCache, MethodDescriptor descriptor) throws CheckedAnalysisException {
    CFG cfg = getCFG(analysisCache, descriptor);
    DepthFirstSearch dfs = getDepthFirstSearch(analysisCache, descriptor);
    DominatorsAnalysis analysis = new DominatorsAnalysis(cfg, dfs, true);
    Dataflow<java.util.BitSet, DominatorsAnalysis> dataflow = new Dataflow<java.util.BitSet, DominatorsAnalysis>(cfg,
            analysis);
    dataflow.execute();
    return analysis;
}
 

开发者ID:ytus,
项目名称:findbugs-all-the-bugs,
代码行数:10,
代码来源:DominatorsAnalysisFactory.java

示例5: analyze

点赞 2

import edu.umd.cs.findbugs.ba.Dataflow; //导入依赖的package包/类
public NonImplicitExceptionPostDominatorsAnalysis analyze(IAnalysisCache analysisCache, MethodDescriptor descriptor)
        throws CheckedAnalysisException {
    CFG cfg = getCFG(analysisCache, descriptor);
    NonImplicitExceptionPostDominatorsAnalysis analysis = new NonImplicitExceptionPostDominatorsAnalysis(cfg,
            getReverseDepthFirstSearch(analysisCache, descriptor), getDepthFirstSearch(analysisCache, descriptor));
    Dataflow<BitSet, PostDominatorsAnalysis> dataflow = new Dataflow<BitSet, PostDominatorsAnalysis>(cfg, analysis);
    dataflow.execute();

    return analysis;
}
 

开发者ID:ytus,
项目名称:findbugs-all-the-bugs,
代码行数:11,
代码来源:NonImplicitExceptionPostDominatorsAnalysisFactory.java

示例6: analyze

点赞 2

import edu.umd.cs.findbugs.ba.Dataflow; //导入依赖的package包/类
public NonExceptionPostdominatorsAnalysis analyze(IAnalysisCache analysisCache, MethodDescriptor descriptor)
        throws CheckedAnalysisException {
    CFG cfg = getCFG(analysisCache, descriptor);
    ReverseDepthFirstSearch rdfs = getReverseDepthFirstSearch(analysisCache, descriptor);
    NonExceptionPostdominatorsAnalysis analysis = new NonExceptionPostdominatorsAnalysis(cfg, rdfs, getDepthFirstSearch(
            analysisCache, descriptor));
    Dataflow<java.util.BitSet, PostDominatorsAnalysis> dataflow = new Dataflow<java.util.BitSet, PostDominatorsAnalysis>(cfg,
            analysis);
    dataflow.execute();
    return analysis;
}
 

开发者ID:ytus,
项目名称:findbugs-all-the-bugs,
代码行数:12,
代码来源:NonExceptionPostdominatorsAnalysisFactory.java

示例7: visitClass

点赞 2

import edu.umd.cs.findbugs.ba.Dataflow; //导入依赖的package包/类
@SuppressWarnings("unchecked")
public void visitClass(ClassDescriptor classDescriptor) throws CheckedAnalysisException {
    if (dataflowClassName == null) {
        return;
    }

    if (!initialized) {
        initialize();
    }

    if (dataflowClass == null) {
        return;
    }

    IAnalysisCache analysisCache = Global.getAnalysisCache();

    XClass classInfo = analysisCache.getClassAnalysis(XClass.class, classDescriptor);

    // Test dataflow analysis on each method]
    for (XMethod xMethod : classInfo.getXMethods()) {
        if (methodName != null && !methodName.equals(xMethod.getName())) {
            continue;
        }
        MethodDescriptor methodDescriptor = xMethod.getMethodDescriptor();

        System.out.println("-----------------------------------------------------------------");
        System.out.println("Method: " + SignatureConverter.convertMethodSignature(methodDescriptor));
        System.out.println("-----------------------------------------------------------------");

        // Create and execute the dataflow analysis
        Dataflow<Fact,AnalysisType> dataflow = analysisCache.getMethodAnalysis(dataflowClass, methodDescriptor);

        System.out.println("Dataflow finished after " + dataflow.getNumIterations());

        if (SystemProperties.getBoolean("dataflow.printcfg")) {
            DataflowCFGPrinter<Fact,AnalysisType> cfgPrinter 
                = new DataflowCFGPrinter<Fact,AnalysisType>(dataflow);
            cfgPrinter.print(System.out);
        }

    }
}
 

开发者ID:ytus,
项目名称:findbugs-all-the-bugs,
代码行数:43,
代码来源:TestDataflowAnalysis.java

示例8: asDataflowClass

点赞 2

import edu.umd.cs.findbugs.ba.Dataflow; //导入依赖的package包/类
@SuppressWarnings("unchecked")
private Class<? extends Dataflow<Fact, AnalysisType>> asDataflowClass(Class<?> c) {
    return (Class<? extends Dataflow<Fact, AnalysisType>>) c.asSubclass(Dataflow.class);
}
 

开发者ID:ytus,
项目名称:findbugs-all-the-bugs,
代码行数:5,
代码来源:TestDataflowAnalysis.java

示例9: inspectResult

点赞 2

import edu.umd.cs.findbugs.ba.Dataflow; //导入依赖的package包/类
public abstract void inspectResult(ClassContext classContext, MethodGen methodGen, CFG cfg,
Dataflow<ResourceValueFrame, ResourceValueAnalysis<Resource>> dataflow, Resource resource);
 

开发者ID:ytus,
项目名称:findbugs-all-the-bugs,
代码行数:3,
代码来源:ResourceTrackingDetector.java


版权声明:本文转自网络文章,转载此文章仅为分享知识,如有侵权,请联系管理员进行删除。
喜欢 (0)