Execute dataflow analyses (only if required).

@throws CheckedAnalysisException
433164
public void execute() throws CheckedAnalysisException {
        method = Global.getAnalysisCache().getMethodAnalysis(Method.class, methodDescriptor);
        ClassContext classContext = Global.getAnalysisCache().getClassAnalysis(ClassContext.class,
                methodDescriptor.getClassDescriptor());

        BitSet bytecodeSet = classContext.getBytecodeSet(method);
        if (bytecodeSet == null) {
            return;
        }
        if (bytecodeSet.get(Const.MONITORENTER) || bytecodeSet.get(Const.MONITOREXIT)) {
            this.lockDataflow = classContext.getLockDataflow(method);
        } else if (method.isSynchronized()) {
            this.vnaDataflow = classContext.getValueNumberDataflow(method); // will
            // need
            // this
            // later
        }
    }
285801
private void processRunnableOperations(
            final Consumer<WorkflowSystem.OperationResult<DAT, RES, OP>> resultConsumer,
            final List<OP> shouldrun,
            final List<OP> shouldskip,
            final DAT inputData
    )
    {
        for (final OP operation : shouldrun) {
            if (shouldskip.contains(operation)) {
                continue;
            }
            pending.remove(operation);

            workflowEngine.event(
                    WorkflowSystemEventType.WillRunOperation,
                    String.format("operation starting: %s", operation),
                    operation
            );
            final ListenableFuture<RES> submit = executorService.submit(() -> operation.apply(inputData));
            inProcess.add(operation);
            futures.add(submit);
            FutureCallback<RES> callback = new FutureCallback<RES>() {
                @Override
                public void onSuccess(final RES successResult) {
                    workflowEngine.event(
                            WorkflowSystemEventType.OperationSuccess,
                            String.format("operation succeeded: %s", successResult),
                            successResult
                    );
                    assert successResult != null;
                    WorkflowSystem.OperationResult<DAT, RES, OP> result = result(successResult, operation);
                    resultConsumer.accept(result);
                    stateChangeQueue.add(successResult);
                    inProcess.remove(operation);
                }

                @Override
                public void onFailure(final Throwable t) {
                    workflowEngine.event(
                            WorkflowSystemEventType.OperationFailed,
                            String.format("operation failed: %s", t),
                            t
                    );
                    WorkflowSystem.OperationResult<DAT, RES, OP> result = result(t, operation);
                    resultConsumer.accept(result);
                    StateObj newFailureState = operation.getFailureState(t);
                    if (null != newFailureState && newFailureState.getState().size() > 0) {
                        WorkflowSystem.OperationCompleted<DAT> objectOperationCompleted = WorkflowEngine.dummyResult(
                                newFailureState);
                        stateChangeQueue.add(objectOperationCompleted);
                    }
                    inProcess.remove(operation);
                }
            };

            Futures.addCallback(submit, callback, manager);
        }
    }
1132791
@Override
    public MethodBytecodeSet analyze(IAnalysisCache analysisCache, MethodDescriptor descriptor) throws CheckedAnalysisException {
        Method method = analysisCache.getMethodAnalysis(Method.class, descriptor);
        Code code = method.getCode();
        if (code == null) {
            return null;
        }

        byte[] instructionList = code.getCode();

        // Create callback
        UnpackedBytecodeCallback callback = new UnpackedBytecodeCallback(instructionList.length);

        // Scan the method.
        BytecodeScanner scanner = new BytecodeScanner();
        scanner.scan(instructionList, callback);

        UnpackedCode unpackedCode = callback.getUnpackedCode();
        MethodBytecodeSet result = null;
        if (unpackedCode != null) {
            result = unpackedCode.getBytecodeSet();
        }

        return result;
    }
1217170
public void process(JCas jcas) {
		try {
			tagger.process(jcas);
		} catch(AnalysisEngineProcessException e) {
			e.printStackTrace();
		}
	}
672573
protected void analyzeImpl(Analyzer analyzer, boolean allowFlow,
                             IntArray pendingTargets,
                             IntArray completedTargets)
    throws Exception
  {
    setOffset(0);
    
    pendingTargets.add(0);

    ArrayList<CodeAttribute.ExceptionItem> exns;
    exns = getExceptions();

    for (int i = 0; i < exns.size(); i++) {
      CodeAttribute.ExceptionItem exn = exns.get(i);

      pendingTargets.add(exn.getHandler());
    }
    
    analyze(analyzer, allowFlow, pendingTargets, completedTargets);
  }
1072545
@Override
    public void visitClass(ClassDescriptor classDescriptor) throws CheckedAnalysisException {

        // Just get the ClassContext from the analysis cache
        // and apply the detector to it.

        IAnalysisCache analysisCache = Global.getAnalysisCache();
        ClassContext classContext = analysisCache.getClassAnalysis(ClassContext.class, classDescriptor);
        Profiler profiler = analysisCache.getProfiler();
        profiler.start(detector.getClass());
        try {
            detector.visitClassContext(classContext);
        } finally {
            profiler.end(detector.getClass());
        }
    }
1219455
@Override
    protected final void prepareAnalyzer(Engine engine) throws InitializationException {
        if (filesMatched) {
            prepareFileTypeAnalyzer(engine);
        } else {
            this.setEnabled(false);
        }
    }
141664
@Override
    public Method analyze(IAnalysisCache analysisCache, MethodDescriptor descriptor) throws CheckedAnalysisException {
        JavaClass jclass = analysisCache.getClassAnalysis(JavaClass.class, descriptor.getClassDescriptor());
        Method[] methodList = jclass.getMethods();

        Method result = null;

        // As a side-effect, cache all of the Methods for this JavaClass
        for (Method method : methodList) {
            MethodDescriptor methodDescriptor = DescriptorFactory.instance().getMethodDescriptor(
                    descriptor.getSlashedClassName(), method.getName(), method.getSignature(), method.isStatic());

            // Put in cache eagerly
            analysisCache.eagerlyPutMethodAnalysis(Method.class, methodDescriptor, method);

            if (methodDescriptor.equals(descriptor)) {
                result = method;
            }
        }

        return result;
    }
1167734
@Override
    public ForwardTypeQualifierDataflowFactory analyze(IAnalysisCache analysisCache, MethodDescriptor descriptor)
            throws CheckedAnalysisException {

        return new ForwardTypeQualifierDataflowFactory(descriptor);
    }
1087774
private void execute() throws Exception {
		if (result == null) {
			env.execute(executionName);
		} else {
			output.write(executionName.toString(), System.out, result);
		}

		System.out.println();
		algorithm.printAnalytics(System.out);

		if (jobDetailsPath.getValue() != null) {
			writeJobDetails(env, jobDetailsPath.getValue());
		}
	}
141658
@Override
    public UnpackedCode analyze(IAnalysisCache analysisCache, MethodDescriptor descriptor) throws CheckedAnalysisException {
        Method method = getMethod(analysisCache, descriptor);
        Code code = method.getCode();
        if (code == null) {
            return null;
        }

        byte[] instructionList = code.getCode();

        // Create callback
        UnpackedBytecodeCallback callback = new UnpackedBytecodeCallback(instructionList.length);

        // Scan the method.
        BytecodeScanner scanner = new BytecodeScanner();
        scanner.scan(instructionList, callback);

        return callback.getUnpackedCode();

    }
651868
@Override
    public LoadedFieldSet analyze(IAnalysisCache analysisCache, MethodDescriptor descriptor) throws CheckedAnalysisException {
        MethodGen methodGen = getMethodGen(analysisCache, descriptor);
        if (methodGen == null) {
            return null;
        }
        InstructionList il = methodGen.getInstructionList();

        LoadedFieldSet loadedFieldSet = new LoadedFieldSet(methodGen);
        ConstantPoolGen cpg = getConstantPoolGen(analysisCache, descriptor.getClassDescriptor());

        for (InstructionHandle handle = il.getStart(); handle != null; handle = handle.getNext()) {
            Instruction ins = handle.getInstruction();
            short opcode = ins.getOpcode();
            try {
                if (opcode == Const.INVOKESTATIC) {
                    INVOKESTATIC inv = (INVOKESTATIC) ins;
                    if (Hierarchy.isInnerClassAccess(inv, cpg)) {
                        InnerClassAccess access = Hierarchy.getInnerClassAccess(inv, cpg);
                        /*
                         * if (access == null) {
                         * System.out.println("Missing inner class access in " +
                         * SignatureConverter.convertMethodSignature(methodGen)
                         * + " at " + inv); }
                         */
                        if (access != null) {
                            if (access.isLoad()) {
                                loadedFieldSet.addLoad(handle, access.getField());
                            } else {
                                loadedFieldSet.addStore(handle, access.getField());
                            }
                        }
                    }
                } else if (fieldInstructionOpcodeSet.get(opcode)) {
                    boolean isLoad = (opcode == Const.GETFIELD || opcode == Const.GETSTATIC);
                    XField field = Hierarchy.findXField((FieldInstruction) ins, cpg);
                    if (field != null) {
                        if (isLoad) {
                            loadedFieldSet.addLoad(handle, field);
                        } else {
                            loadedFieldSet.addStore(handle, field);
                        }
                    }
                }
            } catch (ClassNotFoundException e) {
                AnalysisContext.currentAnalysisContext().getLookupFailureCallback().reportMissingClass(e);
            }
        }

        return loadedFieldSet;
    }
186266
private void analyzeApplication() throws InterruptedException {
        int passCount = 0;
        Profiler profiler = bugReporter.getProjectStats().getProfiler();
        profiler.start(this.getClass());
        AnalysisContext.currentXFactory().canonicalizeAll();
        try {
            boolean multiplePasses = executionPlan.getNumPasses() > 1;
            if (executionPlan.getNumPasses() == 0) {
                throw new AssertionError("no analysis passes");
            }
            int[] classesPerPass = new int[executionPlan.getNumPasses()];
            classesPerPass[0] = referencedClassSet.size();
            for (int i = 0; i < classesPerPass.length; i++) {
                classesPerPass[i] = i == 0 ? referencedClassSet.size() : appClassList.size();
            }
            progressReporter.predictPassCount(classesPerPass);
            XFactory factory = AnalysisContext.currentXFactory();
            Collection<ClassDescriptor> badClasses = new LinkedList<>();
            for (ClassDescriptor desc : referencedClassSet) {
                try {
                    XClass info = Global.getAnalysisCache().getClassAnalysis(XClass.class, desc);
                    factory.intern(info);
                } catch (CheckedAnalysisException e) {
                    AnalysisContext.logError("Couldn't get class info for " + desc, e);
                    badClasses.add(desc);
                } catch (RuntimeException e) {
                    AnalysisContext.logError("Couldn't get class info for " + desc, e);
                    badClasses.add(desc);
                }
            }
            if (!badClasses.isEmpty()) {
                referencedClassSet = new LinkedHashSet<>(referencedClassSet);
                referencedClassSet.removeAll(badClasses);
            }

            long startTime = System.currentTimeMillis();
            bugReporter.getProjectStats().setReferencedClasses(referencedClassSet.size());
            for (Iterator<AnalysisPass> passIterator = executionPlan.passIterator(); passIterator.hasNext();) {
                AnalysisPass pass = passIterator.next();
                // The first pass is generally a non-reporting pass which
                // gathers information about referenced classes.
                boolean isNonReportingFirstPass = multiplePasses && passCount == 0;

                // Instantiate the detectors
                Detector2[] detectorList = pass.instantiateDetector2sInPass(bugReporter);

                // If there are multiple passes, then on the first pass,
                // we apply detectors to all classes referenced by the
                // application classes.
                // On subsequent passes, we apply detector only to application
                // classes.
                Collection<ClassDescriptor> classCollection = (isNonReportingFirstPass) ? referencedClassSet : appClassList;
                AnalysisContext.currentXFactory().canonicalizeAll();
                if (PROGRESS || LIST_ORDER) {
                    System.out.printf("%6d : Pass %d: %d classes%n", (System.currentTimeMillis() - startTime)/1000, passCount,  classCollection.size());
                    if (DEBUG) {
                        XFactory.profile();
                    }
                }
                if (!isNonReportingFirstPass) {
                    OutEdges<ClassDescriptor> outEdges = e -> {
                        try {
                            XClass classNameAndInfo = Global.getAnalysisCache().getClassAnalysis(XClass.class, e);
                            return classNameAndInfo.getCalledClassDescriptors();
                        } catch (CheckedAnalysisException e2) {
                            AnalysisContext.logError("error while analyzing " + e.getClassName(), e2);
                            return Collections.emptyList();

                        }
                    };

                    classCollection = sortByCallGraph(classCollection, outEdges);
                }
                if (LIST_ORDER) {
                    System.out.println("Analysis order:");
                    for (ClassDescriptor c : classCollection) {
                        System.out.println("  " + c);
                    }
                }
                AnalysisContext currentAnalysisContext = AnalysisContext.currentAnalysisContext();
                currentAnalysisContext.updateDatabases(passCount);

                progressReporter.startAnalysis(classCollection.size());
                int count = 0;
                Global.getAnalysisCache().purgeAllMethodAnalysis();
                Global.getAnalysisCache().purgeClassAnalysis(FBClassReader.class);
                for (ClassDescriptor classDescriptor : classCollection) {
                    long classStartNanoTime = 0;
                    if (PROGRESS) {
                        classStartNanoTime = System.nanoTime();
                        System.out.printf("%6d %d/%d  %d/%d %s%n", (System.currentTimeMillis() - startTime)/1000,
                                passCount, executionPlan.getNumPasses(), count,
                                classCollection.size(), classDescriptor);
                    }
                    count++;

                    // Check to see if class is excluded by the class screener.
                    // In general, we do not want to screen classes from the
                    // first pass, even if they would otherwise be excluded.
                    if ((SCREEN_FIRST_PASS_CLASSES || !isNonReportingFirstPass)
                            && !classScreener.matches(classDescriptor.toResourceName())) {
                        if (DEBUG) {
                            System.out.println("*** Excluded by class screener");
                        }
                        continue;
                    }
                    boolean isHuge = currentAnalysisContext.isTooBig(classDescriptor);
                    if (isHuge && currentAnalysisContext.isApplicationClass(classDescriptor)) {
                        bugReporter.reportBug(new BugInstance("SKIPPED_CLASS_TOO_BIG", Priorities.NORMAL_PRIORITY)
                        .addClass(classDescriptor));
                    }
                    currentClassName = ClassName.toDottedClassName(classDescriptor.getClassName());
                    notifyClassObservers(classDescriptor);
                    profiler.startContext(currentClassName);
                    currentAnalysisContext.setClassBeingAnalyzed(classDescriptor);

                    try {
                        for (Detector2 detector : detectorList) {
                            if (Thread.interrupted()) {
                                throw new InterruptedException();
                            }
                            if (isHuge && !FirstPassDetector.class.isAssignableFrom(detector.getClass())) {
                                continue;
                            }
                            if (DEBUG) {
                                System.out.println("Applying " + detector.getDetectorClassName() + " to " + classDescriptor);
                                // System.out.println("foo: " +
                                // NonReportingDetector.class.isAssignableFrom(detector.getClass())
                                // + ", bar: " + detector.getClass().getName());
                            }
                            try {
                                profiler.start(detector.getClass());
                                detector.visitClass(classDescriptor);
                            } catch (ClassFormatException e) {
                                logRecoverableException(classDescriptor, detector, e);
                            } catch (MissingClassException e) {
                                Global.getAnalysisCache().getErrorLogger().reportMissingClass(e.getClassDescriptor());
                            } catch (CheckedAnalysisException e) {
                                logRecoverableException(classDescriptor, detector, e);
                            } catch (RuntimeException e) {
                                logRecoverableException(classDescriptor, detector, e);
                            } finally {
                                profiler.end(detector.getClass());
                            }
                        }
                    } finally {

                        progressReporter.finishClass();
                        profiler.endContext(currentClassName);
                        currentAnalysisContext.clearClassBeingAnalyzed();
                        if (PROGRESS) {
                            long usecs = (System.nanoTime() - classStartNanoTime)/1000;
                            if (usecs > 15000) {
                                int classSize = currentAnalysisContext.getClassSize(classDescriptor);
                                long speed = usecs /classSize;
                                if (speed > 15) {
                                    System.out.printf("  %6d usecs/byte  %6d msec  %6d bytes  %d pass %s%n", speed, usecs/1000, classSize, passCount,
                                            classDescriptor);
                                }
                            }

                        }
                    }
                }

                // Call finishPass on each detector
                for (Detector2 detector : detectorList) {
                    detector.finishPass();
                }

                progressReporter.finishPerClassAnalysis();

                passCount++;
            }


        } finally {

            bugReporter.finish();
            bugReporter.reportQueuedErrors();
            profiler.end(this.getClass());
            if (PROGRESS) {
                System.out.println("Analysis completed");
            }
        }

    }
1019513
def analyze(output_dir, dataset, cloud=False, project_id=None):
  """"""
  job = analyze_async(
      output_dir=output_dir,
      dataset=dataset,
      cloud=cloud,
      project_id=project_id)
  job.wait()
  print('Analyze: ' + str(job.state))
930621
public static void main(String[] args) throws Exception {
    MapReduceIntegrationChecker checker = new MapReduceIntegrationChecker();
    System.exit(checker.run(args));
  }
1286697
private void analyzeModels() {
        try {
            do {
                ExecutorService pool = Executors.newFixedThreadPool(context.getSettings().getNbThread());

                while (context.workToDo()) {
                    pool.execute(new ModelExecutor(context));
                }

                pool.shutdown();
                while (!pool.isTerminated()) {
                    pool.awaitTermination(TIMEOUT, TimeUnit.MILLISECONDS);
                }

            } while (context.workToDo());
        } catch (InterruptedException e) {
            throw new RuntimeException("Interrupted " + e.getMessage());
        }
    }
1350156
public Analysis     analyze() throws Exception
    {
        AtomicReference<String>     error = new AtomicReference<String>(null);
        Map<String, PathComplete>   loadedPaths = loadedPaths(paths, error);
        if ( error.get() != null )
        {
            return new Analysis(error.get(), Lists.<PathComplete>newArrayList(), Lists.<Set<String>>newArrayList());
        }

        List<Node>        resourceAllocationGraph = buildResourceAllocationGraph(loadedPaths);
        List<Set<String>> possibleCycles = checkForCycles(resourceAllocationGraph, loadedPaths);

        return new Analysis(null, loadedPaths.values(), possibleCycles);
    }