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>Attributes</title>
8</head>
9<body>
10
11<script type="text/javascript" language="JavaScript">
12<!--
13if (window.self==window.top)
14  document.write('<a class="largebutton" target="_top" href="../index.html#manual/attributes.html">ProGuard index</a> <a class="largebutton" target="_top" href="http://www.saikoa.com/dexguard">DexGuard</a> <a class="largebutton" target="_top" href="http://www.saikoa.com/">Saikoa</a> <a class="largebutton" target="other" href="http://sourceforge.net/projects/proguard/">Sourceforge</a>')
15//-->
16</script>
17<noscript>
18<a class="largebutton" target="_top"  href="../index.html#manual/attributes.html">ProGuard index</a>
19<a class="largebutton" target="_top"  href="http://www.saikoa.com/dexguard">DexGuard</a>
20<a class="largebutton" target="_top"  href="http://www.saikoa.com/">Saikoa</a>
21<a class="largebutton" target="other" href="http://sourceforge.net/projects/proguard/">Sourceforge</a>
22</noscript>
23
24<h2>Attributes</h2>
25
26Class files essentially define classes, their fields, and their methods. A lot
27of essential and non-essential data are attached to these classes, fields, and
28methods as <i>attributes</i>. For instance, attributes can contain bytecode,
29source file names, line number tables, etc.
30<p>
31
32ProGuard's obfuscation step removes attributes that are generally not
33necessary for executing the code. With
34the <a href="usage.html#keepattributes"><code>-keepattributes</code></a>
35option, you can specify a filter for attributes that you do want to keep, for
36instance, if your code accesses them through reflection or if you want to
37preserve some compilation or debugging information. The filter works like
38any <a href="usage.html#filters">filter</a> in ProGuard.
39<p>
40
41The following wildcards are supported:
42
43<table cellspacing="10">
44<tr><td valign="top"><code><b>?</b></code></td>
45    <td>matches any single character in an attribute name.</td></tr>
46<tr><td valign="top"><code><b>*</b></code></td>
47    <td>matches any part of an attribute name.</td></tr>
48</table>
49
50An attribute name that is preceded by an exclamation mark '<b>!</b>' is
51<i>excluded</i> from further attempts to match with <i>subsequent</i>
52attribute names in the filter. Make sure to specify filters correctly, since
53they are not checked for potential typos.
54<p>
55
56For example, the following setting preserves the optional attributes that are
57typically necessary when processing code that is intended to be used as a
58library:
59<pre>
60-keepattributes Exceptions,InnerClasses,Signature,Deprecated,
61                SourceFile,LineNumberTable,*Annotation*,EnclosingMethod
62</pre>
63<p>
64
65The Java bytecode specifications currently specify the following list of
66attributes.
67
68<h3>Optional attributes</h3>
69
70ProGuard's obfuscation step by default discards the following optional
71attributes. You can keep them with
72the <a href="usage.html#keepattributes"><code>-keepattributes</code></a>
73option.
74
75<dl>
76<dt><code><b>SourceFile</b></code></dt>
77<dd>Specifies the name of the source file from which the class file was
78    compiled. If present, this name is reported in stack traces.</dd>
79
80<dt><div>(J++ extension)</div>
81    <code><b>SourceDir</b></code></dt>
82<dd>Specifies the name of the source directory from which the class file was
83    compiled.</dd>
84
85<dt><code><b>InnerClasses</b></code></dt>
86<dd>Specifies the relationship between a class and its inner classes and outer
87    classes. Other than this and the naming convention with a '$' separator
88    between the names of inner classes and outer classes, inner classes are
89    just like ordinary classes. Compilers may need this information to find
90    classes referenced in a compiled library. Code may access this information
91    by reflection, for instance to derive the simple name of the class.</dd>
92
93<dt><div>(Java 5 or higher)</div>
94    <code><b>EnclosingMethod</b></code></dt>
95<dd>Specifies the method in which the class was defined. Compilers may need
96    this information to find classes referenced in a compiled library. Code
97    may access this information by reflection, for instance to derive the
98    simple name of the class.</dd>
99
100<dt><code><b>Deprecated</b></code></dt>
101<dd>Indicates that the class, field, or method is deprecated.</dd>
102
103<dt><code><b>Synthetic</b></code></dt>
104<dd>Indicates that the class, field, or method was generated by the
105    compiler.</dd>
106
107<dt><div>(Java 5 or higher)</div>
108    <code><b>Signature</b></code></dt>
109<dd>Specifies the generic signature of the class, field, or method. Compilers
110    may need this information to properly compile classes that use generic
111    types from compiled libraries. Code may access this signature by
112    reflection.</dd>
113
114<dt><div>(Java 8 or higher)</div>
115    <code><b>MethodParameters</b></code></dt>
116<dd>Specifies the names and access flags of the parameters of the method. Code
117    may access this information by reflection.</dd>
118
119<dt><code><b>Exceptions</b></code></dt>
120<dd>Specifies the exceptions that a method may throw. Compilers may use this
121    information to enforce catching them.</dd>
122
123<dt><code><b>LineNumberTable</b></code></dt>
124<dd>Specifies the line numbers of the method. If present, these line numbers
125    are reported in stack traces.</dd>
126
127<dt><code><b>LocalVariableTable</b></code></dt>
128<dd>Specifies the names and types of local variables of the method. If present,
129    some IDEs may use this information for helping with auto-completion.</dd>
130
131<dt><div>(Java 5 or higher)</div>
132    <code><b>LocalVariableTypeTable</b></code></dt>
133<dd>Specifies the names and generic types of local variables of the method. If
134    present, some IDEs may use this information for helping with
135    auto-completion.</dd>
136
137<dt><div>(Java 5 or higher)</div>
138    <code><b>RuntimeVisibleAnnotations</b></code></dt>
139<dd>Specifies the annotations that are visible at run-time, for classes,
140    fields, and methods. Compilers and annotation processors may use these
141    annotations. Code may access them by reflection.</dd>
142
143<dt><div>(Java 5 or higher)</div>
144    <code><b>RuntimeInvisibleAnnotations</b></code></dt>
145<dd>Specifies the annotations that are visible at compile-time, for classes,
146    fields, and methods. Compilers and annotation processors may use these
147    annotations.</dd>
148
149<dt><div>(Java 5 or higher)</div>
150    <code><b>RuntimeVisibleParameterAnnotations</b></code></dt>
151<dd>Specifies the annotations that are visible at run-time, for method
152    parameters. Compilers and annotation processors may use these
153    annotations. Code may access them by reflection.</dd>
154
155<dt><div>(Java 5 or higher)</div>
156    <code><b>RuntimeInvisibleParameterAnnotations</b></code></dt>
157<dd>Specifies the annotations that are visible at compile-time, for method
158    parameters. Compilers and annotation processors may use these
159    annotations.</dd>
160
161<dt><div>(Java 8 or higher)</div>
162    <code><b>RuntimeVisibleTypeAnnotations</b></code></dt>
163<dd>Specifies the annotations that are visible at run-time, for generic types,
164    instructions, etc. Compilers and annotation processors may use these
165    annotations. Code may access them by reflection.</dd>
166
167<dt><div>(Java 8 or higher)</div>
168    <code><b>RuntimeInvisibleTypeAnnotations</b></code></dt>
169<dd>Specifies the annotations that are visible at compile-time, for generic
170    types, instructions, etc. Compilers and annotation processors may use
171    these annotations.</dd>
172
173<dt><div>(Java 5 or higher)</div>
174    <code><b>AnnotationDefault</b></code></dt>
175<dd>Specifies a default value for an annotation.</dd>
176
177</dl>
178<p>
179
180<h3>Essential attributes</h3>
181
182ProGuard automatically keeps the following essential attributes, processing
183them as necessary. We're listing them for the sake of completeness.
184
185<dl>
186<dt><code><b>ConstantValue</b></code></dt>
187<dd>Specifies a constant integer, float, class, string, etc.</dd>
188
189<dt><code><b>Code</b></code></dt>
190<dd>Specifies the actual bytecode of a method.</dd>
191
192<dt><div>(Java Micro Edition)</div>
193    <code><b>StackMap</b></code></dt>
194<dd>Provides preverification information. The Java Virtual Machine can use
195    this information to speed up the verification step when loading a
196    class.</dd>
197
198<dt><div>(Java 6 or higher)</div>
199    <code><b>StackMapTable</b></code></dt>
200<dd>Provides preverification information. The Java Virtual Machine can use
201    this information to speed up the verification step when loading a
202    class.</dd>
203
204<dt><div>(Java 7 or higher)</div>
205    <code><b>BootstrapMethods</b></code></dt>
206<dd>Specifies the methods to bootstrap dynamic method invocations.</dd>
207
208</dl>
209<p>
210
211<hr />
212<address>
213Copyright &copy; 2002-2014
214<a target="other" href="http://www.lafortune.eu/">Eric Lafortune</a> @ <a target="top" href="http://www.saikoa.com/">Saikoa</a>.
215</address>
216</body>
217</html>
218