Home | History | Annotate | Download | only in manual
      1 <!doctype html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
      2 <html>
      3 <head>
      4 <meta http-equiv="content-type" content="text/html; charset=iso-8859-1">
      5 <meta http-equiv="content-style-type" content="text/css">
      6 <link rel="stylesheet" type="text/css" href="style.css">
      7 <title>ProGuard Usage</title>
      8 </head>
      9 <body>
     10 
     11 <script type="text/javascript" language="JavaScript">
     12 <!--
     13 if (window.self==window.top)
     14   document.write('<a class="largebutton" target="_top" href="../index.html#manual/usage.html">ProGuard index</a> <a class="largebutton" target="_top" href="http://www.saikoa.com/dexguard">DexGuard</a> <a class="largebutton" target="_top" href="http://www.saikoa.com/">Saikoa</a> <a class="largebutton" target="other" href="http://sourceforge.net/projects/proguard/">Sourceforge</a>')
     15 //-->
     16 </script>
     17 <noscript>
     18 <a class="largebutton" target="_top"  href="../index.html#manual/usage.html">ProGuard index</a>
     19 <a class="largebutton" target="_top"  href="http://www.saikoa.com/dexguard">DexGuard</a>
     20 <a class="largebutton" target="_top"  href="http://www.saikoa.com/">Saikoa</a>
     21 <a class="largebutton" target="other" href="http://sourceforge.net/projects/proguard/">Sourceforge</a>
     22 </noscript>
     23 
     24 <h2>Usage</h2>
     25 
     26 To run ProGuard, just type:
     27 <p class="code">
     28 <code><b>java -jar proguard.jar </b></code><i>options</i> ...
     29 </p>
     30 You can find the ProGuard jar in the <code>lib</code> directory of the
     31 ProGuard distribution. Alternatively, the <code>bin</code> directory contains
     32 some short Linux and Windows scripts containing this command. Typically, you'll
     33 put most options in a configuration file (say, <code>myconfig.pro</code>), and
     34 just call:
     35 <p class="code">
     36 <code><b>java -jar proguard.jar @myconfig.pro</b></code>
     37 </p>
     38 You can combine command line options and options from configuration files. For
     39 instance:
     40 <p class="code">
     41 <code><b>java -jar proguard.jar @myconfig.pro -verbose</b></code>
     42 </p>
     43 <p>
     44 You can add comments in a configuration file, starting with a
     45 <code><b>#</b></code> character and continuing until the end of the line.
     46 <p>
     47 Extra whitespace between words and delimiters is ignored. File names with
     48 spaces or special characters should be quoted with single or double quotes.
     49 <p>
     50 Options can be grouped arbitrarily in arguments on the command line and in
     51 lines in configuration files. This means that you can quote arbitrary sections
     52 of command line options, to avoid shell expansion of special characters, for
     53 instance.
     54 <p>
     55 The order of the options is generally irrelevant. For quick experiments, you
     56 can abbreviate them to their first unique characters.
     57 <p>
     58 
     59 The sections below provide more details:
     60 <ul>
     61 <li><a href="#iooptions">Input/Output Options</a></li>
     62 <li><a href="#keepoptions">Keep Options</a></li>
     63 <li><a href="#shrinkingoptions">Shrinking Options</a></li>
     64 <li><a href="#optimizationoptions">Optimization Options</a></li>
     65 <li><a href="#obfuscationoptions">Obfuscation Options</a></li>
     66 <li><a href="#preverificationoptions">Preverification Options</a></li>
     67 <li><a href="#generaloptions">General Options</a></li>
     68 <li><a href="#classpath">Class Paths</a></li>
     69 <li><a href="#filename">File Names</a></li>
     70 <li><a href="#filefilters">File Filters</a></li>
     71 <li><a href="#filters">Filters</a></li>
     72 <li><a href="#keepoverview">Overview of <code>Keep</code> Options</a></li>
     73 <li><a href="#keepoptionmodifiers">Keep Option Modifiers</a></li>
     74 <li><a href="#classspecification">Class Specifications</a></li>
     75 </ul>
     76 
     77 <h2><a name="iooptions">Input/Output Options</a></h2>
     78 
     79 <dl>
     80 <dt><a name="at"><code><b>@</b></code></a><a href="#filename"><i>filename</i></a></dt>
     81 
     82 <dd>Short for '<a href="#include"><code>-include</code></a>
     83      <a href="#filename"><i>filename</i></a>'.</dd>
     84 
     85 <dt><a name="include"><code><b>-include</b></code></a>
     86     <a href="#filename"><i>filename</i></a></dt>
     87 
     88 <dd>Recursively reads configuration options from the given file
     89     <i>filename</i>.</dd>
     90 
     91 <dt><a name="basedirectory"><code><b>-basedirectory</b></code></a>
     92     <a href="#filename"><i>directoryname</i></a></dt>
     93 
     94 <dd>Specifies the base directory for all subsequent relative file names in
     95     these configuration arguments or this configuration file.</dd>
     96 
     97 <dt><a name="injars"><code><b>-injars</b></code></a>
     98     <a href="#classpath"><i>class_path</i></a></dt>
     99 
    100 <dd>Specifies the input jars (or aars, wars, ears, zips, apks, or directories)
    101     of the application to be processed. The class files in these jars will be
    102     processed and written to the output jars. By default, any non-class files
    103     will be copied without changes. Please be aware of any temporary files
    104     (e.g. created by IDEs), especially if you are reading your input files
    105     straight from directories. The entries in the class path can be filtered,
    106     as explained in the <a href="#filefilters">filters</a> section. For better
    107     readability, class path entries can be specified using multiple
    108     <code>-injars</code> options.</dd>
    109 
    110 <dt><a name="outjars"><code><b>-outjars</b></code></a>
    111     <a href="#classpath"><i>class_path</i></a></dt>
    112 
    113 <dd>Specifies the names of the output jars (or aars, wars, ears, zips, apks,
    114     or directories). The processed input of the preceding <code>-injars</code>
    115     options will be written to the named jars. This allows you to collect the
    116     contents of groups of input jars into corresponding groups of output jars.
    117     In addition, the output entries can be filtered, as explained in
    118     the <a href="#filefilters">filters</a> section. Each processed class file
    119     or resource file is then written to the first output entry with a matching
    120     filter, within the group of output jars.
    121     <p>
    122     You must avoid letting the output files overwrite any input files. For
    123     better readability, class path entries can be specified using multiple
    124     <code>-outjars</code> options. Without any <code>-outjars</code> options,
    125     no jars will be written.</dd>
    126 
    127 <dt><a name="libraryjars"><code><b>-libraryjars</b></code></a>
    128     <a href="#classpath"><i>class_path</i></a></dt>
    129 
    130 <dd>Specifies the library jars (or aars, wars, ears, zips, apks, or
    131     directories) of the application to be processed. The files in these jars
    132     will not be included in the output jars. The specified library jars should
    133     at least contain the class files that are <i>extended</i> by application
    134     class files. Library class files that are only <i>called</i> needn't be
    135     present, although their presence can improve the results of the
    136     optimization step. The entries in the class path can be filtered, as
    137     explained in the <a href="#filefilters">filters</a> section. For better
    138     readability, class path entries can be specified using
    139     multiple <code>-libraryjars</code> options.
    140     <p>
    141     Please note that the boot path and the class path set for running ProGuard
    142     are not considered when looking for library classes. This means that you
    143     explicitly have to specify the run-time jar that your code will use.
    144     Although this may seem cumbersome, it allows you to process applications
    145     targeted at different run-time environments. For example, you can process
    146     <a href="examples.html#application">J2SE applications</a> as well as <a
    147     href="examples.html#midlet">JME midlets</a> or <a
    148     href="examples.html#androidapplication">Android apps</a>, just by
    149     specifying the appropriate run-time jar.</dd>
    150 
    151 <dt><a name="skipnonpubliclibraryclasses"><code><b>-skipnonpubliclibraryclasses</b></code></a></dt>
    152 
    153 <dd>Specifies to skip non-public classes while reading library jars, to speed
    154     up processing and reduce memory usage of ProGuard. By default, ProGuard
    155     reads non-public and public library classes alike. However, non-public
    156     classes are often not relevant, if they don't affect the actual program
    157     code in the input jars. Ignoring them then speeds up ProGuard, without
    158     affecting the output. Unfortunately, some libraries, including recent JSE
    159     run-time libraries, contain non-public library classes that are extended
    160     by public library classes. You then can't use this option. ProGuard will
    161     print out warnings if it can't find classes due to this option being
    162     set.</dd>
    163 
    164 <dt><a name="dontskipnonpubliclibraryclasses"><code><b>-dontskipnonpubliclibraryclasses</b></code></a></dt>
    165 
    166 <dd>Specifies not to ignore non-public library classes. As of version 4.5, this
    167     is the default setting.</dd>
    168 
    169 <dt><a name="dontskipnonpubliclibraryclassmembers"><code><b>-dontskipnonpubliclibraryclassmembers</b></code></a></dt>
    170 
    171 <dd>Specifies not to ignore package visible library class members (fields and
    172     methods). By default, ProGuard skips these class members while parsing
    173     library classes, as program classes will generally not refer to them.
    174     Sometimes however, program classes reside in the same packages as library
    175     classes, and they do refer to their package visible class members. In
    176     those cases, it can be useful to actually read the class members, in order
    177     to make sure the processed code remains consistent.</dd>
    178 
    179 <dt><a name="keepdirectories"><code><b>-keepdirectories</b></code></a>
    180     [<i><a href="#filefilters">directory_filter</a></i>]</dt>
    181 
    182 <dd>Specifies the directories to be kept in the output jars (or aars, wars,
    183     ears, zips, apks, or directories). By default, directory entries are
    184     removed. This reduces the jar size, but it may break your program if the
    185     code tries to find them with constructs like
    186     "<code>mypackage.MyClass.class.getResource("")</code>". You'll then want
    187     to keep the directory corresponding to the package,
    188     "<code>-keepdirectories mypackage</code>". If the option is specified
    189     without a filter, all directories are kept. With a filter, only matching
    190     directories are kept. For instance,
    191     "<code>-keepdirectories mydirectory</code>" matches the specified
    192     directory, "<code>-keepdirectories mydirectory/*</code>" matches its
    193     immediate subdirectories, and
    194     "<code>-keepdirectories mydirectory/**</code>" matches all of its
    195     subdirectories.</dd>
    196 
    197 <dt><a name="target"><code><b>-target</b></code></a> <i>version</i></dt>
    198 
    199 <dd>Specifies the version number to be set in the processed class files. The
    200     version number can be one of <code>1.0</code>, <code>1.1</code>,
    201     <code>1.2</code>, <code>1.3</code>, <code>1.4</code>, <code>1.5</code> (or
    202     just <code>5</code>), <code>1.6</code> (or just <code>6</code>),
    203     <code>1.7</code> (or just <code>7</code>), or <code>1.8</code> (or
    204     just <code>8</code>). By default, the version numbers of the class files
    205     are left unchanged. For example, you may want to
    206     <a href="examples.html#upgrade">upgrade class files to Java 6</a>, by
    207     changing their version numbers and having them preverified. You probably
    208     shouldn't downgrade the version numbers of class files, since the code
    209     may contain constructs that are not supported in older versions.</dd>
    210 
    211 <dt><a name="forceprocessing"><code><b>-forceprocessing</b></code></a></dt>
    212 
    213 <dd>Specifies to process the input, even if the output seems up to date. The
    214     up-to-dateness test is based on a comparison of the date stamps of the
    215     specified input, output, and configuration files or directories.</dd>
    216 
    217 </dl>
    218 <p>
    219 
    220 <h2><a name="keepoptions">Keep Options</a></h2>
    221 
    222 <dl>
    223 <dt><a name="keep"><code><b>-keep</b></code></a>
    224     [<a href="#keepoptionmodifiers">,<i>modifier</i></a>,...]
    225     <a href="#classspecification"><i>class_specification</i></a></dt>
    226 
    227 <dd>Specifies classes and class members (fields and methods) to be preserved
    228     as entry points to your code. For example, in order to <a
    229     href="examples.html#application">keep an application</a>, you can specify
    230     the main class along with its main method. In order to <a
    231     href="examples.html#library">process a library</a>, you should specify all
    232     publicly accessible elements.</dd>
    233 
    234 <dt><a name="keepclassmembers"><code><b>-keepclassmembers</b></code></a>
    235     [<a href="#keepoptionmodifiers">,<i>modifier</i></a>,...]
    236     <a href="#classspecification"><i>class_specification</i></a></dt>
    237 
    238 <dd>Specifies class members to be preserved, if their classes are preserved as
    239     well. For example, you may want to <a
    240     href="examples.html#serializable">keep all serialization fields and
    241     methods</a> of classes that implement the <code>Serializable</code>
    242     interface.</dd>
    243 
    244 <dt><a name="keepclasseswithmembers"><code><b>-keepclasseswithmembers</b></code></a>
    245     [<a href="#keepoptionmodifiers">,<i>modifier</i></a>,...]
    246     <a href="#classspecification"><i>class_specification</i></a></dt>
    247 
    248 <dd>Specifies classes and class members to be preserved, on the condition that
    249     all of the specified class members are present. For example, you may want
    250     to <a href="examples.html#applications">keep all applications</a> that
    251     have a main method, without having to list them explicitly.</dd>
    252 
    253 <dt><a name="keepnames"><code><b>-keepnames</b></code></a>
    254     <a href="#classspecification"><i>class_specification</i></a></dt>
    255 
    256 <dd>Short for <a href="#keep"><code>-keep</code></a>,<a href="#allowshrinking"><code>allowshrinking</code></a>
    257     <a href="#classspecification"><i>class_specification</i></a>
    258     <p>
    259     Specifies classes and class members whose names are to be preserved, if
    260     they aren't removed in the shrinking phase. For example, you may want to
    261     <a href="examples.html#serializable">keep all class names</a> of classes
    262     that implement the <code>Serializable</code> interface, so that the
    263     processed code remains compatible with any originally serialized classes.
    264     Classes that aren't used at all can still be removed. Only applicable when
    265     obfuscating.</dd>
    266 
    267 <dt><a name="keepclassmembernames"><code><b>-keepclassmembernames</b></code></a>
    268     <a href="#classspecification"><i>class_specification</i></a></dt>
    269 
    270 <dd>Short for <a href="#keepclassmembers"><code>-keepclassmembers</code></a>,<a href="#allowshrinking"><code>allowshrinking</code></a>
    271     <a href="#classspecification"><i>class_specification</i></a>
    272     <p>
    273     Specifies class members whose names are to be preserved, if they aren't
    274     removed in the shrinking phase. For example, you may want to preserve the
    275     name of the synthetic <code>class$</code> methods
    276     when <a href="examples.html#library">processing a library</a> compiled by
    277     JDK 1.2 or older, so obfuscators can detect it again when processing an
    278     application that uses the processed library (although ProGuard itself
    279     doesn't need this). Only applicable when obfuscating.</dd>
    280 
    281 <dt><a name="keepclasseswithmembernames"><code><b>-keepclasseswithmembernames</b></code></a>
    282     <a href="#classspecification"><i>class_specification</i></a></dt>
    283 
    284 <dd>Short for <a href="#keepclasseswithmembers"><code>-keepclasseswithmembers</code></a>,<a href="#allowshrinking"><code>allowshrinking</code></a>
    285     <a href="#classspecification"><i>class_specification</i></a>
    286     <p>
    287     Specifies classes and class members whose names are to be preserved, on
    288     the condition that all of the specified class members are present after
    289     the shrinking phase. For example, you may want to <a
    290     href="examples.html#native">keep all native method names</a> and the names
    291     of their classes, so that the processed code can still link with the
    292     native library code. Native methods that aren't used at all can still be
    293     removed. If a class file is used, but none of its native methods are, its
    294     name will still be obfuscated. Only applicable when obfuscating.</dd>
    295 
    296 <dt><a name="printseeds"><code><b>-printseeds</b></code></a>
    297     [<a href="#filename"><i>filename</i></a>]</dt>
    298 
    299 <dd>Specifies to exhaustively list classes and class members matched by the
    300     various <code>-keep</code> options. The list is printed to the standard
    301     output or to the given file. The list can be useful to verify if the
    302     intended class members are really found, especially if you're using
    303     wildcards. For example, you may want to list all the <a
    304     href="examples.html#applications">applications</a> or all the <a
    305     href="examples.html#applets">applets</a> that you are keeping.</dd>
    306 
    307 </dl>
    308 <p>
    309 
    310 <h2><a name="shrinkingoptions">Shrinking Options</a></h2>
    311 
    312 <dl>
    313 <dt><a name="dontshrink"><code><b>-dontshrink</b></code></a></dt>
    314 
    315 <dd>Specifies not to shrink the input class files. By default, shrinking is
    316     applied; all classes and class members are removed, except for the ones
    317     listed by the various <code>-keep</code> options, and the ones on which
    318     they depend, directly or indirectly. A shrinking step is also applied
    319     after each optimization step, since some optimizations may open the
    320     possibility to remove more classes and class members.</dd>
    321 
    322 <dt><a name="printusage"><code><b>-printusage</b></code></a>
    323     [<a href="#filename"><i>filename</i></a>]</dt>
    324 
    325 <dd>Specifies to list dead code of the input class files. The list is printed
    326     to the standard output or to the given file. For example, you can <a
    327     href="examples.html#deadcode">list the unused code of an application</a>.
    328     Only applicable when shrinking.</dd>
    329 
    330 <dt><a name="whyareyoukeeping"><code><b>-whyareyoukeeping</b></code></a>
    331     <a href="#classspecification"><i>class_specification</i></a></dt>
    332 
    333 <dd>Specifies to print details on why the given classes and class members are
    334     being kept in the shrinking step. This can be useful if you are wondering
    335     why some given element is present in the output. In general, there can be
    336     many different reasons. This option prints the shortest chain of methods
    337     to a specified seed or entry point, for each specified class and class
    338     member. <i>In the current implementation, the shortest chain that is
    339     printed out may sometimes contain circular deductions -- these do not
    340     reflect the actual shrinking process.</i> If the <a
    341     href="#verbose"><code>-verbose</code></a> option if specified, the traces
    342     include full field and method signatures. Only applicable when
    343     shrinking.</dd>
    344 
    345 </dl>
    346 <p>
    347 
    348 <h2><a name="optimizationoptions">Optimization Options</a></h2>
    349 
    350 <dl>
    351 <dt><a name="dontoptimize"><code><b>-dontoptimize</b></code></a></dt>
    352 
    353 <dd>Specifies not to optimize the input class files. By default, optimization
    354     is enabled; all methods are optimized at a bytecode level.</dd>
    355 
    356 <dt><a name="optimizations"><code><b>-optimizations</b></code></a>
    357     <a href="optimizations.html"><i>optimization_filter</i></a></dt>
    358 
    359 <dd>Specifies the optimizations to be enabled and disabled, at a more
    360     fine-grained level. Only applicable when optimizing. <i>This is an expert
    361     option.</i></dd>
    362 
    363 <dt><a name="optimizationpasses"><code><b>-optimizationpasses</b></code></a> <i>n</i></dt>
    364 
    365 <dd>Specifies the number of optimization passes to be performed. By default, a
    366     single pass is performed. Multiple passes may result in further
    367     improvements. If no improvements are found after an optimization pass, the
    368     optimization is ended. Only applicable when optimizing.</dd>
    369 
    370 <dt><a name="assumenosideeffects"><code><b>-assumenosideeffects</b></code></a>
    371     <a href="#classspecification"><i>class_specification</i></a></dt>
    372 
    373 <dd>Specifies methods that don't have any side effects (other than maybe
    374     returning a value). In the optimization step, ProGuard will then remove
    375     calls to such methods, if it can determine that the return values aren't
    376     used. ProGuard will analyze your program code to find such methods
    377     automatically. It will not analyze library code, for which this option can
    378     therefore be useful. For example, you could specify the method
    379     <code>System.currentTimeMillis()</code>, so that any idle calls to it will
    380     be removed. With some care, you can also use the option to
    381     <a href="examples.html#logging">remove logging code</a>. Note that
    382     ProGuard applies the option to the entire hierarchy of the specified
    383     methods. Only applicable when optimizing. In general, making assumptions
    384     can be dangerous; you can easily break the processed code. <i>Only use
    385     this option if you know what you're doing!</i></dd>
    386 
    387 <dt><a name="allowaccessmodification"><code><b>-allowaccessmodification</b></code></a></dt>
    388 
    389 <dd>Specifies that the access modifiers of classes and class members may be
    390     broadened during processing. This can improve the results of the
    391     optimization step. For instance, when inlining a public getter, it may be
    392     necessary to make the accessed field public too. Although Java's binary
    393     compatibility specifications formally do not require this (cfr. <a href=
    394     "http://docs.oracle.com/javase/specs/jls/se5.0/html/j3TOC.html"
    395     >The Java Language Specification, Third Edition</a>, <a href=
    396     "http://docs.oracle.com/javase/specs/jls/se5.0/html/binaryComp.html#13.4.6"
    397     >Section 13.4.6</a>), some virtual machines would have problems with the
    398     processed code otherwise. Only applicable when optimizing (and when
    399     obfuscating with the <a
    400     href="#repackageclasses"><code>-repackageclasses</code></a> option).
    401     <p>
    402     <i>Counter-indication:</i> you probably shouldn't use this option when
    403     processing code that is to be used as a library, since classes and class
    404     members that weren't designed to be public in the API may become
    405     public.</dd>
    406 
    407 <dt><a name="mergeinterfacesaggressively"><code><b>-mergeinterfacesaggressively</b></code></a></dt>
    408 
    409 <dd>Specifies that interfaces may be merged, even if their implementing
    410     classes don't implement all interface methods. This can reduce the size of
    411     the output by reducing the total number of classes. Note that Java's
    412     binary compatibility specifications allow such constructs (cfr. <a href=
    413     "http://docs.oracle.com/javase/specs/jls/se5.0/html/j3TOC.html"
    414     >The Java Language Specification, Third Edition</a>, <a href=
    415     "http://docs.oracle.com/javase/specs/jls/se5.0/html/binaryComp.html#13.5.3"
    416     >Section 13.5.3</a>), even if they are not allowed in the Java language
    417     (cfr. <a href=
    418     "http://docs.oracle.com/javase/specs/jls/se5.0/html/j3TOC.html"
    419     >The Java Language Specification, Third Edition</a>, <a href=
    420     "http://docs.oracle.com/javase/specs/jls/se5.0/html/classes.html#8.1.4"
    421     >Section 8.1.4</a>). Only applicable when optimizing.
    422     <p>
    423     <i>Counter-indication:</i> setting this option can reduce the performance
    424     of the processed code on some JVMs, since advanced just-in-time
    425     compilation tends to favor more interfaces with fewer implementing
    426     classes. Worse, some JVMs may not be able to handle the resulting code.
    427     Notably:
    428     <ul>
    429     <li>Sun's JRE 1.3 may throw an <code>InternalError</code> when
    430         encountering more than 256 <i>Miranda</i> methods (interface methods
    431         without implementations) in a class.</li>
    432     </ul></dd>
    433 
    434 </dl>
    435 <p>
    436 
    437 <h2><a name="obfuscationoptions">Obfuscation Options</a></h2>
    438 
    439 <dl>
    440 <dt><a name="dontobfuscate"><code><b>-dontobfuscate</b></code></a></dt>
    441 
    442 <dd>Specifies not to obfuscate the input class files. By default, obfuscation
    443     is applied; classes and class members receive new short random names,
    444     except for the ones listed by the various <code>-keep</code> options.
    445     Internal attributes that are useful for debugging, such as source files
    446     names, variable names, and line numbers are removed.</dd>
    447 
    448 <dt><a name="printmapping"><code><b>-printmapping</b></code></a>
    449     [<a href="#filename"><i>filename</i></a>]</dt>
    450 
    451 <dd>Specifies to print the mapping from old names to new names for classes and
    452     class members that have been renamed. The mapping is printed to the
    453     standard output or to the given file. For example, it is required for
    454     subsequent <a href="examples.html#incremental">incremental
    455     obfuscation</a>, or if you ever want to make sense again of <a
    456     href="examples.html#stacktrace">obfuscated stack traces</a>. Only
    457     applicable when obfuscating.</dd>
    458 
    459 <dt><a name="applymapping"><code><b>-applymapping</b></code></a>
    460     <a href="#filename"><i>filename</i></a></dt>
    461 
    462 <dd>Specifies to reuse the given name mapping that was printed out in a
    463     previous obfuscation run of ProGuard. Classes and class members that are
    464     listed in the mapping file receive the names specified along with them.
    465     Classes and class members that are not mentioned receive new names. The
    466     mapping may refer to input classes as well as library classes. This option
    467     can be useful for <a href="examples.html#incremental">incremental
    468     obfuscation</a>, i.e. processing add-ons or small patches to an existing
    469     piece of code. If the structure of the code changes fundamentally,
    470     ProGuard may print out warnings that applying a mapping is causing
    471     conflicts. You may be able to reduce this risk by specifying the option <a
    472     href="#useuniqueclassmembernames"><code>-useuniqueclassmembernames</code></a>
    473     in both obfuscation runs. Only a single mapping file is allowed. Only
    474     applicable when obfuscating.</dd>
    475 
    476 <dt><a name="obfuscationdictionary"><code><b>-obfuscationdictionary</b></code></a>
    477     <a href="#filename"><i>filename</i></a></dt>
    478 
    479 <dd>Specifies a text file from which all valid words are used as obfuscated
    480     field and method names. By default, short names like 'a', 'b', etc. are
    481     used as obfuscated names. With an obfuscation dictionary, you can specify
    482     a list of reserved key words, or identifiers with foreign characters, for
    483     instance. White space, punctuation characters, duplicate words, and
    484     comments after a <code><b>#</b></code> sign are ignored. Note that an
    485     obfuscation dictionary hardly improves the obfuscation. Decent compilers
    486     can automatically replace them, and the effect can fairly simply be undone
    487     by obfuscating again with simpler names. The most useful application is
    488     specifying strings that are typically already present in class files (such
    489     as 'Code'), thus reducing the class file sizes just a little bit more.
    490     Only applicable when obfuscating.</dd>
    491 
    492 <dt><a name="classobfuscationdictionary"><code><b>-classobfuscationdictionary</b></code></a>
    493     <a href="#filename"><i>filename</i></a></dt>
    494 
    495 <dd>Specifies a text file from which all valid words are used as obfuscated
    496     class names. The obfuscation dictionary is similar to the one of the
    497     option <a
    498     href="#obfuscationdictionary"><code>-obfuscationdictionary</code></a>.
    499     Only applicable when obfuscating.</dd>
    500 
    501 <dt><a name="packageobfuscationdictionary"><code><b>-packageobfuscationdictionary</b></code></a>
    502     <a href="#filename"><i>filename</i></a></dt>
    503 
    504 <dd>Specifies a text file from which all valid words are used as obfuscated
    505     package names. The obfuscation dictionary is similar to the one of the
    506     option <a
    507     href="#obfuscationdictionary"><code>-obfuscationdictionary</code></a>.
    508     Only applicable when obfuscating.</dd>
    509 
    510 <dt><a name="overloadaggressively"><code><b>-overloadaggressively</b></code></a></dt>
    511 
    512 <dd>Specifies to apply aggressive overloading while obfuscating. Multiple
    513     fields and methods can then get the same names, as long as their arguments
    514     and return types are different, as required by Java bytecode (not just
    515     their arguments, as required by the Java language). This option can make
    516     the processed code even smaller (and less comprehensible). Only applicable
    517     when obfuscating.
    518     <p>
    519     <i>Counter-indication:</i> the resulting class files fall within the Java
    520     bytecode specification (cfr. <a href=
    521     "http://docs.oracle.com/javase/specs/jvms/se5.0/html/VMSpecTOC.doc.html"
    522     >The Java Virtual Machine Specification, Second Edition</a>, first
    523     paragraphs of <a href=
    524     "http://docs.oracle.com/javase/specs/jvms/se5.0/html/ClassFile.doc.html#2877"
    525     >Section 4.5</a> and <a href=
    526     "http://docs.oracle.com/javase/specs/jvms/se5.0/html/ClassFile.doc.html#1513"
    527     >Section 4.6</a>), even though this kind of overloading is not allowed in
    528     the Java language (cfr. <a href=
    529     "http://docs.oracle.com/javase/specs/jls/se5.0/html/j3TOC.html"
    530     >The Java Language Specification, Third Edition</a>, <a href=
    531     "http://docs.oracle.com/javase/specs/jls/se5.0/html/classes.html#8.3"
    532     >Section 8.3</a> and <a href=
    533     "http://docs.oracle.com/javase/specs/jls/se5.0/html/classes.html#8.4.5"
    534     >Section 8.4.5</a>). Still, some tools have problems with it. Notably:
    535     <ul>
    536     <li>Sun's JDK 1.2.2 <code>javac</code> compiler produces an exception when
    537         compiling with such a library (cfr. <a href=
    538         "http://bugs.sun.com/view_bug.do?bug_id=4216736">Bug #4216736</a>).
    539         You probably shouldn't use this option for processing libraries.</li>
    540     <li>Sun's JRE 1.4 and later fail to serialize objects with overloaded
    541         primitive fields.</li>
    542     <li>Sun's JRE 1.5 <code>pack200</code> tool reportedly has problems with
    543         overloaded class members.</li>
    544     <li>The class <code>java.lang.reflect.Proxy</code> can't handle overloaded
    545         methods.</li>
    546     <li>Google's Dalvik VM can't handle overloaded static fields.</li>
    547     </ul></dd>
    548 
    549 <dt><a name="useuniqueclassmembernames"><code><b>-useuniqueclassmembernames</b></code></a></dt>
    550 
    551 <dd>Specifies to assign the same obfuscated names to class members that have
    552     the same names, and different obfuscated names to class members that have
    553     different names (for each given class member signature). Without the
    554     option, more class members can be mapped to the same short names like 'a',
    555     'b', etc. The option therefore increases the size of the resulting code
    556     slightly, but it ensures that the saved obfuscation name mapping can
    557     always be respected in subsequent incremental obfuscation steps.
    558     <p>
    559     For instance, consider two distinct interfaces containing methods with the
    560     same name and signature. Without this option, these methods may get
    561     different obfuscated names in a first obfuscation step. If a patch is then
    562     added containing a class that implements both interfaces, ProGuard will
    563     have to enforce the same method name for both methods in an incremental
    564     obfuscation step. The original obfuscated code is changed, in order to
    565     keep the resulting code consistent. With this option <i>in the initial
    566     obfuscation step</i>, such renaming will never be necessary.
    567     <p>
    568     This option is only applicable when obfuscating. In fact, if you are
    569     planning on performing incremental obfuscation, you probably want to avoid
    570     shrinking and optimization altogether, since these steps could remove or
    571     modify parts of your code that are essential for later additions.</dd>
    572 
    573 <dt><a name="dontusemixedcaseclassnames"><code><b>-dontusemixedcaseclassnames</b></code></a></dt>
    574 
    575 <dd>Specifies not to generate mixed-case class names while obfuscating. By
    576     default, obfuscated class names can contain a mix of upper-case characters
    577     and lower-case characters. This creates perfectly acceptable and usable
    578     jars. Only if a jar is unpacked on a platform with a case-insensitive
    579     filing system (say, Windows), the unpacking tool may let similarly named
    580     class files overwrite each other. Code that self-destructs when it's
    581     unpacked! Developers who really want to unpack their jars on Windows can
    582     use this option to switch off this behavior. Obfuscated jars will become
    583     slightly larger as a result. Only applicable when obfuscating.</dd>
    584 
    585 <dt><a name="keeppackagenames"><code><b>-keeppackagenames</b></code></a>
    586     [<i><a href="#filters">package_filter</a></i>]</dt>
    587 
    588 <dd>Specifies not to obfuscate the given package names. The optional filter is
    589     a comma-separated list of package names. Package names can contain
    590     <b>?</b>, <b>*</b>, and <b>**</b> wildcards, and they can be preceded by
    591     the <b>!</b> negator. Only applicable when obfuscating.</dd>
    592 
    593 <dt><a name="flattenpackagehierarchy"><code><b>-flattenpackagehierarchy</b></code></a>
    594     [<i>package_name</i>]</dt>
    595 
    596 <dd>Specifies to repackage all packages that are renamed, by moving them into
    597     the single given parent package. Without argument or with an empty string
    598     (''), the packages are moved into the root package. This option is one
    599     example of further <a href="examples.html#repackaging">obfuscating package
    600     names</a>. It can make the processed code smaller and less comprehensible.
    601     Only applicable when obfuscating.</dd>
    602 
    603 <dt><a name="repackageclasses"><code><b>-repackageclasses</b></code></a>
    604     [<i>package_name</i>]</dt>
    605 
    606 <dd>Specifies to repackage all class files that are renamed, by moving them
    607     into the single given package. Without argument or with an empty string
    608     (''), the package is removed completely. This option overrides the
    609     <a
    610     href="#flattenpackagehierarchy"><code>-flattenpackagehierarchy</code></a>
    611     option. It is another example of further <a
    612     href="examples.html#repackaging">obfuscating package names</a>. It can
    613     make the processed code even smaller and less comprehensible. Its
    614     deprecated name is <code>-defaultpackage</code>. Only applicable when
    615     obfuscating.
    616     <p>
    617     <i>Counter-indication:</i> classes that look for resource files in their
    618     package directories will no longer work properly if they are moved
    619     elsewhere. When in doubt, just leave the packaging untouched by not using
    620     this option.</dd>
    621 
    622 <dt><a name="keepattributes"><code><b>-keepattributes</b></code></a>
    623     [<i><a href="attributes.html">attribute_filter</a></i>]</dt>
    624 
    625 <dd>Specifies any optional attributes to be preserved. The attributes can be
    626     specified with one or more <code>-keepattributes</code> directives. The
    627     optional filter is a comma-separated list
    628     of <a href="attributes.html">attribute names</a> that Java virtual
    629     machines and ProGuard support. Attribute names can
    630     contain <b>?</b>, <b>*</b>, and <b>**</b> wildcards, and they can be
    631     preceded by the <b>!</b> negator. For example, you should at least keep
    632     the <code>Exceptions</code>, <code>InnerClasses</code>, and
    633     <code>Signature</code> attributes when
    634     <a href="examples.html#library">processing a library</a>. You should also
    635     keep the <code>SourceFile</code> and <code>LineNumberTable</code>
    636     attributes for <a href="examples.html#stacktrace">producing useful
    637     obfuscated stack traces</a>. Finally, you may want
    638     to <a href="examples.html#annotations">keep annotations</a> if your code
    639     depends on them. Only applicable when obfuscating.</dd>
    640 
    641 <dt><a name="keepparameternames"><code><b>-keepparameternames</b></code></a></dt>
    642 
    643 <dd>Specifies to keep the parameter names and types of methods that are kept.
    644     This option actually keeps trimmed versions of the debugging attributes
    645     <code>LocalVariableTable</code> and
    646     <code>LocalVariableTypeTable</code>. It can be useful when
    647     <a href="examples.html#library">processing a library</a>. Some IDEs can
    648     use the information to assist developers who use the library, for example
    649     with tool tips or autocompletion. Only applicable when obfuscating.</dd>
    650 
    651 <dt><a name="renamesourcefileattribute"><code><b>-renamesourcefileattribute</b></code></a>
    652     [<i>string</i>]</dt>
    653 
    654 <dd>Specifies a constant string to be put in the <code>SourceFile</code>
    655     attributes (and <code>SourceDir</code> attributes) of the class files.
    656     Note that the attribute has to be present to start with, so it also has to
    657     be preserved explicitly using the <code>-keepattributes</code> directive.
    658     For example, you may want to have your processed libraries and
    659     applications produce <a href="examples.html#stacktrace">useful obfuscated
    660     stack traces</a>. Only applicable when obfuscating.</dd>
    661 
    662 <dt><a name="adaptclassstrings"><code><b>-adaptclassstrings</b></code></a>
    663     [<i><a href="#filters">class_filter</a></i>]</dt>
    664 
    665 <dd>Specifies that string constants that correspond to class names should be
    666     obfuscated as well. Without a filter, all string constants that correspond
    667     to class names are adapted. With a filter, only string constants in
    668     classes that match the filter are adapted. For example, if your code
    669     contains a large number of hard-coded strings that refer to classes, and
    670     you prefer not to keep their names, you may want to use this option.
    671     Primarily applicable when obfuscating, although corresponding classes are
    672     automatically kept in the shrinking step too.</dd>
    673 
    674 <dt><a name="adaptresourcefilenames"><code><b>-adaptresourcefilenames</b></code></a>
    675     [<i><a href="#filefilters">file_filter</a></i>]</dt>
    676 
    677 <dd>Specifies the resource files to be renamed, based on the obfuscated names
    678     of the corresponding class files (if any). Without a filter, all resource
    679     files that correspond to class files are renamed. With a filter, only
    680     matching files are renamed. For example, see <a
    681     href="examples.html#resourcefiles">processing resource files</a>. Only
    682     applicable when obfuscating.</dd>
    683 
    684 <dt><a name="adaptresourcefilecontents"><code><b>-adaptresourcefilecontents</b></code></a>
    685     [<i><a href="#filefilters">file_filter</a></i>]</dt>
    686 
    687 <dd>Specifies the resource files whose contents are to be updated. Any class
    688     names mentioned in the resource files are renamed, based on the obfuscated
    689     names of the corresponding classes (if any). Without a filter, the
    690     contents of all resource files updated. With a filter, only matching files
    691     are updated. The resource files are parsed and written using the
    692     platform's default character set. You can change this default character set
    693     by setting the environment variable <code>LANG</code> or the Java system
    694     property <code>file.encoding</code>. For an example,
    695     see <a href="examples.html#resourcefiles">processing resource files</a>.
    696     Only applicable when obfuscating.
    697     <p>
    698     <i>Caveat:</i> You probably only want to apply this option to text files,
    699     since parsing and adapting binary files as text files can cause unexpected
    700     problems. Therefore, make sure that you specify a sufficiently narrow
    701     filter.</dd>
    702 
    703 
    704 </dl>
    705 <p>
    706 
    707 <h2><a name="preverificationoptions">Preverification Options</a></h2>
    708 
    709 <dl>
    710 <dt><a name="dontpreverify"><code><b>-dontpreverify</b></code></a></dt>
    711 
    712 <dd>Specifies not to preverify the processed class files. By default, class
    713     files are preverified if they are targeted at Java Micro Edition or at
    714     Java 6 or higher. For Java Micro Edition, preverification is required, so
    715     you will need to run an external preverifier on the processed code if you
    716     specify this option. For Java 6, preverification is optional, but as of
    717     Java 7, it is required. Only when eventually targeting Android, it is not
    718     necessary, so you can then switch it off to reduce the processing time a
    719     bit.</dd>
    720 
    721 <dt><a name="microedition"><code><b>-microedition</b></code></a></dt>
    722 
    723 <dd>Specifies that the processed class files are targeted at Java Micro
    724     Edition. The preverifier will then add the appropriate StackMap
    725     attributes, which are different from the default StackMapTable attributes
    726     for Java Standard Edition. For example, you will need this option if you
    727     are <a href="examples.html#midlets">processing midlets</a>.</dd>
    728 
    729 </dl>
    730 <p>
    731 
    732 <h2><a name="generaloptions">General Options</a></h2>
    733 
    734 <dl>
    735 <dt><a name="verbose"><code><b>-verbose</b></code></a></dt>
    736 
    737 <dd>Specifies to write out some more information during processing. If the
    738     program terminates with an exception, this option will print out the entire
    739     stack trace, instead of just the exception message.</dd>
    740 
    741 <dt><a name="dontnote"><code><b>-dontnote</b></code></a>
    742     [<i><a href="#filters">class_filter</a></i>]</dt>
    743 
    744 <dd>Specifies not to print notes about potential mistakes or omissions in the
    745     configuration, such as typos in class names or missing options that
    746     might be useful. The optional filter is a regular expression; ProGuard
    747     doesn't print notes about classes with matching names.</dd>
    748 
    749 <dt><a name="dontwarn"><code><b>-dontwarn</b></code></a>
    750     [<i><a href="#filters">class_filter</a></i>]</dt>
    751 
    752 <dd>Specifies not to warn about unresolved references and other important
    753     problems at all. The optional filter is a regular expression; ProGuard
    754     doesn't print warnings about classes with matching names. Ignoring
    755     warnings can be dangerous. For instance, if the unresolved classes or
    756     class members are indeed required for processing, the processed code will
    757     not function properly. <i>Only use this option if you know what you're
    758     doing!</i></dd>
    759 
    760 <dt><a name="ignorewarnings"><code><b>-ignorewarnings</b></code></a></dt>
    761 
    762 <dd>Specifies to print any warnings about unresolved references and other
    763     important problems, but to continue processing in any case. Ignoring
    764     warnings can be dangerous. For instance, if the unresolved classes or
    765     class members are indeed required for processing, the processed code will
    766     not function properly. <i>Only use this option if you know what you're
    767     doing!</i></dd>
    768 
    769 <dt><a name="printconfiguration"><code><b>-printconfiguration</b></code></a>
    770     [<a href="#filename"><i>filename</i></a>]</dt>
    771 
    772 <dd>Specifies to write out the entire configuration that has been parsed, with
    773     included files and replaced variables. The structure is printed to the
    774     standard output or to the given file. This can sometimes be useful for
    775     debugging configurations, or for converting XML configurations into a more
    776     readable format.</dd>
    777 
    778 <dt><a name="dump"><code><b>-dump</b></code></a>
    779     [<a href="#filename"><i>filename</i></a>]</dt>
    780 
    781 <dd>Specifies to write out the internal structure of the class files, after
    782     any processing. The structure is printed to the standard output or to the
    783     given file. For example, you may want to <a
    784     href="examples.html#structure">write out the contents of a given jar
    785     file</a>, without processing it at all.</dd>
    786 
    787 </dl>
    788 <p>
    789 
    790 <h2><a name="classpath">Class Paths</a></h2>
    791 
    792 ProGuard accepts a generalization of class paths to specify input files and
    793 output files. A class path consists of entries, separated by the traditional
    794 path separator (e.g. '<b>:</b>' on Unix, or '<b>;</b>' on Windows platforms).
    795 The order of the entries determines their priorities, in case of duplicates.
    796 <p>
    797 Each input entry can be:
    798 <ul>
    799 <li>A class file or resource file,</li>
    800 <li>An apk file, containing any of the above,</li>
    801 <li>A jar file, containing any of the above,</li>
    802 <li>An aar file, containing any of the above,</li>
    803 <li>A war file, containing any of the above,</li>
    804 <li>An ear file, containing any of the above,</li>
    805 <li>A zip file, containing any of the above,</li>
    806 <li>A directory (structure), containing any of the above.</li>
    807 </ul>
    808 <p>
    809 The paths of directly specified class files and resource files is ignored, so
    810 class files should generally be part of a jar file, an aar file, a war file,
    811 an ear file, a zip file, or a directory. In addition, the paths of class files
    812 should not have any additional directory prefixes inside the archives or
    813 directories.
    814 
    815 <p>
    816 Each output entry can be:
    817 <ul>
    818 <li>An apk file, in which all class files and resource files will be
    819     collected.</li>
    820 <li>A jar file, in which any and all of the above will be collected,</li>
    821 <li>An aar file, in which any and all of the above will be collected,</li>
    822 <li>A war file, in which any and all of the above will be collected,</li>
    823 <li>An ear file, in which any and all of the above will be collected,</li>
    824 <li>A zip file, in which any and all of the above will be collected,</li>
    825 <li>A directory, in which any and all of the above will be collected.</li>
    826 </ul>
    827 <p>
    828 When writing output entries, ProGuard will generally package the results in a
    829 sensible way, reconstructing the input entries as much as required. Writing
    830 everything to an output directory is the most straightforward option: the
    831 output directory will contain a complete reconstruction of the input entries.
    832 The packaging can be almost arbitrarily complex though: you could process an
    833 entire application, packaged in a zip file along with its documentation,
    834 writing it out as a zip file again. The Examples section shows a few ways
    835 to <a href="examples.html#restructuring">restructure output archives</a>.
    836 <p>
    837 Files and directories can be specified as discussed in the section on <a
    838 href="#filename">file names</a> below.
    839 <p>
    840 In addition, ProGuard provides the possibility to filter the class path
    841 entries and their contents, based on their full relative file names. Each
    842 class path entry can be followed by up to 7 types of <a
    843 href="#filefilters">file filters</a> between parentheses, separated by
    844 semi-colons:
    845 <ul>
    846 <li>A filter for all aar names that are encountered,</li>
    847 <li>A filter for all apk names that are encountered,</li>
    848 <li>A filter for all zip names that are encountered,</li>
    849 <li>A filter for all ear names that are encountered,</li>
    850 <li>A filter for all war names that are encountered,</li>
    851 <li>A filter for all jar names that are encountered,</li>
    852 <li>A filter for all class file names and resource file names that are
    853     encountered.</li>
    854 </ul>
    855 <p>
    856 If fewer than 7 filters are specified, they are assumed to be the latter
    857 filters. Any empty filters are ignored. More formally, a filtered class path
    858 entry looks like this:
    859 <pre>
    860 <i>classpathentry</i><b>(</b>[[[[[[<i>aarfilter</i><b>;</b>]<i>apkfilter</i><b>;</b>]<i>zipfilter</i><b>;</b>]<i>earfilter</i><b>;</b>]<i>warfilter</i><b>;</b>]<i>jarfilter</i><b>;</b>]<i>filefilter</i><b>)</b>
    861 </pre>
    862 <p>
    863 Square brackets "[]" mean that their contents are optional.
    864 <p>
    865 For example, "<code>rt.jar(java/**.class,javax/**.class)</code>" matches all
    866 class files in the <code>java</code> and <code>javax</code> directories inside
    867 the <code>rt</code> jar.
    868 <p>
    869 For example, "<code>input.jar(!**.gif,images/**)</code>" matches all files in
    870 the <code>images</code> directory inside the <code>input</code> jar, except
    871 gif files.
    872 <p>
    873 The different filters are applied to all corresponding file types, irrespective
    874 of their nesting levels in the input; they are orthogonal.
    875 <p>
    876 For example,
    877 "<code>input.war(lib/**.jar,support/**.jar;**.class,**.gif)</code>" only
    878 considers jar files in the <code>lib</code> and <code>support</code>
    879 directories in the <code>input</code> war, not any other jar files. It then
    880 matches all class files and gif files that are encountered.
    881 <p>
    882 The filters allow for an almost infinite number of packaging and repackaging
    883 possibilities. The Examples section provides a few more examples
    884 for <a href="examples.html#filtering">filtering input and output</a>.
    885 <p>
    886 
    887 <h2><a name="filename">File Names</a></h2>
    888 
    889 ProGuard accepts absolute paths and relative paths for the various file names
    890 and directory names. A relative path is interpreted as follows:
    891 <ul>
    892 <li>relative to the base directory, if set, or otherwise</li>
    893 <li>relative to the configuration file in which it is specified, if any, or
    894     otherwise</li>
    895 <li>relative to the working directory.</li>
    896 </ul>
    897 <p>
    898 The names can contain Java system properties (or Ant properties, when using
    899 Ant), delimited by angular brackets, '<b>&lt;</b>' and '<b>&gt;</b>'. The
    900 properties are automatically replaced by their corresponding values.
    901 <p>
    902 For example, <code>&lt;java.home&gt;/lib/rt.jar</code> is automatically
    903 expanded to something like <code>/usr/local/java/jdk/jre/lib/rt.jar</code>.
    904 Similarly, <code>&lt;user.home&gt;</code> is expanded to the user's home
    905 directory, and <code>&lt;user.dir&gt;</code> is expanded to the current
    906 working directory.
    907 <p>
    908 Names with special characters like spaces and parentheses must be quoted with
    909 single or double quotes. Each file name in a list of names has to be quoted
    910 individually. Note that the quotes themselves may need to be escaped when used
    911 on the command line, to avoid them being gobbled by the shell.
    912 <p>
    913 For example, on the command line, you could use an option like <code>'-injars
    914 "my program.jar":"/your directory/your program.jar"'</code>.
    915 <p>
    916 
    917 <h2><a name="filefilters">File Filters</a></h2>
    918 
    919 Like general <a href="#filters">filters</a>, a file filter is a
    920 comma-separated list of file names that can contain wildcards. Only files with
    921 matching file names are read (in the case of input jars), or written (in the
    922 case of output jars). The following wildcards are supported:
    923 
    924 <table cellspacing="10">
    925 <tr><td valign="top"><code><b>?</b></code></td>
    926     <td>matches any single character in a file name.</td></tr>
    927 <tr><td valign="top"><code><b>*</b></code></td>
    928     <td>matches any part of a filename not containing the directory
    929         separator.</td></tr>
    930 <tr><td valign="top"><code><b>**</b></code></td>
    931     <td>matches any part of a filename, possibly containing any number of
    932         directory separators.</td></tr>
    933 </table>
    934 
    935 For example, "<code>java/**.class,javax/**.class</code>" matches all
    936 class files in the <code>java</code> and <code>javax</code>.
    937 <p>
    938 
    939 Furthermore, a file name can be preceded by an exclamation mark '<b>!</b>' to
    940 <i>exclude</i> the file name from further attempts to match with
    941 <i>subsequent</i> file names.
    942 <p>
    943 For example, "<code>!**.gif,images/**</code>" matches all files in the
    944 <code>images</code> directory, except gif files.
    945 <p>
    946 The Examples section provides a few more examples for <a
    947 href="examples.html#filtering">filtering input and output</a>.
    948 
    949 <h2><a name="filters">Filters</a></h2>
    950 
    951 ProGuard offers options with filters for many different aspects of the
    952 configuration: names of files, directories, classes, packages, attributes,
    953 optimizations, etc.
    954 <p>
    955 A filter is a list of comma-separated names that can contain wildcards. Only
    956 names that match an item on the list pass the filter. The supported wildcards
    957 depend on the type of names for which the filter is being used, but the
    958 following wildcards are typical:
    959 
    960 <table cellspacing="10">
    961 <tr><td valign="top"><code><b>?</b></code></td>
    962     <td>matches any single character in a name.</td></tr>
    963 <tr><td valign="top"><code><b>*</b></code></td>
    964     <td>matches any part of a name not containing the package separator or
    965         directory separator.</td></tr>
    966 <tr><td valign="top"><code><b>**</b></code></td>
    967     <td>matches any part of a name, possibly containing any number of
    968         package separators or directory separators.</td></tr>
    969 </table>
    970 
    971 For example, "<code>foo,*bar</code>" matches the name <code>foo</code> and
    972 all names ending with <code>bar</code>.
    973 <p>
    974 
    975 Furthermore, a name can be preceded by a negating exclamation mark '<b>!</b>'
    976 to <i>exclude</i> the name from further attempts to match
    977 with <i>subsequent</i> names. So, if a name matches an item in the filter, it
    978 is accepted or rejected right away, depending on whether the item has a
    979 negator. If the name doesn't match the item, it is tested against the next
    980 item, and so on. It if doesn't match any items, it is accepted or rejected,
    981 depending on the whether the last item has a negator or not.
    982 <p>
    983 For example, "<code>!foobar,*bar</code>" matches all names ending with
    984 <code>bar</code>, except <code>foobar</code>.
    985 <p>
    986 
    987 <h2><a name="keepoverview">Overview of <code>Keep</code> Options</a></h2>
    988 
    989 The various <code>-keep</code> options for shrinking and obfuscation may seem
    990 a bit confusing at first, but there's actually a pattern behind them. The
    991 following table summarizes how they are related:
    992 <p>
    993 
    994 <table cellpadding="5">
    995 
    996 <tr>
    997 <th>Keep</th>
    998 <td>From being removed or renamed</td>
    999 <td>From being renamed</td>
   1000 </tr>
   1001 
   1002 <tr>
   1003 <td>Classes and class members</td>
   1004 <td bgcolor="#E0E0E0"><a href="#keep"><code>-keep</code></a></td>
   1005 <td bgcolor="#E0E0E0"><a href="#keepnames"><code>-keepnames</code></a></td>
   1006 </tr>
   1007 
   1008 <tr>
   1009 <td>Class members only</td>
   1010 <td bgcolor="#E0E0E0"><a href="#keepclassmembers"><code>-keepclassmembers</code></a></td>
   1011 <td bgcolor="#E0E0E0"><a href="#keepclassmembernames"><code>-keepclassmembernames</code></a></td>
   1012 </tr>
   1013 
   1014 <tr>
   1015 <td>Classes and class members, if class members present</td>
   1016 <td bgcolor="#E0E0E0"><a href="#keepclasseswithmembers"><code>-keepclasseswithmembers</code></a></td>
   1017 <td bgcolor="#E0E0E0"><a href="#keepclasseswithmembernames"><code>-keepclasseswithmembernames</code></a></td>
   1018 </tr>
   1019 
   1020 </table>
   1021 <p>
   1022 
   1023 Each of these <code>-keep</code> options is of course followed by a
   1024 <a href="#classspecification">specification</a> of the classes and class
   1025 members (fields and methods) to which it should be applied.
   1026 <p>
   1027 If you're not sure which option you need, you should probably simply use
   1028 <code>-keep</code>. It will make sure the specified classes and class members
   1029 are not removed in the shrinking step, and not renamed in the obfuscation step.
   1030 <p>
   1031 <img class="float" src="attention.gif" width="64" height="64" alt="attention" />
   1032 <ul class="shifted">
   1033 <li>If you specify a class, without class members, ProGuard only preserves the
   1034     class and its parameterless constructor as entry points. It may
   1035     still remove, optimize, or obfuscate its other class members.</li>
   1036 <li>If you specify a method, ProGuard only preserves the method as an entry
   1037     point. Its code may still be optimized and adapted.</li>
   1038 </ul>
   1039 <p>
   1040 
   1041 <h2><a name="keepoptionmodifiers">Keep Option Modifiers</a></h2>
   1042 
   1043 <dl>
   1044 <dt><a name="includedescriptorclasses"><code><b>includedescriptorclasses</b></code></a></dt>
   1045 
   1046 <dd>Specifies that any classes in the type descriptors of the methods and
   1047     fields that the <a href="#keep">-keep</a> option keeps should be kept as
   1048     well. This is typically useful when <a href="examples.html#native">keeping
   1049     native method names</a>, to make sure that the parameter types of native
   1050     methods aren't renamed either. Their signatures then remain completely
   1051     unchanged and compatible with the native libraries.</dd>
   1052 
   1053 <dt><a name="allowshrinking"><code><b>allowshrinking</b></code></a></dt>
   1054 
   1055 <dd>Specifies that the entry points specified in the <a href="#keep">-keep</a>
   1056     option may be shrunk, even if they have to be preserved otherwise. That
   1057     is, the entry points may be removed in the shrinking step, but if they are
   1058     necessary after all, they may not be optimized or obfuscated.</dd>
   1059 
   1060 <dt><a name="allowoptimization"><code><b>allowoptimization</b></code></a></dt>
   1061 
   1062 <dd>Specifies that the entry points specified in the <a href="#keep">-keep</a>
   1063     option may be optimized, even if they have to be preserved otherwise. That
   1064     is, the entry points may be altered in the optimization step, but they may
   1065     not be removed or obfuscated. This modifier is only useful for achieving
   1066     unusual requirements.</dd>
   1067 
   1068 <dt><a name="allowobfuscation"><code><b>allowobfuscation</b></code></a></dt>
   1069 
   1070 <dd>Specifies that the entry points specified in the <a href="#keep">-keep</a>
   1071     option may be obfuscated, even if they have to be preserved otherwise. That
   1072     is, the entry points may be renamed in the obfuscation step, but they may
   1073     not be removed or optimized. This modifier is only useful for achieving
   1074     unusual requirements.</dd>
   1075 
   1076 </dl>
   1077 <p>
   1078 
   1079 <h2><a name="classspecification">Class Specifications</a></h2>
   1080 
   1081 A class specification is a template of classes and class members (fields and
   1082 methods). It is used in the various <code>-keep</code> options and in the
   1083 <code>-assumenosideeffects</code> option. The corresponding option is only
   1084 applied to classes and class members that match the template.
   1085 <p>
   1086 The template was designed to look very Java-like, with some extensions for
   1087 wildcards. To get a feel for the syntax, you should probably look at the <a
   1088 href="examples.html">examples</a>, but this is an attempt at a complete formal
   1089 definition:
   1090 <p>
   1091 
   1092 <pre>
   1093 [<b>@</b><i>annotationtype</i>] [[<b>!</b>]<b>public</b>|<b>final</b>|<b>abstract</b>|<b>@</b> ...] [<b>!</b>]<b>interface</b>|<b>class</b>|<b>enum</b> <i>classname</i>
   1094     [<b>extends</b>|<b>implements</b> [<b>@</b><i>annotationtype</i>] <i>classname</i>]
   1095 [<b>{</b>
   1096     [<b>@</b><i>annotationtype</i>] [[<b>!</b>]<b>public</b>|<b>private</b>|<b>protected</b>|<b>static</b>|<b>volatile</b>|<b>transient</b> ...] <b>&lt;fields&gt;</b> |
   1097                                                                       (<i>fieldtype fieldname</i>)<b>;</b>
   1098     [<b>@</b><i>annotationtype</i>] [[<b>!</b>]<b>public</b>|<b>private</b>|<b>protected</b>|<b>static</b>|<b>synchronized</b>|<b>native</b>|<b>abstract</b>|<b>strictfp</b> ...] <b>&lt;methods&gt;</b> |
   1099                                                                                            <b>&lt;init&gt;(</b><i>argumenttype,...</i><b>)</b> |
   1100                                                                                            <i>classname</i><b>(</b><i>argumenttype,...</i><b>)</b> |
   1101                                                                                            (<i>returntype methodname</i><b>(</b><i>argumenttype,...</i><b>)</b>)<b>;</b>
   1102     [<b>@</b><i>annotationtype</i>] [[<b>!</b>]<b>public</b>|<b>private</b>|<b>protected</b>|<b>static</b> ... ] <b>*;</b>
   1103     ...
   1104 <b>}</b>]
   1105 </pre>
   1106 <p>
   1107 Square brackets "[]" mean that their contents are optional. Ellipsis dots
   1108 "..." mean that any number of the preceding items may be specified. A vertical
   1109 bar "|" delimits two alternatives. Non-bold parentheses "()" just group parts
   1110 of the specification that belong together. The indentation tries to clarify
   1111 the intended meaning, but white-space is irrelevant in actual configuration
   1112 files.
   1113 <p>
   1114 <ul class="spacious">
   1115 
   1116 <li>The <code><b>class</b></code> keyword refers to any interface or class.
   1117     The <code><b>interface</b></code> keyword restricts matches to interface
   1118     classes. The <code><b>enum</b></code> keyword restricts matches to
   1119     enumeration classes. Preceding the <code><b>interface</b></code> or
   1120     <code><b>enum</b></code> keywords by a <code><b>!</b></code> restricts
   1121     matches to classes that are not interfaces or enumerations,
   1122     respectively.</li>
   1123 
   1124 <li>Every <i>classname</i> must be fully qualified, e.g.
   1125     <code>java.lang.String</code>. Inner classes are separated by a dollar sign
   1126     "<code>$</code>", e.g. <code>java.lang.Thread$State</code>. Class names
   1127     may be specified as regular
   1128     expressions containing the following wildcards:
   1129 
   1130 <table cellspacing="10">
   1131 
   1132 <tr><td valign="top"><code><b>?</b></code></td>
   1133 
   1134 <td>matches any single character in a class name, but not the package
   1135     separator. For example, "<code>mypackage.Test?</code>" matches
   1136     "<code>mypackage.Test1</code>" and "<code>mypackage.Test2</code>", but not
   1137     "<code>mypackage.Test12</code>".</td></tr>
   1138 
   1139 <tr><td valign="top"><code><b>*</b></code></td>
   1140 
   1141 <td>matches any part of a class name not containing the package separator. For
   1142     example, "<code>mypackage.*Test*</code>" matches
   1143     "<code>mypackage.Test</code>" and
   1144     "<code>mypackage.YourTestApplication</code>", but not
   1145     "<code>mypackage.mysubpackage.MyTest</code>". Or, more generally,
   1146     "<code>mypackage.*</code>" matches all classes in
   1147     "<code>mypackage</code>", but not in its subpackages.</td></tr>
   1148 
   1149 <tr><td valign="top"><code><b>**</b></code></td>
   1150 
   1151 <td>matches any part of a class name, possibly containing any number of
   1152     package separators. For example, "<code>**.Test</code>" matches all
   1153     <code>Test</code> classes in all packages except the root package. Or,
   1154     "<code>mypackage.**</code>" matches all classes in
   1155     "<code>mypackage</code>" and in its subpackages.</td></tr>
   1156 
   1157 </table>
   1158 
   1159     For additional flexibility, class names can actually be comma-separated
   1160     lists of class names, with optional <code><b>!</b></code> negators, just
   1161     like file name filters. This notation doesn't look very Java-like, so it
   1162     should be used with moderation.
   1163     <p>
   1164     For convenience and for backward compatibility, the class name
   1165     <code><b>*</b></code> refers to any class, irrespective of its package.</li>
   1166 
   1167 <li>The <code><b>extends</b></code> and <code><b>implements</b></code>
   1168     specifications are typically used to restrict classes with wildcards. They
   1169     are currently equivalent, specifying that only classes extending or
   1170     implementing the given class qualify. Note that the given class itself is
   1171     not included in this set. If required, it should be specified in a
   1172     separate option.</li>
   1173 
   1174 <li>The <code><b>@</b></code> specifications can be used to restrict classes
   1175     and class members to the ones that are annotated with the specified
   1176     annotation types. An <i>annotationtype</i> is specified just like a
   1177     <i>classname</i>.</li>
   1178 
   1179 <li>Fields and methods are specified much like in Java, except that method
   1180     argument lists don't contain argument names (just like in other tools
   1181     like <code>javadoc</code> and <code>javap</code>). The specifications can
   1182     also contain the following catch-all wildcards:
   1183 
   1184 <table cellspacing="10">
   1185 
   1186 <tr><td valign="top"><code><b>&lt;init&gt;</b></code></td>
   1187 <td>matches any constructor.</td></tr>
   1188 
   1189 <tr><td valign="top"><code><b>&lt;fields&gt;</b></code></td>
   1190 <td>matches any field.</td></tr>
   1191 
   1192 <tr><td valign="top"><code><b>&lt;methods&gt;</b></code></td>
   1193 <td>matches any method.</td></tr>
   1194 
   1195 <tr><td valign="top"><code><b>*</b></code></td>
   1196 <td>matches any field or method.</td></tr>
   1197 
   1198 </table>
   1199 
   1200     Note that the above wildcards don't have return types. Only the
   1201     <code><b>&lt;init&gt;</b></code> wildcard has an argument list.
   1202     <p>
   1203 
   1204     Fields and methods may also be specified using regular expressions. Names
   1205     can contain the following wildcards:
   1206 
   1207 <table cellspacing="10">
   1208 <tr><td valign="top"><code><b>?</b></code></td>
   1209     <td>matches any single character in a method name.</td></tr>
   1210 <tr><td valign="top"><code><b>*</b></code></td>
   1211     <td>matches any part of a method name.</td></tr>
   1212 </table>
   1213 
   1214     Types in descriptors can contain the following wildcards:
   1215 
   1216 <table cellspacing="10">
   1217 <tr><td valign="top"><code><b>%</b></code></td>
   1218     <td>matches any primitive type ("<code>boolean</code>", "<code>int</code>",
   1219         etc, but not "<code>void</code>").</td></tr>
   1220 <tr><td valign="top"><code><b>?</b></code></td>
   1221     <td>matches any single character in a class name.</td></tr>
   1222 <tr><td valign="top"><code><b>*</b></code></td>
   1223     <td>matches any part of a class name not containing the package                     separator.</td></tr>
   1224 <tr><td valign="top"><code><b>**</b></code></td>
   1225     <td>matches any part of a class name, possibly containing any number of
   1226         package separators.</td></tr>
   1227 <tr><td valign="top"><code><b>***</b></code></td>
   1228     <td>matches any type (primitive or non-primitive, array or
   1229         non-array).</td></tr>
   1230 <tr><td valign="top"><code><b>...</b></code></td>
   1231     <td>matches any number of arguments of any type.</td></tr>
   1232 
   1233 </table>
   1234 
   1235     Note that the <code>?</code>, <code>*</code>, and <code>**</code>
   1236     wildcards will never match primitive types. Furthermore, only the
   1237     <code>***</code> wildcards will match array types of any dimension. For
   1238     example, "<code>** get*()</code>" matches "<code>java.lang.Object
   1239     getObject()</code>", but not "<code>float getFloat()</code>", nor
   1240     "<code>java.lang.Object[] getObjects()</code>".</li>
   1241 
   1242 <li>Constructors can also be specified using their short class names (without
   1243     package) or using their full class names. As in the Java language, the
   1244     constructor specification has an argument list, but no return type.</li>
   1245 
   1246 <li>The class access modifiers and class member access modifiers are typically
   1247     used to restrict wildcarded classes and class members. They specify that
   1248     the corresponding access flags have to be set for the member to match. A
   1249     preceding <code><b>!</b></code> specifies that the corresponding access
   1250     flag should be unset.
   1251     <p>
   1252     Combining multiple flags is allowed (e.g. <code>public static</code>). It
   1253     means that both access flags have to be set (e.g. <code>public</code>
   1254     <i>and</i> <code>static</code>), except when they are conflicting, in
   1255     which case at least one of them has to be set (e.g. at least
   1256     <code>public</code>
   1257     <i>or</i> <code>protected</code>).
   1258     <p>
   1259     ProGuard supports the additional modifiers <code><b>synthetic</b></code>,
   1260     <code><b>bridge</b></code>, and <code><b>varargs</b></code>, which may be
   1261     set by compilers.</li>
   1262 
   1263 </ul>
   1264 
   1265 <hr />
   1266 <address>
   1267 Copyright &copy; 2002-2014
   1268 <a target="other" href="http://www.lafortune.eu/">Eric Lafortune</a> @ <a target="top" href="http://www.saikoa.com/">Saikoa</a>.
   1269 </address>
   1270 </body>
   1271 </html>
   1272