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