ProGuard manual | Optimizations


The optimization step of ProGuard can be switched off with the -dontoptimize option. For more fine-grained control over individual optimizations, experts can use the -optimizations option, with a filter based on the optimization names listed below. The filter works like any filter in ProGuard.

The following wildcards are supported:

  ?      matches any single character in an optimization name.

  *      matches any part of an optimization name.

An optimization that is preceded by an exclamation mark ' !' is excluded from further attempts to match with subsequent optimization names in the filter. Make sure to specify filters correctly, since they are not checked for potential typos.

For example, "code/simplification/variable,code/simplification/arithmetic" only performs the two specified peephole optimizations.

For example, "!method/propagation/*" performs all optimizations, except the ones that propagate values between methods.

For example, "!code/simplification/advanced,code/simplification/*" only performs all peephole optimizations.

Some optimizations necessarily imply other optimizations. These are then indicated. Note that the list is likely to change over time, as optimizations are added and reorganized.


Marks classes as final, whenever possible.


Simplifies enum types to integer constants, whenever possible.


Merges classes vertically in the class hierarchy, whenever possible.

class/merging/horizontal (⇒ code/removal/advanced)

Merges classes horizontally in the class hierarchy, whenever possible.


Removes write-only fields.

field/marking/private (⇒ code/simplification/advanced)

Marks fields as private, whenever possible.


Propagates the values of fields across methods.

method/marking/private (⇒ code/removal/advanced)

Marks methods as private, whenever possible (devirtualization).


Marks methods as static, whenever possible (devirtualization).

method/marking/final (⇒ code/removal/advanced)

Marks methods as final, whenever possible.

method/removal/parameter(⇒ code/simplification/advanced)

Removes unused method parameters.

method/propagation/parameter(⇒ code/simplification/advanced)

Propagates the values of method parameters from method invocations to the invoked methods.


Propagates the values of method return values from methods to their invocations.


Inlines short methods.


Inlines methods that are only called once.


Simplifies tail recursion calls, whenever possible.


Merges identical blocks of code by modifying branch targets.


Performs peephole optimizations for variable loading and storing.


Performs peephole optimizations for arithmetic instructions.


Performs peephole optimizations for casting operations.

code/simplification/field (⇒ code/removal/simple)

Performs peephole optimizations for field loading and storing.


Performs peephole optimizations for branch instructions.

code/simplification/string (best used with code/removal/advanced)

Performs peephole optimizations for constant strings.

code/simplification/advanced (⇒ code/removal/exception)

Simplifies code based on control flow analysis and data flow analysis.

code/removal/advanced (⇒ code/removal/exception)

Removes dead code based on control flow analysis and data flow analysis.


Removes dead code based on a simple control flow analysis.


Removes unused variables from the local variable frame.


Removes exceptions with empty try blocks.


Optimizes variable allocation on the local variable frame.

ProGuard also provides some unofficial settings to control optimizations, that may disappear in future versions. These are Java system properties, which can be set as JVM arguments (with -D.....):

maximum.inlined.code.length (default = 8 bytes)

Specifies the maximum code length (expressed in bytes) of short methods that are eligible to be inlined. Inlining methods that are too long may unnecessarily inflate the code size.

maximum.resulting.code.length (default = 8000 bytes for JSE, 2000 bytes for JME)

Specifies the maximum resulting code length (expressed in bytes) allowed when inlining methods. Many Java virtual machines do not apply just-in-time compilation to methods that are too long, so it's important not to let them grow too large.

optimize.conservatively (default = unset)

Allows input code with ordinary instructions intentionally throwing NullPointerExceptionw, ArrayIndexOutOfBoundsException, or ClassCastException, without any other useful purposes. By default, ProGuard may just discard such seemingly useless instructions, resulting in better optimization of most common code.