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