Home | History | Annotate | Download | only in manual
      1 <!doctype html PUBLIC "-//W3C//DTD HTML 3.2 Final//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 Reference Card</title>
      8 </head>
      9 <body>
     10 
     11 <h1>ProGuard Reference Card</h1>
     12 
     13 <h2>Usage</h2>
     14 
     15 <code><b>java -jar proguard.jar </b></code><i>options</i> ...
     16 <p>
     17 &nbsp;&nbsp;Typically:
     18 <p>
     19 <code><b>java -jar proguard.jar @myconfig.pro</b></code>
     20 <p>
     21 
     22 <h2>Options</h2>
     23 
     24 <table cellspacing="10">
     25 
     26 <tr>
     27 <td valign="top"><a href="usage.html#at"><code><b>@</b></code></a><a href="usage.html#filename"><i>filename</i></a></td>
     28 
     29 <td>Short for '<code>-include</code> <i>filename</i>'.</td>
     30 </tr>
     31 
     32 <tr>
     33 <td valign="top"><a href="usage.html#include"><code><b>-include</b></code></a>
     34                  <a href="usage.html#filename"><i>filename</i></a></td>
     35 
     36 <td>Read configuration options from the given file.</td>
     37 </tr>
     38 
     39 <tr>
     40 <td valign="top"><a href="usage.html#basedirectory"><code><b>-basedirectory</b></code></a>
     41                  <a href="usage.html#filename"><i>directoryname</i></a></td>
     42 
     43 <td>Specifies the base directory for subsequent relative file names.</td>
     44 </tr>
     45 
     46 <tr>
     47 <td valign="top"><a href="usage.html#injars"><code><b>-injars</b></code></a>
     48                  <a href="usage.html#classpath"><i>class_path</i></a></td>
     49 <td>Specifies the program jars (or wars, ears, zips, or directories).</td>
     50 </tr>
     51 
     52 <tr>
     53 <td valign="top"><a href="usage.html#outjars"><code><b>-outjars</b></code></a>
     54                  <a href="usage.html#classpath"><i>class_path</i></a></td>
     55 <td>Specifies the name of the output jars (or wars, ears, zips, or
     56     directories).</td>
     57 </tr>
     58 
     59 <tr>
     60 <td valign="top"><a href="usage.html#libraryjars"><code><b>-libraryjars</b></code></a>
     61                  <a href="usage.html#classpath"><i>class_path</i></a></td>
     62 <td>Specifies the library jars (or wars, ears, zips, or directories).</td>
     63 </tr>
     64 
     65 <tr>
     66 <td valign="top"><a href="usage.html#dontskipnonpubliclibraryclasses"><code><b>-dontskipnonpubliclibraryclasses</b></code></a></td>
     67 <td>Don't ignore non-public library classes.</td>
     68 </tr>
     69 
     70 <tr>
     71 <td valign="top"><a href="usage.html#dontskipnonpubliclibraryclassmembers"><code><b>-dontskipnonpubliclibraryclassmembers</b></code></a></td>
     72 <td>Don't ignore package visible library class members.</td>
     73 </tr>
     74 
     75 <tr>
     76 <td valign="top"><a href="usage.html#keepdirectories"><code><b>-keepdirectories</b></code></a>
     77                  [<a href="usage.html#filters"><i>directory_filter</i></a>]</td>
     78 <td>Keep the specified directories in the output jars (or wars, ears, zips, or
     79     directories).</td>
     80 </tr>
     81 
     82 <tr>
     83 <td valign="top"><a href="usage.html#target"><code><b>-target</b></code></a>
     84                  <i>version</i></td>
     85 <td>Set the given version number in the processed classes.</td>
     86 </tr>
     87 
     88 <tr>
     89 <td valign="top"><a href="usage.html#forceprocessing"><code><b>-forceprocessing</b></code></a></td>
     90 <td>Process the input, even if the output seems up to date.</td>
     91 </tr>
     92 
     93 <tr>
     94 <td valign="top"><a href="usage.html#keep"><code><b>-keep</b></code></a>
     95                  [<a href="usage.html#keepoptionmodifiers">,<i>modifier</i></a>,...]
     96                  <a href="usage.html#classspecification"><i>class_specification</i></a></td>
     97 <td>Preserve the specified classes <i>and</i> class members.</td>
     98 
     99 </tr>
    100 <tr>
    101 <td valign="top"><a href="usage.html#keepclassmembers"><code><b>-keepclassmembers</b></code></a>
    102                  [<a href="usage.html#keepoptionmodifiers">,<i>modifier</i></a>,...]
    103                  <a href="usage.html#classspecification"><i>class_specification</i></a></td>
    104 <td>Preserve the specified class members, if their classes are preserved as
    105     well.</td>
    106 </tr>
    107 
    108 <tr>
    109 <td valign="top"><a href="usage.html#keepclasseswithmembers"><code><b>-keepclasseswithmembers</b></code></a>
    110                  [<a href="usage.html#keepoptionmodifiers">,<i>modifier</i></a>,...]
    111                  <a href="usage.html#classspecification"><i>class_specification</i></a></td>
    112 <td>Preserve the specified classes <i>and</i> class members, if all of the
    113     specified class members are present.</td>
    114 </tr>
    115 
    116 <tr>
    117 <td valign="top"><a href="usage.html#keepnames"><code><b>-keepnames</b></code></a>
    118                  <a href="usage.html#classspecification"><i>class_specification</i></a></td>
    119 <td>Preserve the names of the specified classes <i>and</i> class members (if
    120     they aren't removed in the shrinking step).</td>
    121 </tr>
    122 
    123 <tr>
    124 <td valign="top"><a href="usage.html#keepclassmembernames"><code><b>-keepclassmembernames</b></code></a>
    125                  <a href="usage.html#classspecification"><i>class_specification</i></a></td>
    126 <td>Preserve the names of the specified class members (if they aren't removed
    127     in the shrinking step).</td>
    128 </tr>
    129 
    130 <tr>
    131 <td valign="top"><a href="usage.html#keepclasseswithmembernames"><code><b>-keepclasseswithmembernames</b></code></a>
    132                  <a href="usage.html#classspecification"><i>class_specification</i></a></td>
    133 <td>Preserve the names of the specified classes <i>and</i> class members, if
    134     all of the specified class members are present (after the shrinking
    135     step).</td>
    136 </tr>
    137 
    138 <tr>
    139 <td valign="top"><a href="usage.html#printseeds"><code><b>-printseeds</b></code></a>
    140                  [<a href="usage.html#filename"><i>filename</i></a>]</td>
    141 <td>List classes and class members matched by the various <code>-keep</code>
    142     options, to the standard output or to the given file.</td>
    143 </tr>
    144 
    145 <tr>
    146 <td valign="top"><a href="usage.html#dontshrink"><code><b>-dontshrink</b></code></a></td>
    147 <td>Don't shrink the input class files.</td>
    148 </tr>
    149 
    150 <tr>
    151 <td valign="top"><a href="usage.html#printusage"><code><b>-printusage</b></code></a>
    152                  [<a href="usage.html#filename"><i>filename</i></a>]</td>
    153 <td>List dead code of the input class files, to the standard output or to the
    154     given file.</td>
    155 </tr>
    156 
    157 <tr>
    158 <td valign="top"><a href="usage.html#whyareyoukeeping"><code><b>-whyareyoukeeping</b></code></a>
    159                  <a href="usage.html#classspecification"><i>class_specification</i></a></td>
    160 <td>Print details on why the given classes and class members are being kept in
    161     the shrinking step.</td>
    162 </tr>
    163 
    164 <tr>
    165 <td valign="top"><a href="usage.html#dontoptimize"><code><b>-dontoptimize</b></code></a></td>
    166 <td>Don't optimize the input class files.</td>
    167 </tr>
    168 
    169 <tr>
    170 <td valign="top"><a href="usage.html#optimizations"><code><b>-optimizations</b></code></a>
    171                  <a href="optimizations.html"><i>optimization_filter</i></a></td>
    172 <td>The optimizations to be enabled and disabled.</td>
    173 </tr>
    174 
    175 <tr>
    176 <td valign="top"><a href="usage.html#optimizationpasses"><code><b>-optimizationpasses</b></code></a>
    177                  <i>n</i></td>
    178 <td>The number of optimization passes to be performed.</td>
    179 </tr>
    180 
    181 <tr>
    182 <td valign="top"><a href="usage.html#assumenosideeffects"><code><b>-assumenosideeffects</b></code></a>
    183                  <a href="usage.html#classspecification"><i>class_specification</i></a></td>
    184 <td>Assume that the specified methods don't have any side effects, while
    185     optimizing.</td>
    186 </tr>
    187 
    188 <tr>
    189 <td valign="top"><a href="usage.html#allowaccessmodification"><code><b>-allowaccessmodification</b></code></a></td>
    190 <td>Allow the access modifiers of classes and class members to be modified,
    191     while optimizing.</td>
    192 </tr>
    193 
    194 <tr>
    195 <td valign="top"><a href="usage.html#mergeinterfacesaggressively"><code><b>-mergeinterfacesaggressively</b></code></a></td>
    196 <td>Allow any interfaces to be merged, while optimizing.</td>
    197 </tr>
    198 
    199 <tr>
    200 <td valign="top"><a href="usage.html#dontobfuscate"><code><b>-dontobfuscate</b></code></a></td>
    201 <td>Don't obfuscate the input class files.</td>
    202 </tr>
    203 
    204 <tr>
    205 <td valign="top"><a href="usage.html#printmapping"><code><b>-printmapping</b></code></a>
    206                  [<a href="usage.html#filename"><i>filename</i></a>]</td>
    207 <td>Print the mapping from old names to new names for classes and class members
    208     that have been renamed, to the standard output or to the given file.</td>
    209 </tr>
    210 
    211 <tr>
    212 <td valign="top"><a href="usage.html#applymapping"><code><b>-applymapping</b></code></a>
    213                  <a href="usage.html#filename"><i>filename</i></a></td>
    214 <td>Reuse the given mapping, for incremental obfuscation.</td>
    215 </tr>
    216 
    217 <tr>
    218 <td valign="top"><a href="usage.html#obfuscationdictionary"><code><b>-obfuscationdictionary</b></code></a>
    219                  <a href="usage.html#filename"><i>filename</i></a></td>
    220 <td>Use the words in the given text file as obfuscated field names and method names.</td>
    221 </tr>
    222 
    223 <tr>
    224 <td valign="top"><a href="usage.html#classobfuscationdictionary"><code><b>-classobfuscationdictionary</b></code></a>
    225                  <a href="usage.html#filename"><i>filename</i></a></td>
    226 <td>Use the words in the given text file as obfuscated class names.</td>
    227 </tr>
    228 
    229 <tr>
    230 <td valign="top"><a href="usage.html#packageobfuscationdictionary"><code><b>-packageobfuscationdictionary</b></code></a>
    231                  <a href="usage.html#filename"><i>filename</i></a></td>
    232 <td>Use the words in the given text file as obfuscated package names.</td>
    233 </tr>
    234 
    235 <tr>
    236 <td valign="top"><a href="usage.html#overloadaggressively"><code><b>-overloadaggressively</b></code></a></td>
    237 <td>Apply aggressive overloading while obfuscating.</td>
    238 </tr>
    239 
    240 <tr>
    241 <td valign="top"><a href="usage.html#useuniqueclassmembernames"><code><b>-useuniqueclassmembernames</b></code></a></td>
    242 <td>Ensure uniform obfuscated class member names for subsequent incremental
    243     obfuscation.</td> </tr>
    244 
    245 <tr>
    246 <td valign="top"><a href="usage.html#dontusemixedcaseclassnames"><code><b>-dontusemixedcaseclassnames</b></code></a></td>
    247 <td>Don't generate mixed-case class names while obfuscating.</td>
    248 </tr>
    249 
    250 <tr>
    251 <td valign="top"><a href="usage.html#keeppackagenames"><code><b>-keeppackagenames</b></code></a>
    252                  [<i><a href="usage.html#filters">package_filter</a></i>]</td>
    253 <td>Keep the specified package names from being obfuscated.</td>
    254 </tr>
    255 
    256 <tr>
    257 <td valign="top"><a href="usage.html#flattenpackagehierarchy"><code><b>-flattenpackagehierarchy</b></code></a>
    258                  [<i>package_name</i>]</td>
    259 <td>Repackage all packages that are renamed into the single given parent
    260     package.</td>
    261 </tr>
    262 
    263 <tr>
    264 <td valign="top"><a href="usage.html#repackageclasses"><code><b>-repackageclasses</b></code></a>
    265                  [<i>package_name</i>]</td>
    266 <td>Repackage all class files that are renamed into the single given
    267     package.</td>
    268 </tr>
    269 
    270 <tr>
    271 <td valign="top"><a href="usage.html#keepattributes"><code><b>-keepattributes</b></code></a>
    272                  [<i><a href="usage.html#filters">attribute_filter</a></i>]</td>
    273 <td>Preserve the given optional attributes; typically
    274     <code>Exceptions</code>, <code>InnerClasses</code>,
    275     <code>Signature</code>, <code>Deprecated</code>,
    276     <code>SourceFile</code>, <code>SourceDir</code>,
    277     <code>LineNumberTable</code>,
    278     <code>LocalVariableTable</code>, <code>LocalVariableTypeTable</code>,
    279     <code>Synthetic</code>, <code>EnclosingMethod</code>, and
    280     <code>*Annotation*</code>.</td>
    281 </tr>
    282 
    283 <tr>
    284 <td valign="top"><a href="usage.html#renamesourcefileattribute"><code><b>-renamesourcefileattribute</b></code></a>
    285                  [<i>string</i>]</td>
    286 <td>Put the given constant string in the <code>SourceFile</code>
    287     attributes.</td>
    288 </tr>
    289 
    290 <tr>
    291 <td valign="top"><a href="usage.html#adaptclassstrings"><code><b>-adaptclassstrings</b></code></a>
    292                  [<a href="usage.html#filters"><i>class_filter</i></a>]</td>
    293 <td>Adapt string constants in the specified classes, based on the obfuscated
    294     names of any corresponding classes.</td>
    295 </tr>
    296 
    297 <tr>
    298 <td valign="top"><a href="usage.html#adaptresourcefilenames"><code><b>-adaptresourcefilenames</b></code></a>
    299                  [<a href="usage.html#filefilters"><i>file_filter</i></a>]</td>
    300 <td>Rename the specified resource files, based on the obfuscated names of the
    301     corresponding class files.</td>
    302 </tr>
    303 
    304 <tr>
    305 <td valign="top"><a href="usage.html#adaptresourcefilecontents"><code><b>-adaptresourcefilecontents</b></code></a>
    306                  [<a href="usage.html#filefilters"><i>file_filter</i></a>]</td>
    307 <td>Update the contents of the specified resource files, based on the
    308     obfuscated names of the processed classes.</td>
    309 </tr>
    310 
    311 <tr>
    312 <td valign="top"><a href="usage.html#dontpreverify"><code><b>-dontpreverify</b></code></a></td>
    313 <td>Don't preverify the processed class files.</td>
    314 </tr>
    315 
    316 <tr>
    317 <td valign="top"><a href="usage.html#microedition"><code><b>-microedition</b></code></a></td>
    318 <td>Target the processed class files at Java Micro Edition.</td>
    319 </tr>
    320 
    321 <tr>
    322 <td valign="top"><a href="usage.html#verbose"><code><b>-verbose</b></code></a></td>
    323 <td>Write out some more information during processing.</td>
    324 </tr>
    325 
    326 <tr>
    327 <td valign="top"><a href="usage.html#dontnote"><code><b>-dontnote</b></code></a>
    328                  [<a href="usage.html#filters"><i>class_filter</i></a>]</td>
    329 <td>Don't print notes about potential mistakes or omissions in the
    330     configuration.</td>
    331 </tr>
    332 
    333 <tr>
    334 <td valign="top"><a href="usage.html#dontwarn"><code><b>-dontwarn</b></code></a>
    335                  [<a href="usage.html#filters"><i>class_filter</i></a>]</td>
    336 <td>Don't warn about unresolved references at all.</td>
    337 </tr>
    338 
    339 <tr>
    340 <td valign="top"><a href="usage.html#ignorewarnings"><code><b>-ignorewarnings</b></code></a></td>
    341 <td>Print warnings about unresolved references, but continue processing
    342     anyhow.</td>
    343 </tr>
    344 
    345 <tr>
    346 <td valign="top"><a href="usage.html#printconfiguration"><code><b>-printconfiguration</b></code></a>
    347                  [<a href="usage.html#filename"><i>filename</i></a>]</td>
    348 <td>Write out the internal structure of the processed class files, to the
    349     standard output or to the given file.</td>
    350 </tr>
    351 
    352 <tr>
    353 <td valign="top"><a href="usage.html#dump"><code><b>-dump</b></code></a>
    354                  [<a href="usage.html#filename"><i>filename</i></a>]</td>
    355 <td>Write out the entire configuration in traditional ProGuard style, to the
    356     standard output or to the given file.</td>
    357 </tr>
    358 
    359 </table>
    360 <p>
    361 Notes:
    362 <ul>
    363 
    364 <li><i>class_path</i> is a list of jars, wars, ears, zips, and directories,
    365     with optional filters, separated by path separators.
    366 <li><i>filename</i> can contain Java system properties delimited by
    367     '<b>&lt;</b>' and '<b>&gt;</b>'.
    368 <li>If <i>filename</i> contains special characters, the entire name
    369     should be quoted with single or double quotes.
    370 </ul>
    371 <p>
    372 
    373 <h2>Overview of <code>Keep</code> Options</h2>
    374 
    375 <table cellpadding="5">
    376 
    377 <tr>
    378 <th>Keep</th>
    379 <td>From being removed or renamed</td>
    380 <td>From being renamed</td>
    381 </tr>
    382 
    383 <tr>
    384 <td>Classes and class members</td>
    385 <td bgcolor="#E0E0E0"><a href="usage.html#keep"><code>-keep</code></a></td>
    386 <td bgcolor="#E0E0E0"><a href="usage.html#keepnames"><code>-keepnames</code></a></td>
    387 </tr>
    388 
    389 <tr>
    390 <td>Class members only</td>
    391 <td bgcolor="#E0E0E0"><a href="usage.html#keepclassmembers"><code>-keepclassmembers</code></a></td>
    392 <td bgcolor="#E0E0E0"><a href="usage.html#keepclassmembernames"><code>-keepclassmembernames</code></a></td>
    393 </tr>
    394 
    395 <tr>
    396 <td>Classes and class members, if class members present</td>
    397 <td bgcolor="#E0E0E0"><a href="usage.html#keepclasseswithmembers"><code>-keepclasseswithmembers</code></a></td>
    398 <td bgcolor="#E0E0E0"><a href="usage.html#keepclasseswithmembernames"><code>-keepclasseswithmembernames</code></a></td>
    399 </tr>
    400 
    401 </table>
    402 <p>
    403 
    404 <h2>Keep Option Modifiers</h2>
    405 
    406 <table cellspacing="10">
    407 
    408 <tr>
    409 <td valign="top"><a href="usage.html#allowshrinking"><code><b>allowshrinking</b></code></a></td>
    410 <td>The entry points specified in the keep tag may be shrunk.</td>
    411 </tr>
    412 
    413 <tr>
    414 <td valign="top"><a href="usage.html#allowoptimization"><code><b>allowoptimization</b></code></a></td>
    415 <td>The entry points specified in the keep tag may be optimized.</td>
    416 </tr>
    417 
    418 <tr>
    419 <td valign="top"><a href="usage.html#allowobfuscation"><code><b>allowobfuscation</b></code></a></td>
    420 <td>The entry points specified in the keep tag may be obfuscated.</td>
    421 </tr>
    422 
    423 </table>
    424 <p>
    425 
    426 <h2>Class Specifications</h2>
    427 
    428 <pre>
    429 [<b>@</b><i>annotationtype</i>] [[<b>!</b>]<b>public</b>|<b>final</b>|<b>abstract</b> ...] [<b>!</b>]<b>interface</b>|<b>class</b> <i>classname</i>
    430     [<b>extends</b>|<b>implements</b> [<b>@</b><i>annotationtype</i>] <i>classname</i>]
    431 [<b>{</b>
    432     [<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> |
    433                                                                       (<i>fieldtype fieldname</i>)<b>;</b>
    434     [<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> |
    435                                                                                            <b>&lt;init&gt;(</b><i>argumenttype,...</i><b>)</b> |
    436                                                                                            <i>classname</i><b>(</b><i>argumenttype,...</i><b>)</b> |
    437                                                                                            (<i>returntype methodname</i><b>(</b><i>argumenttype,...</i><b>)</b>)<b>;</b>
    438     [<b>@</b><i>annotationtype</i>] [[<b>!</b>]<b>public</b>|<b>private</b>|<b>protected</b>|<b>static</b> ... ] <b>*;</b>
    439     ...
    440 <b>}</b>]
    441 </pre>
    442 <p>
    443 Notes:
    444 <ul>
    445 <li>Class names must always be fully qualified, i.e. including their package
    446     names.
    447 <li>Types in <i>classname</i>, <i>annotationtype</i>, <i>returntype</i>, and
    448     <i>argumenttype</i> can contain wildcards: '<code><b>?</b></code>' for a
    449     single character, '<code><b>*</b></code>' for any number of characters
    450     (but not the package separator), '<code><b>**</b></code>' for any number
    451     of (any) characters, '<code><b>%</b></code>' for any primitive type,
    452     '<code><b>***</b></code>' for any type, and '<code><b>...</b></code>' for       any number of arguments..
    453 <li><i>fieldname</i> and <i>methodname</i> can contain wildcards as well:
    454     '<code><b>?</b></code>' for a single character and '<code><b>*</b></code>'
    455     for any number of characters.
    456 </ul>
    457 <p>
    458 
    459 <hr>
    460 <address>
    461 Copyright &copy; 2002-2009
    462 <a href="http://www.graphics.cornell.edu/~eric/">Eric Lafortune</a>.
    463 </address>
    464 </body>
    465 </html>
    466