All Downloads are FREE. Search and download functionalities are using the official Maven repository.

org.checkerframework.dataflow.cfg.playground.ConstantPropagationPlayground Maven / Gradle / Ivy

Go to download

The Checker Framework enhances Java's type system to make it more powerful and useful. This lets software developers detect and prevent errors in their Java programs. The Checker Framework includes compiler plug-ins ("checkers") that find bugs or verify their absence. It also permits you to write your own compiler plug-ins.

There is a newer version: 3.44.0
Show newest version
package org.checkerframework.dataflow.cfg.playground;

import org.checkerframework.dataflow.analysis.ForwardAnalysis;
import org.checkerframework.dataflow.analysis.ForwardAnalysisImpl;
import org.checkerframework.dataflow.cfg.visualize.CFGVisualizeLauncher;
import org.checkerframework.dataflow.constantpropagation.Constant;
import org.checkerframework.dataflow.constantpropagation.ConstantPropagationStore;
import org.checkerframework.dataflow.constantpropagation.ConstantPropagationTransfer;

public class ConstantPropagationPlayground {

  /** Run constant propagation for a specific file and create a PDF of the CFG in the end. */
  public static void main(String[] args) {

    /* Configuration: change as appropriate */
    String inputFile = "cfg-input.java"; // input file name and path
    String outputDir = "cfg"; // output directory
    String method = "test"; // name of the method to analyze
    String clazz = "Test"; // name of the class to consider

    // run the analysis and create a PDF file
    ConstantPropagationTransfer transfer = new ConstantPropagationTransfer();
    ForwardAnalysis
        forwardAnalysis = new ForwardAnalysisImpl<>(transfer);
    CFGVisualizeLauncher cfgVisualizeLauncher = new CFGVisualizeLauncher();
    cfgVisualizeLauncher.generateDOTofCFG(
        inputFile, outputDir, method, clazz, true, false, forwardAnalysis);
  }
}




© 2015 - 2024 Weber Informatics LLC | Privacy Policy