Search in sources :

Example 6 with CompilationDeathException

use of soot.CompilationDeathException in project soot by Sable.

the class ProcessData method main.

/**
 * @param args
 */
public static void main(String[] args) {
    int argLength = args.length;
    if (argLength == 0) {
        printIntro();
        useHelp();
        System.exit(1);
    }
    if (args[0].equals("--help")) {
        printHelp();
        System.exit(1);
    } else if (args[0].equals("-metricList")) {
        metricListFileName(args);
        System.out.println("A list of metrics will be stored in: " + metricListFileName);
        readXMLFileNames(2, args);
        try {
            OutputStream streamOut = new FileOutputStream(metricListFileName);
            PrintWriter writerOut = new PrintWriter(new OutputStreamWriter(streamOut));
            writeMetricLists(writerOut);
            writerOut.flush();
            streamOut.close();
        } catch (IOException e) {
            throw new CompilationDeathException("Cannot output file " + metricListFileName);
        }
    } else if (args[0].equals("-tables")) {
        metricListFileName(args);
        System.out.println("Will read column table headings from: " + metricListFileName);
        // read aggregation option
        aggregationOption(args);
        if (aggregationMechanism == ProcessData.BENCHMARK) {
            System.out.println("Aggregating over benchmarks...each row is one of the xml files");
            System.out.println("Only one tex file with the name" + metricListFileName + ".tex will be created");
        } else if (aggregationMechanism == ProcessData.CLASS) {
            System.out.println("Aggregating over class...each row is one class...");
            System.out.println("Each benchmark (xml file) will have its own tex file");
        }
        readXMLFileNames(3, args);
        // TODO: hello
        generateMetricsTables();
    } else {
        System.out.println("Incorrect argument number 1: expecting -metricList or -tables");
        System.exit(1);
    }
}
Also used : OutputStream(java.io.OutputStream) FileOutputStream(java.io.FileOutputStream) FileOutputStream(java.io.FileOutputStream) OutputStreamWriter(java.io.OutputStreamWriter) CompilationDeathException(soot.CompilationDeathException) IOException(java.io.IOException) PrintWriter(java.io.PrintWriter)

Example 7 with CompilationDeathException

use of soot.CompilationDeathException in project soot by Sable.

the class ProcessData method closeWriteFile.

private static void closeWriteFile(PrintWriter writerOut, String fileName) {
    try {
        writerOut.flush();
        streamOut.close();
    } catch (IOException e) {
        throw new CompilationDeathException("Cannot output file " + fileName);
    }
}
Also used : CompilationDeathException(soot.CompilationDeathException) IOException(java.io.IOException)

Example 8 with CompilationDeathException

use of soot.CompilationDeathException in project soot by Sable.

the class ProcessData method openWriteFile.

private static PrintWriter openWriteFile(String fileName) {
    PrintWriter writerOut;
    try {
        streamOut = new FileOutputStream(fileName);
        writerOut = new PrintWriter(new OutputStreamWriter(streamOut));
    } catch (IOException e) {
        throw new CompilationDeathException("Cannot output file " + fileName);
    }
    return writerOut;
}
Also used : FileOutputStream(java.io.FileOutputStream) OutputStreamWriter(java.io.OutputStreamWriter) CompilationDeathException(soot.CompilationDeathException) IOException(java.io.IOException) PrintWriter(java.io.PrintWriter)

Example 9 with CompilationDeathException

use of soot.CompilationDeathException in project soot by Sable.

the class ReflInliner method main.

public static void main(String[] args) {
    PackManager.v().getPack("wjpp").add(new Transform("wjpp.inlineReflCalls", new ReflectiveCallsInliner()));
    Scene.v().addBasicClass(Object.class.getName());
    Scene.v().addBasicClass(SootSig.class.getName(), SootClass.BODIES);
    Scene.v().addBasicClass(UnexpectedReflectiveCall.class.getName(), SootClass.BODIES);
    Scene.v().addBasicClass(IUnexpectedReflectiveCallHandler.class.getName(), SootClass.BODIES);
    Scene.v().addBasicClass(DefaultHandler.class.getName(), SootClass.BODIES);
    Scene.v().addBasicClass(OpaquePredicate.class.getName(), SootClass.BODIES);
    Scene.v().addBasicClass(ReflectiveCalls.class.getName(), SootClass.BODIES);
    ArrayList<String> argList = new ArrayList<String>(Arrays.asList(args));
    argList.add("-w");
    argList.add("-p");
    argList.add("cg");
    argList.add("enabled:false");
    argList.add("-app");
    Options.v().set_keep_line_number(true);
    logger.debug("TamiFlex Booster Version " + ReflInliner.class.getPackage().getImplementationVersion());
    try {
        soot.Main.main(argList.toArray(new String[0]));
    } catch (CompilationDeathException e) {
        logger.debug("\nERROR: " + e.getMessage() + "\n");
        logger.debug("The command-line options are described at:\n" + "http://www.sable.mcgill.ca/soot/tutorial/usage/index.html");
        if (Options.v().verbose()) {
            throw e;
        } else {
            logger.debug("Use -verbose to see stack trace.");
        }
        usage();
    }
}
Also used : ArrayList(java.util.ArrayList) CompilationDeathException(soot.CompilationDeathException) ReflectiveCallsInliner(soot.jimple.toolkits.reflection.ReflectiveCallsInliner) UnexpectedReflectiveCall(soot.rtlib.tamiflex.UnexpectedReflectiveCall) DefaultHandler(soot.rtlib.tamiflex.DefaultHandler) SootSig(soot.rtlib.tamiflex.SootSig) OpaquePredicate(soot.rtlib.tamiflex.OpaquePredicate) Transform(soot.Transform) ReflectiveCalls(soot.rtlib.tamiflex.ReflectiveCalls) IUnexpectedReflectiveCallHandler(soot.rtlib.tamiflex.IUnexpectedReflectiveCallHandler)

Example 10 with CompilationDeathException

use of soot.CompilationDeathException in project soot by Sable.

the class DexFileProvider method updateIndex.

private void updateIndex(List<File> dexSources) throws IOException {
    for (File theSource : dexSources) {
        String key = theSource.getCanonicalPath();
        Map<String, DexContainer> dexFiles = dexMap.get(key);
        if (dexFiles == null) {
            try {
                dexFiles = mappingForFile(theSource);
                dexMap.put(key, dexFiles);
            } catch (IOException e) {
                throw new CompilationDeathException("Error parsing dex source", e);
            }
        }
    }
}
Also used : MultiDexContainer(org.jf.dexlib2.iface.MultiDexContainer) CompilationDeathException(soot.CompilationDeathException) IOException(java.io.IOException) DexBackedDexFile(org.jf.dexlib2.dexbacked.DexBackedDexFile) File(java.io.File)

Aggregations

CompilationDeathException (soot.CompilationDeathException)10 IOException (java.io.IOException)7 File (java.io.File)3 FileOutputStream (java.io.FileOutputStream)3 OutputStreamWriter (java.io.OutputStreamWriter)3 PrintWriter (java.io.PrintWriter)2 DexBackedDexFile (org.jf.dexlib2.dexbacked.DexBackedDexFile)2 MultiDexContainer (org.jf.dexlib2.iface.MultiDexContainer)2 BufferedWriter (java.io.BufferedWriter)1 FileNotFoundException (java.io.FileNotFoundException)1 OutputStream (java.io.OutputStream)1 UnsupportedEncodingException (java.io.UnsupportedEncodingException)1 Path (java.nio.file.Path)1 ArrayList (java.util.ArrayList)1 JarFile (java.util.jar.JarFile)1 ZipFile (java.util.zip.ZipFile)1 ZipOutputStream (java.util.zip.ZipOutputStream)1 Transform (soot.Transform)1 ReflectiveCallsInliner (soot.jimple.toolkits.reflection.ReflectiveCallsInliner)1 DefaultHandler (soot.rtlib.tamiflex.DefaultHandler)1