net.nicoulaj.maven.plugins.soot
Class SootMojo

java.lang.Object
  extended by org.apache.maven.plugin.AbstractMojo
      extended by net.nicoulaj.maven.plugins.soot.SootMojo
All Implemented Interfaces:
ContextEnabled, Mojo

@Mojo(name="soot",
      defaultPhase=COMPILE,
      threadSafe=false)
public final class SootMojo
extends AbstractMojo

Mojo that invokes Soot.

Since:
0.1
Author:
Julien Nicoulaud

Nested Class Summary
static class SootMojo.OutputFormat
          Values for outputFormat option.
static class SootMojo.SourcePrecedence
          Values for sourcePrecedence option.
static class SootMojo.ThrowAnalysis
          Values for throwAnalysis option.
 
Field Summary
protected  boolean allowPhantomRefs
          Allow Soot to process a class even if it cannot find all classes referenced by that class.
protected  boolean applicationMode
          Run in application mode, processing all classes referenced by argument classes.
protected  boolean astMetrics
          If this flag is set and soot converts java to jimple then AST metrics will be computed.
protected  boolean debug
          Print various debugging information as Soot runs, particularly from the Baf Body Phase and the Jimple Annotation Pack Phase.
protected  boolean debugResolver
          Print debugging information about class resolving.
protected  List dumpBody
          Dump the internal representation of each method before and after given phase.
protected  List dumpCfg
          Dump the internal representation of each CFG constructed during given phase.
protected  List dynamicClasses
          Note that class may be loaded dynamically.
protected  List dynamicDirectories
          Mark all class files in directory as classes that may be loaded dynamically.
protected  List dynamicPackages
          Marks all class files belonging to the package package or any of its subpackages as classes which the application may load dynamically.
protected  List excludes
          Exclude classes in pkg from application classes.
protected  boolean fullResolver
          Normally, Soot resolves only that application classes and any classes that they refer to, along with any classes it needs for the Jimple typing, but it does not transitively resolve references in these additional classes that were resolved only because they were referenced.
protected  boolean gzip
          GZip IR output files.
protected  boolean help
          Display the textual help message and exit immediately without further processing.
protected  boolean includeAll
          Set default excluded packages to empty list.
protected  List includes
          Include classes in pkg as application classes.
protected  boolean interactiveMode
          Runs interactively, with Soot providing detailed information as it iterates through intra-procedural analyses.
protected  boolean j2me
          Use J2ME mode.
protected  boolean keepBytecodeOffset
          Maintain bytecode offset tables for class files throughout the transformations.
protected  boolean keepLineNumber
          Keep line number tables.
protected  String mainClass
          By default, the first class encountered with a main method is treated as the main class (entry point) in whole- program analysis.
static String NAME
          Mojo name.
protected  boolean noBodiesForExcluded
          Prevents Soot from loading method bodies for all excluded classes (see exclude option), even when running in whole-program mode.
protected  boolean noOutputInnerClassesAttribute
          Don't output inner classes attribute in class files.
protected  boolean noOutputSourceFileAttribute
          Don't output Source File Attribute when producing class files.
protected  boolean omitExceptingUnitEdges
          Omit CFG edges to handlers from excepting units which lack side effects.
protected  String outputDirectory
          Store output files in directory. directory may be relative to the working directory.
protected  SootMojo.OutputFormat outputFormat
          Specify the format of output files Soot should produce, if any.
protected  boolean outputJar
          Make output dir a Jar file instead of dir.
protected  List phaseHelp
          Print a help message about the phase or sub-phase named phase, then exit.
protected  boolean phaseList
          Print a list of the available phases and sub-phases, then exit.
protected  boolean polyglot
          Use Java 1.4 Polyglot frontend instead of JastAdd, which supports Java 5 syntax.
protected  boolean prependClasspath
          Instead of replacing the default soot classpath with the classpath given on the command line, prepent it with that classpath.
protected  boolean printTags
          Print in output files (either in Jimple or Dave) a variety of tags which Soot has attached to its internal representations of the application classes.
protected  List processDirectory
          Add all classes found in directory to the set of argument classes which is analyzed and transformed by Soot.
protected  MavenProject project
          The Maven project.
protected  boolean showExceptionDests
          Include exception destination edges as well as CFG edges in dumped CFGs.
protected  String sootClasspath
          Use path as the list of directories in which Soot should search for classes. path should be a series of directories, separated by the path separator character for your system.
protected  SootMojo.SourcePrecedence sourcePrecedence
          Sets format as Soot's preference for the type of source files to read when it looks for a class.
protected  boolean subtractGC
          Attempt to subtract time spent in garbage collection from the reports of times required for transformations.
protected  SootMojo.ThrowAnalysis throwAnalysis
          This option specifies how to estimate the exceptions which each statement may throw when constructing exceptional CFGs.
protected  boolean time
          Report the time required to perform some of Soot's transformations.
protected  boolean unfriendlyMode
          With this option, Soot does not stop even if it received no command-line options.
protected  boolean validate
          Causes internal checks to be done on bodies in the various Soot IRs,to make sure the transformations have not done something strange.
protected  boolean verbose
          Provide detailed information about what Soot is doing as it runs.
protected  boolean version
          Display information about the version of Soot being run, then exit without further processing.
protected  boolean viaGrimp
          Convert Jimple to bytecode via the Grimp intermediate representation instead of via the Baf intermediate representation.
protected  boolean viaShimple
          Enable Shimple, Soot's SSA representation.
protected  boolean wholeProgram
          Run in whole program mode, taking into consideration the whole program when performing analyses and transformations.
protected  boolean wholeShimple
          Run in whole shimple mode, taking into consideration the whole program when performing Shimple analyses and transformations.
protected  boolean xmlAttributes
          Save in XML format a variety of tags which Soot has attached to its internal representations of the application classes.
 
Fields inherited from interface org.apache.maven.plugin.Mojo
ROLE
 
Constructor Summary
SootMojo()
           
 
Method Summary
protected  void configureLogging()
           
protected  void configureOptions()
           
 void execute()
           
protected  void run()
           
 
Methods inherited from class org.apache.maven.plugin.AbstractMojo
getLog, getPluginContext, setLog, setPluginContext
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

NAME

public static final String NAME
Mojo name.

See Also:
Constant Field Values

project

@Parameter(property="project",
           required=true,
           readonly=true)
protected MavenProject project
The Maven project.

Since:
0.1

help

@Parameter(defaultValue="false")
protected boolean help
Display the textual help message and exit immediately without further processing.


phaseList

@Parameter(defaultValue="false")
protected boolean phaseList
Print a list of the available phases and sub-phases, then exit.


phaseHelp

@Parameter
protected List phaseHelp
Print a help message about the phase or sub-phase named phase, then exit. To see the help message of more than one phase, specify multiple phase-help options.


version

@Parameter(defaultValue="false")
protected boolean version
Display information about the version of Soot being run, then exit without further processing.


verbose

@Parameter(defaultValue="false")
protected boolean verbose
Provide detailed information about what Soot is doing as it runs.


interactiveMode

@Parameter(defaultValue="false")
protected boolean interactiveMode
Runs interactively, with Soot providing detailed information as it iterates through intra-procedural analyses.


unfriendlyMode

@Parameter(defaultValue="true")
protected boolean unfriendlyMode
With this option, Soot does not stop even if it received no command-line options. Useful when setting Soot options programmatically and then calling soot.Main.main() with an empty list.


applicationMode

@Parameter(defaultValue="false")
protected boolean applicationMode
Run in application mode, processing all classes referenced by argument classes.


wholeProgram

@Parameter(defaultValue="false")
protected boolean wholeProgram
Run in whole program mode, taking into consideration the whole program when performing analyses and transformations. Soot uses the Call Graph Constructor to build a call graph for the program, then applies enabled transformations in the Whole-Jimple Transformation, Whole-Jimple Optimization, and Whole-Jimple Annotation packs before applying enabled intraprocedural transformations. Note that the Whole-Jimple Optimization pack is normally disabled (and thus not applied by whole program mode), unless you also specify the Whole Program Optimize option.


wholeShimple

@Parameter(defaultValue="false")
protected boolean wholeShimple
Run in whole shimple mode, taking into consideration the whole program when performing Shimple analyses and transformations. Soot uses the Call Graph Constructor to build a call graph for the program, then applies enabled transformations in the Whole-Shimple Transformation and Whole-Shimple Optimization before applying enabled intraprocedural transformations. Note that the Whole-Shimple Optimization pack is normally disabled (and thus not applied by whole shimple mode), unless you also specify the Whole Program Optimize option.


validate

@Parameter(defaultValue="false")
protected boolean validate
Causes internal checks to be done on bodies in the various Soot IRs,to make sure the transformations have not done something strange. This option may degrade Soot's performance.


debug

@Parameter(defaultValue="false")
protected boolean debug
Print various debugging information as Soot runs, particularly from the Baf Body Phase and the Jimple Annotation Pack Phase.


debugResolver

@Parameter(defaultValue="false")
protected boolean debugResolver
Print debugging information about class resolving.


sootClasspath

@Parameter(property="project.build.outputDirectory")
protected String sootClasspath
Use path as the list of directories in which Soot should search for classes. path should be a series of directories, separated by the path separator character for your system. If no classpath is set on the command line, but the system property soot.class.path has been set, Soot uses its value as the classpath. If neither the command line nor the system properties specify a Soot classpath, Soot falls back on a default classpath consisting of the value of the system property java.class.path followed by java.home/lib/rt.jar, where java.home stands for the contents of the system property java.home and / stands for the system file separator.


prependClasspath

@Parameter(defaultValue="true")
protected boolean prependClasspath
Instead of replacing the default soot classpath with the classpath given on the command line, prepent it with that classpath. The default classpath holds whatever is set in the CLASSPATH environment variable, followed by rt.jar (resolved through the JAVA-UNDERSCORE-HOME environment variable). If whole-program mode is enabled, jce.jar is also appended in the end.


processDirectory

@Parameter(property="project.build.outputDirectory")
protected List processDirectory
Add all classes found in directory to the set of argument classes which is analyzed and transformed by Soot. You can specify the option more than once, to add argument classes from multiple directories. You can also state JAR files. If subdirectories of directory contain .class or .jimple files, Soot assumes that the subdirectory names correspond to components of the classes' package names. If directory containssubA/subB/MyClass.class, for instance, then Soot assumes MyClass is in package subA.subB.


astMetrics

@Parameter(defaultValue="TODO")
protected boolean astMetrics
If this flag is set and soot converts java to jimple then AST metrics will be computed.


sourcePrecedence

@Parameter(defaultValue="CLASS")
protected SootMojo.SourcePrecedence sourcePrecedence
Sets format as Soot's preference for the type of source files to read when it looks for a class.


fullResolver

@Parameter(defaultValue="false")
protected boolean fullResolver
Normally, Soot resolves only that application classes and any classes that they refer to, along with any classes it needs for the Jimple typing, but it does not transitively resolve references in these additional classes that were resolved only because they were referenced. This switch forces full transitive resolution of all references found in all classes that are resolved, regardless of why they were resolved. In whole-program mode, class resolution is always fully transitive. Therefore, in whole-program mode, this switch has no effect, and class resolution is always performed as if it were turned on.


allowPhantomRefs

@Parameter(defaultValue="false")
protected boolean allowPhantomRefs
Allow Soot to process a class even if it cannot find all classes referenced by that class. This may cause Soot to produce incorrect results.


noBodiesForExcluded

@Parameter(defaultValue="false")
protected boolean noBodiesForExcluded
Prevents Soot from loading method bodies for all excluded classes (see exclude option), even when running in whole-program mode. This is useful for computing a shallow points-to analysis that does not, for instance, take into account the JDK. Of course, such analyses may be unsound. You get what you are asking for.


j2me

@Parameter(defaultValue="false")
protected boolean j2me
Use J2ME mode. J2ME does not have class Cloneable nor Serializable, so we have to change type assignment to not refer to those classes.


mainClass

@Parameter
protected String mainClass
By default, the first class encountered with a main method is treated as the main class (entry point) in whole- program analysis. This option overrides this default.


polyglot

@Parameter(defaultValue="false")
protected boolean polyglot
Use Java 1.4 Polyglot frontend instead of JastAdd, which supports Java 5 syntax.


outputDirectory

@Parameter(property="project.build.outputDirectory")
protected String outputDirectory
Store output files in directory. directory may be relative to the working directory.


outputFormat

@Parameter(defaultValue="CLASS")
protected SootMojo.OutputFormat outputFormat
Specify the format of output files Soot should produce, if any. Note that while the abbreviated formats (jimp, shimp,b, andgrimp) are easier to read than their unabbreviated counterparts (jimple, shimple,baf, and grimple), they may contain ambiguities. Method signatures in the abbreviated formats, for instance, are not uniquely determined.


outputJar

@Parameter(defaultValue="false")
protected boolean outputJar
Make output dir a Jar file instead of dir.

The output Jar file name should be specified using the outputDirectory option. Note that if the output Jar file exists before Soot runs, any files inside it will first be removed.


xmlAttributes

@Parameter(defaultValue="false")
protected boolean xmlAttributes
Save in XML format a variety of tags which Soot has attached to its internal representations of the application classes. The XML file can then be read by the Soot plug-in for the Eclipse IDE, which can display the annotations together with the program source, to aid program understanding.


printTags

@Parameter(defaultValue="false")
protected boolean printTags
Print in output files (either in Jimple or Dave) a variety of tags which Soot has attached to its internal representations of the application classes. The tags will be printed on the line succeeding the stmt that they are attached to.


noOutputSourceFileAttribute

@Parameter(defaultValue="false")
protected boolean noOutputSourceFileAttribute
Don't output Source File Attribute when producing class files.


noOutputInnerClassesAttribute

@Parameter(defaultValue="false")
protected boolean noOutputInnerClassesAttribute
Don't output inner classes attribute in class files.

Don't output inner classes attribute in class files.


dumpBody

@Parameter
protected List dumpBody
Dump the internal representation of each method before and after given phase.


dumpCfg

@Parameter
protected List dumpCfg
Dump the internal representation of each CFG constructed during given phase.


showExceptionDests

@Parameter(defaultValue="true")
protected boolean showExceptionDests
Include exception destination edges as well as CFG edges in dumped CFGs.

Indicate whether to show exception destination edges as well as control flow edges in dumps of exceptional control flow graphs.


gzip

@Parameter(defaultValue="false")
protected boolean gzip
GZip IR output files.

This option causes Soot to compress output files of intermediate representations with GZip. It does not apply to class files output by Soot.


viaGrimp

@Parameter(defaultValue="false")
protected boolean viaGrimp
Convert Jimple to bytecode via the Grimp intermediate representation instead of via the Baf intermediate representation.


viaShimple

@Parameter(defaultValue="false")
protected boolean viaShimple
Enable Shimple, Soot's SSA representation. This generates Shimple bodies for the application classes, optionally transforms them with analyses that run on SSA form, then turns them back into Jimple for processing by the rest of Soot. For more information, see the documentation for theshimp,stp, and sop phases.


throwAnalysis

@Parameter(defaultValue="UNIT")
protected SootMojo.ThrowAnalysis throwAnalysis
This option specifies how to estimate the exceptions which each statement may throw when constructing exceptional CFGs.


omitExceptingUnitEdges

@Parameter(defaultValue="false")
protected boolean omitExceptingUnitEdges
Omit CFG edges to handlers from excepting units which lack side effects.

When constructing an ExceptionalUnitGraph or ExceptionalBlockGraph, include edges to an exception handler only from the predecessors of an instruction which may throw an exception to the handler, and not from the excepting instruction itself, unless the excepting instruction has potential side effects. Omitting edges from excepting units allows more accurate flow analyses (since if an instruction without side effects throws an exception, it has not changed the state of the computation). This accuracy, though, could lead optimizations to generate unverifiable code, since the dataflow analyses performed by bytecode verifiers might include paths to exception handlers from all protected instructions, regardless of whether the instructions have side effects. (In practice, the pedantic throw analysis suffices to pass verification in all VMs tested with Soot to date, but the JVM specification does allow for less discriminating verifiers which would reject some code that might be generated using the pedantic throw analysis without also adding edges from all excepting units.)


includes

@Parameter
protected List includes
Include classes in pkg as application classes.

Designate classes in packages whose names begin with pkg (e.g.java.util.) as application classes which should be analyzed and output. This option allows you to selectively analyze classes in some packages that Soot normally treats as library classes. You can use the include option multiple times, to designate the classes of multiple packages as application classes. If you specify both include and exclude options, first the classes from all excluded packages are marked as library classes, then the classes from all included packages are marked as application classes.


excludes

@Parameter
protected List excludes
Exclude classes in pkg from application classes.

Excludes any classes in packages whose names begin with pkg from the set of application classes which are analyzed and output, treating them as library classes instead. This option allows you to selectively exclude classes which would normally be treated as application classes. You can use the exclude option multiple times, to designate the classes of multiple packages as library classes. If you specify both include and exclude options, first the classes from all excluded packages are marked as library classes, then the classes from all included packages are marked as application classes.


includeAll

@Parameter(defaultValue="TODO")
protected boolean includeAll
Set default excluded packages to empty list.

Soot uses a default list of packages (such as java.) which are deemed to contain library classes. This switch removes the default packages from the list of packages containing library classes. Individual packages can then be added using the exclude option.


dynamicClasses

@Parameter
protected List dynamicClasses
Note that class may be loaded dynamically.

Mark class as a class which the application may load dynamically. Soot will read it as a library class even if it is not referenced from the argument classes. This permits whole program optimizations on programs which load classes dynamically if the set of classes that can be loaded is known at compile time.


dynamicDirectories

@Parameter
protected List dynamicDirectories
Mark all class files in directory as classes that may be loaded dynamically. Soot will read them as library classes even if they are not referenced from the argument classes. You can specify more than one directory of potentially dynamic classes by specifying multiple dynamic directory options.


dynamicPackages

@Parameter
protected List dynamicPackages
Marks all class files belonging to the package package or any of its subpackages as classes which the application may load dynamically. Soot will read all classes in package as library classes, even if they are not referenced by any of the argument classes.


keepLineNumber

@Parameter(defaultValue="true")
protected boolean keepLineNumber
Keep line number tables.

Preserve line number tables for class files throughout the // transformations.


keepBytecodeOffset

@Parameter(defaultValue="false")
protected boolean keepBytecodeOffset
Maintain bytecode offset tables for class files throughout the transformations.


time

@Parameter(defaultValue="false")
protected boolean time
Report the time required to perform some of Soot's transformations.


subtractGC

@Parameter(defaultValue="false")
protected boolean subtractGC
Attempt to subtract time spent in garbage collection from the reports of times required for transformations.

Constructor Detail

SootMojo

public SootMojo()
Method Detail

execute

public void execute()
             throws MojoExecutionException,
                    MojoFailureException
Throws:
MojoExecutionException
MojoFailureException

configureLogging

protected void configureLogging()

configureOptions

protected void configureOptions()

run

protected void run()
            throws MojoFailureException
Throws:
MojoFailureException


Copyright © 2012-2013. All Rights Reserved.