ProGuard manual | Optimizations

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.

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.