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