1 # Keep - Applications. Keep all application classes, along with their 'main' 2 # methods. 3 -keepclasseswithmembers public class * { 4 public static void main(java.lang.String[]); 5 } 6 7 # Keep - Applets. Keep all extensions of java.applet.Applet. 8 -keep public class * extends java.applet.Applet 9 10 # Keep - Servlets. Keep all extensions of javax.servlet.Servlet. 11 -keep public class * extends javax.servlet.Servlet 12 13 # Keep - Midlets. Keep all extensions of javax.microedition.midlet.MIDlet. 14 -keep public class * extends javax.microedition.midlet.MIDlet 15 16 # Keep - Xlets. Keep all extensions of javax.tv.xlet.Xlet. 17 -keep public class * extends javax.tv.xlet.Xlet 18 19 # Keep - Library. Keep all public and protected classes, fields, and methods. 20 -keep public class * { 21 public protected <fields>; 22 public protected <methods>; 23 } 24 25 # Also keep - Enumerations. Keep the special static methods that are required in 26 # enumeration classes. 27 -keepclassmembers enum * { 28 public static **[] values(); 29 public static ** valueOf(java.lang.String); 30 } 31 32 # Also keep - Serialization code. Keep all fields and methods that are used for 33 # serialization. 34 -keepclassmembers class * extends java.io.Serializable { 35 static final long serialVersionUID; 36 static final java.io.ObjectStreamField[] serialPersistentFields; 37 private void writeObject(java.io.ObjectOutputStream); 38 private void readObject(java.io.ObjectInputStream); 39 java.lang.Object writeReplace(); 40 java.lang.Object readResolve(); 41 } 42 43 # Also keep - BeanInfo classes. Keep all implementations of java.beans.BeanInfo. 44 -keep class * implements java.beans.BeanInfo 45 46 # Also keep - Bean classes. Keep all specified classes, along with their getters 47 # and setters. 48 -keep class * { 49 void set*(***); 50 void set*(int,***); 51 52 boolean is*(); 53 boolean is*(int); 54 55 *** get*(); 56 *** get*(int); 57 } 58 59 # Also keep - Database drivers. Keep all implementations of java.sql.Driver. 60 -keep class * implements java.sql.Driver 61 62 # Also keep - Swing UI L&F. Keep all extensions of javax.swing.plaf.ComponentUI, 63 # along with the special 'createUI' method. 64 -keep class * extends javax.swing.plaf.ComponentUI { 65 public static javax.swing.plaf.ComponentUI createUI(javax.swing.JComponent); 66 } 67 68 # Also keep - RMI interfaces. Keep all interfaces that extend the 69 # java.rmi.Remote interface, and their methods. 70 -keep interface * extends java.rmi.Remote { 71 <methods>; 72 } 73 74 # Also keep - RMI implementations. Keep all implementations of java.rmi.Remote, 75 # including any explicit or implicit implementations of Activatable, with their 76 # two-argument constructors. 77 -keep class * implements java.rmi.Remote { 78 <init>(java.rmi.activation.ActivationID,java.rmi.MarshalledObject); 79 } 80 81 # Keep names - Native method names. Keep all native class/method names. 82 -keepclasseswithmembernames class * { 83 native <methods>; 84 } 85 86 # Keep names - _class method names. Keep all .class method names. This may be 87 # useful for libraries that will be obfuscated again with different obfuscators. 88 -keepclassmembernames class * { 89 java.lang.Class class$(java.lang.String); 90 java.lang.Class class$(java.lang.String,boolean); 91 } 92 93 # Remove - System method calls. Remove all invocations of System 94 # methods without side effects whose return values are not used. 95 -assumenosideeffects public class java.lang.System { 96 public static long currentTimeMillis(); 97 static java.lang.Class getCallerClass(); 98 public static int identityHashCode(java.lang.Object); 99 public static java.lang.SecurityManager getSecurityManager(); 100 public static java.util.Properties getProperties(); 101 public static java.lang.String getProperty(java.lang.String); 102 public static java.lang.String getenv(java.lang.String); 103 public static java.lang.String mapLibraryName(java.lang.String); 104 public static java.lang.String getProperty(java.lang.String,java.lang.String); 105 } 106 107 # Remove - Math method calls. Remove all invocations of Math 108 # methods without side effects whose return values are not used. 109 -assumenosideeffects public class java.lang.Math { 110 public static double sin(double); 111 public static double cos(double); 112 public static double tan(double); 113 public static double asin(double); 114 public static double acos(double); 115 public static double atan(double); 116 public static double toRadians(double); 117 public static double toDegrees(double); 118 public static double exp(double); 119 public static double log(double); 120 public static double log10(double); 121 public static double sqrt(double); 122 public static double cbrt(double); 123 public static double IEEEremainder(double,double); 124 public static double ceil(double); 125 public static double floor(double); 126 public static double rint(double); 127 public static double atan2(double,double); 128 public static double pow(double,double); 129 public static int round(float); 130 public static long round(double); 131 public static double random(); 132 public static int abs(int); 133 public static long abs(long); 134 public static float abs(float); 135 public static double abs(double); 136 public static int max(int,int); 137 public static long max(long,long); 138 public static float max(float,float); 139 public static double max(double,double); 140 public static int min(int,int); 141 public static long min(long,long); 142 public static float min(float,float); 143 public static double min(double,double); 144 public static double ulp(double); 145 public static float ulp(float); 146 public static double signum(double); 147 public static float signum(float); 148 public static double sinh(double); 149 public static double cosh(double); 150 public static double tanh(double); 151 public static double hypot(double,double); 152 public static double expm1(double); 153 public static double log1p(double); 154 } 155 156 # Remove - Number method calls. Remove all invocations of Number 157 # methods without side effects whose return values are not used. 158 -assumenosideeffects public class java.lang.* extends java.lang.Number { 159 public static java.lang.String toString(byte); 160 public static java.lang.Byte valueOf(byte); 161 public static byte parseByte(java.lang.String); 162 public static byte parseByte(java.lang.String,int); 163 public static java.lang.Byte valueOf(java.lang.String,int); 164 public static java.lang.Byte valueOf(java.lang.String); 165 public static java.lang.Byte decode(java.lang.String); 166 public int compareTo(java.lang.Byte); 167 168 public static java.lang.String toString(short); 169 public static short parseShort(java.lang.String); 170 public static short parseShort(java.lang.String,int); 171 public static java.lang.Short valueOf(java.lang.String,int); 172 public static java.lang.Short valueOf(java.lang.String); 173 public static java.lang.Short valueOf(short); 174 public static java.lang.Short decode(java.lang.String); 175 public static short reverseBytes(short); 176 public int compareTo(java.lang.Short); 177 178 public static java.lang.String toString(int,int); 179 public static java.lang.String toHexString(int); 180 public static java.lang.String toOctalString(int); 181 public static java.lang.String toBinaryString(int); 182 public static java.lang.String toString(int); 183 public static int parseInt(java.lang.String,int); 184 public static int parseInt(java.lang.String); 185 public static java.lang.Integer valueOf(java.lang.String,int); 186 public static java.lang.Integer valueOf(java.lang.String); 187 public static java.lang.Integer valueOf(int); 188 public static java.lang.Integer getInteger(java.lang.String); 189 public static java.lang.Integer getInteger(java.lang.String,int); 190 public static java.lang.Integer getInteger(java.lang.String,java.lang.Integer); 191 public static java.lang.Integer decode(java.lang.String); 192 public static int highestOneBit(int); 193 public static int lowestOneBit(int); 194 public static int numberOfLeadingZeros(int); 195 public static int numberOfTrailingZeros(int); 196 public static int bitCount(int); 197 public static int rotateLeft(int,int); 198 public static int rotateRight(int,int); 199 public static int reverse(int); 200 public static int signum(int); 201 public static int reverseBytes(int); 202 public int compareTo(java.lang.Integer); 203 204 public static java.lang.String toString(long,int); 205 public static java.lang.String toHexString(long); 206 public static java.lang.String toOctalString(long); 207 public static java.lang.String toBinaryString(long); 208 public static java.lang.String toString(long); 209 public static long parseLong(java.lang.String,int); 210 public static long parseLong(java.lang.String); 211 public static java.lang.Long valueOf(java.lang.String,int); 212 public static java.lang.Long valueOf(java.lang.String); 213 public static java.lang.Long valueOf(long); 214 public static java.lang.Long decode(java.lang.String); 215 public static java.lang.Long getLong(java.lang.String); 216 public static java.lang.Long getLong(java.lang.String,long); 217 public static java.lang.Long getLong(java.lang.String,java.lang.Long); 218 public static long highestOneBit(long); 219 public static long lowestOneBit(long); 220 public static int numberOfLeadingZeros(long); 221 public static int numberOfTrailingZeros(long); 222 public static int bitCount(long); 223 public static long rotateLeft(long,int); 224 public static long rotateRight(long,int); 225 public static long reverse(long); 226 public static int signum(long); 227 public static long reverseBytes(long); 228 public int compareTo(java.lang.Long); 229 230 public static java.lang.String toString(float); 231 public static java.lang.String toHexString(float); 232 public static java.lang.Float valueOf(java.lang.String); 233 public static java.lang.Float valueOf(float); 234 public static float parseFloat(java.lang.String); 235 public static boolean isNaN(float); 236 public static boolean isInfinite(float); 237 public static int floatToIntBits(float); 238 public static int floatToRawIntBits(float); 239 public static float intBitsToFloat(int); 240 public static int compare(float,float); 241 public boolean isNaN(); 242 public boolean isInfinite(); 243 public int compareTo(java.lang.Float); 244 245 public static java.lang.String toString(double); 246 public static java.lang.String toHexString(double); 247 public static java.lang.Double valueOf(java.lang.String); 248 public static java.lang.Double valueOf(double); 249 public static double parseDouble(java.lang.String); 250 public static boolean isNaN(double); 251 public static boolean isInfinite(double); 252 public static long doubleToLongBits(double); 253 public static long doubleToRawLongBits(double); 254 public static double longBitsToDouble(long); 255 public static int compare(double,double); 256 public boolean isNaN(); 257 public boolean isInfinite(); 258 public int compareTo(java.lang.Double); 259 260 public byte byteValue(); 261 public short shortValue(); 262 public int intValue(); 263 public long longValue(); 264 public float floatValue(); 265 public double doubleValue(); 266 267 public int compareTo(java.lang.Object); 268 public boolean equals(java.lang.Object); 269 public int hashCode(); 270 public java.lang.String toString(); 271 } 272 273 # Remove - String method calls. Remove all invocations of String 274 # methods without side effects whose return values are not used. 275 -assumenosideeffects public class java.lang.String { 276 public static java.lang.String copyValueOf(char[]); 277 public static java.lang.String copyValueOf(char[],int,int); 278 public static java.lang.String valueOf(boolean); 279 public static java.lang.String valueOf(char); 280 public static java.lang.String valueOf(char[]); 281 public static java.lang.String valueOf(char[],int,int); 282 public static java.lang.String valueOf(double); 283 public static java.lang.String valueOf(float); 284 public static java.lang.String valueOf(int); 285 public static java.lang.String valueOf(java.lang.Object); 286 public static java.lang.String valueOf(long); 287 public boolean contentEquals(java.lang.StringBuffer); 288 public boolean endsWith(java.lang.String); 289 public boolean equalsIgnoreCase(java.lang.String); 290 public boolean equals(java.lang.Object); 291 public boolean matches(java.lang.String); 292 public boolean regionMatches(boolean,int,java.lang.String,int,int); 293 public boolean regionMatches(int,java.lang.String,int,int); 294 public boolean startsWith(java.lang.String); 295 public boolean startsWith(java.lang.String,int); 296 public byte[] getBytes(); 297 public byte[] getBytes(java.lang.String); 298 public char charAt(int); 299 public char[] toCharArray(); 300 public int compareToIgnoreCase(java.lang.String); 301 public int compareTo(java.lang.Object); 302 public int compareTo(java.lang.String); 303 public int hashCode(); 304 public int indexOf(int); 305 public int indexOf(int,int); 306 public int indexOf(java.lang.String); 307 public int indexOf(java.lang.String,int); 308 public int lastIndexOf(int); 309 public int lastIndexOf(int,int); 310 public int lastIndexOf(java.lang.String); 311 public int lastIndexOf(java.lang.String,int); 312 public int length(); 313 public java.lang.CharSequence subSequence(int,int); 314 public java.lang.String concat(java.lang.String); 315 public java.lang.String replaceAll(java.lang.String,java.lang.String); 316 public java.lang.String replace(char,char); 317 public java.lang.String replaceFirst(java.lang.String,java.lang.String); 318 public java.lang.String[] split(java.lang.String); 319 public java.lang.String[] split(java.lang.String,int); 320 public java.lang.String substring(int); 321 public java.lang.String substring(int,int); 322 public java.lang.String toLowerCase(); 323 public java.lang.String toLowerCase(java.util.Locale); 324 public java.lang.String toString(); 325 public java.lang.String toUpperCase(); 326 public java.lang.String toUpperCase(java.util.Locale); 327 public java.lang.String trim(); 328 } 329 330 # Remove - StringBuffer method calls. Remove all invocations of StringBuffer 331 # methods without side effects whose return values are not used. 332 -assumenosideeffects public class java.lang.StringBuffer { 333 public java.lang.String toString(); 334 public char charAt(int); 335 public int capacity(); 336 public int codePointAt(int); 337 public int codePointBefore(int); 338 public int indexOf(java.lang.String,int); 339 public int lastIndexOf(java.lang.String); 340 public int lastIndexOf(java.lang.String,int); 341 public int length(); 342 public java.lang.String substring(int); 343 public java.lang.String substring(int,int); 344 } 345 346 # Remove - StringBuilder method calls. Remove all invocations of StringBuilder 347 # methods without side effects whose return values are not used. 348 -assumenosideeffects public class java.lang.StringBuilder { 349 public java.lang.String toString(); 350 public char charAt(int); 351 public int capacity(); 352 public int codePointAt(int); 353 public int codePointBefore(int); 354 public int indexOf(java.lang.String,int); 355 public int lastIndexOf(java.lang.String); 356 public int lastIndexOf(java.lang.String,int); 357 public int length(); 358 public java.lang.String substring(int); 359 public java.lang.String substring(int,int); 360 } 361 362 # Remove debugging - Throwable_printStackTrace calls. Remove all invocations of 363 # Throwable.printStackTrace(). 364 -assumenosideeffects public class java.lang.Throwable { 365 public void printStackTrace(); 366 } 367 368 # Remove debugging - Thread_dumpStack calls. Remove all invocations of 369 # Thread.dumpStack(). 370 -assumenosideeffects public class java.lang.Thread { 371 public static void dumpStack(); 372 } 373 374 # Remove debugging - All logging API calls. Remove all invocations of the 375 # logging API whose return values are not used. 376 -assumenosideeffects public class java.util.logging.* { 377 <methods>; 378 } 379 380 # Remove debugging - All Log4j API calls. Remove all invocations of the 381 # Log4j API whose return values are not used. 382 -assumenosideeffects public class org.apache.log4j.** { 383 <methods>; 384 } 385