Removal
Removal — Options
The Removal Options panel controls what happens to unused classes and members in the inputs and the removal of metadata in classes that are output.
Unused Classes
This controls the handling of unused classes. Options are to remove all unused classes, only those that are not public, or to perform no removal at all. See <removal> Section for details.
Unused Members
This controls the handling of unused methods and fields. Options are to remove all unused members, only those that are not public, or to perform no removal at all. See <removal> Section for details.
Debug Information
This controls the removal of debugging information inserted by the compiler. Most information is used by debuggers, but the most useful to retain are the Line Number Table
and the Source File
. To generate a stack trace with meaningful line numbers these two should be retained. See <debug> Section for details.
Note:
Field names in Local Variables and Local Variable Types are not renamed. Leaving these attributes in a production release may compromise the obfuscation.
Attributes
The Java compiler generates additional metadata for classes and their members and stores that information in attributes in the class files. Some of this information is required by the compiler, when you compile against a library, or by applications using reflection. You can use these settings to selectively remove information that your application does not require at runtime to reduce the size of your class files. See <attributes> Section for details.
Note:
Type Annotations will always be removed. This is hard coded and cannot be un-checked.
Removal — Exclude
The Removal Exclude panel lets you compose rules that exclude classes and/or their methods and fields from removal. Individual methods, fields, classes, or entire packages may be excluded.
You can create rules that exclude individual or groups of classes or even entire packages using regular expressions. See Graphical Rules Editor for details.
Note:
Classes referenced here will still be removed if referenced in the Classes section.
Removal — Classes
If your inputs contain classes that you do not want to appear in the resulting output, such as unit tests or samples, you can have DashO remove them. Classes matched by these rules will not appear in DashO's output. If any other input classes reference them, they will be treated as if they were support classes.
You can create rules that match individual or groups of classes or even entire packages using regular expressions. See Graphical Rules Editor for details.
Note:
Classes referenced here, will be removed even if referenced in the Exclude section as well.
Method Call Removal
If your project inputs contain calls to methods you do not want to be present in the resulting output, such as logging or console output, you can use DashO to remove them (for example Android Logging Removal). Calls to the methods specified here will be removed from all input classes. The methods themselves are not removed, just the calls to them.
Unlike other features, regular expressions are not supported in the class names, method names or signatures for method call removal. See <methodCallRemoval> Section for additional details.
Note:
Prior versions of DashO supported use of**
to match any class. This feature is dangerous. It is deprecated and will be removed.
Effect on Behavior
Method call removal affects the behavior of your program. Removing method calls may have subtle side-effects, and this feature should be used with caution.
Removal of non-void methods calls is applied regardless of whether or not the return value from the method is actually used. When non-void method calls are removed, a default value is provided as the result in place of the call. The value is either zero, false, or null, as appropriate for the method's return type. For example, replacement results for return types Double
, int[]
, and Set<String>
will all be null
. This may cause unexpected issues.
Method call removal does not alter bytecode outside of the method call, including the expression containing the call:
String[] pathSplitterToRemove(String path) { ... }
...
String message = "First path: " + pathSplitterToRemove(path)[0]; // null array access
It may not be obvious that the code even does anything with the result:
Double methodCallToRemove() { ... }
...
double ignoredValue = methodCallToRemove(); // unboxing a null
After method call removal (of the two *ToRemove
methods), both of these examples will throw a NullPointerException
.